Identify regions in a mesh imported from Gmsh

Hi everybody!
I’m having some troubles in the identifications of different regions into a mesh imported from Gmsh with the format .mesh with the line:

mesh3 Th = readmesh3(“Trial1.mesh”);

The loading of the mesh is perfect since I can plot and visualize it and is exactly what I’m looking for, but my mesh is formed by two volumes that are identified as two separate “physical groups” in gmsh, however if I try to access the label of the regions in FreeFEM with the line:

int r1 = Th(xc,yc,zc).region;
int r2 = Th(xs,ys,zs).region;

(where the (x,y,z) tripletused before are representative of two points belonging to different volumes).

what I actually get is that r1 = r2, differently from what I was expecting and from what I need unfortunately!

Is some of you able to tell me some ways in which I can solve this problem? Should I do something particoular during the mesh generation procedure?

If it can help the two volumes are in contact since they are representative of a cable and its jacket.

Thanks a lot to everyone will help me!

yours sincerely


Can you send the mesh “Trial1.mesh” to see where is the problem. (3.0 MB) For sure I can! I have zipped it with also the few lines of code that I have used… I was required to do that since uploding it “as is” was causing some issues!
In any case you can find the file you are asking for inthe attached zip!

A huge thank for the help!

If you write:

cout << int3d(Th,1)(1.) << endl;
cout << int3d(Th,2)(1.) << endl;
cout << int3d(Th)(1.) << endl;

you can check that there are indeed two regions.

Also Th(0.,0.,1170).region gives region 1

Oh… the reasons for which I were not able to find out the two regions was that I was expecting dimensions of the order of 1 [m] since in the cad that I have used to produce the geometry I have introduced dimensions of the order of 1e3 [mm], but it seems that FreeFEM is going to read that [mm] as [m]… is it possible?

to solve you problem do with gmsh the conversion to inria mesh format here infield tt.mesh and you can read directly in the script

gmsh Trial1.mesh -o tt.mesh -format mesh -save

mesh3 Th("tt.mesh")

Thanks a lot to everybody for the precious help!