Refine different regions with adaptmesh

Hi to all,

i have the following mesh and variational problem:

//Rectangle [0 2] x [-1 0]
border b(t=0,1) {x=t; y=-1; label=1;};
border c(t=1,2) {x=t; y=-1; label=2;};
border d(t=-1,0) {x=2; y=t; label=3;};
border e(t=0,1) {x=2-t; y=0; label=4;};
border f(t=0,1) {x=1-t; y=0; label=5;};
border a(t=0,1 ) {x=0 ; y=-t; label=6;};
border g(t=-1,0) {x=1; y=t; label=7;};

mesh Th = buildmesh(a(5)+b(5)+c(5)+d(5)+e(5)+f(5)+g(10));

//TIME-DEPENDENT PROBLEM
fespace Vhh(Th,P1);
fespace Nh(Th,P0);
Vhh u1,u2,v1,v2,uold1,uold2;
real Dt=0.5;

uold1=1e+2;
uold2=1e+2;

problem TIME(u1,u2,v1,v2,solver=sparsesolver,eps=1e-10)=
int2d(Th,qforder=2)(D1*(dx(u1)dx(v1)+dy(u1)dy(v1)))
+int2d(Th,qforder=2)(D2
(dx(u2)dx(v2)+dy(u2)dy(v2)))
+int2d(Th,qforder=2) (vinv1
u1
v1/Dt)
-int2d(Th,qforder=2) (vinv1
uold1v1/Dt)
+int2d(Th,qforder=2) (vinv2
u2v2/Dt)
-int2d(Th,qforder=2) (vinv2
uold2v2/Dt)
+int2d(Th,qforder=2)((Sa1+Ss12)u1v1)
+int2d(Th,qforder=2)((Sa2+Ss21)u2v2)
-int2d(Th,qforder=2)(Ss21
u2v1)
-int2d(Th,qforder=2)(Ss12
u1v2)
-int2d(Th,qforder=2)(f0
v1)
-int2d(Th,qforder=2)(Sf1u1v1+Sf2u2v1)
+on(4,u1=1e-10,u2=1e-10);

//definition of metric “h” wrt u1 or u2
(…)

Th = adaptmesh(Th,h, IsMetric=1, nbvx=800000,hmin=hmin,hmax=hmax);

My goal is refine ONLY the “first” square [0 1]x[-1 0] when i pass the “h” calculated wrt u1, refine ONLY the “second” square [1 2]x[-1 0] when i pass the “h” calculated wrt u2, and of course refine the ENTIRE domain if i calculate “h” as a linear combination of u1 and u2

How can i do this?
Initially i try to split my mesh in 2 mesh like :

Mesh Th1 = \first square;
Mesh Th2 = \second square;
Mesh Th = Th1+Th2;

but the second one [1 2]x[-1 0] gives an error.
Apart from this, i think that the “chi” function could help in this way:

u1=u1chi(Th1);
u2=u2
chi(Th2);

…but does not work as i expect.

Anyone can give me some tips? Thanks!

The problem to refined only one once region is not so simple, but you can do
this kind of trick


mesh Th1 = square(10,10,region=1);
mesh Th2 = square(10,10,region=2,[-x,y]);
// remarg the label = 4 is common line 
int[int] llr=[4]; // list of label of required edges 
mesh Th = Th1+Th2; 

//

Th2 = adaptmesh(Th2,1./20,IsMetric=1,requirededges=llr);

Th = Th1+Th2;

plot(Th,wait=1);


But bee careful with the compatibility of the metric and mes mesh border required

and if i consider only the “full” domain and want refine only the top-left corner (for example) when i pass the metric “h” calculated wrt u1? There is a way to impose this using adaptmesh?

To day no way to say a region is fixe in adaptmesh.
But it is not so hard add this trick in adaptmesh.

I’m trying to do the same thing, but no success. I did something like this:

int globalRef = 2;
int localRef = 2;

mesh Th = square(globalRef,globalRef,region=1);
mesh Th1 = square(localRef,localRef, region=2, [x/2,y/2]);

plot(Th1,wait=1);

mesh P = Th + Th1;

plot(P,wait=1);

But what I really want to do is to refine each triangle differently

Remark,

The mesh Th is wrong because you have overlap region.

I have make a example a hard to build a mesh of a screw with this trick between line 200 to 220.
Sorry this is a really an hard script to build the mesh.

mesh-vis-3d.edp (8.6 KB)