Mmg3d generates anisotropic meshes

Hello
I’m sorry to bother you again. I generated 3D anisotropic meshes with my own metrics and mmg3d. I found that the tetrahedron segmentation speed is too fast. How does mmg3d control the number of tetrahedrons? I tried to add the parameter mem = 100, and found that mmg3d did not work after adding mem.
Thank you very much.

Without your mesh, it is hard to give an answer.
I have to try to se if it is a bug!

load “msh3”
load “tetgen”
load “mshmet”
load “medit”
load “mmg”
load “aniso”

real epsilon=1e-6;
func b1=1;
func b2=2;
func b3=3;

func ue=-y^2exp(b1(x-1)/epsilon)-xexp(b2(y-1)/epsilon)-zexp(b3(z-1)/epsilon)+exp((b1*(x-1)+b2*(y-1)+b3*(z-1))/epsilon)+xy^2z^3;
func uex=y^2z^3 - exp((b2(y - 1))/epsilon) + (b1exp((b1(x - 1) + b2*(y - 1) + b3*(z - 1))/epsilon))/epsilon - (b1y^2exp((b1*(x - 1))/epsilon))/epsilon;
func uey=2xyz^3 - 2yexp((b1(x - 1))/epsilon) + (b2exp((b1(x - 1) + b2*(y - 1) + b3*(z - 1))/epsilon))/epsilon - (b2xexp((b2*(y - 1))/epsilon))/epsilon;
func uez=(b3exp((b1(x - 1) + b2*(y - 1) + b3*(z - 1))/epsilon))/epsilon - exp((b3*(z - 1))/epsilon) + 3xy^2z^2 - (b3zexp((b3(z - 1))/epsilon))/epsilon;
func f=epsilon*(2exp((b1(x - 1))/epsilon) - 2xz^3 - 6xy^2z + (2b3exp((b3(z - 1))/epsilon))/epsilon - (b1^2exp((b1(x - 1)

  • b2*(y - 1) + b3*(z - 1))/epsilon))/epsilon^2 - (b2^2exp((b1(x - 1) + b2*(y - 1) + b3*(z - 1))/epsilon))/epsilon^2 - (b3^2exp((b1(x - 1)
  • b2*(y - 1) + b3*(z - 1))/epsilon))/epsilon^2 + (b2^2xexp((b2*(y - 1))/epsilon))/epsilon^2 + (b3^2zexp((b3*(z - 1))/epsilon))/epsilon^2
  • (b1^2y^2exp((b1*(x - 1))/epsilon))/epsilon^2) - b1*(exp((b2*(y - 1))/epsilon) - y^2z^3 - (b1exp((b1*(x - 1) + b2*(y - 1) + b3*(z - 1))/epsilon))/epsilon
  • (b1y^2exp((b1*(x - 1))/epsilon))/epsilon) - b3*(exp((b3*(z - 1))/epsilon) - (b3exp((b1(x - 1) + b2*(y - 1) + b3*(z - 1))/epsilon))/epsilon - 3xy^2*z^2
  • (b3zexp((b3*(z - 1))/epsilon))/epsilon) - b2*(2yexp((b1*(x - 1))/epsilon) - 2xyz^3 - (b2exp((b1*(x - 1) + b2*(y - 1) + b3*(z - 1))/epsilon))/epsilon
  • (b2xexp((b2*(y - 1))/epsilon))/epsilon);

int nn = 10;
int[int] lc=[1,2,2,1,1,2];

mesh3 Th=cube(nn,nn,nn,label=lc);
fespace Vh(Th,P1);
fespace Mh(Th,[P1,P1,P1,P1,P1,P1]);
Vh u,v;
Mh [n11,n21,n22,n31,n32,n33];

problem Lap3d (u, v)
= int3d(Th)(
epsilon*(dx(u)dx(v)+dy(u)dy(v)+dz(u)dz(v))
)
+int3d(Th)(
(b1
dx(u)+b2
dy(u)+b3
dz(u))*v
)
- int3d(Th)(
f * v
)
+ on(0, 1, u=ue)
;

real lerr=0.05;
int a=9;
for(int ii=0; ii<a; ii++)
{
[n11,n21,n22,n31,n32,n33]=[0,0,0,0,0,0];
real cc=(u.max-u.min);
real[int] met=mshmet(Th,u,hmin=1e-8,hmax=0.2,err=lerr,aniso=1);
n11=met;
Th=mmg3d(Th,metric=n11,mem=100,hgrad=1000000);
lerr=lerr/1.5;
mesh3 Th4=trunc (Th,(x<0.5|y<0.5|z<0.5),label=1);
if(ii>a-2) medit(“U-adap-aniso-”+ii,Th4,u,wait=1);
}

This is the program. When I add men = 100, mmg3d will not work. Thank you.

Please some character disappear please send the file not a paste of the file.

test.edp (2.5 KB)

First You code is wrong,

u is never set, I tty to correct but I do not understand you code
remark, I get no error on my Mac and the mesh never change

I change mem to 500 and I don adaptation with ue no u.

my change:
test.edp (2.6 KB)

Thank you very much for your answer. I want to use the approximate solution to generate the metrics of anisotropy, and then generate the meshes of anisotropy based on the metrics. I run the program you modified, MEM = 500, the grid changes little, and the anisotropic is lost. Since the mesh does not change after adding MEM, how should we set parameters to control the number of tetrahedrons? This is the program after removing mem.There is also a problem about the second derivative of the approximate solution in this program.
test.edp (2.6 KB)

To control the number of element change the level of err in mshmet.

Thank you very much for your answer. But how can I control the number of tetrahedrons if I generate metrics by other methods instead of mshmet?