DUNE PDELab (2.8)
Here we show how to solve a linear system of equations originating from a PDE directly using ISTL instead of PDELab's abstractions.
Note that generally, we recommend going the all-PDELab route as explained in Solving a linear system within PDELab.
First, we assemble our residual as in Assembling a linear system from a PDE
as well as the system matrix we want to solve:
So far, these are data types provided by PDELab. We can access the underlying ISTL data types via
and the ISTL vectors or matrices behind a PDELab object via:
Now we can wrap our matrix in a LinearOperator object
and pass that into our desired solver along with a preconditioner of our choice.
Applying the solver now returns the solution of the defect problem, i.e. A*v=d.
Finally, we can subtract that from our initial guess to obtain the solution of A*x=b:
In the end, let's print the solution to console.
Full example code: recipe-linear-system-solution-istl.cc