13#ifndef GAUSS_SEIDEL_PRECONDITIONER_HH
14#define GAUSS_SEIDEL_PRECONDITIONER_HH
16#include "dune/istl/preconditioners.hh"
17#include "dune/istl/solvercategory.hh"
48 template <
class Matrix,
72 static_assert(std::is_same_v<Domain,Range>,
73 "Gauss Seidel works only for square matrices with coinciding domain and range types.");
77 void apply(Domain& x, Range
const& y)
override
83 for (
int i=0; i<A.N(); ++i)
85 auto const& row = A[i];
87 auto ci = row.begin();
88 for (; ci!=row.end() && ci.index()<i; ++ci)
89 ci->usmv(-1.0,z[ci.index()],rhs);
90 assert(ci!=row.end());
97 for (
int i=A.N()-1; i>=0; --i)
99 auto const& row = A[i];
101 auto ci = row.begin();
102 while (ci.index()<i && ci!=row.end())
104 assert(ci.index()==i);
106 for (; ci!=row.end(); ++ci)
107 ci->usmv(-1.0,x[ci.index()],rhs);
113 field_type
applyDp(Domain& x, Range
const& y)
override
bool requiresInitializedInput() const override
Returns true if the target vector x has to be initialized to zero before calling apply or applyDp.
field_type applyDp(Domain &x, Range const &y) override
GaussSeidelPreconditioner(Matrix const &A_, field_type w_=1.0, GaussSeidelPreconditionerMode mode_=GaussSeidelPreconditionerMode::SYMMETRIC)
Constructor.
void apply(Domain &x, Range const &y) override
Interface for symmetric preconditioners.
Domain::field_type field_type
This file contains various utility functions that augment the basic functionality of Dune.
GaussSeidelPreconditionerMode
void NaturalDomain
The natural domain type.
static bool isSquare(Matrix const &A)
Checks whether a matrix is square.
void NaturalRange
The natural range type.