//int Nh=20; // d u /dt = cos(t), u= sin(t) + u0 // avec de methode para reel. // schema euler explicite // (u,v)' = (v,-u) // u_n+1 - u_n = v_n*dt, u_n+1 = u_n + v_n*dt // v_n+1 - v_n = -u_n*dt, // u=cos(t) u' = - sin(t) = v // v=sin(t), v' = cos(t) = u // ---------------------------- real DT=0.4; int nbT=50; // nb de big time step int ksub=50; // nb of small time step int Nbig=20; // max number of Big iteration real T0=0; // initial time real tol=1e-5; // tolerance // ---------------------------------------------------- int nbt=ksub*nbT; real dt=DT/ksub; // array for plotting real[int] pt(nbt+1),pT(nbT+1),pu(nbt+1),pU(nbT+1); // gros maillage mesh TH=square(3,3); // maillage fin mesh Th=trunc(TH,1,split=1); fespace VH(TH,P1); fespace Vh(Th,P1); int n=2; int N=2; func real Norm(real[int] & U) { return sqrt(square(U[10])+square(U[11])); } // restriction func bool h2H(real[int] & u,real[int] & U) { U=0; U[10+0]=u[0]; U[10+1]=u[1]; return true; } // prolongement func bool H2h(real[int] & U,real[int] & u) { u=0; u[0]=U[10+0]; u[1]=U[10+1]; return true; } func bool initG(real[int] & U) { U=0; U[10+0]=1;// cos(0) U[10+1]=0;// sin(0) } // un pas de temps FIN func bool F(real[int] & u,real[int] & up) { u[0] = up[0] + up[1]*dt; u[1] = up[1] - up[0]*dt; // cout << up[0] << " " << up[1] << endl; return true; } // pas de temps grossier func bool G(real[int] & U,real[int] & Up) { U[0+10] = Up[0+10] + Up[1+10]*DT; U[1+10] = Up[1+10] - Up[0+10]*DT; // cout << Up[10] << " " << Up[11] << endl; return true; } func bool AddGp(real[int] & U,int I) { pT[I]= T0+I*DT; pU[I]=U[10]; return true; } func bool AddFp(real[int] & u,int I,int i) { pt[I*ksub+i]= T0+I*DT+i*dt; pu[I*ksub+i]= u[0]; return true; } Vh ustart[nbT+1],uend[nbT]; // start VH Uend[nbT]; VH U0,U1; real t=T0,T=T0; // temps courant int it=0,iT=0; pt[it]=t; pT[iT]=T; initG(U0[]); AddGp(U0[],iT); H2h(U0[], ustart[iT][]); // initial for (int I=0;I