5 #include <Eigen/IterativeLinearSolvers> 6 #include <Eigen/MetisSupport> 7 #include <Eigen/SparseLU> 8 #include <Eigen/SuperLUSupport> 9 #include <Eigen/UmfPackSupport> 10 #include <unsupported/Eigen/IterativeSolvers> 12 #include <amdis/CreatorMap.hpp> 13 #include <amdis/Initfile.hpp> 14 #include <amdis/Output.hpp> 16 #include <amdis/linearalgebra/LinearSolverInterface.hpp> 17 #include <amdis/linearalgebra/eigen/DirectRunner.hpp> 18 #include <amdis/linearalgebra/eigen/IterativeRunner.hpp> 19 #include <amdis/linearalgebra/eigen/Traits.hpp> 23 template <
class M,
class X,
class Y,
template <
class>
class IterativeSolver>
28 using T =
typename M::Scalar;
30 template <
class Precon>
33 template <
class Ordering>
40 std::string precon =
"no";
43 if (precon ==
"diag" || precon ==
"jacobi") {
44 return std::make_unique<Solver<Eigen::DiagonalPreconditioner<T>>>(prefix);
46 else if (precon ==
"ilu") {
47 return std::make_unique<Solver<Eigen::IncompleteLUT<T>>>(prefix);
49 else if (precon ==
"ic") {
50 std::string ordering =
"amd";
53 if (ordering ==
"amd") {
54 using AMD = Eigen::AMDOrdering<typename M::StorageIndex>;
55 return std::make_unique<IncompleteCholesky<AMD>>(prefix);
58 using NATURAL = Eigen::NaturalOrdering<typename M::StorageIndex>;
59 return std::make_unique<IncompleteCholesky<NATURAL>>(prefix);
63 return std::make_unique<Solver<Eigen::IdentityPreconditioner>>(prefix);
79 template <
class M,
class X,
class Y>
82 template <
template <
class>
class IterativeSolver>
86 template <
template <
class>
class DirectSolver>
87 using DirectSolverCreator
91 template <
class Precon>
92 using CG = Eigen::ConjugateGradient<M, Eigen::Lower|Eigen::Upper, Precon>;
94 template <
class Precon>
95 using BCGS = Eigen::BiCGSTAB<M, Precon>;
97 template <
class Precon>
98 using MINRES = Eigen::MINRES<M, Eigen::Lower|Eigen::Upper, Precon>;
100 template <
class Precon>
101 using GMRES = Eigen::GMRES<M, Precon>;
103 template <
class Precon>
104 using DGMRES = Eigen::DGMRES<M, Precon>;
115 Map::addCreator(
"cg", cg);
119 Map::addCreator(
"bicgstab", bicgstab);
120 Map::addCreator(
"bcgs", bicgstab);
124 Map::addCreator(
"minres", minres);
128 Map::addCreator(
"gmres", gmres);
132 Map::addCreator(
"dgmres", dgmres);
135 Map::addCreator(
"default", gmres);
137 init_direct(std::is_same<
typename Dune::FieldTraits<typename M::Scalar>::real_type,
double>{});
140 static void init_direct(std::false_type) {}
141 static void init_direct(std::true_type)
143 #if HAVE_SUITESPARSE_UMFPACK 145 auto umfpack =
new DirectSolverCreator<Eigen::UmfPackLU>;
146 Map::addCreator(
"umfpack", umfpack);
151 auto superlu =
new DirectSolverCreator<Eigen::SuperLU>;
152 Map::addCreator(
"superlu", superlu);
156 #if HAVE_SUITESPARSE_UMFPACK 157 Map::addCreator(
"direct", umfpack);
159 Map::addCreator(
"direct", superlu);
Definition: DirectRunner.hpp:26
Interface for creators with name.
Definition: CreatorInterface.hpp:42
A CreatorMap is used to construct objects, which types depends on key words determined at run time...
Definition: CreatorMap.hpp:29
Definition: AdaptBase.hpp:6
static std::optional< T > get(std::string const &key)
Get parameter-values from parameter-tree.
Definition: Initfile.hpp:25
Definition: IterativeRunner.hpp:14
Definition: LinearSolverInterface.hpp:8
Definition: CreatorMap.hpp:16
std::unique_ptr< SolverBase > createWithString(std::string prefix) override
Must be implemented by sub classes of CreatorInterfaceName. Creates a new instance of the sub class o...
Definition: Solvers.hpp:37
Default solver creator for iterative solvers.
Definition: Solvers.hpp:24
void init(std::string const &prefix) override
Prepare the solver for the creation.
Definition: ISTLSolverCreator.hpp:96