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

Pi symbol in blockMesh file

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

Reply
 
LinkBack Thread Tools Display Modes
Old   September 2, 2005, 03:14
Default Hi! How can I introduce a 2
  #1
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 9
maka is on a distinguished road
Hi!

How can I introduce a 2*Pi symbol in block mesh file?

Thanks.
maka is offline   Reply With Quote

Old   September 2, 2005, 03:25
Default Here is some explanation: u
  #2
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 9
maka is on a distinguished road
Here is some explanation:

usually in channel flow dimensions are specified in terms of Pi and delta. But Pi only shows itself in the periodic directions (x,z), which means we can not just added to convertToMeter as a scale and we have to introduce its in each point dimesion. This will require at least a 6 (may be more) digit accuracy in every x and z coordinate for all points.

One can enter it by hand but its a tiring process especially if you have multiple blocks. I there any way to introduce a symbole and a multiplication operator in blockMesh file.

ex: 2*Pi

Thanks.
maka is offline   Reply With Quote

Old   September 2, 2005, 03:41
Default The best way we have found to
  #3
Senior Member
 
Join Date: Mar 2009
Posts: 854
Rep Power: 13
henry is on a distinguished road
The best way we have found to do this is to use the m4 macro pre-processor inconjunction with gawk or perl to do the maths. Imply write a blockMeshDict.m4 as an input file to m4, run m4 on it and output the blockMeshDict for blockMesh. m4 allows you to define variable, evaluate expressions etc. etc., with a bit of effort it makes generating complex meshes with blockMesh much easier.
henry is offline   Reply With Quote

Old   September 2, 2005, 06:23
Default Or if you're not keen on m4 yo
  #4
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 12
eugene is on a distinguished road
Or if you're not keen on m4 you can just use the transformPoints utility to scale all your x and z dimensions by Pi after you have run blockMesh.
eugene is offline   Reply With Quote

Old   September 2, 2005, 07:26
Default Perhaps incorporate PI into th
  #5
New Member
 
Chris Greenshields
Join Date: Mar 2009
Posts: 28
Rep Power: 8
chris is on a distinguished road
Perhaps incorporate PI into the converToMeters field of the blockMeshDict - it is just a fixed scaling:
http://www.opencfd.co.uk/openfoam/do...ml#dx31-165018
chris is offline   Reply With Quote

Old   September 2, 2005, 08:02
Default Another good idea would be to
  #6
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 12
eugene is on a distinguished road
Another good idea would be to alter blockMesh to use a vector instead of a scalar scaling factor. That way you would be able to scale by PI in the x and z directions but not the y direction.

This is very easy to do. You need to alter 2 files:
blockMesh.H: line 65
change
scalar scale_
to
vector scale_

createPoints.C: line 62
change
] = scale_*blockPoints[blockPointLabel];
to
] = vector
(
scale_.x()*blockPoints[blockPointLabel].x(),
scale_.y()*blockPoints[blockPointLabel].y(),
scale_.z()*blockPoints[blockPointLabel].z(),
);

To accommodate this you need to modify your blockMeshDict:
convertToMeters <somenumber>;
convertToMeters (<num> <num> <num>);

Recompile and you are ready to go.
eugene is offline   Reply With Quote

Old   September 2, 2005, 08:45
Default Is there an example of using b
  #7
Senior Member
 
Billy
Join Date: Mar 2009
Posts: 167
Rep Power: 8
billy is on a distinguished road
Is there an example of using blockMeshDict.m4 to define variables in the current OpenFOAM release?
billy is offline   Reply With Quote

Old   September 2, 2005, 09:50
Default Here is an example of an m4 ma
  #8
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 12
eugene is on a distinguished road
Here is an example of an m4 macro I used during my PhD. The foam formatting is probably out of date now, since I used it with Foam2.2.

If you get it working, please post the script to the Wiki so everyone can benefit from it.

meshDescription.m4
eugene is offline   Reply With Quote

Old   September 2, 2005, 11:32
Default Is it possible to use standard
  #9
Senior Member
 
Billy
Join Date: Mar 2009
Posts: 167
Rep Power: 8
billy is on a distinguished road
Is it possible to use standard math functions such as sin and cos?
billy is offline   Reply With Quote

Old   September 5, 2005, 11:32
Default vector scale_ I followed th
  #10
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 9
maka is on a distinguished road
vector scale_

I followed the steps for redefining scale_ as vector and compiled, sourced but when I run blockMesh I get the following message:

file: /home/maka/OpenFOAM/marwan-1.2/run/tutorials/icoFoam/cavity/constant/polyMesh/bl ockMeshDict::convertToMeters at line 26.

From function operator>>(Istream&, scalar&)
in file primitives/scalar/scalar.C at line 94.

it seems that there is convertToMeters is read at another location where we need to modify the defined input operator to:

operator>>(Istream&, vector&)

I did grep and found scale_ in :

blockMesh.C: scale_(readScalar(meshDescription.lookup("convertT oMeters")))

Should not readScalar be readVector?
can any body help?

Regards,
Maka
maka is offline   Reply With Quote

Old   September 5, 2005, 12:15
Default compiler errors: It turned
  #11
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 9
maka is on a distinguished road
compiler errors:

It turned out that, the compilation did not go well after I did the changes. Here is the message: any hint on what to do to make it work:

+ cd mesh
+ ./Allwmake
+ cd generation
+ ./Allwmake
+ wmake blockMesh
make: Nothing to be done for `allFiles'.
make: `Make/linuxGcc4Opt/dependencies' is up to date.

SOURCE_DIR=.
SOURCE=blockMesh.C ; g++ -m32 -Dlinux -Wall -W -Wno-unused-parameter -Wold-style-cast -O3 -ffast-math -DNoRepository -ftemplate-depth-30 -IcurvedEdges -I/home/marwan/OpenFOAM/OpenFOAM-1.2/src/meshTools/lnInclude -I/home/marwan/OpenFOAM/OpenFOAM-1.2/src/dynamicMesh/lnInclude -I/home/marwan/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude -IlnInclude -I. -fPIC -pthread -c $SOURCE -o Make/linuxGcc4Opt/blockMesh.o
blockMesh.C: In constructor 'Foam::blockMesh::blockMesh(Foam::IOdictionary&)':
blockMesh.C:51: error: no matching function for call to 'Foam::Vector<foam::scalar>::Vector(Foam::scalar)'
/home/marwan/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude/VectorI.H:79: note: candidates are: Foam::Vector<cmpt>::Vector(Foam::Istream&) [with Cmpt = Foam::scalar]
/home/marwan/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude/VectorI.H:69: note: Foam::Vector<cmpt>::Vector(const Cmpt&, const Cmpt&) [with Cmpt = Foam::scalar]
/home/marwan/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude/VectorI.H:59: note: Foam::Vector<cmpt>::Vector(const Cmpt&, const Cmpt&, const Cmpt&) [with Cmpt = Foam::scalar]
/home/marwan/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude/VectorI.H:51: note: Foam::Vector<cmpt>::Vector(const Foam::VectorSpace<foam::vector<cmpt>, Cmpt, 3>&) [with Cmpt = Foam::scalar]
/home/marwan/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude/VectorI.H:45: note: Foam::Vector<cmpt>::Vector() [with Cmpt = Foam::scalar]
/home/marwan/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude/Vector.H:62: note: Foam::Vector<foam::scalar>::Vector(const Foam::Vector<foam::scalar>&)
make: *** [Make/linuxGcc4Opt/blockMesh.o] Error 1

Thanks,
Maka
maka is offline   Reply With Quote

Old   September 5, 2005, 12:19
Default Yes: read the message, readi i
  #12
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,762
Rep Power: 21
hjasak will become famous soon enough
Yes: read the message, readi it carefully and then read it again:

blockMesh.C:51: error: no matching function for call to
'Foam::Vector::Vector(Foam::scalar)

It says: on line 51 of the file blockMesh.C you are attempting to create a vector out of a scalar.

Hope it is now clearer :-)

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   September 5, 2005, 12:30
Default readVector, I tried to repl
  #13
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 9
maka is on a distinguished road
readVector,

I tried to replace readScalar by readVector I got the following error. Sorry if it looks easy but this is my first attempt to modify a file of the code.

blockMesh.C: In constructor 'Foam::blockMesh::blockMesh(Foam::IOdictionary&)':
blockMesh.C:46: error: 'readVector' was not declared in this scope

Thanks
maka is offline   Reply With Quote

Old   September 5, 2005, 12:42
Default scale_(meshDescription.lookup(
  #14
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,762
Rep Power: 21
hjasak will become famous soon enough
scale_(meshDescription.lookup("convertToMeters")),
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   September 5, 2005, 12:51
Default Thanks.
  #15
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 9
maka is on a distinguished road
Thanks.
maka is offline   Reply With Quote

Old   December 18, 2010, 08:45
Default How to run .m4 file in Windows
  #16
New Member
 
Pavel Mostovykh
Join Date: Dec 2010
Posts: 2
Rep Power: 0
andrewfedosov is on a distinguished road
I use the Windows OpenFOAM 1.5. Can I run the .m4 file in order to construct a blockMeshDict file?

Maybe, someone can give a link to the tutorial for the m4 language (for instance, can I have if-statements in .m4 file)?

Thanks in advance
andrewfedosov is offline   Reply With Quote

Reply

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
libudf error: undefined symbol: Prashanth FLUENT 5 July 28, 2010 07:03
OpenFOAM 15 libreadlineso5 undefined symbol PC frafridr OpenFOAM Installation 0 February 3, 2009 20:37
undefined symbol Dario Nexus FLUENT 0 October 12, 2006 07:54
Unresolved external symbol Ritesh Chhabra FLUENT 0 August 31, 2004 12:27
Unresolved external symbol Hamsdi CFX 1 November 5, 2001 15:01


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