// poisson.edp // https://m-katsurada.sakura.ne.jp/program/fem/poisson.edp // https://m-katsurada.sakura.ne.jp/labo/text/welcome-to-freefem/node4.html // 境界の定義 (単位円), いわゆる正の向き border Gamma(t=0,2*pi) { x=cos(t); y=sin(t); } // 三角形要素分割を生成 (境界を50に分割) mesh Th = buildmesh(Gamma(50)); plot(Th,wait=true); // plot(Th,wait=true,ps="Th.eps"); // 有限要素空間は P1 (区分的1次多項式) 要素 real [int] levels =-0.012:0.001:0.012; fespace Vh(Th,P1); Vh u,v; // Poisson 方程式 -△u=f の右辺 func f = x*y; // 現在時刻をメモ real start = clock(); // 問題を解く solve Poisson(u,v) = int2d(Th)(dx(u)*dx(v)+dy(u)*dy(v))-int2d(Th)(f*v) +on(Gamma,u=0); // 可視化 (等高線) plot(u,wait=true); //plot(u,viso=levels,fill=true,wait=true); // 可視化 (3次元) --- マウスで使って動かせる //plot(u,dim=3,wait=true); plot(u,dim=3,viso=levels,fill=true,wait=true); // 計算時間を表示 cout << " CPU time= " << clock() - start << endl;