CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Pre-Processing (
-   -   Mesh to points cells faces and boundaries files (

billy April 28, 2005 12:36

Hi, Is there any visual too

Is there any visual tool to build the initial geometry for blockMesh?

I have noticed that OpenFOAM mesh data is very structured. The internal faces come first and then boundary faces come last. Also boundary faces are sequential for a given patch. I think this is to help create the patches.

My question is how do I translate a mesh with only a list of nodes and and a list of elements (completly unstrucutured) into OpenFOAM. I can develop a program to find the points, faces and cells but how do I extract the patches from this information?

mattijs April 28, 2005 13:08

Try gmsh. It allows you to do
Try gmsh. It allows you to do put coordinates in space (not very interactively though) and can also generate a mesh from it. Or you can probably extract the points from its .geo to use inside blockMesh.

I once used a cad package and put blocks where I wanted the blockMesh blocks and then took over the point locations. If you come across any interesting other way please let us know.

To translate those meshes have a look at one of the existing converters. Almost all use a format like you describe (i.e. cell shape and vertices) E.g. gmshToFoam.

Boundaries are usually input as a list of faces (i.e. triangles or quads using boundary points)

The polyMesh constructor in e.g. gmshToFoam will automatically convert this format into the OpenFOAM face based format.

hjasak April 28, 2005 14:53

Heya, I have noticed that O


I have noticed that OpenFOAM mesh data is very structured
Yes, that's right - I like my life well organised and it helps with the efficiency as well :-)

If you happen to have an external mesh format in terms of points, cell shapes and boundary faces, I've got just the thing for you. Have a look at:


(for me around line 288):

//- Construct from cell shapes
const IOobject& io,
const pointField& points,
const cellShapeList& shapes,
const faceListList& boundaryFaces,
const wordList& boundaryPatchNames,
const wordList& boundaryPatchTypes,
const word& defaultBoundaryPatchType,
const wordList& boundaryPatchPhysicalTypes

This constructor will take a list of points, cell shapes and a list of lists of boundary faces and make a foam mesh. In other words, it will calculate and re-order the faces for you. If you haven't got the boundary faces, you can keep the list empty and all external faces will end up in the default patch + you can re-patch the mesh later.

This is how some of the simpler mesh converters are written, have a look at the fluent and gambit converter for examples of use.



billy April 28, 2005 15:08

Thank you very much for your r
Thank you very much for your reply.

I will look into gmsh.

About the meshing, I thought of developing a tool for translating the mesh and discovering the patches (initial guess based on the connectivity and angles between boundary faces). Do you think this would be useful?

Why does the ideasToFoam translator convert ansys files and not the universal (*.unv) file?

mattijs April 28, 2005 15:17

As for the discovering of patc
As for the discovering of patches: have a look at autoPatch (in the utilities/mesh/manipulation directory) which does exactly what you describe.

henry April 28, 2005 15:24

> Why does the ideasToFoam tra
> Why does the ideasToFoam translator convert ansys files and not the universal (*.unv) file?

Because that is what we were given by the people who asked for the converter and it was easier.

billy April 28, 2005 15:27

One more thing!! I have be
One more thing!!

I have been searching for a tool to some way help me import / build geometries and visualize models with OpenFOAM.

I have looked and I can't find anyhting simple and easy to use. I thought about programming something myself using:

- Qt and QGLWidget,
- KDE-based with QGLWidget,
- GLUI and GLUT. I like this one problem is that I can't seem to get GLUI working correctly.

I don't know about Java 3D, has anyone used it? Is is easy to install and learn? I am open to suggestions.

mattijs April 28, 2005 15:44

A fourth one: the fox toolkit.
A fourth one: the fox toolkit. Ports very nicely and has nice OpenGL demo.

Java3D is quite nice but very hard to couple to C++ (if you would like to use OpenFOAM mesh routines or dictionary handling). Have a look at the patchTool in the mesh/manipulation directory.

Wasn't Guiseppe also trying to make some visual tool? (have a search on this site)

billy April 29, 2005 08:46

I have downloaded gmsh and it
I have downloaded gmsh and it seems very good. I am having problems to model complex shapes. Does anyone know of a good CAD tool for linux for solid modelling and meshing? I have seen OpenCASCADE and SALOME but I can't get them installed properly.

Fox toolkit is also very nice and comes with great examples. I will try to learn more about it.

Thanks for the tips.

hsieh April 29, 2005 13:33

Hi, Billy, I have been usin
Hi, Billy,

I have been using netgen (with step format generated using SolidWorks). I have built complex geometry meshes without any problem. There are two drawbacks assoicated with netgen:

1. only supports Tet elements.
2. can have only one volume.


billy April 30, 2005 12:02

Hello everyone, I finally i
Hello everyone,

I finally imported my meshes into OpenFOAM. I converted all of them into gmsh format (list of nodes and elements) and then used gmshToFoam utility as suggested here. It worked great, organized all the data and wrote the points, faces and cells files. Then I ran the autoPatch utility and it reconstructed the boundary patches automatically. This also worked very well.

The funny thing is that I still can't translate the meshes built using gmsh. It gives an error about missing a face or something. However, this doesn't matter for now because the other method works very well.

I am very impressed with OpenFOAM capabilities. I wish that I can also contribute to OpenFOAM development some day.

Thank you very much.

mattijs April 30, 2005 12:18

Hi Billy, Did you use the l
Hi Billy,

Did you use the latest gmshToFoam.C? It has some additional commandline options (-invertHex, -invertPrism) and you'll need to run checkMesh afterwards on the resulting OpenFOAM mesh until you figured out the correct option.

This gmshToFoam.C is posted somewhere. Have a search.

billy April 30, 2005 18:20

Hi Mattijs, Maybe it is not
Hi Mattijs,

Maybe it is not the latest version, since I am using OpenFOAM 1.0.2. I will check that out. Thanks.

hsieh May 4, 2005 10:32

Hi, Mattijs, Can you give a
Hi, Mattijs,

Can you give a brief explaination how autoPatch works? I took a look at it. It requires input of an angle. Does it mean that it will try to find the boundary faces with the specified angle? What if I have a curved boundary patch (the angles of the boundary faces of this boundary patch may vary)? Thanks!


eugene May 4, 2005 17:20

IIRC autoPatch groups faces in
IIRC autoPatch groups faces in boundary regions that are not seperated by a corner of the specified angle (i.e. feature lines). Note autoPatch will replace all old patches with feature line delineated patches.

akamgang May 13, 2005 14:20

hello Billy ; i am Trying
hello Billy ;

i am Trying to do a volume Mesh but i will like to know if there are some Basich ron rules concerning the Volume Mesh ???
And Please tell hoe to view a file after Exporting on MED Format ??? i have tried to export a file after meshind and i could not open it after , please tell me how to do it.

billy May 14, 2005 06:49

Hi Alain, I do not recogniz
Hi Alain,

I do not recognize the MED format. Do you mean MSH format?

Until now, I have only used the MSH format of GMSH + autoPatch utility to import meshes into OpenFOAM.

akamgang May 17, 2005 18:34

Hi Billy ; Do you know the
Hi Billy ;

Do you know the Open souce Programm Salome
that which i have been asking you is a specific format base on Salom , and i have not found any ook where i can get information concerning Salome.Please if you have any information about this please just tell .

hsieh April 18, 2006 15:00

Hi, Billy, It looked like y
Hi, Billy,

It looked like you have successfully converted your mesh to gmsh format and then converted to OpenFOAM format using gmshToFoam. I have a mesh exported to Ansys format from I-DEAS. I might be able to convert the Ansys format to gmesh and do exactly what you did. In the gmsh format, do you know what reg-phys and reg-elem are?

reg-phys: the number of the physical entity to which the element belongs.
reg-element: the number of the elementary entity to which the element belongs.

I do not understant these definitions. What is elementary entity?

It will be appreciated if you can shed some light on this.


hsieh April 18, 2006 15:38

Hi, Billy, I just found out
Hi, Billy,

I just found out that I-DEAS does not support pyramid. I have a part with two volumes, one volume was meshed with Hex and one volume was meshed with Tet. So, on one face of some Hex elements, the Quad face was split into two triangles (this occurs on the Hex element that has Tet neighbours). Can OpenFOAM handle this situation?


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