Mesh error when combine two regions

Can someone spot the error: there is no problem to generate Thf and Ths, but there is an error to combine these to regions which is weird:

Bug in mortar constrution : close to vertex 3
current line = 7
Assertion fail : (linkd[is] == -2)
line :380, in file …/femlib/fem.cpp
catch Err bamg
Assertion fail : (linkd[is] == -2)
line :380, in file …/femlib/fem.cpp
err code 6 , mpirank 0

code:
testmesh.edp (1.1 KB)

int mh=5, m=20, lf=4;
real L=5.e-2, H=3.e-2, h=8.e-3, l=lf*H, L1 = (L-2.*h);
real HH=0.2e0, LL=0.5*HH;


// Fluid Region
border a1(t=-LL,LL) {x=t; y=-HH ;label=1;};
border a2(t=-HH,HH) {x=LL; y=t ;label=2;};
border a3(t=LL,-LL) {x=t; y=HH ;label=1;};
border a4(t=HH,-HH) {x=-LL; y=t ;label=3;};
func fluidbound = a1(m)+a2(2*m)+a3(m)+a4(2*m);
plot(fluidbound, dim=2, wait=1);


// Solid Region
border b1(t=-L1/2., L1/2.) {x=t; y=0. ;label=5;};
border b2(t=0,-l) {x=L1/2.; y=t ;label=5;};
border b3(t=L1/2., L1/2. + h) {x=t; y=-l ;label=5;};
border b4(t=-l, H) {x=L1/2.+h; y=t ;label=5;};
border b5(t=L/2.,-L/2.) {x=t; y=H ;label=5;};
border b6(t=H, -l) {x=-L/2; y=t;label=5;};
border b7(t=-L/2,-L1/2.) {x=t; y=-l;label=5;};
border b8(t=-l,0) {x=-L1/2.; y=t;label=5;};
border b9(t=-L1/2., L1/2.) {x=t; y=0;label=5;};
func solidbound = b1(2*mh)+b2(lf*mh)+b3(3)+b4((lf+1)*mh)+b5(2*mh)+b6((lf+1)*mh)+b7(3)+b8(lf*mh)+b9(2*mh);
plot(fluidbound + solidbound, dim=2, wait=1);

mesh Thf = buildmesh(fluidbound);
plot(Thf, wait=1);

mesh Ths = buildmesh(solidbound);
plot(Ths, wait=1);

mesh Th = buildmesh(fluidbound + solidbound);
plot(Th, wait=1);

I think the orientation of your parameterized boundary is incorrect.

int mh=5, m=20, lf=4;
real L=5.e-2, H=3.e-2, h=8.e-3, l=lf*H, L1 = (L-2.*h);
real HH=0.2e0, LL=0.5*HH;


// Fluid Region
border a1(t=-LL,LL) {x=t; y=-HH ;label=1;};
border a2(t=-HH,HH) {x=LL; y=t ;label=2;};
border a3(t=LL,-LL) {x=t; y=HH ;label=1;};
border a4(t=HH,-HH) {x=-LL; y=t ;label=3;};
func fluidbound = a1(m)+a2(2*m)+a3(m)+a4(2*m);
plot(fluidbound, dim=2, wait=1);

// Solid Region
border b1(t=-L1/2., L1/2.) {x=t; y=0. ;label=5;};
border b2(t=0,-l) {x=L1/2.; y=t ;label=5;};
border b3(t=L1/2., L1/2. + h) {x=t; y=-l ;label=5;};
border b4(t=-l, H) {x=L1/2.+h; y=t ;label=5;};
border b5(t=L/2.,-L/2.) {x=t; y=H ;label=5;};
border b6(t=H, -l) {x=-L/2; y=t;label=5;};
border b7(t=-L/2,-L1/2.) {x=t; y=-l;label=5;};
border b8(t=-l,0) {x=-L1/2.; y=t;label=5;};
border b9(t=-L1/2., L1/2.) {x=t; y=0;label=5;};
func solidbound = b1(2*mh)+b2(lf*mh)+b3(3)+b4((lf+1)*mh)+b5(2*mh)+b6((lf+1)*mh)+b7(3)+b8(lf*mh)+b9(2*mh);
func solidbound2 = b1(-2*mh)+b2(-lf*mh)+b3(-3)+b4(-(lf+1)*mh)+b5(-2*mh)+b6(-(lf+1)*mh)+b7(-3)+b8(-lf*mh)+b9(-2*mh);
plot(fluidbound + solidbound, dim=2, wait=1);
mesh Thf = buildmesh(fluidbound);
plot(Thf, wait=1);
mesh Ths = buildmesh(solidbound);
plot(Ths, wait=1);
mesh Th = buildmesh(fluidbound + solidbound2);
plot(Th, wait=1);

Thank you @cmd , but I actually need the solid mesh instead of a hole… shouldn’t have been a problem ?

Then just create the solid and fluid meshes separately and then add the mesh objects.

int mh=5, m=20, lf=4;
real L=5.e-2, H=3.e-2, h=8.e-3, l=lf*H, L1 = (L-2.*h);
real HH=0.2e0, LL=0.5*HH;


// Fluid Region
border a1(t=-LL,LL) {x=t; y=-HH ;label=1;};
border a2(t=-HH,HH) {x=LL; y=t ;label=2;};
border a3(t=LL,-LL) {x=t; y=HH ;label=1;};
border a4(t=HH,-HH) {x=-LL; y=t ;label=3;};
func fluidbound = a1(m)+a2(2*m)+a3(m)+a4(2*m);
plot(fluidbound, dim=2, wait=1);
// Solid Region
border b1(t=-L1/2., L1/2.) {x=t; y=0. ;label=5;};
border b2(t=0,-l) {x=L1/2.; y=t ;label=5;};
border b3(t=L1/2., L1/2. + h) {x=t; y=-l ;label=5;};
border b4(t=-l, H) {x=L1/2.+h; y=t ;label=5;};
border b5(t=L/2.,-L/2.) {x=t; y=H ;label=5;};
border b6(t=H, -l) {x=-L/2; y=t;label=5;};
border b7(t=-L/2,-L1/2.) {x=t; y=-l;label=5;};
border b8(t=-l,0) {x=-L1/2.; y=t;label=5;};
border b9(t=-L1/2., L1/2.) {x=t; y=0;label=5;};
func solidbound = b1(2*mh)+b2(lf*mh)+b3(3)+b4((lf+1)*mh)+b5(2*mh)+b6((lf+1)*mh)+b7(3)+b8(lf*mh)+b9(2*mh);
func solidbound2 = b1(-2*mh)+b2(-lf*mh)+b3(-3)+b4(-(lf+1)*mh)+b5(-2*mh)+b6(-(lf+1)*mh)+b7(-3)+b8(-lf*mh)+b9(-2*mh);
plot(fluidbound + solidbound, dim=2, wait=1);
mesh Thf = buildmesh(fluidbound);
plot(Thf, wait=1);
mesh Ths = buildmesh(solidbound);
plot(Ths, wait=1);
mesh Th = buildmesh(fluidbound + solidbound2);
plot(Th, wait=1);

mesh Thsum = Ths + Th;

plot(Thsum, wait=1);

1 Like

Thank you very much! it works. I am used to trunc ()