1#ifndef DUNE_COPASI_SOLVER_ISTL_FACTORY_DIRECT_HH
2#define DUNE_COPASI_SOLVER_ISTL_FACTORY_DIRECT_HH
9#if HAVE_SUITESPARSE_UMFPACK
11#define DUNE_COPASI_DEFAULT_DIRECT_SOLVER "UMFPack"
14#include <dune/istl/solver.hh>
15#include <dune/istl/superlu.hh>
17#include <dune/common/exceptions.hh>
18#include <dune/common/indices.hh>
20#include <fmt/ranges.h>
25template<
class M,
class X,
class Y,
class A>
27 std::shared_ptr<InverseOperator<X, Y>>(
const std::shared_ptr<AssembledLinearOperator<M, X, Y>>&,
30template<
class M,
class X,
class Y,
class A>
34template<
class Op,
class Alloc>
38 using M =
typename Op::matrix_type;
39 using X =
typename Op::domain_type;
40 using Y =
typename Op::range_type;
41 return [](
const std::shared_ptr<AssembledLinearOperator<M, X, Y>>&
op,
43 const Alloc&
alloc) -> std::shared_ptr<InverseOperator<X, Y>> {
44 static_assert(
blockLevel<M>() == 1,
"Matrices for this solver can only be 1 level depth");
45 std::shared_ptr<InverseOperator<X, Y>>
inverse_op;
46 using namespace Dune::Indices;
47 const auto&
mat =
op->getmat();
49 Hybrid::integralRange(1
_uc, 20
_uc),
53 throw format_exception(InvalidStateException{},
54 "Matrix {}x{} is not square!",
78template<
class Op,
class Alloc>
82 using M =
typename Op::matrix_type;
83 using X =
typename Op::domain_type;
84 using Y =
typename Op::range_type;
85 return [](
const std::shared_ptr<AssembledLinearOperator<M, X, Y>>&
op,
87 const Alloc&
alloc) -> std::shared_ptr<InverseOperator<X, Y>> {
88 static_assert(
blockLevel<M>() == 1,
"Matrices for this solver can only be 1 level depth");
89 std::shared_ptr<InverseOperator<X, Y>>
inverse_op;
93 using Solver = Dune::SuperLU<M>;
105template<Concept::AssembledLinearOperator O,
class Alloc>
107 typename O::domain_type,
108 typename O::range_type,
112 using M =
typename O::matrix_type;
113 using X =
typename O::domain_type;
114 using Y =
typename O::range_type;
118 static std::once_flag flag;
119 std::call_once(flag, [] {
120 if constexpr (blockLevel<M>() == 1)
121 registry.
define(
"DenseInverse", Impl::denseInverseFactory<O, Alloc>());
122#if HAVE_SUITESPARSE_UMFPACK
126 if constexpr (blockLevel<M>() == 1)
127 registry.
define(
"SuperLU", Impl::superLUFactory<O, Alloc>());
133template<Concept::AssembledLinearOperator Op,
class Alloc = std::allocator<Op>>
134std::shared_ptr<InverseOperator<typename Op::domain_type, typename Op::range_type>>
136 const ParameterTree& config,
137 const Alloc& alloc = Alloc())
140 auto& registry = getDirectSolverRegistry<Op, Alloc>();
141#ifdef DUNE_COPASI_DEFAULT_DIRECT_SOLVER
142 auto type_name = config.get(
"type", DUNE_COPASI_DEFAULT_DIRECT_SOLVER);
144 auto type_name = config.get(
"type",
"None");
146 if (registry.contains(type_name))
147 return registry.create(type_name, op, config, alloc);
150 "The key '{}' is not a known direct solver type. Allowed types are {}",
simple wrapper that captures and exposes the keys of Dune::ParameterizedObjectFactory
Definition parameterized_object.hh:14
void define(Key const &key, T &&t)
Definition parameterized_object.hh:21
Definition block_jacobi.hh:14
ParameterizedObjectFactoryWrapper< DirectSolverFactorySignature< M, X, Y, A > > DirectSolverRegistry
Definition direct.hh:31
const DirectSolverRegistry< typename O::matrix_type, typename O::domain_type, typename O::range_type, Alloc > & getDirectSolverRegistry()
Definition direct.hh:110
std::shared_ptr< InverseOperator< X, Y > >(const std::shared_ptr< AssembledLinearOperator< M, X, Y > > &, const ParameterTree &, const A &) DirectSolverFactorySignature
Definition direct.hh:26
std::shared_ptr< InverseOperator< typename Op::domain_type, typename Op::range_type > > makeDirectSolver(const std::shared_ptr< Op > &op, const ParameterTree &config, const Alloc &alloc=Alloc())
Definition direct.hh:135
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
Definition dense_inverse.hh:10