Hi, can anyone help with my following question.
I’m trying to get the circumference of an ellipse. I have the following mesh which have two domains. The correct circumference for my ellipse (a = 1.5, b = 1) should be c ~= 7.9, this could be obtained through my following code if I set mesh density factor n = 1. However, if I change the mesh density factor n to 2 (OR 3,4,…), this c will change to c ~= 3.9. Strangely, if I change it to a circle with a = 1 and b = 1, then regardless of the value of n, it always gives me right answer with c ~= 6.28.
I realize that by using a different mesh, say only define the 4 sides and directly mesh the whole domain, I can get the correct ellipse circumference with n >= 2. But how to explain such difference by using different mesh discretization algorithms?
Codes are as follows. Thanks! circumference.edp (648 Bytes)
/* circumference of an ellipse or circle */
/* mesh and FE space /
border bottom(t=-2.0,2.0){x=t;y=-2.0;}
border right(t=-2.0,2.0){x=2.0;y=t;}
border top(t=-2.0,2.0){x=-t;y=2.0;}
border left(t=-2.0,2.0){x=-2.0;y=-t;}
real a = 1.5;
real b = 1.;
real n = 2.;
border ellipse(t=0.,2.pi){x=acos(t);y=bsin(t);}
mesh Th1 = buildmesh(bottom(n20)+right(n20)+top(n20)+left(n20)+ellipse(-n40));
mesh Th2 = buildmesh(ellipse(n40));
mesh Th = Th1 + Th2;
fespace Vh(Th,P1);
/* levelset */
func phio = (x^2./a^2.+y^2./b^2.-1.);
/* circumference */
real c = int1d(Th,levelset=phio)(1.);
cout << "n: " << n << ", c: " << c << endl;