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

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

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread 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: 16
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: 27
Rep Power: 17
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: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
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
rajibroy likes this.
olesen is offline   Reply With Quote

Reply

Tags
constant blockmesh


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
[Other] Tabulated thermophysicalProperties library chriss85 OpenFOAM Community Contributions 62 October 2, 2022 04:50
[swak4Foam] Installation Problem with OF 6 version Aurel OpenFOAM Community Contributions 14 November 18, 2020 17:18
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 14:59
[swak4Foam] funkySetFields compilation error tayo OpenFOAM Community Contributions 39 December 3, 2012 06:18
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 02:24


All times are GMT -4. The time now is 06:25.