Previous Up Next
Previous: 3.7.5 Boundary conditions at corners
Up: 3.7 Solving an equation

3.7.6 Weak formulation

The new keyword varsolve allows the user to enter PDEs in weak form. Syntax:

varsolve(<unknown function list>;<test function list>
          ,<<int>>) <<instruction>> : <expression>>;

where

We have used the notation << >> whenever the entities can be omitted. Examples

varsolve(u;w)  /* Dirichlet problem -laplace(u) =x*y */
begin
        onbdy(1) u = 0;
        f = dx(u)*dx(w) + dy(u)*dy(w)
        g = x*y;
end : intt[f] - intt[g,w];

varsolve(u;w,-1)  /* same  with prefactorized matrix */
begin
        onbdy(1) u = 0;
        f = dx(u)*dx(w) + dy(u)*dy(w)
        g = x*y;
end : intt[f] - intt[g,w];

varsolve(u;w)  /* Neuman problem u-laplace(u) = x*y */
begin
        f = dx(u)*dx(w) + dy(u)*dy(w) -x*y;
        g = x;
end : intt[f] + int[u,w] - int(1)[g,w];

varsolve(u,v;w,s) /* Lame's equations */
begin
   onbdy(1) u=0;
   onbdy(1) v=0;
   e11 = dx(u);
   e22 = dy(v);
   e12 = 0.5*(dx(v)+dy(u));
   e21 = e12;
   dive = e11 + e22;
   s11w=2*(lambda*dive+2*mu*e11)*dx(w);
   s22s=2*(lambda*dive+2*mu+e22)*dy(s);
   s12s = 2*mu*e12*(dy(w)+dx(s));
   s21w = s12s;
   a = s11w+s22s+s12s+s21w +0.1*s;
end : intt[a];

How does it works The interpreter evaluates the expression after the ":" for each triangle and for each 3 vertices; if there is an instruction prior the ":" it is also evaluated similarly. Each evaluation is done with one of the unknown and one of the test functions being 1 at one vertices and zero at the 2 others. This will give an element of the contribution of the triangle to the linear system of the problem. The right hand side is constructed by having all unknowns equal to zero and one test function equal to one at one vertex. whenever integrals appear they are computed on the current triangle only.

Note that varsolve takes longer than solve because derivatives like dx(u) are evaluated 9 times instead of once.


Christophe Prud'homme

Previous Up Next