# Is it possible to retain sets (physical tags) after remeshing the model in Gmsh?

I am currently working on a remeshing algorithm for Abaqus using Gmsh as part of my Bachelors thesis and I seem to be stuck at some point. I am able to remesh .geo and .msh files using the script given in Gmsh tutorial "t13".

t13.geo:

Merge "myJob5.msh";
angle = DefineNumber[40, Min 20, Max 120, Step 1,
Name "Parameters/Angle for surface detection" ];
forceParametrizablePatches = 0;
forceIncludeBoundary = 0;
ClassifySurfaces{angle * Pi/180, forceIncludeBoundary, forceParametrizablePatches};
CreateGeometry;
Background Field = 1;


The only problem I face is that my sets (physical tags) are still existent, but Gmsh didn't (or couldn't) match them with the appropriate nodes / lines / surfaces. I started with a basic model.

myJob5.geo:

SetFactory("OpenCASCADE");
Point(1) = {0, 0, 0, 1.0};
Point(2) = {15, 0, 0, 1.0};
Point(3) = {15, 15, 0, 1.0};
Point(4) = {0, 15, 0, 1.0};
Point(5) = {7.5, 7.5, 0, 1.0};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line(5) = {1, 5};
Line(6) = {5, 3};
Line(7) = {2, 5};
Line(8) = {5, 4};
Physical Point("setNode1") = {3};
Physical Point("setNode2") = {2};
Physical Point("setNode2") += {1};
Physical Curve("setLine1") = {3};
Physical Curve("setLine2") = {4};
Physical Curve("setLine2") += {1};
Curve Loop(1) = {3, -8, 6};
Plane Surface(1) = {1};
Curve Loop(2) = {7, 6, -2};
Plane Surface(2) = {2};
Curve Loop(3) = {8, 4, 5};
Plane Surface(3) = {3};
Curve Loop(4) = {5, -7, -1};
Plane Surface(4) = {4};
Physical Surface("setSurf1") = {1};
Physical Surface("setSurf1") += {2};
Physical Surface("setSurf2") = {3};
Physical Surface("setSurf2") += {4};


which translates into this picture:

After meshing, I ended up with this .msh file.

myJob5.msh:

$$MeshFormat 4.1 0 8$$EndMeshFormat
$$PhysicalNames 6 0 1 "setNode1" 0 2 "setNode2" 1 4 "setLine1" 1 5 "setLine2" 2 7 "setSurf1" 2 9 "setSurf2"$$EndPhysicalNames
$$Entities 5 8 4 0 1 0 0 0 1 2 2 15 0 0 1 2 3 15 15 0 1 1 4 0 15 0 0 5 7.5 7.5 0 0 1 -1.000000002804313e-07 -1e-07 -1e-07 15.0000001 1e-07 1e-07 1 5 2 1 -2 2 14.9999999 -1.000000002804313e-07 -1e-07 15.0000001 15.0000001 1e-07 0 2 2 -3 3 -1.000000002804313e-07 14.9999999 -1e-07 15.0000001 15.0000001 1e-07 1 4 2 3 -4 4 -1e-07 -1.000000002804313e-07 -1e-07 1e-07 15.0000001 1e-07 1 5 2 4 -1 5 -9.999999983634211e-08 -9.999999983634211e-08 -1e-07 7.5000001 7.5000001 1e-07 0 2 1 -5 6 7.4999999 7.4999999 -1e-07 15.0000001 15.0000001 1e-07 0 2 5 -3 7 7.4999999 -9.999999983634211e-08 -1e-07 15.0000001 7.5000001 1e-07 0 2 2 -5 8 -9.999999983634211e-08 7.4999999 -1e-07 7.5000001 15.0000001 1e-07 0 2 5 -4 1 -1.000000002804313e-07 7.4999999 -1e-07 15.0000001 15.0000001 1e-07 1 7 3 3 -8 6 2 7.4999999 -1.000000002804313e-07 -1e-07 15.0000001 15.0000001 1e-07 1 7 3 7 6 -2 3 -9.999999983634211e-08 -1.000000002804313e-07 -1e-07 7.5000001 15.0000001 1e-07 1 9 3 8 4 5 4 -1.000000002804313e-07 -9.999999983634211e-08 -1e-07 15.0000001 7.5000001 1e-07 1 9 3 5 -7 -1$$EndEntities
$$Nodes 12 5 1 5 0 1 0 1 1 0 0 0 0 2 0 1 2 15 0 0 0 3 0 1 3 15 15 0 0 4 0 1 4 0 15 0 0 5 0 1 5 7.5 7.5 0 1 1 0 0 1 3 0 0 1 4 0 0 2 1 0 0 2 2 0 0 2 3 0 0 2 4 0 0$$EndNodes
$$Elements 10 10 1 10 0 1 15 1 1 1 0 2 15 1 2 2 0 3 15 1 3 3 1 1 1 1 4 1 2 1 3 1 1 5 3 4 1 4 1 1 6 4 1 2 1 2 1 7 3 4 5 2 2 2 1 8 2 5 3 2 3 2 1 9 1 5 4 2 4 2 1 10 1 5 2$$EndElements


and this image:

Only the numbers are shown in this image to highlight the set that they are part of, e.g. the purple "0" means that that entity (surface, line or node) is not a part of any set, the yellow 4 means that the entity "line" is part of the set "setLine1".

Now, with the script of "t13" I tried to remesh the .msh file, giving me this image.

You can get this by simply 2d meshing the above given t13.geo file in gmsh.

Now my question is how I can retain the sets in my model, if possible at all with this method. What I am looking for is a way to match the newly generated elements with the previously assigned sets.

I know that this somehow must be possible since Gmsh does keep the sets accurate when refining the mesh, essentially multiplying the number of elements and assigning all of them to their respective set.

I really hope that my example is as clear and concise as possible. But still, if there is anything unclear, I'd love to clear things up and I am looking forward to anyone who can help me with this. Thanks.

• That's really a question you ought to ask on the gmsh-specific forums. – Wolfgang Bangerth Sep 24 at 3:15
• I tried to find one, but the only Gmsh-specific Q&A forum ist their dedicated mailing list. I applied for that one, too and now I am waiting for the approval to also post my question there. But I have got more insight now to my problem. I have noticed that all the sets (physical groups) get deleted (at least get detached) from the entities themselves, before I even start remeshing. Therefore, I assume it has to do with the "CreateGeometry" and "ClassifySurfaces{exp, exp, exp}" functions given in the "t13.geo" file. – fruitiest Punch Sep 24 at 11:36