CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Native Meshers: blockMesh

Is it possible to define a CONSTANT in the blockMesh file?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   March 18, 2010, 07:47
Default Is it possible to define a CONSTANT in the blockMesh file?
  #1
New Member
 
Marco
Join Date: Mar 2010
Posts: 9
Rep Power: 7
om3ro is on a distinguished road
I need to simulate several different configurations by changing a geometrical parameter, so I would like to change just the value of a constant instead of changing all the points of the mesh:

A simple example of what i need:

int b;
b=4; // b can vary from 2 to 6 : 2, 2.1, 2.2, 2.3, ... , 5.9, 6.

vertices
(
(0 -1 0)
(b -1 0)
(b 0 0)
(0 0 0)
(0 -1 1)
(b -1 1)
(b 0 1)
(0 0 1)
);

Is it possible to make that?

Regards
Marco
om3ro is offline   Reply With Quote

Old   March 18, 2010, 11:27
Default
  #2
New Member
 
Paul Garlick
Join Date: Mar 2009
Location: Bournemouth, UK
Posts: 25
Rep Power: 8
pg22 is on a distinguished road
The m4 pre-processor is handy for this sort of thing. You define the constants in a separate file, blockMeshDict.m4 say, and use m4 to do any necessary calculations and write out a new blockMeshDict file.

There are some examples in the forum and also on the wiki (e.g. OSIG)
pg22 is offline   Reply With Quote

Old   March 19, 2010, 03:14
Default
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 777
Rep Power: 18
olesen will become famous soon enough
Quote:
Originally Posted by pg22 View Post
The m4 pre-processor is handy for this sort of thing. You define the constants in a separate file, blockMeshDict.m4 say, and use m4 to do any necessary calculations and write out a new blockMeshDict file.

There are some examples in the forum and also on the wiki (e.g. OSIG)
Indeed m4 is the most reasonable approach at the moment.
The dictionary $variable expansions will generally not work, since the blockMeshDict entries are mostly read as straight lists.

However, you don't need to look any further than some of the tutorial examples.
Code:
$ git ls-files | grep m4
yields this list of files:

Code:
tutorials/compressible/rhoPimpleFoam/angledDuct/constant/polyMesh/blockMeshDict.m4
tutorials/compressible/rhoPorousSimpleFoam/angledDuctImplicit/constant/polyMesh/blockMeshDict.m4
tutorials/incompressible/MRFSimpleFoam/mixerVessel2D/constant/polyMesh/blockMeshDict.m4
tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/polyMesh/blockMeshDict.m4
tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/constant/polyMesh/blockMeshDict.m4
tutorials/multiphase/interDyMFoam/ras/sloshingTank2D3DoF/constant/polyMesh/blockMeshDict.m4
tutorials/multiphase/interDyMFoam/ras/sloshingTank3D/constant/polyMesh/blockMeshDict.m4
tutorials/multiphase/interDyMFoam/ras/sloshingTank3D3DoF/constant/polyMesh/blockMeshDict.m4
tutorials/multiphase/interDyMFoam/ras/sloshingTank3D6DoF/constant/polyMesh/blockMeshDict.m4
tutorials/multiphase/interFoam/MRFInterFoam/mixerVessel2D/constant/polyMesh/blockMeshDict.m4
olesen is offline   Reply With Quote

Reply

Tags
constant blockmesh

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Statically Compiling OpenFOAM Issues herzfeldd OpenFOAM Installation 21 January 6, 2009 10:38
Paraview command not found hardy OpenFOAM Paraview & paraFoam 7 September 18, 2008 04:59
Regarding FoamX running Kindly help out hariya03 OpenFOAM Pre-Processing 0 April 18, 2008 04:26
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51
gcc and executable file from Mac to Linux simone Marras Main CFD Forum 0 April 8, 2007 15:49


All times are GMT -4. The time now is 09:00.