CFD Online Logo CFD Online URL
Home > Forums > Open Source Meshers: Gmsh, Netgen, CGNS, ...

gmshToFoam : problem with patch

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   October 4, 2009, 05:28
Default gmshToFoam : problem with patch
Jean-Michel FONTAINE
Join Date: Aug 2009
Location: Orleans - France
Posts: 53
Rep Power: 10
jmf is on a distinguished road
Hello everybody

I try to use gmshToFoam (from 1.6 binaries) to convert meshes with patches from gmsh 2.4.2.

I get following error message:

Found $MeshFormat tag; assuming version 2 file format.
Starting to read physical names at line 5
Physical names:3
wrong token type - expected string found on line 0 the label 1
file: IStringStream.sourceFile at line 0.
    From function operator>>(Istream&, string&)
    in file primitives/strings/string/stringIO.C at line 57.
FOAM exiting
I assumed that gmshToFoam supports now .msh version 2
Does anybody know how to solve that ? Here attached one mesh sample

Thanks in advance

Attached Files
File Type: zip (1.3 KB, 23 views)
jmf is offline   Reply With Quote

Old   October 4, 2009, 06:43
Senior Member
Philippose Rajan
Join Date: Mar 2009
Location: Germany
Posts: 549
Rep Power: 18
philippose will become famous soon enough
Hello Michel,

A Good Day to you!

I was looking through the GMSH "msh" file that you have posted. It looks like there was a change in the "msh" file format when GMSH 2.4.0 (22 Aug 2009) was released.

The older "msh" versions had the following format for the patch names:
<length of list>
<number> <patch name>

The current "msh" has the following format:
<length of list>
<physical dimension> <number> <patch name>

gmshToFoam parses the mesh file using the first format, and hence, aborts with an error because the current format has an additional number in each row.

This is a change which has to be made by the maintainers of the "gmshToFoam" code.

The other option is that you make the change to the file "gmshToFoam.C" at line number 316:

lineStr >> regionI >> regionName;


lineStr >> physDim >> regionI >> regionName;

and just ignore the variable "physDim" in the rest of the code. If this works fine, you can submit the change to the "bugs" section of the forum, and get it integrated into the OpenFOAM code base.

I am not sure why this change was made in GMSH, but here is the change log entry which mentions this change:

2.4.0 (Aug 22, 2009): switched build system to CMake; optionally copy
transfinite mesh contraints during geometry transformations; bumped
mesh version format to 2.1 (small change in the $PhysicalNames
section, where the group dimension is now required); ported most
plugins to the new post-processing API; switched from MathEval to
MathEx and Flu_Tree_Browser to Fl_Tree; small bug fixes and
improvements all over the place.

Hope this helps...!

Have a nice day!

philippose is offline   Reply With Quote

Old   October 4, 2009, 09:22
Super Moderator
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 13
7islands is on a distinguished road
Hi guys,
Mattijs says the fix is already in 1.6.x:

7islands is offline   Reply With Quote

Old   October 4, 2009, 16:27
Default gmshToFoam : 1.6 version may not handle .msh version 2.0
Jean-Michel FONTAINE
Join Date: Aug 2009
Location: Orleans - France
Posts: 53
Rep Power: 10
jmf is on a distinguished road
Dear Philippose and Takuya

Thanks for the time you spend to help me.

The cause of the problem is indeed the new dimension field in patches list.
gmeshToFoam works again after removing this field in each patch line at the beginning of .msh file.

Apparently my OF1.6 did not include up to date gmeshToFoam.
I followed the link given by Takuya, and compiled gmeshToFoam.C.gz archive posted by Etienne. Now it works.

Many thanks to all of you


jmf is offline   Reply With Quote


gmshtofoam patch

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Runing InterFoam for 3 D damBreak case Patch issue nishant_hull OpenFOAM Running, Solving & CFD 5 February 18, 2009 01:32
Given field does not correspond to patch david OpenFOAM Bugs 2 January 29, 2009 14:24
Adiabatic and Rotating wall (Convection problem) ParodDav CFX 5 April 29, 2007 19:13
Import gmsh msh to Foam adorean Open Source Meshers: Gmsh, Netgen, CGNS, ... 24 April 27, 2005 08:19
Multicomponent fluid Andrea CFX 2 October 11, 2004 05:12

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