# Duplicate Surface Meshes in different Gmsh files

My objective is to get a conformal surface mesh between two geometries meshed independently in different files. By example, I can start with a simple cube in one .geo file and mesh this geometry.

The script for this test1.geo file is as follows:

        // points - Block 1
L = 1; H =1; Fin = 1/5; e =1; // L = length, H = width, e = elevation (z axis), Fin = mesh-size

Point(1) = {0,0,0, Fin};
Point(2) = {L/2,0,0, Fin};
Point(3) = {L/2,H,0, Fin};
Point(4) = {0,H,0, Fin};
Point(5) = {0,0,e, Fin};
Point(6) = {L/2,0,e, Fin};
Point(7) = {L/2,H,e, Fin};
Point(8) = {0,H,e, Fin};

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

// surfaces Block 1
Line Loop(1) = {-1,-2,-3,-4};
Plane Surface(1) = {1};
Line Loop(2) = {5,6,7,8};
Plane Surface(2) = {2};
Line Loop(3) = {1,10,-5,-9};
Plane Surface(3) = {3};
Line Loop(4) = {2,11,-6,-10};
Plane Surface(4) = {4};
Line Loop(5) = {3,12,-7,-11};
Plane Surface(5) = {5};
Line Loop(6) = {4,9,-8,-12};
Plane Surface(6) = {6};

// Volume Block 1
Surface Loop(1) = {4,1,3,2,5,6};
Volume(1) = {1};


For various reasons, I need to write explicitly define all the lines and surfaces.

A part of the surface 4 has a physical interface with the second .geo file. i.e.

test2.geo

L = 1; H= 1; e = 1; Fin = 1/50;

Point(13) = {L/2,0,0.1*e, Fin};
Point(14) = {0.9*L,0,0.1*e, Fin};
Point(15) = {0.9*L,H,0.1*e, Fin};
Point(16) = {L/2,H,0.1*e, Fin};
Point(17) = {L/2,0,0.9*e, Fin};
Point(18) = {0.9*L,0,0.9*e, Fin};
Point(19) = {0.9*L,H,0.9*e, Fin};
Point(20) = {L/2,H,0.9*e, Fin};

Line(13) = {13,14};
Line(14) = {14,15};
Line(15) = {15,16};
Line(16) = {16,13};
Line(17) = {17,18};
Line(18) = {18,19};
Line(19) = {19,20};
Line(20) = {20,17};
Line(21) = {13,17};
Line(22) = {14,18};
Line(23) = {15,19};
Line(24) = {16,20};

Line Loop(13) = {-13,-14,-15,-16};
Plane Surface(13) = {13};
Line Loop(14) = {17,18,19,20};
Plane Surface(14) = {14};
Line Loop(15) = {13,22,-17,-21};
Plane Surface(15) = {15};
Line Loop(16) = {14,23,-18,-22};
Plane Surface(16) = {16};
Line Loop(17) = {15,24,-19,-23};
Plane Surface(17) = {17};
Line Loop(18) = {16,21,-20,-24};
Plane Surface(18) = {18};

// Volume Block 2
Surface Loop(13) = {16,13,15,14,17,18};
Volume(13) = {13};


I want a conformal mesh on the mating physical interface between the .geo files which is shown by the red arrow. The previous posts I read had a complete surface mating so it was possible to duplicate the surface use the Geometry.CopyMeshingMethod = 1 option, however this is not the case that I have. any suggestions, comments could be helpful! Thanks a lot in advance,

• does it have to be done in separate GEO files? Currently, you two "cubes" touch at the interface, is that the case? (btw, e=1, I suppose, is missing from the first code segment). Is there a limitation why you cannot draw the "combined" geometry to start with? – Anton Menshov Jul 3 '19 at 16:26
• Thanks for the correction, you are right about e =1 for the first file. – Bullet Jul 4 '19 at 12:31
• Yes, I need two different .geo files which is a requirement for the workflow. I need to mesh the smaller cube multiple times without affecting the mesh for the bigger cube, if I combine, I will have to mesh both cubes. However, I would like to start with a combined geometry, since I am running out of ideas how to proceed, thanks for the feedback ! – Bullet Jul 4 '19 at 12:34
• Does that imply you want the surface mesh from the larger cube to be a "fixed" input in the second? That would definitely imply you're going to need that surface defined in your first file regardless, although I'm not sure whether you're then better off reading the .msh file as the topology, or attempting to recreate the meshing parameters. – origimbo Jul 4 '19 at 13:40
• That is a good remark, this is what I realized, and I redefined the mating surface with the two cubes in the first geo file. I managed in 2D by using transfinite command, however in 3D, I do not see Gmsh doing robust meshes on the same surface in two different files. – Bullet Jul 5 '19 at 8:32