# How to use union of two different meshes in a single integration? Where I am doing the mistake?

int n=32;
int m=ceil(2n/pi);
border C1(t=0,pi){x=cos(t); y=sin(t);label=1;}
border C2(t=-1,1) {x=t;y=0;}
border C3(t=-1,1) {x=-t;y=0;}
border C4(t=pi,2
pi){x=cos(t); y=sin(t);label=2;}
mesh Th1 = buildmesh(C1(n)+C2(m));
mesh Th2 = buildmesh(C3(m)+C4(n));
mesh Th = Th1+Th2;
plot (Th1,wait=true);
plot (Th2,wait=true);
plot (Th,wait=true);
fespace Vh(Th, P1);
Vh u, v;// Define u and v as piecewise-P1 continuous functions
func f= x*y;
// Define the PDE
solve Poisson(u, v, solver=LU)
= int2d(Th1)(dx(u)*dx(v)+dy(u)*dy(v))
+ int2d(Th2)(dx(u)dx(v)+dy(u)dy(v))
- int2d(Th1)(f
v)
- int2d(Th2)(f
v)
+ on(1,2, u=0); // The Dirichlet boundary condition

// Plot the result
plot(u,dim=3,value=true,fill=true,ShowAxes=0,ColorScheme =1);

No way to compute bilinear form with integrale of on mesh test or unkown function defined on an other mesh. I suggest this to you:

int n=32;
int m=ceil(2n/pi);
border C1(t=0,pi){x=cos(t); y=sin(t);label=1;}
border C2(t=-1,1) {x=t;y=0;}
border C3(t=-1,1) {x=-t;y=0;}
border C4(t=pi,2
pi){x=cos(t); y=sin(t);label=2;}
mesh Th1 = buildmesh(C1(n)+C2(m));
mesh Th2 = buildmesh(C3(m)+C4(n));
mesh Th = Th1+Th2;
plot (Th1,wait=true);
plot (Th2,wait=true);
plot (Th,wait=true);

fespace Vh1(Th1,P1);
fespace Vh2(Th2,P1);

fespace Vh(Th, P1);
Vh u, v;

// Define u and v as piecewise-P1 continuous functions
func f= x*y;
// Define the PDE
solve Poisson(u, v, solver=LU)
= int2d(Th)(dx(u)*dx(v)+dy(u)*dy(v))

• int2d(Th)(dx(u)*dx(v)+dy(u)*dy(v))
• int2d(Th1)(f*v)
• int2d(Th2)(f*v)
• on(1,2, u=0); // The Dirichlet boundary condition

// Plot the result
plot(u,dim=3,value=true,fill=true,ShowAxes=0,ColorScheme =1);

What are those black dots ? It is not working.
Still I am getting this error–
No way to compute bilinear form with integrale of on mesh test or unkown function defined on an other mesh! sorry to hard.

I want to split the mesh so that I can use different transformations for different sub meshes Th1 and Th2 of Th.

sorry it’s the sign “+” and “-”

define two subspaces Vh1 and Vh2 of test functions and your solution u=(u1,u2) such that u1 is the restriction of u in Vh1 and u2 the restriction of u in Vh2.

Dear, I think you haven’t understood my query. Take this example
int n=32;int m=ceil(n/sqrt(2));
border C1(t=0,-1){x=t; y=1-t;}
border C2(t=2,0) {x=-1;y=t;}
border C3(t=-1,0) {x=t;y=-t-1;}
border C4(t=-1,1){x=0; y=t;}

border C5(t=1,0){x=t; y=t+1;}
border C6(t=1,-1) {x=0;y=t;}
border C7(t=0,1) {x=t;y=t-1;}
border C8(t=0,2){x=1; y=t;}

mesh Sh1 = buildmesh(C1(m)+C2(n)+C3(m)+C4(n));
mesh Sh2 = buildmesh(C5(m)+C6(n)+C7(m)+C8(n));
mesh Sh = Sh1+Sh2;

plot(Sh,wait=true);

mesh Th1 = movemesh(Sh1,[x, y+x]);
mesh Th2 = movemesh(Sh2,[x, y-x]);
mesh Th = Th1+Th2;
plot(Th,wait=true);

Suppose the original problem is to solve the poisson equation in Sh. Now I have splitted Sh into Sh1 and Sh2. I have transformed Sh1 into Th1 and Sh2 into Th2. Now Th1+Th2=Th is a square. I want to solve the poisson equation in a single integral setup. Integration is closure under addition. int_(Sh1+Sh2)=int_(Sh1)+int(Sh2). Now you have suggested to use Sh inplace of Sh1 and Sh2. Then how can I use different transformations for Sh1 and Sh2? Remember that border goes to border. Please help.

You can use composite finite element spaces: see in the documentation. The Stokes problem is on 2 different meshes.

You’ll need version > 4.13

To do that you need to user the matrix form through varf.

I am using ffcs-14.3-Win64.exe . You can see here
https://www.ljll.math.upmc.fr/lehyaric/ffcs/install.htm
Can I use composite fem on freefem cs integrated.

I am using ffcs-14.3-Win64.exe . You can see here
https://www.ljll.math.upmc.fr/lehyaric/ffcs/install.htm

This version is very very old, so no!

Hello Sir,
I have tried this code in FreeFem version 4.13. Still I am getting error in line number 21.
poissonmeshpartition.edp (776 Bytes)

Yes it normal because
(dx(u1)*dx(v1) is non linear
u1, v1 are unknowns fields !

Dear sir,
Poissonwithoutpartition.edp (799 Bytes)
If you look at the above code there is also the non linear term (dx(u)*dx(v)). But it’s not creating the problem there. u is the finite element solution to be approximated in the fespace Vh and v is the test function in the fespace. Can you please modify the below code of mesh partition
poissonmeshpartition.edp (776 Bytes)
It will be a great help if you can help me with this code of mesh partition.

the correction is
solve Poisson(<[u1],[u2]>, <[v1],[v2]>)

the first bock in unknown <[u1],[u2]> function and the second block <[v1],[v2]> is the test functions.

Thank you sir. Now it’s working.