CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[Gmsh] Version 20 of the bmshb file format to FOAM converter

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 15, 2007, 22:24
Default Version 20 of the bmshb file format to FOAM converter
  #1
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
Hi all,
Have anyone tried supporting version 2.0 of the .msh file format in gmshToFoam?

Thanks,
Takuya
7islands is offline   Reply With Quote

Old   February 16, 2007, 01:58
Default OK here's the one (with quick
  #2
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
OK here's the one (with quick and dirty hacks of course).
gmshToFoam-20070216.C
Regards,
Takuya
7islands is offline   Reply With Quote

Old   February 16, 2007, 08:32
Default Hi all, I've renamed it to gm
  #3
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
Hi all,
I've renamed it to gmsh2ToFoam and posted it on Wiki.

http://openfoamwiki.net/index.php/Contrib_gmsh2ToFoam

Takuya
7islands is offline   Reply With Quote

Old   February 17, 2007, 23:50
Default Hi all, I've made an importan
  #4
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
Hi all,
I've made an important fix to the correspondence problem between OpenFOAM cellZone/patch numbering and Gmsh physical/elementary entity tagging.

If there's anyone who have tried the first version could you please try the new version (gmsh2ToFoam-20070218) again.

Thanks,
Takuya
7islands is offline   Reply With Quote

Old   February 19, 2007, 03:55
Default Hi Gmsh users, This time gm
  #5
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
Hi Gmsh users,

This time gmsh2ToFoam assigns physical entity names defined by "Physical Surface" and "Physical Volume" gmsh commands (such as "inlet", "outlet", ...) to patches / cellZones / faceZones insted of automatically generated names (such as "patch0", "patch1", ...). This is realized by utilizing one of the new key features in Gmsh 2.0.

This is supposed to be useful especially in practical use and actually is what I really wanted to do through gmsh2ToFoam. For Gmsh 1.x users who don't get what I mean, I've prepared a deteiled example on the Wiki.

http://openfoamwiki.net/index.php/Contrib_gmsh2ToFoam

Thanks,
Takuya
7islands is offline   Reply With Quote

Old   February 21, 2007, 07:18
Default Thanks for the updates Takuya.
  #6
Senior Member
 
Srinath Madhavan (a.k.a pUl|)
Join Date: Mar 2009
Location: Edmonton, AB, Canada
Posts: 703
Rep Power: 21
msrinath80 is on a distinguished road
Thanks for the updates Takuya. I'll give your version a try when I create my next mesh
msrinath80 is offline   Reply With Quote

Old   March 9, 2007, 09:27
Default Hi Marco, Thanks for testing
  #7
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
Hi Marco,
Thanks for testing gmsh2ToFoam. Seems that gmsh2ToFoam.C you tested is an old one (maybe the initial version I guess) since the current version gmsh2ToFoam-20070305 (05 Mar 2007) on the Wiki already has the code almost exactly like what you wrote. Further the 20070305 version can assign string labels in $PhysicalNames section as patch names. If you have time to test the version please give it a try.

Takuya
7islands is offline   Reply With Quote

Old   March 9, 2007, 10:13
Default Hi Takuya, I write a small pi
  #8
Member
 
Marco Moscaritolo
Join Date: Mar 2009
Location: Bergamo, Italy
Posts: 33
Rep Power: 17
mavimo is on a distinguished road
Hi Takuya,
I write a small piece of code to applay $PhysicalNames to patch generated with gmsh2ToFoam, the name of physical surface is saved into physicalNameList variable and after the code apply this name to patch (replace pathc0, patch1, ...). It's so easy to write the code, I don't have my version of gmsh2ToFoam.C file on this PC, sorry, but work with my case (It has not been tested with other models).

Bye
Marco
mavimo is offline   Reply With Quote

Old   March 9, 2007, 10:55
Default Hi, Yes, that's exactly what
  #9
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
Hi,
Yes, that's exactly what I've done in the newest gmsh2ToFoam-20070305 (saving the region numbers and string labels in $PhysicalNames section into arrays and later matching the numbers with the labels). Maybe with your knowledge you can get what I've done as soon as you look into my newest code.

http://openfoamwiki.net/images/e/eb/...0070305.tar.gz

Additionaly, the code also has ability to remove unused points (still experimental though) frequently discussed in the Gmsh mailing list e. g.:
http://www.geuz.org/pipermail/gmsh/2007/002396.html
so that checkMesh test no longer fails even if a .msh file contains such points.

Takuya
7islands is offline   Reply With Quote

Old   March 9, 2007, 11:22
Default Thanks Bya Marco
  #10
Member
 
Marco Moscaritolo
Join Date: Mar 2009
Location: Bergamo, Italy
Posts: 33
Rep Power: 17
mavimo is on a distinguished road
Thanks

Bya Marco
mavimo is offline   Reply With Quote

Old   March 9, 2007, 11:23
Default Thanks! Bye Marco
  #11
Member
 
Marco Moscaritolo
Join Date: Mar 2009
Location: Bergamo, Italy
Posts: 33
Rep Power: 17
mavimo is on a distinguished road
Thanks!

Bye
Marco
mavimo is offline   Reply With Quote

Old   March 9, 2007, 18:21
Default I have create a new model with
  #12
Member
 
Marco Moscaritolo
Join Date: Mar 2009
Location: Bergamo, Italy
Posts: 33
Rep Power: 17
mavimo is on a distinguished road
I have create a new model with gmsh 2.0.4:
// Gmsh project created on Mon Mar 5 14:41:29 2007
nc = 10;

// ************************************************** ***** //
// * Flame plane *
// ************************************************** *****
Point(1) = {0,0,0,0.1};

l1[] = Extrude {0,0.035,0} { Point{1}; Layers{nc*3,1}; };
l2[] = Extrude {0,0.008,0} { Point{2}; Layers{nc*1,1}; };
l3[] = Extrude {0,0.017,0} { Point{3}; Layers{nc*1,1}; };

s1[] = Extrude {{0,0,1}, {0,0,0}, Pi/16} {
Line{l1[1]}; Layers{nc*0.5,1}; Recombine;
};
s2[] = Extrude {{0,0,1}, {0,0,0}, Pi/16} {
Line{l2[1]}; Layers{nc*0.5,1}; Recombine;
};
s3[] = Extrude {{0,0,1}, {0,0,0}, Pi/16} {
Line{l3[1]}; Layers{nc*0.5,1}; Recombine;
};

// Uniscle superfici
stot[] = {s1[1], s2[1], s3[1]};

// Le estrudo per creare il volume
Extrude {0,0,0.023} {
Surface{stot[]}; Layers{nc*2,1}; Recombine;
}

// ************************************************** ***** //
// * wall plane *
// ************************************************** *****
Extrude {0,0,0.008} {
Surface{53}; Layers{nc*2,1}; Recombine;
}
Extrude {0,0,0.008} {
Surface{75}; Layers{nc*2,1}; Recombine;
}

// ************************************************** ***** //
// * smoke plane *
// ************************************************** ***** //
l4[] = Extrude {0,0.035,0} { Point{37}; Layers{nc*3,1}; };
s4[] = Extrude {{0,0,1}, {0,0,0}, Pi/16} {

Line{l4[1]}; Layers{nc*0.5,1}; Recombine;
};


Extrude {0,0,0.06} {
Surface{123}; Layers{nc*2,1}; Recombine;
}

Extrude {0,0,0.06} {
Surface{119}; Layers{nc*2,1}; Recombine;
}

Extrude {0,0,0.06} {
Surface{97}; Layers{nc*2,1}; Recombine;
}

// Create a volume
Surface Loop(185) = {139,123,131,140,135};
Volume(186) = {185};


// ************************************************** ***** //
// * Assegnazione nomi *
// ************************************************** ***** //
// Generate surface whit name
Physical Surface("plate") = {123,96,31};
Physical Surface("inlet-flame") = {6};
Physical Surface("inlet-inert") = {10};
Physical Surface("atmosphere") = {14,66,110,153,184,162,140};
Physical Surface("simmetry1") = {139,179,157,114,92,48,70,30};
Physical Surface("simmetry2") = {131,22,40,62,149,171,84,106};
Physical Volume("internalField") = {186};

but when I convert the mesh obtain this error:

.msh file version 2

Found $PhysicalNames section.

Read nVerts:15036

Read nElems:6000

Mapping physical region 2 to Foam physical patch 0
Mapping physical region 1 to Foam physical patch 1
Mapping physical region 4 to Foam physical patch 2
Mapping physical region 3 to Foam physical patch 3
Mapping physical region 6 to Foam physical patch 4
Mapping physical region 5 to Foam physical patch 5

Cells:
total:0
hex :0
prism:0
pyr :0
tet :0

Patches:
Patch Size Name
0 150 inlet-flame
1 400 plate
2 600 atmosphere
3 50 inlet-inert
4 2400 simmetry2
5 2400 simmetry1

CellZones:
Zone Size Name



--> FOAM FATAL ERROR : faces deallocated

From function const faceList& polyMesh::allFaces() const
in file meshes/polyMesh/polyMesh.C at line 655.

FOAM aborting

Foam::error::printStack(Foam:stream&)
Foam::error::abort()
Foam::polyMesh::allFaces() const
Foam::polyPatch::polyPatch(Foam::word const&, int, int, int, Foam::polyBoundaryMesh const&)
Foam::polyPatch::addwordConstructorToTable<foam::p olypatch>::New(Foam::word const&, int, int, int, Foam::polyBoundaryMesh const&)
Foam::polyPatch::New(Foam::word const&, Foam::word const&, int, int, int, Foam::polyBoundaryMesh const&)
Foam::polyMesh::polyMesh(Foam::IOobject const&, Foam::Field<foam::vector<double> > const&, Foam::List<foam::cellshape> const&, Foam::List<foam::list<foam::face> > const&, Foam::List<foam::word> const&, Foam::List<foam::word> const&, Foam::word const&, Foam::List<foam::word> const&)
gmsh2ToFoam [0x8052fe0]
__libc_start_main
__gxx_personality_v0
Aborted


(I had removed the code for delete unused points)

Bye
Marco
mavimo is offline   Reply With Quote

Old   March 9, 2007, 20:34
Default Hi, I tested your .geo also w
  #13
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
Hi,
I tested your .geo also with Gmsh 2.0.4, and found the resulting .msh after generating a 3D mesh contains no volumetric elements (tet, hexa, ...) even though a physical volume 186 is defined. I guess the last line of your .geo

Physical Volume("internalField") = {186};

should be replaced by

Physical Volume("internalField") = {1,2,3,4,5,6,7,8};

and gmsh2ToFoam converts the mesh successfully (although checkMesh fails the face skewness test). Could you have a careful look into the generated mesh with Tools -> Visibility menu of Gmsh?

Takuya
7islands is offline   Reply With Quote

Old   March 10, 2007, 13:45
Default With Physical Volume("interna
  #14
Member
 
Marco Moscaritolo
Join Date: Mar 2009
Location: Bergamo, Italy
Posts: 33
Rep Power: 17
mavimo is on a distinguished road
With
Physical Volume("internalField") = {186};
and
Physical Volume("internalField") = {1,2,3,4,5,6,7,8};
I don't see mesh into tools -> Visibility -> Mesh partitions, but I see volume in Physical partitions.

Bye
Marco
mavimo is offline   Reply With Quote

Old   March 10, 2007, 20:36
Default No, no. You must *remove* the
  #15
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
No, no. You must *remove* the line

Physical Volume("internalField") = {186};

and add the line

Physical Volume("internalField") = {1,2,3,4,5,6,7,8};

instead.

Checking your physical volume definition with Tools -> Visibility -> Physical groups menu and selecting internalField -> Apply you should only see



which apparently does not contain any internal mesh. But replacing volume 186 with 1-8 and doing the same checking you'll see the entire volume with internal mesh.



And the final generated 3D .msh's follow the figures above -- the .msh genereted by your original .geo does not contain any internal meshes but the corrected one does.

T.
7islands is offline   Reply With Quote

Old   March 10, 2007, 20:45
Default No, no. You must *remove* the
  #16
Super Moderator
 
Takuya OSHIMA
Join Date: Mar 2009
Location: Niigata City, Japan
Posts: 518
Blog Entries: 1
Rep Power: 20
7islands is on a distinguished road
No, no. You must *remove* the line

Physical Volume("internalField") = {186};

and add the line

Physical Volume("internalField") = {1,2,3,4,5,6,7,8};

instead.

Checking your original physical volume definition 186 with Tools -> Visibility -> Physical groups menu and selecting internalField -> Apply you should only see



which apparently does not contain any internal mesh. But replacing volume 186 with 1-8 and doing the same checking you'll see the entire volume with internal mesh.



And the final generated 3D .msh's follow the figures above -- the .msh genereted by your original .geo does not contain any internal meshes but the corrected one does.

T.
7islands is offline   Reply With Quote

Old   March 11, 2007, 06:23
Default Sorry, I'm explained to me bad
  #17
Member
 
Marco Moscaritolo
Join Date: Mar 2009
Location: Bergamo, Italy
Posts: 33
Rep Power: 17
mavimo is on a distinguished road
Sorry, I'm explained to me badly ... I use ONLY Physical Volume("internalField") = {186}; or Physical Volume("internalField") = {1,2,3,4,5,6,7,8};. With your explanation I solved the problem.

Thanks for your patience.
Marco
mavimo is offline   Reply With Quote

Old   October 4, 2007, 09:14
Default Hi, I just found the gmshFoam
  #18
Member
 
David Segersson
Join Date: Mar 2009
Posts: 39
Rep Power: 17
segersson is on a distinguished road
Hi,
I just found the gmshFoam utility on the Wiki, quite impressing. I'm also using gmsh, constructing the .geo files from ESRI shape-files with a small Python module. I've run into some serious trouble using gmsh that maybe you can help me with.

I'm extruding multiple surfaces (simultainously) to form a volume mesh of a city block. The buildings are later cut out of the mesh using OpenFoam utilities:



The conversion using gmsh2ToFoam produces warnings (could not match face and unused points) and the short mesh check says that the mesh is invalid. A total meshCheck produces a great number of errors, failing 6 mesh checks. This despite the fact that the mesh is quite simple. A visual check of the 2d-mesh that is extruded in gmsh makes it hard to understand all the errors. My conclusion is that something goes wrong either during the extrusion (although gmsh does not complain) or during the export to OpenFOAM. I'm having a really hard time figuring out how to fix this, and considering the ~2 weeks I've put into getting the shapeToGeo conversion funcion I do not want to let it go.

Does anybody (7islands?) have the possibility to try an example .geo file:
buildings.geo

and maybe give some suggestion on what´s going wrong.

The .geo-file uses the pos-file as a background-grid/size function when setting the mesh sizes. The files need to be in the same directory or the link in the .geo-file should be changed.

With hope of help
/David
segersson is offline   Reply With Quote

Old   October 4, 2007, 09:33
Default A small correction, I could n
  #19
Member
 
David Segersson
Join Date: Mar 2009
Posts: 39
Rep Power: 17
segersson is on a distinguished road
A small correction,
I could not upload the .pos file since it was to big. I commented out this part from the .geo-file and it works anyway, just giving other cell sizes.

Regards
David
segersson is offline   Reply With Quote

Old   October 4, 2007, 16:21
Default Hi David, just ran gmsh2.08
  #20
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
Hi David,

just ran gmsh2.08 on your .geo case, ran it through 1.4.1 gmshToFoam and get a lot of warnings of the form

--> FOAM Warning :
From function gmshToFoam
in file gmshToFoam.C at line 799
Could not match gmsh face 3(215 2086 214) to any of the interior or exterior faces that share the same 0th point

which means that the surfaces you export (triangles I assume) don't cover the faces of your volume mesh? (gmshToFoam tries to use the surface mesh triangles/quads to denote the patches of the volume mesh)

Anyway end up with following geometry
which makes me believe your geometry consists of multiple parts and only one gets meshed or exported?
mattijs is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SimpleFoam cannot open include file Marija OpenFOAM Running, Solving & CFD 1 October 28, 2020 11:35
[mesh manipulation] RefineMesh Error and Foam warning jiahui_93 OpenFOAM Meshing & Mesh Conversion 4 March 3, 2018 12:32
OpenFoam "Permission denied" and "command not found" problems. iyidaniel@yahoo.co.uk OpenFOAM Running, Solving & CFD 11 January 2, 2018 07:47
polynomial BC srv537 OpenFOAM Pre-Processing 4 December 3, 2016 10:07
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08


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