# [Gmsh] Duplicate Surface Meshes in different Gmsh files

Christophe Geuzaine cgeuzaine at uliege.be
Sun Jul 14 23:03:16 CEST 2019

```
> On 5 Jul 2019, at 13:55, Sanghavi, Chaitanya <chaitanya.sanghavi at siemens.com> wrote:
>
> Dear All,
>
> Thank you for a having a platform where the users can pose some questions. I have an issue which I would like to share.
>
>
>
> Objective : 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:
> 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. (see attached figure)
> 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!

If you mesh your 2 files completely independently there's nothing Gmsh can do to ensure the meshes are the same. You somehow need to enforce the link. There are multiple solutions: in .geo files you could use the Periodic feature, or you could mesh one geometry first, export the surface mesh, load it in another .geo to create a discrete surface, which could then constrain the other mesh. This second pipeline would be cleaner using the Gmsh API, where if your application involves distributed meshing you could exchange the meshes using e.g. MPI.

Christophe

> Thanks a lot in advance,
>
>
> Regards
> Chaitanya
>
>
> <Picture.PNG>_______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh

—
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science
http://www.montefiore.ulg.ac.be/~geuzaine

```