⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 membranerror.edp

📁 FreeFem++可以生成高质量的有限元网格。可以用于流体力学
💻 EDP
字号:
// 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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -