test1.edp
来自「FreeFem++可以生成高质量的有限元网格。可以用于流体力学」· EDP 代码 · 共 29 行
EDP
29 行
//Tutorial file test1.pde
// YOUR FIRST PROGRAM
border C(t=0,2*pi){x=cos(t); y=sin(t);} // the boundary
mesh Th = buildmesh (C(50)); // of the domain and its mesh
fespace Vh(Th,P1); // Finite Element of degree 2 defined here for Vh
Vh u,v; // defines u and v as piecewise-P2 continuous functions
func f= x*y; // definition of an algebraic function
real cpu = clock();
solve Poisson(u,v,solver=LU) = // defines and solves the PDE
int2d(Th)( dx(u)*dx(v) + dy(u)*dy(v)) // bilinear part
- int2d(Th)( f*v) // right hand side
+ on(C,u=0) ; // Dirichlet boundary condition
plot(u,wait=1);
cout << " CPU time = " << clock()-cpu << endl;
// ENDS HERE
// FOR THE PRO: The same done with total control over the algebra
varf a(u,v) = int2d(Th)( dx(u)*dx(v) + dy(u)*dy(v))+ on(C,u=0) ;
matrix A=a(Vh,Vh); // stiffness matrix, see (\ref{eqn:Stiffness0})
varf b(u,v) = int2d(Th)( u*v ) ;
matrix B=b(Vh,Vh);
Vh F=f;
v[] = B*F[];
u[]=A^-1*v[];
plot(u,wait=1);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?