Heat equation, thanks to G. Sadaka
$$ \begin{array}{rcll} \partial_tu-\nu\Delta u & =& f & \mbox{on } \Omega=(0,1)^2,\quad t>0\\ u(x,y,t=0)&=& u_0 &\mbox{on } \Omega\\ \nu\partial_{\bf n}u+\alpha(u-u_e)&=&0&\mbox{on } \Gamma_2\cup \Gamma_3\\ u&=&u_e&\mbox{on } \Gamma_1\cup \Gamma_4\\ \end{array} $$
download example: Sadaka_Heat.edp or return to 2D examples
verbosity=0.; real Dx=.02,Dy=.02; mesh Th=square(floor(1./Dx),floor(1./Dy)); fespace Vh(Th,P1); Vh uh,vh,uh0=10.; real ue = 4., mu = 1., alpha=.001, dt=0.01, Tf=10. ; func f=20.*(.6<=x & x<=.8)*(.4<=y & y<=.6); macro Grad(u)[dx(u),dy(u)]// problem chaleur(uh,vh) = int2d(Th)(uh*vh/dt + Grad(uh)'*Grad(vh)*mu) - int2d(Th)(uh0*vh/dt + f*vh) + int1d(Th,2,3)(uh*vh*alpha) - int1d(Th,2,3)(ue*vh*alpha) + on(1,4,uh=ue); int kk=0; for (real t=0.;t<Tf;t+=dt) { chaleur; uh0=uh; if ( !(kk % 20)) plot(uh,cmm="t="+t+"[sec]",dim=2,fill=true,value=true,wait=1); kk+=1; }