6#include <dune/istl/preconditioners.hh>
7#include <dune/istl/novlpschwarz.hh>
8#include <dune/istl/schwarz.hh>
10#include <amdis/CreatorInterface.hpp>
11#include <amdis/CreatorMap.hpp>
12#include <amdis/linearalgebra/istl/PreconWrapper.hpp>
13#include <amdis/linearalgebra/istl/Traits.hpp>
22 template <
class Traits>
25 template <
class Traits>
38 template <
class Traits>
42 using X =
typename Traits::X;
43 using Y =
typename Traits::Y;
45 std::unique_ptr<tag::preconditioner<Traits>> create()
final {
return {}; };
49 virtual void init(std::string
const& prefix)
55 virtual std::unique_ptr<Dune::Preconditioner<X,Y>>
56 createPrecon(
typename Traits::M
const& A,
typename Traits::Comm
const& comm)
const = 0;
69 template <
class Precon,
class Traits>
73 std::unique_ptr<typename Traits::Prec>
74 createPrecon(
typename Traits::M
const& mat,
typename Traits::Comm
const& )
const override
76 return std::make_unique<Precon>(mat, this->iter_, this->w_);
82 template <
class X,
class Y,
class Traits>
86 std::unique_ptr<typename Traits::Prec>
87 createPrecon(
typename Traits::M
const& ,
typename Traits::Comm
const& )
const override
89 using Precon = Dune::Richardson<X, Y>;
90 return std::make_unique<Precon>(this->w_);
96 template <
class M,
class X,
class Y,
class Traits>
97 struct ISTLPreconCreator<Dune::SeqILDL<M, X, Y>,
Traits>
98 :
public ISTLPreconCreatorBase<Traits>
100 std::unique_ptr<typename Traits::Prec>
101 createPrecon(
typename Traits::M
const& mat,
typename Traits::Comm
const& )
const override
103 using Precon = Dune::SeqILDL<M, X, Y>;
104 return std::make_unique<Precon>(mat, this->w_);
114 template <
class M,
class X,
class Y,
class Comm,
class Traits>
115 struct ISTLPreconCreator<Dune::ParSSOR<M, X, Y, Comm>,
Traits>
116 :
public ISTLPreconCreatorBase<Traits>
118 std::unique_ptr<typename Traits::Prec>
119 createPrecon(
typename Traits::M
const& mat,
typename Traits::Comm
const& comm)
const override
121 test_exit(Dune::SolverCategory::category(comm) == Dune::SolverCategory::overlapping,
122 "Dune::ParSSOR preconditioner can be used with overlapping domain decomposition.");
124 using Precon = Dune::ParSSOR<M,X,Y,Comm>;
125 return std::make_unique<Precon>(mat, this->iter_, this->w_, comm.impl());
131 template <
class Traits>
132 class ISTLSolverCreatorBase;
144 template <
class Traits>
150 void init(std::string
const& prefix)
override
154 std::string solver =
"default";
160 assert(solverCreator_ !=
nullptr);
162 solverCreator_->init(prefix +
"->solver");
165 std::unique_ptr<typename Traits::Prec>
166 createPrecon(
typename Traits::M
const& mat,
typename Traits::Comm
const& comm)
const override
168 using InverseOp = Dune::InverseOperator<typename Traits::X, typename Traits::Y>;
169 using Precon = Dune::InverseOperator2Preconditioner<InverseOp>;
172 assert(solverCreator_ !=
nullptr);
173 return std::make_unique<Wrapper>(solverCreator_->createSolver(mat, comm));
177 ISTLSolverCreatorBase<Traits>* solverCreator_ =
nullptr;
193 template <
class Traits>
200 void init(std::string
const& prefix)
override
204 std::string subPrecon =
"default";
210 assert(subPreconCreator_ !=
nullptr);
211 subPreconCreator_->init(prefix +
"->sub precon");
214 std::unique_ptr<typename Traits::Prec>
215 createPrecon(
typename Traits::M
const& mat,
typename Traits::Comm
const& comm)
const override
217 assert(subPreconCreator_ !=
nullptr);
218 return Traits::ParPrecCreator::create(Dune::SolverCategory::category(comm),
219 subPreconCreator_->createPrecon(mat, comm.sequential()),
224 ISTLPreconCreatorBase<SeqTraits>* subPreconCreator_ =
nullptr;
Interface for the implementation of the factory method pattern. The creation of an object of a sub cl...
Definition: CreatorInterface.hpp:24
A CreatorMap is used to construct objects, which types depends on key words determined at run time....
Definition: CreatorMap.hpp:30
static CreatorInterface< BaseClass > * get(std::string key, std::string initFileStr)
Creates a object of the type corresponding to key.
Definition: CreatorMap.hpp:44
Base class for precon creators,.
Definition: ISTLPreconCreator.hpp:41
virtual void init(std::string const &prefix)
Prepare the preconditioner for the creation.
Definition: ISTLPreconCreator.hpp:49
Base class for solver creators,.
Definition: ISTLSolverCreator.hpp:56
static std::optional< T > get(std::string const &key)
Get parameter-values from parameter-tree.
Definition: Initfile.hpp:25
Definition: PreconWrapper.hpp:22
void init(std::string const &prefix) override
Prepare the preconditioner for the creation.
Definition: ISTLPreconCreator.hpp:200
void init(std::string const &prefix) override
Prepare the preconditioner for the creation.
Definition: ISTLPreconCreator.hpp:150
Default precon creator.
Definition: ISTLPreconCreator.hpp:72
Definition: Traits.hpp:68
Definition: ISTLPreconCreator.hpp:19
Definition: ISTLPreconCreator.hpp:26
Definition: ISTLSolverCreator.hpp:39