📄 lap3-cpu.edp
字号:
// a example to test the level of optimisation// --------------------------------------------int nn=300; mesh Th=square(nn,nn);verbosity=5; fespace Vh(Th,P1); // P1 FE space Vh uh,vh; // unkown and test function. func f=1; // right hand side function func g=0; // boundary condition function problem laplace0(uh,vh,solver=Cholesky,tgv=1e30) = // definion of the problem int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) // bilinear form + int1d(Th,1)( uh*vh) + int1d(Th,1)( - vh) + int2d(Th)( -f*vh ) // linear form + on(2,3,4,uh=g) ; // boundary condition form problem laplace1(uh,vh,solver=CG,tgv=1e30) = // definion of the problem int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) // bilinear form + int1d(Th,1)( uh*vh) + int1d(Th,1)( - vh) + int2d(Th)( -f*vh ) // linear form + on(2,3,4,uh=g) ; // boundary condition form problem laplaceLU(uh,vh,solver=LU,tgv=1e30) = // definion of the problem int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) // bilinear form + int1d(Th,1)( uh*vh) + int1d(Th,1)( - vh) + int2d(Th)( -f*vh ) // linear form + on(2,3,4,uh=g) ; // boundary condition form problem laplaceCrout(uh,vh,solver=Crout,tgv=1e30) = // definion of the problem int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) // bilinear form + int1d(Th,1)( uh*vh) + int1d(Th,1)( - vh) + int2d(Th)( -f*vh ) // linear form + on(2,3,4,uh=g) ; // boundary condition formreal cpu=clock() ;laplace0; // solve the problem plot(uh); // to see the resultcout << "-- lap Cholesky " << nn << "x" << nn << " : " << -cpu+clock() << " s, max =" << uh[].max << endl;uh=0;cpu=clock() ;laplace1; // solve the problem plot(uh); // to see the resultcout << "-- lap CG " << nn << "x" << nn << " : " << -cpu+clock() << " s, max =" << uh[].max << endl;uh=0;cpu=clock() ;laplaceLU; // solve the problem plot(uh); // to see the resultcout << "-- lap LU " << nn << "x" << nn << " : " << -cpu+clock() << " s, max =" << uh[].max << endl;uh=0;cpu=clock() ;laplaceCrout; // solve the problem plot(uh); // to see the resultcout << "-- lap Crout " << nn << "x" << nn << " : " << -cpu+clock() << " s, max =" << uh[].max << endl;uh=0;if(HaveUMFPACK){ problem laplace2(uh,vh,solver=UMFPACK,tgv=1e30) = // definion of the problem int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) // bilinear form + int1d(Th,1)( uh*vh) + int1d(Th,1)( - vh) + int2d(Th)( -f*vh ) // linear form + on(2,3,4,uh=g) ; // boundary condition form cpu=clock(); laplace2; // solve the problem plot(uh); // to see the result cout << "-- lap UMFPACK " << nn << "x" << nn << " : " << -cpu+clock() << " s, max =" << uh[].max << endl;}else{ cout << "-- lap UMFPACK " << nn << "x" << nn << " : " << "not available" << endl;}// plot(uh,ps="lap1-cpu.eps",value=true);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -