5#include <Eigen/IterativeLinearSolvers>
6#if HAVE_METIS && !HAVE_SCOTCH_METIS
7#include <Eigen/MetisSupport>
9#include <Eigen/SparseLU>
11#include <Eigen/SuperLUSupport>
13#if HAVE_SUITESPARSE_UMFPACK
14#include <Eigen/UmfPackSupport>
16#include <unsupported/Eigen/IterativeSolvers>
18#include <amdis/CreatorMap.hpp>
19#include <amdis/Initfile.hpp>
20#include <amdis/Output.hpp>
22#include <amdis/linearalgebra/LinearSolverInterface.hpp>
23#include <amdis/linearalgebra/eigen/DirectRunner.hpp>
24#include <amdis/linearalgebra/eigen/IterativeRunner.hpp>
25#include <amdis/linearalgebra/eigen/Traits.hpp>
29 template <
class M,
class X,
class Y,
template <
class>
class IterativeSolver>
34 using T =
typename M::Scalar;
36 template <
class Precon>
39 template <
class Ordering>
46 std::string precon =
"no";
49 if (precon ==
"diag" || precon ==
"jacobi") {
50 return std::make_unique<Solver<Eigen::DiagonalPreconditioner<T>>>(prefix);
52 else if (precon ==
"ilu") {
53 return std::make_unique<Solver<Eigen::IncompleteLUT<T>>>(prefix);
55 else if (precon ==
"ic") {
56 std::string ordering =
"amd";
59 if (ordering ==
"amd") {
60 using AMD = Eigen::AMDOrdering<typename M::StorageIndex>;
61 return std::make_unique<IncompleteCholesky<AMD>>(prefix);
64 using NATURAL = Eigen::NaturalOrdering<typename M::StorageIndex>;
65 return std::make_unique<IncompleteCholesky<NATURAL>>(prefix);
69 return std::make_unique<Solver<Eigen::IdentityPreconditioner>>(prefix);
85 template <
class M,
class X,
class Y>
88 template <
template <
class>
class IterativeSolver>
92 template <
template <
class>
class DirectSolver>
93 using DirectSolverCreator
97 template <
class Precon>
98 using CG = Eigen::ConjugateGradient<M, Eigen::Lower|Eigen::Upper, Precon>;
100 template <
class Precon>
101 using BCGS = Eigen::BiCGSTAB<M, Precon>;
103 template <
class Precon>
104 using MINRES = Eigen::MINRES<M, Eigen::Lower|Eigen::Upper, Precon>;
106 template <
class Precon>
107 using GMRES = Eigen::GMRES<M, Precon>;
109 template <
class Precon>
110 using DGMRES = Eigen::DGMRES<M, Precon>;
121 Map::addCreator(
"cg", cg);
125 Map::addCreator(
"bicgstab", bicgstab);
126 Map::addCreator(
"bcgs", bicgstab);
130 Map::addCreator(
"minres", minres);
134 Map::addCreator(
"gmres", gmres);
138 Map::addCreator(
"dgmres", dgmres);
141 Map::addCreator(
"default", gmres);
143 init_direct(std::is_same<
typename Dune::FieldTraits<typename M::Scalar>::real_type,
double>{});
146 static void init_direct(std::false_type) {}
147 static void init_direct(std::true_type)
149#if HAVE_SUITESPARSE_UMFPACK
151 auto umfpack =
new DirectSolverCreator<Eigen::UmfPackLU>;
152 Map::addCreator(
"umfpack", umfpack);
157 auto superlu =
new DirectSolverCreator<Eigen::SuperLU>;
158 Map::addCreator(
"superlu", superlu);
162#if HAVE_SUITESPARSE_UMFPACK
163 Map::addCreator(
"direct", umfpack);
165 Map::addCreator(
"direct", superlu);
Interface for creators with name.
Definition: CreatorInterface.hpp:44
A CreatorMap is used to construct objects, which types depends on key words determined at run time....
Definition: CreatorMap.hpp:30
Definition: CreatorMap.hpp:16
static std::optional< T > get(std::string const &key)
Get parameter-values from parameter-tree.
Definition: Initfile.hpp:25
Definition: IterativeRunner.hpp:16
Definition: DirectRunner.hpp:27
Default solver creator for iterative solvers.
Definition: Solvers.hpp:32
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:43