← Back to team overview

dolfin team mailing list archive

Stokes in DOLFIN

 

Looks like it's working now. The following simple code is the complete
DOLFIN implementation of the Stokes solver (which looks almost
identical to the Poisson solver):

    Stokes::BilinearForm a;
    Stokes::LinearForm L(f);

    Matrix A;
    Vector x, b;
    FEM::assemble(a, L, A, b, mesh, bc);

    GMRES solver;
    solver.solve(A, x, b);

    Function u(x, mesh, a.trial());
    File file("stokes.m");
    file << u;

and the following is the FFC implementation of the bilinear form:

    a = (dot(grad(u), grad(v)) - p*div(v) + div(u)*q)*dx

It can't get much simpler. We will probably add an additional set of
tools to abstract away the linear algebra whenever that is possible,
so that one can work entirely with Function and never have to look at
vectors and matrices. The current tools will remain, however, in
particular the assembly functions in FEM and of course Vector and
Matrix, but there will be tools that build on these.

One suggestion is to create a class PDE which holds a pair (a, L) of
bilinear and linear forms. FFC would automatically generate a class
Stokes that inherits from PDE and just initializes the two forms. Thus,
instead of accessing the forms directly like Stokes::BilinearForm
(which will still be possible), one can just do

    Function u;
    Stokes pde(f, mesh, bc);
    pde.solve(u);    
    File file("stokes.m");
    file << u;

Choice of linear solvers etc can be controlled with parameters.

We also need to add some functionality to Function for representing
slices of vector-valued functions (like velocity and pressure in the
example above). This is easy (just need to keep an extra integer
component_offset) but we need to decide on a proper syntax for
creating slices.

Attached is a plot of the Stokes solution with Taylor-Hood elements.

/Anders

Attachment: stokes.eps
Description: PostScript document


Follow ups