CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[snappyHexMesh] user defined variables

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 12, 2015, 08:22
Default user defined variables
  #1
New Member
 
Lluís M. Biscarri
Join Date: Nov 2011
Posts: 24
Rep Power: 14
biscarri is on a distinguished road
Hi foamers,

I'm trying to create parametrized meshes using blockMesh and snappyHexMesh.

Is it possible to define user variables at the beggining of blockMeshDict and snappyHexMeshDict, and then to use them in algebraic expressions to input the values of meshing parameters?

Can somebody explain me how?

Thank you very much,
Lluis
biscarri is offline   Reply With Quote

Old   June 12, 2021, 07:29
Default
  #2
Member
 
Giles Richardson
Join Date: Jun 2012
Location: Cambs UK
Posts: 98
Rep Power: 13
ufocfd is on a distinguished road
good question - did you find a way to do this?
ufocfd is offline   Reply With Quote

Old   June 16, 2021, 11:59
Default
  #3
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14
Tobermory will become famous soon enough
You can define the variables in a separate file, and then include them at the top of the blockMesh and snappyHexMesh dictionaries with an #include command, remembering that the path is relative to the location of the dictionary.

For example, in your case folder, create a folder called include, and in that folder create a file variables, eg:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  dev
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       IOobject;
    location    "include";
    object      variables;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
U0      3.0;
p0      0.0;
k0      0.8;
eps0    0.03;
Now, in the dictionary where you want to reference these variables, just add an include statement, e.g.:

Code:
#include "../include/variables"
and the variables will be defined and ready for use below. You can use #calc or codestream to do calculations based on these variables, if you need. Hope that helps.
Tobermory is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User defined time step - Possible to put variable time stepping in it? maccheese Fluent UDF and Scheme Programming 19 June 4, 2018 09:49
User defined heat source redwanamit034 STAR-CCM+ 2 April 6, 2018 10:00
[General] Paraview User defined view prapanj ParaView 3 January 3, 2014 20:54
user defined turbulence model manuutin STAR-CD 5 October 14, 2009 05:29
User Defined Scalars - Returning Values Carlos V. FLUENT 0 April 19, 2006 18:18


All times are GMT -4. The time now is 18:40.