相關鏈接:http://wenku.baidu.com/view/f17e57e8856a561252d36f5e.html
問題描述:
求解泊松方程 -Δu=1 求解區域為單位圓盤,邊界條件為在圓盤邊界上u=0
下面求它的數值解,編寫程序如下:
%(1)問題定義 g='circleg'; %單位圓 b='circleb1'; %邊界上為零條件 c=1;a=0;f=1; %(2)產生初始的三角形網格 [p,e,t]=initmesh(g); %(3)迭代直至得到誤差允許范圍內的合格解 error=[]; err=1; while err > 0.01, [p,e,t]=refinemesh(g,p,e,t); u=assempde(b,p,e,t,c,a,f); %求得數值解 exact=(1-p(1,:).^2-p(2,:).^2)/4; err=norm(u-exact',inf); error=[error err]; end %結果顯示 subplot(2,2,1),pdemesh(p,e,t); subplot(2,2,2),pdesurf(p,t,u) subplot(2,2,3),pdesurf(p,t,u-exact')
顯示結果如下: