← Back to team overview

dolfin team mailing list archive

dolfin-convert: bug with conversion from gmsh?

 

Garth N. Wells wrote:
angelo simone wrote:
Garth N. Wells wrote:
angelo simone wrote:
Hi again,

I read the manual... so, here is the patch. To convert a Gmsh mesh one must add an extra option to define the element type:

dolfin-convert -i gmsh -o xml  -e <el_type> mesh.msh mesh.xml

where <el_type> is either "tria" for triangles or "tet" for tetrahedra. Dolfin-convert will complain if one attempts to convert a Gmsh mesh without the -e option. The patch has been tested with triangular meshes but is should work fine with tetraheda as well.


It should be possible to imply the element type from the gmsh file. Can you post the gmsh output file which you're trying to convert?

Sure. It represents a unit square which can has been meshed with 4 crossed triangle selecting a large characteristic length factor, say 7, in the Gmsh input file after it.

---- Gmsh output

$MeshFormat
2 0 8
$EndMeshFormat
$Nodes
5
1 -0 -0 0
2 1 0 0
3 1 1 0
4 0 1 0
5 0.5000306693508283 0.5000716782088586 0
$EndNodes
$Elements
8
1 1 2 1 1 2 1
2 1 2 2 2 1 4
3 1 2 3 3 4 3
4 1 2 4 4 3 2

gmsh is outputting lines elements. You don't want these.

5 2 2 6 6 3 2 5
6 2 2 6 6 2 1 5
7 2 2 6 6 4 3 5
8 2 2 6 6 1 4 5

These are the triangles that you want. If you create a "physical surface", then gmsh will just output the triangles only.

Garth


$EndElements

---- Gmsh input

Point(1) = {-0,-0,0,0.1};
Point(2) = {1,0,0,0.1};
Point(3) = {1,1,0,0.1};
Point(4) = {0,1,0,0.1};
Line(1) = {2,1};
Line(2) = {1,4};
Line(3) = {4,3};
Line(4) = {3,2};
Line Loop(5) = {1,2,3,4};
Plane Surface(6) = {5};
Physical Surface (7) = {6};

Adding the above will do the trick.  You can also do it through the GUI.

Garth


you are indeed right. I have just realized the mistake. thanks
angelo