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

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

 March 18, 2010, 07:47 Is it possible to define a CONSTANT in the blockMesh file? #1 New Member   Marco Join Date: Mar 2010 Posts: 9 Rep Power: 8 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

 March 18, 2010, 11:27 #2 New Member   Paul Garlick Join Date: Mar 2009 Location: Bournemouth, UK Posts: 25 Rep Power: 9 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)

March 19, 2010, 03:14
#3
Senior Member

Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 780
Rep Power: 19
Quote:
 Originally Posted by pg22 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```

 Tags constant blockmesh

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post herzfeldd OpenFOAM Installation 21 January 6, 2009 10:38 hardy OpenFOAM Paraview & paraFoam 7 September 18, 2008 04:59 hariya03 OpenFOAM Pre-Processing 0 April 18, 2008 04:26 matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51 simone Marras Main CFD Forum 0 April 8, 2007 15:49

All times are GMT -4. The time now is 19:29.