Previous Up Next

Chapter 4  Examples

4.1  Triangulations examples

4.2  Scalar examples

4.3  Complex number example

complex; nowait;
border(1,0,1,10) begin x:=t; y:=0; end;
border(1,0,1,10) begin x:=1; y:=t; end;
border(2,0,1,10) begin x:=1-t; y:=1; end;
border(1,0,1,10) begin x:=0; y:=1-t; end;
buildmesh(200);

solve(u)  /* observe than Re(u) = Im(u) */
begin
     onbdy(1,2) u=0;
      pde(u) id(u)-laplace(u)=1+I ;
end;
v=Im(u);
 plot(u);plot(v);plot(u-v);

4.4  2-system example

/* This is a 2-system example for which the solution is know
analytically, thus the precision of Gfem can be checked */
nowait;
ns:=40; 
border(1,0,2*pi,2*ns) begin x:= 3*cos(t); y:= 2*sin(t); end;
border(2,0,2*pi,ns)   begin x:= cos(-t); y:= sin(-t); end;
buildmesh(ns*ns);

ue= sin(x+y);
ve = ue;
p = ue;
nx = -x;
ny =- y;
dxue = cos(x+y);

c = 0.2;
a1 = y;
a2 =x;
nu = 1;
nu11 = 1; 
nu22 = 2;
nu21 =0.3;
nu12 =0.4;
b=1;

dnuue=dxue*(nu*(nx+ny) + 
(nu11 + nu12)*nx + (nu21+ nu22)*ny);
g = ue*c+dnuue;
f = b*ue+dxue*(a1+a2) +ue*(2*nu+nu11+nu12+nu21+nu22);

solve(u,v) begin
onbdy(1) u = p;
onbdy(1) v = p;
onbdy(2) 
          id(u)*c/2 + id(v)*c/2 + dnu(u) = g;
onbdy(2)   id(v)*c + dnu(v) = g;
pde(u) id(u)*b + dx(u)*a1 + dy(u)*a2
          -laplace(u)*nu - dxx(u)*nu11 -   
             dxy(u)*nu12 - dyx(u)*nu21 - dyy(u)*nu22 =f;

pde(v) id(v)*b/2+id(u)*b/2 
       + dx(v)*a1 + dy(v)*a2 -laplace(v)*nu 
        - dxx(v)*nu11 - dxy(v)*nu12 -          
        dyx(v)*nu21 - dyy(v)*nu22 =f;
end;

plot(abs(u-ue) + abs(v-ve));

Previous Up Next