CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Open Source Meshers: Gmsh, Netgen, CGNS, ... (
-   -   problem converting mesh from gmsh (

Fried October 17, 2011 05:28

problem converting mesh from gmsh
Hello everyone,
as a OpenFoam user, I always build my mesh with gmsh and then export it with gmshToFoam.
Now, I have a problem I cannot solve. My geometry is a squared horizontal channel on which some vertical channels for inlet and outflow are placed. These channels are not aligned and they are cylindrical. I want to run a 3D simulation.
On gmsh everything is fine, all displayed and with correctly groups (boundaries) assigned. When I export to OpenFoam one of the channels disappears, a defaulfaces region is crated on the face of its intersection with the horizontal channels and in the output file I get this message:

Could not match gmsh face 4(27013 27044 27035 27052) to any of the interior or exterior faces that share the same 0th point

As I said, I checked more than once with gmsh and there everything looks fine. Changing mesh refinement on the sides does not change anything. I also have to say that if I try draw every single vertical channel alone it works.
Please, does anyone have an idea or a tip for that?

Hisham October 17, 2011 16:29

Hi Fried

I have no clear idea (actually no clue). But maybe you could try the following:
2. Generate the parts separately import them to different cases then merge and stitch them with OF utilities (e.g.
1. Try rebuilding your Gmsh model in a strictly incremental way "commenting blocks of the .geo file" and exporting the mesh (after each change) to have a better idea of what went wrong
3. Maybe provide the .geo file

Good luck!

Fried October 18, 2011 03:36

1 Attachment(s)
Hello Hisham,
thanks for the answer, I am going to look how the utilities you mentioned work (I guess the stitchMesh, if I want to make the vertexes coincide).
I post here the .geo file I use to build my geometry. Maybe this will give some inspiration? I already tried to make piece by piece and in that case it works; the problem is when I put all the channels at the same time.
Thanks again,

Hisham October 18, 2011 04:27

Hi Fried,

I ran gmshToFoam on the mesh. I guess maybe some external patches are not defined as physical surface. I would try to carefully review that, but I am sure you did! But why not do that again.

I found all volumes are defined as a physical vol. and I can't spot a bug really.

You may want to re-select your physical surfaces using the GUI and compare them to the ones you did before (just unbiased check)

You may also separate the extrude for the missing vol.


Fried October 18, 2011 04:38

Hello Hisha,
thanks again for the tips. unluckily I already tried all the options you mentioned. I only have one doubt, concerning surface 3, since i define it using many loop lines: do I need to give them a -/+ direction? (actually I tried also this, then I don't think so...)
But from your answer, should I guess the problem is in gmsh?
Couldn't it be related to the gmshToFoam utility?
Any other idea looking to the geo file?
Thanks again,

Hisham October 18, 2011 05:02

It is obvious that there is no problem with gmsh. The error is either in the gmshToFoam or just an input error. It is always a good idea to eliminate the second possibility first.

Looking at gmshToFoam.C near line 954, there is a comment about internal faces and faceZones. What I understood is maybe you need to define some extra internal surfaces as physical surfaces and see if it works. They will not appear as patches (in boundary file) rather a faceZone.


Fried October 18, 2011 07:52

Hallo again Hisham,
I tried adding internal faces but again it didn't give the result I hope.
Then, I would like to try with stitchMesh, but I am not familiar enough to use it properly, I am afraid.
Please, could you drive me step by step (I mean, with the command lines for stitchMesh)?
I already created the two different meshes. Then, I don't know if I did correctly, I put them in two different directories and built them separately but now?
Thanks a lot in advance!

Hisham October 18, 2011 08:30

Sorry! I have not used these utilities before. Maybe search the forum or Google it. If results are not helpful, try starting a new thread on the topic to attract their users.

I would also suggest trying to play with gmshToFoam switches (gmshToFoam -help).

If all is not working, maybe use blockMesh with #codeStream (OF 2.x) support like the potentialFoam cylinder tutorial (better than typical blockMesh). Or else maybe draw a CAD model and import it to gmsh before meshing!


Fried October 18, 2011 08:53

Ok, I will try with a new tread about merge/stitchMesh
Thanks for the help

All times are GMT -4. The time now is 01:16.