[Dune] STL vector and CGSolver
Markus Blatt
Markus.Blatt at ipvs.uni-stuttgart.de
Thu Oct 9 13:31:30 CEST 2008
Hi Arne,
On Thu, Oct 09, 2008 at 01:00:18PM +0200, Arne Rekdal wrote:
> I am currently working on implementing a simple FEM solver with DUNE.
> I am solving a problem with only Dirichlet boundaries. Currently I
> mark the vertices which is part of the boundary, and the unknowns are
> all the vertices minus the boundary vertices.
>
> The plan next was to create a linear operator (A*x) so that the global
> matrix is not needed to be formed explicitly, and solve the equation
> system with conjugate gradients method.
>
> I am encountering problems with this approach. The first problem is
> that I try to use vectors of type FieldVector<Type,Size>. In this
> class it is needed to know the size at compilation, but this is not
> available without finding the number of boundary vertices first. I
> have also tried to use std::vector<Type> representation, but this
> class does not have the ::field_type type definition which is used in
> CGSolver. I also see that a preconditioner is required, but I am not
> sure how to create one.
>
std::vector won't work because it does not fullfill the ISTL vector
interface.
What you are probably looking for is
BlockVector<FieldVector<double, 1> > (see
http://www.dune-project.org/doc-1.1/doxygen/html/group__ISTL__SPMV.html)
Here FieldVector simply models a scalar.
More about the ISTL linear algebra approach can be found in "The
Iterative Solver Template Library" paper (available via publications
from the DUNE website).
> I am looking for explanations for how/why use fixed size vectors. Is
> the FieldVector intended for this use? Any help would be greatly
> appreciated.
We use fixed size vectors (but only as entries in variable sized
vectors like BlockVector), because there might be several unknowns
(e.g. pressure and velocity) associated to one node (FE vertex). In
this case if one wants to solve the fully coupled problem it is
advisable to collect all unknowns per node in a FieldVector of
size n>1. Using a BCRSMatrix with block_type FieldMatrix<double,n,n>
the compiler is able to optimize the FieldMatrix-FieldVector
operations and allows us to gain efficiency via better cache usage.
Regards,
Markus
More information about the Dune
mailing list