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

[blockMesh] Calculating mesh size, round down

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By bjnieuwboer

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 26, 2017, 10:20
Default Calculating mesh size, round down
  #1
New Member
 
Join Date: Oct 2017
Posts: 4
Rep Power: 8
DeAldeEiam is on a distinguished road
Hello,

i have a small Problem to create my blockMeshDict. I use a m4 script where I calculate all elements for my blocks with one source block. But now I get a point number and an error message.

Is there a possibility to round numbers in my m4 script? e.g. 71.25 => 71

thanks a lot
DeAldeEiam is offline   Reply With Quote

Old   December 5, 2017, 20:36
Default
  #2
Senior Member
 
Join Date: Aug 2013
Posts: 407
Rep Power: 15
Antimony is on a distinguished road
Hi,

Can you not make use of the "floor" function?

Cheers,
Antimony
Antimony is offline   Reply With Quote

Old   April 18, 2018, 07:43
Default floor a floating point
  #3
Member
 
Bas Nieuwboer
Join Date: Mar 2013
Posts: 32
Rep Power: 13
bjnieuwboer is on a distinguished road
I encoutered the same problem when I tried to compute the mesh size. I looked a bit into perl and found that the printf statement can be used to print integers.

In most m4 blockmesh files the calc function is defined. I defined a second calc function:
Code:
define(calc_round, [esyscmd(perl -e "printf ('%d', $1)")])
Instead of computing a floating point value
Code:
define(Nx,calc(L/dx))
you can now use:
Code:
define(Nx,calc_round(L/dx))
to compute the integer value.

I found this solution here. It might be a good reference if you want to do some other formatting.
arvindpj and Hughtong like this.
bjnieuwboer 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] dynamicTopoFVMesh and pointDisplacement RandomUser OpenFOAM Meshing & Mesh Conversion 6 April 26, 2018 07:30
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 18:57
[snappyHexMesh] Layers:problem with curvature giulio.topazio OpenFOAM Meshing & Mesh Conversion 10 August 22, 2012 09:03
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 03:01
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 17:27


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