// MPIGMRSmacro.idp file.. version 0.1 // include in MPIGMRES.edp file .. // Frederic Hecht 2010 // LGPL licence // Author Frederic.Hecht@upmc.fr // ------------------------------- // macro to def // send-recv message // ----------------------------------- /******************************************************************/ func real maxM(matrix & A) { int[int] I(1),J(1); real[int] C(1); [I,J,C] =A; return C.max ; } /******************************************************************/ macro InitU(n,Vh,Th,aTh,U) Vh[int] U(n); for(int j=0;j> Ri[j]; } // EOM /******************************************************************/ macro CheckUV(comm,jpart,Si,Ri) { int n= jpart.n; int[int] rn(n),sn(n),in(n); for (int j=0;j> rn[j]; for (int j=0;j> in[j]; int err=0; for (int j=0;j " << in[j] << " " << err << endl; } assert(err==0); }//EOM /******************************************************************/ macro SendRecvUV(comm,jpart,Si,Ri) { int n= jpart.n; mpiRequest[int] rq(n); for (int j=0;j> Ri[j][];*/ for (int j=0;j1 && ipart==0) metisdual(part[],Thg,npart); broadcast(processor(0,comm),part[]); } /* build ... */ if(vdebug>10&& mpirank==0 && !NoGraphicWindow) plot(part,fill=1,cmm="dual",wait=1); /* overlapping partition */ Vhi unssd; int nnn = sizeoverlaps*2;/* to be sure exact in thii */ { int[int] n2o(1); Phg suppi= abs(part-ipart)<0.1; /* boolean function 1 in the subdomain 0 elswhere */ Thin=trunc(Thg,suppi>0,label=10,renum=false); /* non-overlapping mesh, interfaces have label 10 */ AddLayers(Thg,suppi[],nnn,unssd[]); /* see above ! suppi and unssd are modified */ unssd[] *= nnn; /* to put value nnn a 0 */ /* build a local mesh of thii such that all compuation of the unit partition are */ /* exact in thii */ Thii=trunc(Thg,unssd> 0.001 ,label=10,new2old=n2o,renum=false); /* overlapping mesh, interfaces have label 10 */ unssd= unssd;/* put on Thii*/ real[int] p=part[]; part=0.; part[]=p(n2o); real nnn0 = nnn - sizeoverlaps + 0.001 ; Thi=trunc(Thii,unssd>nnn0 ,label=10,renum=false); /* overlapping mesh, interfaces have label 10 */ } settt int npij=npart; Vhi[int] pij(npij);/* local partition of unit + pii */ { /* construction of the partition of the unit, let phi_i P1 FE function 1 on Thin and zero ouside of Thi and positive the partition is build with $$ p_i = phi_i/ \sum phi_i to build the partition of one domain i we nned to find all j such that supp(phi_j) \cap supp(phi_j) is not empty <=> int phi_j */ { /* find all j mes (supp(p_j) \cap supp(p_i)) >0 */ /* compute all phi_j on Thii */ /* remark supp p_i include in Thi */ /* */ fespace Phii(Thii,P0); fespace Vhii(Thii,P1); Vhi sumphi=0; jpart=0; njpart=0; if(ipart==0) cout <<" sizeoverlaps=" << sizeoverlaps << " " << " nnn = " << nnn<< endl; if(dplot1) plot(unssd,wait=1,cmm=" bbbb"); pii= max(unssd-sizeoverlaps,0.)/sizeoverlaps; if(RAS) pii[]=pii[] ? 1. : 0.; if(dplot1) plot(pii,wait=1,cmm=" 0000 max="+pii[].max); sumphi[] += pii[]; if(dplot1) plot(sumphi,wait=1,cmm=" summ 0000"); Vhii phii=0; real epsmes=1e-10*Thii.mesure; /*cout << " epsmes = " << epsmes < 0.5) { AddLayers(Thii,suppii[],sizeoverlaps,phii[]); if(RAS) { phii[]=phii[] ? 1. : 0.; if(dplot1) plot(phii,wait=1,cmm=" RAS ij"); } assert(phii[].min >= -1e-10); real interij = int#mesh(Thi)( phii); if(interij>epsmes) { pij[njpart]=abs(phii); if(vdebug1>2) cout << " ***** " << int#mesh(Thi)(real(pij[njpart])<0) << " " <2) cout << " sum min " < 1.-1e-6 && sumphi[].max< 1.+1e-6); /* verification */ }}/* (Thii is remove here) */ /* end of the construction of the local partition of the unity ... */ /* on Thi ... */ /* ----------------------------------------------------------------- */ if(mpiRank(comm)==0) cout << " *** end build partition " << endl; /* computation of number of intersection .. */ /* ------------------------------------------ */ /* here pii and the pij is the locate partition of the unite on */ /* Thi ( mesh with overlap ).... */ /*Thi=splitmesh(Thi,2); */ if(dplot1 ) { plot(Thi,pii,wait=1); for(int j=0;j we have to recive */ /* data on intersection of the support of pij[0] and pij[j] */ settt aThij.resize(njpart); /* construction of the mesh intersect i,j part */ for(int jp=0;jp1e-6,label=10,renum=false); /* mesh of the supp of pij */ } if(mpiRank(comm)==0) cout << " *** end build mesh intersection " << endl; // EOM macro defPk1(i,j) i j // macro defPk2(i,j) [i j,i#1 j]// macro defPk3(i,j) [i j,i#1 j,i#2 j]// macro defPk4(i,j) [i j,i#1 j,i#2 j,i#3 j]// macro defPk5(i,j) [i j,i#1 j,i#2 j,i#3 j, i#4 j]// macro Times1(i) i // macro Times2(i) [i,i]// macro Times3(i) [i,i,i]// macro Times4(i) [i,i,i,i]// macro Times5(i) [i,i,i,i,i]// macro InitUdef(n,Vh,Th,aTh,U,N) Vh[int] defPk#N(U,)(n); for(int j=0;j99)savemesh(Thij,"Th-"+j+"--"+ipart+".mesh"); int [int] U2Vdata=[0]; matrix I = interpolate(Whij,Whi,U2Vc=U2Vdata); /* Whji <- Whi */ sMj[jp] = I*Pii; /* Whi -> s Whij */ rMj[jp] = interpolate(Whij,Whi,t=1,U2Vc=U2Vdata); /* Whji -> Whi */ if(vdebug>10) { {Whi defPk#N(uuu,)=Times#N(1); Whij defPk#N(vvv,)=Times#N(-1); cout << vvv[].n <<"+=" << I.n << "x" << I.m << "*" << uuu[].n << endl; vvv[]+=I*uuu[]; cout << jp << " %%% " << vvv[].linfty << endl; assert(vvv[].linfty < 1e-6);} {Whi defPk#N(uuu,)=Times#N(1); Whij defPk#N(vvv,)=Times#N(-1) ; vvv[]+=rMj[jp]'*uuu[]; cout << jp << " ### " << vvv[].linfty << endl; assert(vvv[].linfty < 1e-6);}} }} if(ipart==0) cout << " *** end build transfert matrix " << endl; settt /* alloc array of send and recv data .. */ InitUdef(jpart.n,Whij,Thij,aThij,Usend,N) /* initU(n,Vh,Th,aTh,U) */ InitUdef(jpart.n,Whij,Thij,aThij,Vrecv,N) /* ... */ if(ipart==0) cout << " *** end init data for send/revc " << endl; // /******************************************************************/ macro BuildTransferMat(ipart,mesh,Pk,N,U2V,Thi,Whi,Whij,Thij,aThij,Usend,Vrecv,jpart,vdebug) BuildTransferMat2(ipart,mesh,Pk,N,U2V,Thi,Whi,Whij,Thij,aThij,Usend,Vrecv,jpart,Pii,vdebug) // /******************************************************************/ /******************************************************************/ // usage uplot is allu or [allu,allu1] : macro PLOTMPIALLU(mesh,Pk,defPk, Th, u, uplot, plotparm) { int ver=verbosity; verbosity=2; if(NoGraphicWindow==0) { if(mpirank==0) { mesh Thi=Th; mesh[int] ath(mpisize); fespace Xh(Thi,Pk); Xh[int] defPk(allu,)(mpisize); allu[0][]=u; ath[0]=Th; mpiRequest[int] rq(mpisize); for(int i= 1; i