CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Pre-Processing (
-   -   Import geometry from CAD (

Giuseppe (Giuseppe) February 13, 2005 07:55

Is there any tool to import g
Is there any tool to import geometry from CAD ?
I mean, is it possible to import geometry from PRO/E, UG or from IGES, STL and so on ?
In my opinion, it is very hard to define the geometry in blockMeshDict file for complex domains: it should be very important to have a tool to model the geometry in an user friendly way or, alternatively, to have the possibility to import geometry modelled in CAD.

Thank you


Eugene de Villiers (Eugene) February 13, 2005 08:28

OpenFOAM has several unitliti
OpenFOAM has several unitlities to convert all the major mesh formats (Fluent, STAR, gridgen and many more) into Foam format. So your best bet is to use one of these 3rd party meshers to convert the CAD geometry and then to import it into OpenFOAM.

While a CAD-> mesh tool would obviously be very usefull, development of such a utility is difficult, costly and time consuming. Given that OpenFOAM is open source, it pretty much has to be written in someone's spare time.

As a free option, netgen or tetgen are probably your best options. Both produce all tetrahedral meshes from STL surfaces.

Pei-Ying Hsieh (Hsieh) February 13, 2005 08:48

HI, I think Netgen is the

I think Netgen is the best tool because the latest version can import STEP format. IGES format is somewhat problematic. Another good thing about Netgen is that "it is open source". I have not played with it enough. I do not know how good its mesh control is (dense elements in one area and coarse elements in other areas).


Henry Weller (Henry) February 13, 2005 09:38

For those wanting to avoid tet
For those wanting to avoid tet-meshes (as I do) gmsh is an interesting opern-source mesher:

Giuseppe (Giuseppe) February 13, 2005 10:22

I'm developing a software usi
I'm developing a software using java + VTK .
This software reads a STL geometry and produces a tetrahedral mesh using both the adventure and Tetgen meshers.
I'm at early stage of development but my software can mesh very complex geometry (with automatic mesh refinement based upon local curvature of stl geometry). My target was to make a preprocessor and meshing tool for tochnog (I have alredy performed stress analysis calculation): the postprocess is done by paraview. I tried to convert a .msh file with the conversion utility mshToFoam but the it seems that the program requires also the blockMeshDict file: is it correct ?
If this is true the problem is to convert the cad geometry to a blockMeshDict file.
Now I see that OpenFoam performs also stress analysis (only plane stress or plane strain ??) computation and so I'm planning to use also OpenFoam engine to integrate my program.
I tried Netgen: it seems to fail or require hepic meshing times with complex geometry.
Tetgen is not bad.
In my opinion the best mesher is the Adventure one.
gmsh fails with complex geometry and does not work with stl (even if it reads stl).


Mattijs Janssens (Mattijs) February 13, 2005 10:39

Hi Guiseppe, sounds very i
Hi Guiseppe,

sounds very interesting the work you are doing! Will this be an open source tool?

About mshToFoam: it should not need a blockMeshDict. Could be a bug. What kind of error are you getting?

Will your tool allow you to select sets of faces to create a patch from? Would be great to scrap patchTool and use your tool.

We also have the need for a tool to select arbitrary faces / cells or points inside a mesh. We work a lot with faceSets, cellSets and pointSets to do various things but they are hard to select at the moment.


Giuseppe (Giuseppe) February 13, 2005 10:56

Hi MattiJs, I am not used to
Hi MattiJs,
I am not used to law and licenses: I don't know if my software could be a open source one because one of the developing language is java (I use Netbeans IDE) and java is licensed under the Sun public licence. If someone could explain me the details I do not have problem to share my job.
I must say that my work progresses very slow: I do not have much time to work.
By now in my software a can pick points to assign boundary conditions: i was planning to develop an algorithm to select areas or lines but it seems an hard question.

This is the error from mshToFoam:

| ========= | |
| \ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \ / O peration | Version: 1.0.2 |
| \ / A nd | Web: |
| \/ M anipulation | |

Exec : mshToFoam /home/giuseppe/Desktop/win_d/backup-29012005/prove7 stl2pch-14 uno.1.ele.msh
Date : Feb 13 2005
Time : 15:00:07
Host : localhost
PID : 5406
Root : /home/giuseppe/Desktop/win_d/backup-29012005/prove7
Case : stl2pch-14
Nprocs : 1
Create database

--> FOAM FATAL IO ERROR : cannot open file

file: /home/giuseppe/Desktop/win_d/backup-29012005/prove7/stl2pch-14/system/controlDict at line 0.

Function: regIOobject::readStream(const word&)
in file: db/regIOobject/regIOobjectRead.C at line: 68.

FOAM exiting


Mattijs Janssens (Mattijs) February 14, 2005 05:51

Hi Guiseppe, mshToFoam req
Hi Guiseppe,

mshToFoam requires a system/controlDict file. This file determines among others where and how the mesh files (from converting .msh data) are written.

It does not require a blockMeshDict (the input file for the blockMesh utility).


Giuseppe (Giuseppe) February 14, 2005 17:01

Hi MattiJs, you are right.
Hi MattiJs,
you are right.
I'm new to OpenFoam and as you can see I make trivial errors.
Anyway mshToFoam works: I meshed with 4 node tetrahedrons a 3d complex domain with my software and then I used mshToFoam.
What I understand at a first sight is that all the surface faces are considered as default patches.
Now I need a little time to understand more deeply the OpenFoam system to see if it is possible to develop a gui to apply boundary condition and loads in a user frindly fashion.
Some questions:
1) does Open foam perform stress analysis in 3D domains ?
2)Is it possible to perform thermo-fluidodynamic simulation of a fluid with phase change (e.g: solidification of metal in a mould)

Thank you


Mattijs Janssens (Mattijs) February 15, 2005 04:11

Hi Guiseppe, the problem i
Hi Guiseppe,

the problem is that Adventure/msh does not seem to output any patch information. (correct me if I'm wrong)

1) yes, stressedFoam (finite volume stress) or stressedFemFoam (finite element stress)


Henry Weller (Henry) February 15, 2005 05:02

2) Yes but we don't yet inclu
2) Yes but we don't yet include a sample application for this. However, if you have the model for the process you should be able to adapt the example codes we do supply for your purpose.

Giuseppe (Giuseppe) February 15, 2005 17:26

Mattijs, it is correct what
it is correct what you say.
Anyway during the conversion mshToFoam produces the points, faces, cells files.
It also produces a boundary file with all the surface triangles.
The problem I want to solve is the following: the patches can be the union of one ore more boundary faces of the mesh.
I would like to develop a program to select the faces, apply the boundary condition and create a corrected boundary file and initial values directory.


1) does stressedFoam or stressedFemFoam perform only plane stress or plane strain analysis or it is possible to perform also generic structural analysis ?

Henry, I will try to adapt some example to fit my need to simulate casting process.


Pei-Ying Hsieh (Hsieh) February 15, 2005 17:47

Hi, Giuseppe, For the limi
Hi, Giuseppe,

For the limited time that I played with Netgen, it allows you to select the face(s) and set a boundary condition number (1, 2 , 3 ..etc.). Using netgenToFoam utility, the boundary file can be edited to the correct physical boundary conditions (such as inlet, outlet..).

In this CAD to foam topic, I think that the strongest point of Netgen is that it can import STEP format. I think STEP is much better(easier?) than IGES and stl.

I think that based on what you describe, your tool will be very cool (similar to gambit, but, gambit does not let the users define initial condition). Is there a possibility add STEP conversion into your tool?


Giuseppe (Giuseppe) February 15, 2005 18:00

Hi Pei, I agree with you abo
Hi Pei,
I agree with you about Netgen possibilities.
There is a problem: I tried to import and mesh complex geometry (stl, stp, igs) in Netgen: generally Netgen is not able to mesh them (perhaps I don't make the correct setup).
The possibility of Netgen to import igs and stp relies on the fact that Netgen uses the OpenCascade modules.
I tried to understand how to use OpenCascade in my program: the problem is to make the java Wrappers.
For Python exists PythoCascade (OpenCascade wrappers for Python).
For Java (my program uses Java) I don't know if exist OpenCascade wrappers or if I have to use the JNI.


Eugene de Villiers (Eugene) February 15, 2005 18:07

I think many people and espec
I think many people and especially those just starting out with OpenFOAM would find an integrated mesher/pre-processor useful.

Re your questions:
Both stress solvers are 3D.

If you want to modify a code for casting, I suggest starting from the two-phase VOF codes interFoam.

Mattijs Janssens (Mattijs) February 16, 2005 04:59

To create boundary regions (p
To create boundary regions (patches) you can

- use the mesh/manipulation/patchTool/runPatchTool
utility. It allows you to select faces, collect them in a set and create a patch from them. It is not very nice though and I'd love to scrap it (though the auto-patch facility is nice)

- use the autoPatch utility. It will generate patches on all regions separated by feature edges. Works great for simple geometries like lid-driven cavity

- createPatch can add patches together or take a faceSet (list of face labels) and create a patch from that. faceSets can be created using the faceSet utility.

- if you have a surface with the correct region information (e.g. 'SOLID..ENDSOLID' in stl) you can apply that information using surfaceToPatch which will take over the region information onto the nearest boundary face.

- if you're feeling adventurous: you can edit the patch names and types in the polyMesh/boundary by hand. Do not change the start and size parameters since they should be consistent with the mesh itself.


Giuseppe (Giuseppe) February 17, 2005 09:52

Thank you Mattijs. For Pei
Thank you Mattijs.

For Pei:
were is located the netgenToFoam utility ?


Pei-Ying Hsieh (Hsieh) February 17, 2005 18:32

HI, Giuseppe I got the netg
HI, Giuseppe

I got the netgenToFOam utility from Mattijs. Please send me your email address so that I can email you.


Giuseppe (Giuseppe) February 20, 2005 07:13

Hi Pei, I sent you an e-mail.
Hi Pei,
I sent you an e-mail.
Than you in advance.


P.S.: I have seen that a new release of Salome is ready( My first impression is that this is a very powerfull tool for pre and post processing.

Also OpenCascade 5.2 is ready (

gruber2 August 8, 2005 10:30

Hi Pei, Mattijs, Giuseppe
Hi Pei, Mattijs, Giuseppe

We are a Heating Company and want to Import 3D-Models from our CATIA System to OpenFOAM.
As it is described, I want to Export the 3D-Models from CATIA as STEP-Files, import and mesh it in netgen and transfer it with 'netgenToFoam' to OpenFOAM.

Please send me the 'netgenToFoam'-Tool or tell me where i can download it.

My email address is:

All times are GMT -4. The time now is 07:38.