CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Meshing & Mesh Conversion (
-   -   Error converting Gmsh mesh to OpenFOAM format (

Martin_ December 8, 2009 10:16

Error converting Gmsh mesh to OpenFOAM format
2 Attachment(s)
Dear OpenFOAM users,

I've been using gmsh for some time now and I'm very happy with this grid generator. I'd also like to work with OpenFOAM, but I'm not able to convert a simple mesh (cube with all faces defined as physical in my geo file) using gmsh2ToFoam. I went through the forum, followed some advices but nothing helped me to solve my problem. The error message I get is this:

--> FOAM Warning :
From function polyMesh: polyMesh(... construct from shapes...)
in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 577
Found 136 undefined faces in mesh; adding to default patch.

I'm not sure if the problem is caused by the msh file created by gmsh or if my testcase which I use for conversion is missing some important information. One thing I'm particularly uncertain about is whether the orientation of the faces of the cube matters or not (should all face normals point outside the cube, for example?). Could anyone please be so kind and either give me a hint or provide me with some conversion testcase which works (can be a very simple one)?
I'm using OpenFOAM 1.6 and gmsh 2.4.2.
The complete output of OpenFOAM and the whole case directory are attached.

Thank you very much

Martin Vymazal

P.S. I hade to remove Cube.msh from the attached folder ConversionTest.tar.gz because the size of attachments is limited. However, the msh file can be reproduced by running 'gmsh -3 Cube.geo'. The file Cube.geo is included.

elorriaux December 9, 2009 07:43

Hello Martin,

upgrade to OpenFOAM-1.6.x, it includes a fix for gmsh >= 2.4 format, or downgrade to gmsh 2.3.



Martin_ December 9, 2009 08:53

Hello Etienne,

thank you for the reply. I was not exact in my previous post. I have OpenFOAM 1.6.x and I'm already using your fix (thanks for it). I tried to generate the mesh with Gmsh 2.2 and with Gmsh 2.3 and in both cases, the error remains the same. I tried both the legacy ('version 1') format of msh files and the version 2 format. The only difference is that when I use the old format, I have 150 undefined faces in mesh, while with version 2 format, I have 156 undefined faces. As a first step, I'd like to know if the problem is with my installation of OpenFOAM or if it is caused by the gmsh file. Could you please be so kind and provide me (even with a very simple) gmsh file that works for you?

Best regards,

Martin Vymazal

elorriaux December 9, 2009 10:35

Hi again,

it's just a warning, I've never searched the reason of the warning, but it's not fatal, don't care about it. I've already used many gmsh meshes (I only use version 2 format since a long time) showing this warning without any problem.

I've tried your mesh file (with gmsh dev version), and I'm also getting this warning, but the mesh is valid, run checkMesh on your case. The only warning you will get with your mesh concerns non orthogonal faces. It's due to your non structured tetrahedral mesh which is not recommanded for CFD. You should use a structured hexahedral mesh (in gmsh, just do a simple square and mesh it using transfinite and recombine functionalities, then extrude it and recombine to get a structured hex meshed cube). But in any case, your mesh is valid after conversion.

You can also check that the defaultFaces patch (the one concerned by the warning) contains 0 faces (you can edit constant/polyMesh/boundary to check it).

Regards, Etienne.

edit: why are you using gmsh2ToFoam? Just use the standard gmshToFoam utility provided in OF-1.6.x.

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