# Combine Multiple Meshes

**URL:** <https://community.freefem.org/t/combine-multiple-meshes/2872>\
**Category:** General Discussion\
**Created:** [January 9, 2024, 3:29pm UTC](https://community.freefem.org/t/combine-multiple-meshes/2872 "2024-01-09T15:29:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![YOuungLi](https://avatars.discourse-cdn.com/v4/letter/y/ecd19e/32.png) [@YOuungLi](https://community.freefem.org/u/YOuungLi)\
**Post date:** [January 9, 2024, 3:29pm UTC](https://community.freefem.org/t/combine-multiple-meshes/2872/1 "2024-01-09T15:29:30Z")

</div>

Dear All,

I’m encountering an error while attempting to combine multiple meshes, and I’m having trouble understanding why this error persists even after adjusting the orientation.  
error : “Bug in mortar constrution : close to vertex 9  
current line = 14  
Assertion fail : (linkd[is] == -2)  
line :380, in file …/femlib/fem.cpp”

Below is the code I’ve been using:

int a = 2;

int m = 10;  
int SD = m;  
int HC = m;  
int Bar = m;  
int bar = m;  
int SC = m;

border C1(t=0, 1.5){x=3-2_t; y=0; label=99;};  
border C2(t=0, 1){x=3; y=2_t-2; label=99;};  
border C3(t=0, 1){x=3+(a/2)_(1-t); y=-2; label=99;};  
border C4(t=0, 1){x=a_2; y=-2+a\*(1-t); label=99;};  
border C5(t=0, 1.5){x=a_2+2_(1.5-t); y=0; label=99;};  
border C6(t=0, 1){x=7; y=-2\*(1-t); label=99;};  
border C7(t=0, 1){x=7+(a/2)_(1-t); y=-2; label=99;};  
border C8(t=0, 1){x=a_4; y=-2+a\*(1-t); label=99;};  
border C9(t=0, 1.5){x=8+2\*(1.5-t); y=0; label=99;};  
border C10(t=0, 1){x=11; y=a\*(1-t); label=99;};  
border C11(t=0, 1.5){x=11-a\*(1.5-t); y=a; label=99;};  
border C12(t=0, 1){x=8; y=a+a\*(1-t); label=99;};  
border C13(t=0, 1){x=8-(a/2)_(1-t); y=a_2; label=99;};  
border C14(t=0, 1){x=7; y=4-a\*(1-t); label=99;};  
border C15(t=0, 1.5){x=7-a\*(1.5-t); y=2; label=99;};  
border C16(t=0, 1){x=4; y=a+a\*(1-t); label=99;};  
border C17(t=0, 1){x=4-(a/2)_(1-t); y=a_2; label=99;};  
border C18(t=0, 1){x=3; y=4-a\*(1-t); label=99;};  
border C19(t=0, 1.5){x=3-2\*(1.5-t); y=2; label=99;};  
border C20(t=0, 1){x=0; y=a-a\*(1-t); label=99;};

// Contact1  
border C21(t=0, 0.5){x=-1_t; y=0; label=1;};  
border C22(t=0,2){x=0; y=1_t; label=1;};  
border C23(t=0, 0.5){x=-0.5+1_t; y=2; label=1;};  
border C24(t=0, 2){x=-0.5; y=2-1_t; label=1;};

// Contact2  
border C25(t=0, 0.5){x=3; y=-2-1_t; label=1;};  
border C26(t=0, 1){x=3+1_t; y=-2.5; label=1;};  
border C27(t=0, 0.5){x=4; y=-2.5+1_t; label=1;};  
border C28(t=0, 1){x=3+1_t; y=-2; label=1;};

// Contact3  
border C29(t=0, 0.5){x=3; y=4.5-1_t; label=1;};  
border C30(t=0, 1){x=4-1_t; y=4; label=1;};  
border C31(t=0, 0.5){x=4; y=4+1_t; label=1;};  
border C32(t=0, 1){x=4-1_t; y=4.5; label=1;};

// Contact4  
border C33(t=0, 0.5){x=7; y=-2-1_t; label=1;};  
border C34(t=0, 1){x=7+1_t; y=-2.5; label=1;};  
border C35(t=0, 0.5){x=8; y=-2.5+1_t; label=1;};  
border C36(t=0, 1){x=7+1_t; y=-2; label=1;};

// Contact5  
border C37(t=0, 0.5){x=11+1_t; y=0; label=1;};  
border C38(t=0, 2){x=11.5; y=1_t; label=1;};  
border C39(t=0, 0.5){x=11.5-1_t; y=2; label=1;};  
border C40(t=0, 2){x=11; y=1_t; label=1;};

// Contact6  
border C41(t=0, 0.5){x=7; y=4.5-1_t; label=1;};  
border C42(t=0, 1){x=8-1_t; y=4; label=1;};  
border C43(t=0, 0.5){x=8; y=4+1_t; label=1;};  
border C44(t=0, 1){x=8-1_t; y=4.5; label=1;};

func Hallbar = C1(-Bar)+C2(-bar)+C3(-HC)+C4(-bar)+C5(-Bar)+C6(-bar)+C7(-HC)+C8(-bar)+C9(-Bar)+C10(-SD)+C11(-Bar)+C12(-bar)+C13(-HC)  
+C14(-bar)+C15(-Bar)+C16(-bar)+C17(-HC)+C18(-bar)+C19(-Bar)+C20(-SD);  
plot(Hallbar, dim=2, wait=1);

func Contacts = C21(-SC)+C22(SD)+C23(-SC)+C24(SD)+C25(SC)+C26(HC)+C27(SC)+C28(-HC)+C29(SC)+C30(-HC)+C31(SC)+C32(HC)  
+C33(SC)+C34(HC)+C35(SC)+C36(-HC)+C37(SC)+C38(SD)+C39(SC)+C40(-SD)+C41(SC)+C42(-HC)+C43(SC)+C44(HC);  
//#plot(Contacts, dim=2, wait=1);

mesh Th = buildmesh(Hallbar+Contacts);  
plot(Th,wait=1);

Thank you in advance!
