From OpenFOAMWiki

Valid versions: OF Version 21.png

Also needed: pyFoam

1 Short description

A utility for reading a z0 distribution in a WAsP map file writing z0 dictionary file, and copying it into nut nutkAtmRoughWallFunction or other wall boundary conditions requiring z0 . The code is a copy of Xabier Pedruelo Tapia's MsC. thesis roughnessToFoam utility, changed to produce z0 rather then Ks and Cs dictionary's.

2 Usage

The original utility is described in the appendix of Xabier Pedruelo Tapia's MsC. thesis. The changes I made to the C code are:

  • Writing z0 dictionary rather then Cs and Ks
  • writing the general z0 value outside of the polygons -
    • For every polygon, two values are expected - z0 inside the polygon , and z0 outside of the polygon.
    • The value outside of the first polygon is used as the value for the entire field, and only then is each polygon probed and it's value written.

Additionally, the code is configured to run through a python script called

  • It first creates a dummy z0 dictionary by copying and changing the p dictionary in the case
  • It reads the offset parameters that quantify the difference between the roughness map coordinates and the mesh coordinates (they are assumed to be the same coordinates if no parameter is given)
  • It calls roughnessToFoam.C
  • It copies the result to the nut dictionary - expecting a boundary wall patch named "terrain_*" as in the turbinesiting case

The reason the z0 dictionary is kept, instead of directly writing to the nut file, is that it is very useful as it is loaded into paraview with all the other dictionary files.

A test case is included in the github repository: testCases.tgz

3 Download

The code is hosted on github:

To fork the repository follow these instructions: - or simply clone directly, and then run wmake:

git clone
cd roughnessToFoam

And to run the test case included:

tar -xzf testCase.tgz
cd testCase

4 History

--Hananlevy (talk) 12:55, 14 October 2012 (CEST)