1#ifndef DUNE_COPASI_SOLVER_ISTL_FACTORY_ITERATIVE_HH
2#define DUNE_COPASI_SOLVER_ISTL_FACTORY_ITERATIVE_HH
9#include <dune/istl/blocklevel.hh>
10#include <dune/istl/preconditioner.hh>
11#include <dune/istl/solver.hh>
12#include <dune/istl/solvers.hh>
14#include <dune/common/classname.hh>
15#include <dune/common/exceptions.hh>
17#include <fmt/ranges.h>
19#define DUNE_COPASI_DEFAULT_ITERATIVE_SOLVER "BiCGSTAB"
24template<
class X,
class Y,
class A>
26 std::shared_ptr<IterativeSolver<X, Y>>(
const std::shared_ptr<LinearOperator<X, Y>>&,
27 const std::shared_ptr<ScalarProduct<X>>&,
28 const std::shared_ptr<Preconditioner<X, Y>>&,
31template<
class X,
class Y,
class A>
36template<
class Solver,
class Alloc>
38defaultIterativeSolverFactory()
40 using X =
typename Solver::domain_type;
41 using Y =
typename Solver::range_type;
42 return [](
const std::shared_ptr<LinearOperator<X, Y>>&
op,
43 const std::shared_ptr<ScalarProduct<X>>&
sp,
44 const std::shared_ptr<Preconditioner<X, Y>>&
prec,
57 "Minimum number of iterations '{}' cannot be set for solver '{}. It has been set to '1'.'",
63 if constexpr (std::derived_from<Solver, RestartedGMResSolver<X, Y>>) {
66 }
else if constexpr (std::derived_from<Solver, GeneralizedPCGSolver<X>>
or std::derived_from<Solver, RestartedFCGSolver<X>>) {
76template<Concept::LinearOperator O,
class Alloc>
80 using X =
typename O::domain_type;
81 using Y =
typename O::range_type;
85 static std::once_flag
flag;
86 std::call_once(
flag, [] {
99 registry.define(
"RestartedFlexibleGMRes",
111template<Concept::LinearOperator Op,
class Alloc = std::allocator<Op>>
112std::shared_ptr<IterativeSolver<typename Op::domain_type, typename Op::range_type>>
114 const std::shared_ptr<Op>&
op,
116 const std::shared_ptr<Preconditioner<typename Op::domain_type, typename Op::range_type>>&
prec,
125 if (
config.get(
"verbosity", 1) > 0)
126 spdlog::info(
"Creating iterative solver with type '{}'",
type_name);
132 "The key '{}' is not a known iterative solver type. Allowed types are {}",
simple wrapper that captures and exposes the keys of Dune::ParameterizedObjectFactory
Definition parameterized_object.hh:14
#define DUNE_COPASI_DEFAULT_ITERATIVE_SOLVER
Definition iterative.hh:19
Definition block_jacobi.hh:14
const IterativeSolverRegistry< typename O::domain_type, typename O::range_type, Alloc > & getIterativeSolverRegistry()
Definition iterative.hh:78
std::shared_ptr< IterativeSolver< typename Op::domain_type, typename Op::range_type > > makeIterativeSolver(const std::shared_ptr< Op > &op, const std::shared_ptr< ScalarProduct< typename Op::domain_type > > &sp, const std::shared_ptr< Preconditioner< typename Op::domain_type, typename Op::range_type > > &prec, const ParameterTree &config, const Alloc &alloc=Alloc())
Definition iterative.hh:113
std::shared_ptr< IterativeSolver< X, Y > >(const std::shared_ptr< LinearOperator< X, Y > > &, const std::shared_ptr< ScalarProduct< X > > &, const std::shared_ptr< Preconditioner< X, Y > > &, const ParameterTree &, const A &) IterativeSolverFactorySignature
Definition iterative.hh:25
auto format_exception(Exception &&e, fmt::format_string< Args... > format, Args &&... args)
Definition exceptions.hh:23
constexpr bool is_bitflags_v
Alias for Bitflag indicator.
Definition bit_flags.hh:24