CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Open Source Meshers: Gmsh, Netgen, CGNS, ... (
-   -   Dealing with stl files from Calculix in Netgen (

psosnows February 12, 2009 09:03

Hello Foamers, since my wor
Hello Foamers,

since my work required creating tetragonal mesh, as advised on this forum I went on with installing Calculix-1.7 (for geometry) and Natgen-4.9.5 (for meshing).
After a lot of effort I managed to make it running.

Now I am trying to get some basic experience with creating a tetragonal mesh with those tools. And (as suspected) some problems appeared.

I created geometry in Calculix (simple, ordinary cube with 4 points on each edge):

PNT P000 -0.00000 -0.00000 -0.00000
PNT P001 -0.00000 1.00000 -0.00000
PNT P002 1.00000 1.00000 -0.00000
PNT P003 1.00000 -0.00000 -0.00000
PNT P004 -0.00000 -0.00000 1.00000
PNT P005 -0.00000 1.00000 1.00000
PNT P006 1.00000 1.00000 1.00000
PNT P007 1.00000 -0.00000 1.00000
LINE L000 P000 P001 4
LINE L001 P001 P002 4
LINE L002 P002 P003 4
LINE L003 P003 P000 4
LINE L005 P004 P005 4
LINE L006 P005 P006 4
LINE L007 P006 P007 4
LINE L009 P007 P004 4
LINE L00A P000 P004 4
LINE L00B P001 P005 4
LINE L00C P002 P006 4
LINE L00D P003 P007 4
GSUR A000 + BLEND + L000 + L001 + L002 + L003
GSUR A001 + BLEND + L005 + L006 + L007 + L009
GSUR A002 + BLEND - L00A + L000 + L00B - L005
GSUR A003 + BLEND - L00B + L001 + L00C - L006
GSUR A005 + BLEND - L00C + L002 + L00D - L007
GSUR A006 + BLEND - L00D + L003 + L00A - L009
GBOD B000 NORM + A000 - A001 - A005 - A006 - A002 - A003

After that I performed:
mesh all
send all stl

This created 2 files:
all.stl (with stl triangles) and all.nod (with edges)

I opened Netgen and read the geometry.
And got this error message:
ERROR: 64 wrong oriented neighbourtriangles found!
ERROR: try to correct it (with stldoctor)!

I belive that this is due to wrong surface orientation.

As expected, any attempt of meshing results Netgen to dump.

Unfortunately I could not find manual to stldoctor (it is not provided yet). I simply do not know what is wrong and how to fix this.

Do any of You have some ideas how to overcome this problem?

Thanks in advance!

philippose February 12, 2009 14:38

Hello Pawel :-)! Looks like
Hello Pawel :-)!

Looks like I end up catching you here too :-)! A Very good evening to you :-)!

So you are having trouble with STL Files exported from Calculix into Netgen....

Try the following:

1. Open the STL file in Netgen

2. Turn around the geometry in the GUI, and see if you can find triangles which are "light" or "bright" blue....
... In Netgen, triangles which are oriented with their normals facing outwards are always brighter coloured than triangles whose normals point inwards into the geometry

3. Now... In the "Geometry" menu, choose the "STL-Doctor", and change the "Double click selects" option to "triangle"

4. Switch to the "Edit Topology" tab

5. Double click on one of the triangles on the geometry which is coloured bright blue.

6. Once the triangle is selected, click on the "orient after selected trig" button in the STL Doctor window

Now, all the other triangles should also turn bright blue....

As a check, if you choose the "STL Info" menu option under the "Geometry" menu, you should see "Status: Good"

If you are having more trouble.... send me the STL file that you generated using calculix, and I could have a look...

Have a great day!


psosnows February 12, 2009 16:42

Hi Phillipose! It just as t
Hi Phillipose!

It just as the old saying tells: the World is small ;-) especially when you deal with some speciallistic field, and I belive open-software numerical simulations are one of them.

Your guide works great- the geometry is loaded correctly.
(to be honest I needed half an hour to find it myself, but hope this topic will help someone in the future)

In the end, I have a question very close to the last one:

Lets get back to the geometry I described in the first post. Before I send it to stl file, I mesh it with triangles. I get 2 files: .stl .ned.
After loading .stl to Netgen I follow steps described by you and get correct geometry.
The question is about the triangular surface mesh generated by Calculix. I found two ways of applying that surface mesh as "pre-mesh" for Netgen to calculate 3D mesh:

1) go to stldoctor, select "Edit Edges", set "double click marks as confirmed" and double click on each and every line corresponding to each triangle. After that, save the edgedata

2) I wrote a simple program which extracts all different lines witch are parts of triangles in .stl and writes it in .ned format.

The first approach is terrible even for simple geometries. As for the second, I am not sure will the program work correctly for more complex meshing (I did not worry about the order of the two points which describe the lines).

Did I miss some simple method of sellecting edges? Or is there some other way?
This question refers only importing triangular mesh from Calculix ;-)

philippose February 12, 2009 17:58

Hello again Pawel, Great to
Hello again Pawel,

Great to hear that you were able to get the geometry into Netgen :-)!

As for Calculix... I must say... have never used to software before!

What information does the ".ned" file actually store? Is it the size of the mesh at each co-ordinate or something similar?


psosnows February 12, 2009 18:54

Greetings once again Philippos
Greetings once again Philippose,

the .ned file seems to have very simple structure:
in the first line you find number of data lines,
and it is followed by that number of lines. Each of them has 6 numbers divided by white characters. First three give xyz coordinates of first point of the edge, second triplet describes xyz of the second point.

This is the beggining of .ned file generated by Calculix for my simple cube case:
2 -2.775558e-17 -2.775558e-17 -2.775558e-17 -2.775558e-17 5.000000e-01 -2.775558e-17
2 -2.775558e-17 5.000000e-01 -2.775558e-17 -2.775558e-17 1.000000e+00 -2.775558e-17

My concern is that as I remember, different generators and solvers use different orders in numbering points (so line AB differs from line BA). As I mentioned before, if I use my own generated .ned file which does not use any rule to keep order between points, for simple cases it works ok.

As for Calculix, I found some opinion (even on this forum) that it is really great tool for geometry and hexagonal mesh generation. It also allows to export mesh and geometry to OF. In fact I find it quite pleasent to work with. Unfortunately it does not support tetragonal meshing (this explains Netgen).

Btw, I looked around Netgen a little more, and now I am sure that even without this edge transfer routine I will be able to generate mesh siutable for my case (refining makes wonders ;-) )


psosnows February 12, 2009 19:06

ahh, as for the second questio
ahh, as for the second question (it is getting late...):

the .ned file can be loaded/saved by Netgen in stlDoctor (in EditEdges: "load edgedata"/"save edgedata"). In my opinion it describes the edges that Netgen sould consider while mesh generation. That is why I think if one wants to use "pre-mesh" created in stl, he has to load the stl triangles and "confirm" each edge of each triangle to be used. After this "confirmation" and saving, they are added to .ned file and used by Netgen in mesh generation.

Please correct me if I am wrong.



desert_1250 June 25, 2011 03:50

Hi fomers
why can't open the .stl file with GAMBIT, i created .stl file with MATLAB, but when i import it into GAMBIT or other vitualized software such az NETGEN or STL viewer,cant open it:( i am very confused that why this happen. can every one help or guide me. tnx

vikramanvikraman July 11, 2011 11:17

dear Philippose rajan this is vikraman
i sent u a mandible mesh u hav not replied me yet
about it ..pls... reply still i am unable to creat a volume mesh for FEA with it
hope u reply

All times are GMT -4. The time now is 21:12.