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

[blockMesh] Pi symbol in blockMesh file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 2, 2005, 04:14
Default Pi symbol in blockMesh file
  #1
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
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, 04:25
Default Here is some explanation: u
  #2
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
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, 04:41
Default The best way we have found to
  #3
Senior Member
 
Join Date: Mar 2009
Posts: 854
Rep Power: 22
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, 07: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: 21
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, 08:26
Default Perhaps incorporate PI into th
  #5
New Member
 
Chris Greenshields
Join Date: Mar 2009
Posts: 28
Rep Power: 17
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, 09:02
Default Another good idea would be to
  #6
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21
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, 09:45
Default Is there an example of using b
  #7
Senior Member
 
Billy
Join Date: Mar 2009
Posts: 167
Rep Power: 17
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, 10:50
Default Here is an example of an m4 ma
  #8
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21
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, 12:32
Default Is it possible to use standard
  #9
Senior Member
 
Billy
Join Date: Mar 2009
Posts: 167
Rep Power: 17
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, 12:32
Default vector scale_ I followed th
  #10
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
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, 13:15
Default compiler errors: It turned
  #11
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
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, 13:19
Default Yes: read the message, readi i
  #12
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
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, 13:30
Default readVector, I tried to repl
  #13
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
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, 13:42
Default scale_(meshDescription.lookup(
  #14
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
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, 13:51
Default Thanks.
  #15
Senior Member
 
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18
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


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] swak4foam for OpenFOAM 4.0 mnikku OpenFOAM Community Contributions 80 May 17, 2022 09:06
[foam-extend.org] Problems installing foam-extend-4.0 on openSUSE 42.2 and Ubuntu 16.04 ordinary OpenFOAM Installation 19 September 3, 2019 19:13
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch gschaider OpenFOAM Installation 225 August 25, 2015 20:43
[swak4Foam] build problem swak4Foam OF 2.2.0 mcathela OpenFOAM Community Contributions 14 April 23, 2013 14:59


All times are GMT -4. The time now is 04:45.