4#ifndef DUNE_PDELAB_BACKEND_ISTL_MATRIXFREE_BACKENDS_HH
5#define DUNE_PDELAB_BACKEND_ISTL_MATRIXFREE_BACKENDS_HH
7#include<dune/grid/common/rangegenerators.hh>
8#include<dune/istl/preconditioner.hh>
12#include<dune/pdelab/backend/istl/matrixfree/gridoperatorpreconditioner.hh>
13#include<dune/pdelab/gridoperator/fastdg.hh>
14#include<dune/pdelab/backend/istl/matrixfree/blocksorpreconditioner.hh>
15#include<dune/pdelab/backend/istl/matrixfree/checklopinterface.hh>
26 struct isBlockSORPreconditionerLocalOperator : std::false_type {};
28 template <
typename JacobianLOP,
typename BlockOffDiagonalLOP,
typename Gr
idFunctionSpace>
29 struct isBlockSORPreconditionerLocalOperator<BlockSORPreconditionerLocalOperator<JacobianLOP,
36 struct isFastDGGridOperator : std::false_type {};
38 template<
typename GFSU,
typename GFSV,
typename LOP,
39 typename MB,
typename DF,
typename RF,
typename JF,
40 typename CU,
typename CV>
41 struct isFastDGGridOperator<FastDGGridOperator<GFSU, GFSV, LOP, MB, DF, RF, JF, CU, CV >>
62 template<
class GO,
class PrecGO,
63 template<
class>
class Solver>
65 :
public Dune::PDELab::SequentialNorm
66 ,
public Dune::PDELab::LinearResultStorage
68 using V =
typename GO::Traits::Domain;
69 using W =
typename GO::Traits::Range;
75 unsigned maxiter=5000,
int verbose=1)
76 : opa_(go), seqprec_(precgo)
77 , maxiter_(maxiter), verbose_(verbose)
85 static_assert(not(impl::isBlockSORPreconditionerLocalOperator<
86 typename PrecGO::Traits::LocalAssembler::LocalOperator>::value
87 and not impl::isFastDGGridOperator<PrecGO>::value),
88 "If you use the BlockSORPreconditioner you need to use FastDGGridOperator!");
92 static_assert(!
decltype(Dune::PDELab::impl::hasOldLOPInterface(go.localAssembler().localOperator()))::value,
94 "In order to use the matrix-free solvers your grid operator must follow the new\n"
95 "local operator interface for nonlinear jacobian applys, where the current\n"
96 "solution and the linearization point can have different types. This is best\n"
97 "explained by an example.\n\n"
98 "old: void jacobian_apply_volume (const EG& eg, const LFSU& lfsu, const X& x, const X& z, const LFSV& lfsv, Y& y) const {}\n"
99 "new: void jacobian_apply_volume (const EG& eg, const LFSU& lfsu, const X& x, const Z& z, const LFSV& lfsv, Y& y) const {}\n\n"
100 "Note that in the new interface the type of z is Z and doesn't have to be X.\n"
101 "You need to adjust all the nonlinear jacobian apply methods in your local operator\n"
102 "in a similar way.");
103 static_assert(!
decltype(Dune::PDELab::impl::hasOldLOPInterface(precgo.localAssembler().localOperator()))::value,
105 "In order to use the matrix-free solvers your grid operator must follow the new\n"
106 "local operator interface for nonlinear jacobian applys, where the current\n"
107 "solution and the linearization point can have different types. This is best\n"
108 "explained by an example.\n\n"
109 "old: void jacobian_apply_volume (const EG& eg, const LFSU& lfsu, const X& x, const X& z, const LFSV& lfsv, Y& y) const {}\n"
110 "new: void jacobian_apply_volume (const EG& eg, const LFSU& lfsu, const X& x, const Z& z, const LFSV& lfsv, Y& y) const {}\n\n"
111 "Note that in the new interface the type of z is Z and doesn't have to be X.\n"
112 "You need to adjust all the nonlinear jacobian apply methods in your local operator\n"
113 "in a similar way.");
116 void apply(V& z, W& r,
typename V::ElementType reduction)
118 Solver<V> solver(opa_,seqprec_,reduction,maxiter_,verbose_);
120 solver.apply(z, r, stat);
136 constexpr static bool isMatrixFree {
true};
147 class ISTLBackend_SEQ_BCGS_SOR
148 :
public ISTLBackend_SEQ_Base<Dune::SeqSOR, Dune::BiCGSTABSolver>
156 explicit ISTLBackend_SEQ_BCGS_SOR (
unsigned maxiter_=5000,
int verbose_=1)
157 : ISTLBackend_SEQ_Base<
Dune::SeqSOR,
Dune::BiCGSTABSolver>(maxiter_, verbose_)
Turn a grid operator that represents a preconditioner into an ISTL preconditioner.
Definition: gridoperatorpreconditioner.hh:21
void setLinearizationPoint(const Domain &u)
Definition: gridoperatorpreconditioner.hh:39
Sequential matrix-free solver backend.
Definition: backends.hh:67
void setLinearizationPoint(const V &u)
Definition: backends.hh:130
void setLinearizationPoint(const X &u)
Definition: seqistlsolverbackend.hh:61
Implementations of the inverse operator interface.
Dune namespace.
Definition: alignedallocator.hh:13
Define general, extensible interface for operators. The available implementation wraps a matrix.
Statistics about the application of an inverse operator.
Definition: solver.hh:50
double elapsed
Elapsed time in seconds.
Definition: solver.hh:84
int iterations
Number of iterations.
Definition: solver.hh:69
double reduction
Reduction achieved: .
Definition: solver.hh:72
double conv_rate
Convergence rate (average reduction per step)
Definition: solver.hh:78
bool converged
True if convergence criterion has been met.
Definition: solver.hh:75