1#ifndef DUNE_COPASI_SOLVER_ISTL_FACTORY_INVERSE_HH
2#define DUNE_COPASI_SOLVER_ISTL_FACTORY_INVERSE_HH
8#include <dune/istl/scalarproducts.hh>
9#include <dune/istl/solver.hh>
11#ifdef DUNE_COPASI_DEFAULT_DIRECT_SOLVER
12#define DUNE_COPASI_DEFAULT_LINEAR_INVERSE_OPERATOR DUNE_COPASI_DEFAULT_DIRECT_SOLVER
14#define DUNE_COPASI_DEFAULT_LINEAR_INVERSE_OPERATOR DUNE_COPASI_DEFAULT_ITERATIVE_SOLVER
21template<Concept::LinearOperator Op,
class Alloc = std::allocator<Op>>
22std::shared_ptr<InverseOperator<typename Op::domain_type, typename Op::range_type>>
24 const ParameterTree& config,
25 const Alloc& alloc = Alloc(),
30 if (config.get(
"verbosity", 1) > 0)
31 spdlog::info(
"Creating linear solver with type '{}'", type_name);
32 if (
auto& registry = getIterativeSolverRegistry<Op, Alloc>(); registry.contains(type_name)) {
34 if constexpr (
requires { op->getCommunication(); })
35 throw format_exception(NotImplemented{},
"Parallel solvers have not been implemented!");
36 using ScalarProd = ScalarProduct<typename Op::domain_type>;
37 using ScalarProdAlloc =
38 typename std::allocator_traits<Alloc>::template rebind_alloc<ScalarProd>;
39 auto sp = std::allocate_shared<ScalarProd>(ScalarProdAlloc(alloc));
40 return registry.create(type_name, op, sp, prec, config, alloc);
41 }
else if constexpr (Concept::AssembledLinearOperator<Op>) {
42 if (
auto& registry = getDirectSolverRegistry<Op, Alloc>(); registry.contains(type_name)) {
43 return registry.create(type_name, op, config, alloc);
48 auto iterative_keys = getIterativeSolverRegistry<Op, Alloc>().keys();
49 std::set<std::string> direct_keys;
50 if constexpr (Concept::AssembledLinearOperator<Op>)
51 direct_keys = getDirectSolverRegistry<Op, Alloc>().keys();
54 "The key '{}' is not a known inverse operator type.\nPossible iterative "
55 "solvers: {}\nPossible direct solvers: {}",
63template<Concept::LinearOperator Op,
class Alloc = std::allocator<Op>>
64std::shared_ptr<InverseOperator<typename Op::domain_type, typename Op::range_type>>
66 const ParameterTree& config,
67 const Alloc& alloc = Alloc())
#define DUNE_COPASI_DEFAULT_LINEAR_INVERSE_OPERATOR
Definition: inverse.hh:14
Definition: block_jacobi.hh:14
std::shared_ptr< InverseOperator< typename Op::domain_type, typename Op::range_type > > makeInverseOperator(const std::shared_ptr< Op > &op, const ParameterTree &config, const Alloc &alloc=Alloc())
Definition: inverse.hh:65
std::shared_ptr< Preconditioner< typename Op::domain_type, typename Op::range_type > > makePreconditioner(const std::shared_ptr< Op > &op, const ParameterTree &config, const Alloc &alloc=Alloc())
Definition: preconditioner.hh:121
auto format_exception(Exception &&e, fmt::format_string< Args... > format, Args &&... args)
Definition: exceptions.hh:23