How-tos

Import gmsh mesh

If we have in the file quad.geo a parameterized mesh, as this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
lc = 0.05 ;

Point(1) = {0,0,0,lc};
Point(2) = {1,0,0,lc};
Point(3) = {1,1,0,lc};
Point(4) = {0,1,0,lc};

Line(5) = {1,2};
Line(6) = {2,3};
Line(7) = {3,4};
Line(8) = {4,1};

Line Loop(9) = {5,6,7,8};
Plane Surface(10) = {9};

Physical Line(101) = {7};
Physical Line(102) = {5};
Physical Line(103) = {8};
Physical Line(104) = {6};

Physical Surface(201) = {10};

then, when we run:

$ gmsh -2 quad.geo -format msh1

the file quad.msh is created and contains the encoding of the mesh and its regions. We can import that file (quad.msh) to getfem:

import getfem as gf

m = gf.Mesh('import','gmsh','quad.msh')
print m.regions()

with the second command we can see the regions ids. When we import the mesh, we might be warned with the following:

Level 3 Warning in getfem_import.cc, line 137:
  All regions must have different number!

this means that the parametrization of the mesh in Gmsh .geo file must assign a different number to each region, the problem exists because in Gmsh can coexist, for example, “Physical Surface (200)” and “Physical Line (200)”, as they are different “types of regions” in Gmsh, that which does not occur in GetFEM since there is only one “type of region”.