CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   How to define macros in Dictionary files? (http://www.cfd-online.com/Forums/openfoam/116754-how-define-macros-dictionary-files.html)

keepfit April 24, 2013 10:46

How to define macros in Dictionary files?
 
Hi Foamers,

as the newest version of OpenFOAM 2.2.x supports Dictionary Macro Expansion, I wonder if it can be used for blockMeshDict:

....

xSize 10;
ySize 18;
zSize 15;

...

hex (0 22 24 11 37 47 35 40) (xSize ySize zSize) simpleGrading (0.5 0.5 1);

....

But when runing blockMesh, it says

Quote:

wrong token type - expected int, found on line 85 the word 'xSize1'..
So I wonder how to use Macros in OpenFoam correctly.

Best,

David



Edit1: Using predefined variables needs '$' .

Edit2: It would be great if mathematical operation is supported via macros, e.g.

a 5;
b 6;
c = $a + $b;

wyldckat April 26, 2013 20:29

Greetings David,

Quote:

Originally Posted by keepfit (Post 422880)
Edit2: It would be great if mathematical operation is supported via macros, e.g.

a 5;
b 6;
c = $a + $b;

That has been requested some time ago: http://www.openfoam.org/mantisbt/view.php?id=447 - and it might itself tell you how you can perform said calculation ;)

Best regards,
Bruno

keepfit April 27, 2013 15:38

Quote:

Originally Posted by wyldckat (Post 423440)
Greetings David,


That has been requested some time ago: http://www.openfoam.org/mantisbt/view.php?id=447 - and it might itself tell you how you can perform said calculation ;)

Best regards,
Bruno

thanks very much Bruno.

Now it's very straightforward to define parameters in blockMeshdict, other than using .m4 file or blender Swiftblock.

Edit1: Does it support c++ math functions: e.g. sin( ), sqrt( ), log( ), etc.

bhushanvelis December 16, 2013 16:13

Quote:

Originally Posted by wyldckat (Post 423440)
Greetings David,


That has been requested some time ago: http://www.openfoam.org/mantisbt/view.php?id=447 - and it might itself tell you how you can perform said calculation ;)

Best regards,
Bruno

Thanks Bruno ..


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