6#include <boost/numeric/itl/itl.hpp>
9#include <amdis/linearalgebra/mtl/itl/minres.hpp>
10#include <amdis/linearalgebra/mtl/itl/gcr.hpp>
11#include <amdis/linearalgebra/mtl/itl/fgmres.hpp>
12#include <amdis/linearalgebra/mtl/itl/fgmres_householder.hpp>
13#include <amdis/linearalgebra/mtl/itl/gmres2.hpp>
14#include <amdis/linearalgebra/mtl/itl/gmres_householder.hpp>
15#include <amdis/linearalgebra/mtl/itl/preonly.hpp>
17#include <amdis/CreatorMap.hpp>
18#include <amdis/Initfile.hpp>
19#include <amdis/linearalgebra/mtl/KrylovRunner.hpp>
20#include <amdis/linearalgebra/mtl/Traits.hpp>
21#include <amdis/linearalgebra/mtl/UmfpackRunner.hpp>
38 template <
class LinOp,
class X,
class B,
class P,
class I>
39 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
41 return itl::cg(A, x, b, precon, iter);
58 template <
class LinOp,
class X,
class B,
class P,
class I>
59 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
61 return itl::cgs(A, x, b, precon, iter);
78 template <
class LinOp,
class X,
class B,
class P,
class I>
79 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
81 return itl::bicg(A, x, b, precon, iter);
98 template <
class LinOp,
class X,
class B,
class P,
class I>
99 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
101 return itl::bicgstab(A, x, b, precon, iter);
118 template <
class LinOp,
class X,
class B,
class P,
class I>
119 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
121 return itl::bicgstab_2(A, x, b, precon, iter);
137 template <
class LinOp,
class X,
class B,
class P,
class I>
138 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
140 itl::pc::identity<LinOp> id(A);
141 return itl::qmr(A, x, b, precon,
id, iter);
158 template <
class LinOp,
class X,
class B,
class P,
class I>
159 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
161 itl::pc::identity<LinOp> id(A);
162 return itl::tfqmr(A, x, b, precon,
id, iter);
183 template <
class LinOp,
class X,
class B,
class P,
class I>
184 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
186 itl::pc::identity<LinOp> id(A);
187 return itl::bicgstab_ell(A, x, b, precon,
id, iter, ell);
205 explicit gmres_type(std::string
const& prefix) : restart(30), ortho(GRAM_SCHMIDT)
210 template <
class LinOp,
class X,
class B,
class P,
class I>
211 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
213 itl::pc::identity<LinOp> id(A);
218 return itl::gmres2(A, x, b,
id, precon, iter, restart);
221 return itl::gmres_householder(A, x, b, precon, iter, restart);
227 static constexpr int GRAM_SCHMIDT = 1;
228 static constexpr int HOUSEHOLDER = 2;
253 explicit idr_s_type(std::string
const& prefix) : s(30)
257 template <
class LinOp,
class X,
class B,
class P,
class I>
258 int operator()(LinOp
const& A, X& x, B
const& b, P
const&, I& iter)
260 itl::pc::identity<LinOp> id(A);
261 return itl::idr_s(A, x, b,
id,
id, iter, s);
278 template <
class LinOp,
class X,
class B,
class P,
class I>
279 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
281 return itl::minres(A, x, b, precon, iter);
300 explicit gcr_type(std::string
const& prefix) : restart(30)
304 template <
class LinOp,
class X,
class B,
class P,
class I>
305 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
307 itl::pc::identity<LinOp> id(A);
308 return itl::gcr(A, x, b,
id, precon, iter, restart);
327 : restart(30), orthogonalization(GRAM_SCHMIDT)
332 template <
class LinOp,
class X,
class B,
class P,
class I>
333 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
335 itl::pc::identity<LinOp> id(A);
336 switch (orthogonalization)
340 return itl::fgmres(A, x, b,
id, precon, iter, restart);
343 return itl::fgmres_householder(A, x, b, precon, iter, restart);
349 static constexpr int GRAM_SCHMIDT = 1;
350 static constexpr int HOUSEHOLDER = 2;
353 int orthogonalization;
368 template <
class LinOp,
class X,
class B,
class P,
class I>
369 int operator()(LinOp
const& A, X& x, B
const& b, P
const& precon, I& iter)
371 return itl::preonly(A, x, b, precon, iter);
397 template <
class M,
class X,
class Y>
402 template <
class ITLSolver>
405#if HAVE_SUITESPARSE_UMFPACK
414 auto cg =
new SolverCreator<cg_solver_type>;
415 Map::addCreator(
"cg", cg);
417 auto cgs =
new SolverCreator<cgs_solver_type>;
418 Map::addCreator(
"cgs", cgs);
420 auto bicg =
new SolverCreator<bicg_solver_type>;
421 Map::addCreator(
"bicg", bicg);
423 auto bcgs =
new SolverCreator<bicgstab_type>;
424 Map::addCreator(
"bicgstab", bcgs);
425 Map::addCreator(
"bcgs", bcgs);
427 auto bcgs2 =
new SolverCreator<bicgstab2_type>;
428 Map::addCreator(
"bicgstab2", bcgs2);
429 Map::addCreator(
"bcgs2", bcgs2);
431 auto qmr =
new SolverCreator<qmr_solver_type>;
432 Map::addCreator(
"qmr", qmr);
434 auto tfqmr =
new SolverCreator<tfqmr_solver_type>;
435 Map::addCreator(
"tfqmr", tfqmr);
437 auto bcgsl =
new SolverCreator<bicgstab_ell_type>;
438 Map::addCreator(
"bicgstab_ell", bcgsl);
439 Map::addCreator(
"bcgsl", bcgsl);
441 auto gmres =
new SolverCreator<gmres_type>;
442 Map::addCreator(
"gmres", gmres);
444 auto fgmres =
new SolverCreator<fgmres_type>;
445 Map::addCreator(
"fgmres", fgmres);
447 auto minres =
new SolverCreator<minres_solver_type>;
448 Map::addCreator(
"minres", minres);
450 auto idrs =
new SolverCreator<idr_s_type>;
451 Map::addCreator(
"idrs", idrs);
453 auto gcr =
new SolverCreator<gcr_type>;
454 Map::addCreator(
"gcr", gcr);
456 auto preonly =
new SolverCreator<preonly_type>;
457 Map::addCreator(
"preonly", preonly);
460 Map::addCreator(
"default", gmres);
462 init_direct(std::is_same<
typename Dune::FieldTraits<typename M::value_type>::real_type,
double>{});
465 static void init_direct(std::false_type) {}
466 static void init_direct(std::true_type)
468#if HAVE_SUITESPARSE_UMFPACK
469 auto umfpack =
new UmfpackSolverCreator;
470 Map::addCreator(
"umfpack", umfpack);
473 Map::addCreator(
"direct", umfpack);
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: LinearSolverInterface.hpp:9
ITL_Solver <bicg_solver_type> implementation of bi-conjugate gradient method.
Definition: Solvers.hpp:75
ITL_Solver <bicgstab2_type> implementation of BiCGStab(l) method with l=2.
Definition: Solvers.hpp:115
ITL_Solver <bicgstab_ell_type> implementation of stabilized BiCG(ell) method.
Definition: Solvers.hpp:176
ITL_Solver <bicgstab_type> implementation of stabilized bi-conjugate gradient method.
Definition: Solvers.hpp:95
ITL_Solver <cg_solver_type> implementation of conjugate gradient method.
Definition: Solvers.hpp:35
ITL_Solver <cgs_solver_type> implementation of squared conjugate gradient method.
Definition: Solvers.hpp:55
ITL_Solver <fgmres_type> implementation of flexible GMRes method.
Definition: Solvers.hpp:324
ITL_Solver <gcr_type> implementation of generalized conjugate residual method.
Definition: Solvers.hpp:296
ITL_Solver <gmres_type> implementation of generalized minimal residual method.
Definition: Solvers.hpp:202
ITL_Solver <idr_s_type> implementation of Induced Dimension Reduction method.
Definition: Solvers.hpp:250
ITL_Solver <minres_solver_type> implementation of minimal residual method.
Definition: Solvers.hpp:275
ITL_Solver <preonly_type> implementation of preconditioner as.
Definition: Solvers.hpp:365
ITL_Solver <qmr_solver_type> implementation of Quasi-Minimal Residual method.
Definition: Solvers.hpp:134
ITL_Solver <tfqmr_solver_type> implementation of Transposed-Free Quasi-Minimal Residual method.
Definition: Solvers.hpp:155
Definition: KrylovRunner.hpp:33
Definition: UmfpackRunner.hpp:37