cout << endl;
cout << “convergence:” << endl;
real r=1;real L2error;
func uhold=0;
for ( int log2 = 4; log2 <= 5; log2++ )
{
int m = pow ( 2.0, log2 );
border C(t=0, 2*pi){x=cos(t); y=sin(t);}
mesh Th = buildmesh(C(m));
func f= 1;
func u=(1-x^2-y^2)/4;
fespace Vh(Th, P1);
Vh uh, v,uhold;// Define u and v as piecewise-P1 continuous functions
solve Poisson(uh, v, solver=LU)
= int2d(Th)(dx(uh)*dx(v)+ dy(uh)dy(v)) - int2d(Th)(fv)+ on(C, uh=0);
if(4==log2)
{
Vh uhold=uh;
plot(uhold,dim=3,value=true,fill=true,ShowAxes=0,ColorScheme =1);
}
if(4<log2)
{
plot(uhold,dim=3,value=true,fill=true,ShowAxes=0,ColorScheme =1);
plot(uh,dim=3,value=true,fill=true,ShowAxes=0,ColorScheme =1);
L2error=sqrt(int2d(Th)((uh-uhold)^2));
cout << " L2 = " << L2error << endl;
}
}
cout << “\n”;
cout << “convergence:\n”;
cout << " Normal end of execution.\n";
this the problem,
L2error=sqrt(int2d(Th)((uh-u)^2));
The have corrected you script
the main issue is the mesh change and your want to compare 2 solution on different meshes;
:so the mesh must be defined outside of the loop
poisson.edp (952 Bytes)
Thanks, I thought he meant " known " lol.
Thanks Sir. I got it.