CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Open Source Meshers: Gmsh, Netgen, CGNS, ... (
-   -   mesh grading with netgen (

RugbyGandalf November 8, 2010 05:40

mesh grading with netgen

i have imported a *.stp geometry in netgen. From this i would like to build a volume mesh. This works already, but i have another problem:

the geometry ist a cylinder with another curved body inside. The aim is to simulate airflow around the body inside the cylinder.
That is why i need to have a very fine mesh directly on the body's surface, but a less fine mesh in the rest of the cylinder...

Could someone tell me how to configure netgen to do so?

Thank you very much in forecast


philippose November 8, 2010 07:46

3 Attachment(s)
Hello there,

A Good Day to you :-)!

Nice to see that you are interested in checking out the various grading options present in Netgen...

Its particularly easier given the fact that you are using the STEP geometry format, becuase Netgen has some extra tricks for OCC geometry.

There are essentially two ways you can achieve the local mesh grading you need:

1. Limit the maximum mesh size on the surfaces around which you want a fine mesh.

2. Use a "Mesh Size File" (MSZ) to specify a set of points and the corresponding maximum mesh size at and around these points. Using this method, you can create something like a cloud point in the form of a box around the region where you want a finer mesh, and limit the mesh size at these points.

I think in your particular situation, the easier method would be to use Method:1.... where you directly click the individual surfaces directly within the Netgen interface and limit the max mesh size at these surfaces.

In order to use the functionality, do the following:

1. Specify a global max and min allowable mesh size and a grading factor (0...1) in the menu "Mesh -> Meshing Options -> Mesh Size".

2. Create a clipping plane so that you can gain access to the inside of the geometry using "View -> Clipping Plane".

3 Now, use the menu: "Geometry -> Edit Face Mesh Size", and double click one by one on each of the surfaces you want to make finer, and each time, specify the maximum mesh size allowed on that face.

I made a quick example.... check the screen-shots... The mesh has been coloured using the element mesh sizes (View -> Viewing Options -> Mesh)

Hope this helps.

Have a nice day!


RugbyGandalf November 8, 2010 18:17

2 Attachment(s)
Dear Philippose,

thank you very much for your fast answer!
I tried a little with cubes, how different configurations worked out for the mesh.
After this i was meshing my case i described before.

The mesh grading worked so far, as you can see on those screenshots below.
The curved body in the middle of the cylindric geometry has the finest net - as it should be. meshing also the volume, worked after using Geometry -> IGES/STEP topology doctor -> analyse -> heal
Are there any options i can / have to select before healing?

I also have some additional questions:
- what does Mesh -> meshing options -> Mesh -> second order elements mean?
- and what about Mesh -> meshing options -> Mesh -> second order elements -> quad dominated?
- How are dimensions handled? If i export a file out of Pro/E with meter as dimension, what does the max mesh size in netgen mean? also meter?
- what is happening when i select optimize mesh (and maybe three optimation steps?

Thank you very very much for your help!!!
Your first answer was great for me ;)

If you know where to get a good manual for netgen i would be glad if you could give me a link...



philippose November 9, 2010 02:15

Hi again,

A Good Morning to you :-)!

Nice that you were able to get the mesh grading part of it working!

So, to answer your questions:

1. Geometry Healing.... There are no specific options you can / need to set other than the different types of healing Netgen performs, and also the threshold that is used... but you need to play around with them to get it right for your geometry. However..... I would personally suggest, that you ensure that you do as much of the geometry part within the CAD software itself, and make sure that the STEP that you export is "good", rather than relying on the healing feature.

2. Second Order.... This option creates second order surface and volume elements.... which implies... 6 instead of 3 points for triangles, and 10 instead of 4 points for tetrahedra. However, this is intended for use in FEM, and you cannot use second order elements with OpenFOAM.

3. Quad Dominated.... This option only works for surface meshes, and as the name suggests, it causes Netgen to create a surface mesh which is essentially made up of Quadrilateral elements, with triangles only used in small local areas where pure Quads do not give a valid mesh.

4. Dimensions.... Netgen only imports the raw data from a STEP / IGES file. Usually, when exporting geometry from Pro/E, Pro/E converts the mesh from whatever units were used to create the geometry, into "mm", and then puts in a "Units" specification in the STEP File. However, Netgen does not do any reconversion.... only the raw point and topology data are read in. This means, that if you create your geometry in "m", and export it, the values you see in netgen will have co-ordinates amplified by a factor of 1000.

5. Mesh Optimisation.... This step is used to improve the quality of the surface and volume meshes by running through multiple routines of edge-swapping, smoothing, point movement, etc...etc.... Usually, if you select more optimisation steps, you get a better mesh.... but as can be expected, there is a limit after which your mesh cannot be improved anymore, and choosing more steps only takes up more time. The exact limit depends purely on the complexity of the geometry. I usually use between 8 to 10 optimisation steps for both the surface and the volume mesh elements.

(You can see the mesh quality in the form of a graph under the "Viewing Options" menu.... and this is updated in real-time at the end of each optimisation step.... so if you ask it to do too many steps, you will see that the quality plot does not change any more).

6. Manual for Netgen.... :-) :-)! Oops.... welll.... there is a very preliminary PDF file which is present in the installation... but this is old. Have a look around on the Netgen Sourceforge Wiki.... I had put in a couple of screen-casts, and there should also be another PDF. However, on the whole..... I agree.... there is no comprehensive documentation for Netgen. This is purely because of a lack of resources and time... As always, any form of contributions are always welcome :-) ;-)!

Have a great day ahead!


RugbyGandalf November 9, 2010 11:26

1 Attachment(s)
Hello Philippose,

thanks a lot again.
I was also looking for the wiki (but only two screencasts will work) :-(

now i have a strange problem: when the mesh on the streamlined body has to small element sizes, the meshing won't work and Netgen gives out the following error message:

Face 1 / 6 (parameter space projection)
Face 2 / 6 (parameter space projection) Face 3 / 6 (parameter space projection)
Face 4 / 6 (parameter space projection)
Face 5 / 6 (parameter space projection)
Singular Matrix
retry Surface 5
Face 5 / 6 (plane space projection)
ERROR: Problem in Surface mesh generation
Face 6 / 6 (parameter space projection)
Surface meshing error occured before (in 1 faces)
Singular Matrix
retry Surface 6
Face 6 / 6 (plane space projection)
Surface meshing error occured before (in 1 faces)
Face 5

for more information open IGES/STEP Topology Explorer

Problem in Surface mesh generation

Face 5 and 6 are the two sides of of the streamlined body, which i gave a maximum mesh size of 2, mesh grading is set to 0.1 and the max element sizes of the other faces are set to 50.
Heal the geometry seems not to work, because this destroys my streamlined body :(
Do you have any idea, how i could handle this?
I will try to make an attachment with the *.stp file... This is a *.txt file, so if it is possible to download this, one need to rename the ending to *.stp.
Maybe the problem gets clearer than...!?

Thank you very much again!

Best Greetings,


philippose November 9, 2010 14:12

Hi again,

Good Evening to you !!

Yes... you are right, there is an issue with the combination of the way the geoemtry on the droplet is defined, and small mesh sizes.... but as always, there is an easy solution :-)!

What you need to do, is to make use of the "Uniform Refine" feature in Netgen.... What Uniform refine does, is as the name suggests, uniformly refine the mesh... which means, every Tetrahedra is split into 8 tetrahedra...

Try the following:

Max global mesh size = 50
Min global mesh size = 0.5
Grading = 0.4

And then for the faces of the droplet.... use a Max mesh size of 5.0

Now let Netgen mesh the geometry... and once thats done (you get around 45000 volume elements), go to the "Refinement -> Refine Uniform" option.... this will uniformly refine the mesh giving you are really nice looking distribution....

Always..... after performing a Uniform refine.... also run "Mesh -> Optimize Volume"... this will improve the uniformly refined mesh even more.

Have a great evening ahead!


(P.S.... the Geometry you sent me was an IGS and not a STP file :-)!)

RugbyGandalf November 15, 2010 06:18

Dear Philippose,

thank you very much for your very helpful answers.
With your help it worked to improve the mesh and start a calculation with OpenFOAM.

I would be very happy, if i could ask more questions about Netgen when some occur..



shivaprasad123 July 7, 2011 06:04

Netgen Batch Mode (Mesh Grading)
Dear Philippose,

Iam Trying to Use NETGEN in the batch mode. It Works well for importing a STEP Geometry and then geneating volume mesh. I wanted to know how to control the mesh grading (Size ad Refinement) in the batch mode.
Can u please send me a sample Meshsize file and a RefinementInfo file.

Regarding the geometry healing... when i import a step file and perform healing and then export the geometry to a Step file...the changes (Healing Changes ...i.e, shortest edge length) are not saved.

Thanks in advance

M.ShivaPrasad Reddy

Logrus October 5, 2014 06:36

How to make mesh for OpenFOAm usage? When i trying to use included geometry files, it make syrface mesh, then mesh inside the body.But OpenFoam need mesh around body.How to make this?Sorry, but i am completely newby and cannot solve this problem.
P.S. I am using windows version of netgen.

JohnMontreal September 2, 2015 07:43

Netgen tutor online
Hi All ;
For CFD Academy online , we are looking for a netgen tutor
the academy is
thanks in advance for help
for more information please write us to
best regards.
Maria Zuzuvecha - CEO academy

All times are GMT -4. The time now is 06:17.