/usr/share/doc/freefem++/examples/examples++-chapt3/membranerror.edp is in freefem++-doc 3.19.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | // file membranerror.edp
verbosity=0;
real theta=4.*pi/3.;
real a=1.,b=1.; // the length of the semimajor axis and semiminor axis
border Gamma1(t=0,theta) { x = a * cos(t); y = b*sin(t); }
border Gamma2(t=theta,2*pi) { x = a * cos(t); y = b*sin(t); }
func f=-4*(cos(x^2+y^2-1) -(x^2+y^2)*sin(x^2+y^2-1));
func phiexact=sin(x^2+y^2-1);
real[int] L2error(2);
for(int n=0;n<2;n++)
{
mesh Th=buildmesh(Gamma1(40*(n+1))+Gamma2(20*(n+1)));
fespace Vh(Th,P2);
Vh phi,w;
solve laplace(phi,w)=int2d(Th)(dx(phi)*dx(w) + dy(phi)*dy(w))
- int2d(Th)(f*w) - int1d(Th,Gamma2)(2*w)+ on(Gamma1,phi=0);
plot(Th,phi,wait=true,ps="membrane.eps"); //Plot Th and phi
L2error[n]= sqrt(int2d(Th)((phi-phiexact)^2));
}
for(int n=0;n<2;n++)
cout << " L2error " << n << " = "<< L2error[n] <<endl;
cout <<" convergence rate = "<< log(L2error[0]/L2error[1])/log(2.) <<endl;
|