load "medit" include "getARGV.idp" func f= 1. ; // right hand side function func g=0.; ; // boundary condition function func u0= 0; real dt=getARGV("-dt",0.01); int nn=getARGV("-n",10); int imax=getARGV("-niter",10); int op=getARGV("-op",1); int pplot=getARGV("-plot",0); mesh Th2D=square(nn,nn); int[int] refm=[1,1,2,1,3,1,4,1]; int[int] refu=[0,1]; mesh3 Th=buildlayers(Th2D,nn,zbound=[0.,1.],labelmid=refm,labelup=refu,labeldown=refu); // to slip integral on each processor // set a region number of a processor number real ccc = mpisize/real(Th.nt) ; if(op) Th=change(Th,fregion= min(mpisize-1,int(nuTriangle* ccc+1e-10))); else Th=change(Th,fregion=0); int reg= op ? mpirank : 0; // end of trick cout << " *** Th: vol " << Th.mesure << " " << int3d(Th,reg)(1.) << endl; fespace Vh(Th,P2) ; // P1 FE space Vh uh=u0 ; // unkown and test function. real temps=clock(); real time1,time2,time6; time1=clock(); // compute only on region number = processor number varf vlaplace(uh,vh) = // definition de problem int3d(Th,reg)( uh*vh+ dt*(dx(uh)*dx(vh) + dy(uh)*dy(vh)+ dz(uh)*dz(vh)) ) // bil. form + int3d(Th,reg)( dt*vh*f) + on(1,uh=g) ; varf vmasse(u,v) = int3d(Th,reg)(u*v); varf von1(uh,vh) = on(1,uh=1) ; matrix AA = vlaplace(Vh,Vh,tgv=ttgv) ; time1=clock()-time1; // reduce the matrice to get the full matrice // warning the tgv number is now mpisize*tgv for B.C. varf vffullpattern(u,v) = int2d(Th,qforder=1)(u*v); matrix A=vffullpattern(Vh,Vh); time6=clock(); if(op) mpiAllReduce(AA,A,mpiCommWorld,mpiSUM); else A=AA; time6 = clock()-time6; time2=clock(); set(A,solver=sparsesolver,tgv=ttgv) ; // factorize time2=clock()-time2; real time3=clock(); matrix M = vmasse(Vh,Vh); time3=clock()-time3; real [int] b(A.n),bb(A.n) ; real[int] bcl= vlaplace(0,Vh,tgv=ttgv) ; // The B.C vector real[int] Gamma = von1(0,Vh,tgv=1); // real time4=0,time5=0; for(int i=0 ;i