DUNE PDELab (git)
This recipe shows how to assemble a linear system of equations discretizing a PDE.
In particular, we start from a LocalOperator representing the PDE's bilinear form. Rather than defining one by ourselves, we use one already provided in PDELab. Further, we assume that a GridFunctionSpace and Constraints have already been set up.
This per-element LocalOperator can now be plugged into a GridOperator, which is capable of assembling a matrix for the entire domain.
Next, we set up our degree of freedom vector.
and ensure it matches the Dirichlet boundary conditions at constrained degrees of freedom. In addition to specifying Dirichlet constrained degrees of freedom, it also serves as initial guess at unconstrained ones.
Now, from the GridOperator, we can assemble our residual vector depending on our initial guess
and print it to console.
Likewise, we can assemble our matrix which again depends on the initial guess
and print it as well.
Full example code: recipe-linear-system-assembly.cc