13#ifndef DUMUX_LINEAR_ISTL_SOLVERS_MULTITYPE_HH
14#define DUMUX_LINEAR_ISTL_SOLVERS_MULTITYPE_HH
16#include <dune/common/version.hh>
18#include <dune/istl/solvers.hh>
19#include <dune/istl/cholmod.hh>
20#include <dune/istl/umfpack.hh>
26DUMUX_REGISTER_SOLVER(
"loopsolver", Dumux::MultiTypeBlockMatrixSolverTag, defaultIterativeSolverCreator<Dune::LoopSolver>());
27DUMUX_REGISTER_SOLVER(
"gradientsolver", Dumux::MultiTypeBlockMatrixSolverTag, defaultIterativeSolverCreator<Dune::GradientSolver>());
28DUMUX_REGISTER_SOLVER(
"cgsolver", Dumux::MultiTypeBlockMatrixSolverTag, defaultIterativeSolverCreator<Dune::CGSolver>());
29DUMUX_REGISTER_SOLVER(
"bicgstabsolver", Dumux::MultiTypeBlockMatrixSolverTag, defaultIterativeSolverCreator<Dune::BiCGSTABSolver>());
30DUMUX_REGISTER_SOLVER(
"minressolver", Dumux::MultiTypeBlockMatrixSolverTag, defaultIterativeSolverCreator<Dune::MINRESSolver>());
31DUMUX_REGISTER_SOLVER(
"restartedgmressolver", Dumux::MultiTypeBlockMatrixSolverTag, defaultIterativeSolverCreator<Dune::RestartedGMResSolver>());
32DUMUX_REGISTER_SOLVER(
"restartedflexiblegmressolver", Dumux::MultiTypeBlockMatrixSolverTag, defaultIterativeSolverCreator<Dune::RestartedFlexibleGMResSolver>());
33DUMUX_REGISTER_SOLVER(
"generalizedpcgsolver", Dumux::MultiTypeBlockMatrixSolverTag, defaultIterativeSolverCreator<Dune::GeneralizedPCGSolver>());
34DUMUX_REGISTER_SOLVER(
"restartedfcgsolver", Dumux::MultiTypeBlockMatrixSolverTag, defaultIterativeSolverCreator<Dune::RestartedFCGSolver>());
35DUMUX_REGISTER_SOLVER(
"completefcgsolver", Dumux::MultiTypeBlockMatrixSolverTag, defaultIterativeSolverCreator<Dune::CompleteFCGSolver>());
36#if HAVE_SUITESPARSE_CHOLMOD
38 [](
auto opTraits,
const auto& op,
const Dune::ParameterTree& config)
39 -> std::shared_ptr<
typename decltype(opTraits)::solver_type>
41 using OpTraits =
decltype(opTraits);
42 using M =
typename OpTraits::matrix_type;
43 using D =
typename OpTraits::domain_type;
45 if constexpr (OpTraits::isParallel){
46 if(opTraits.getCommOrThrow(op).communicator().size() > 1)
47 DUNE_THROW(Dune::InvalidStateException,
"CholMod works only for sequential operators.");
49 if constexpr (OpTraits::isAssembled &&
51 (std::is_same_v<typename FieldTraits<D>::field_type,
double> ||
52 std::is_same_v<typename FieldTraits<D>::field_type,
float>)){
53 const auto& A = opTraits.getAssembledOpOrThrow(op);
54 const M& mat = A->getmat();
55 auto solver = std::make_shared<Dune::Cholmod<D>>();
56 solver->setMatrix(mat);
59 DUNE_THROW(UnsupportedType,
60 "Unsupported Type in Cholmod (only double and float supported)");
63#if HAVE_SUITESPARSE_UMFPACK && DUNE_VERSION_GTE(DUNE_ISTL, 2, 10)
65 [](
auto opTraits,
const auto& op,
const Dune::ParameterTree& config)
66 -> std::shared_ptr<
typename decltype(opTraits)::solver_type>
68 using OpTraits =
decltype(opTraits);
70 if constexpr (OpTraits::isParallel){
71 if(opTraits.getCommOrThrow(op).communicator().size() > 1)
72 DUNE_THROW(Dune::InvalidStateException,
"UMFPack works only for sequential operators.");
74 if constexpr (OpTraits::isAssembled){
75 using M =
typename OpTraits::matrix_type;
79 if constexpr (UMFPackImpl::isValidBlock<OpTraits>::value) {
80 const auto& A = opTraits.getAssembledOpOrThrow(op);
81 const M& mat = A->getmat();
82 int verbose = config.get(
"verbose", 0);
83 return std::make_shared<Dune::UMFPack<M>>(mat,verbose);
86 DUNE_THROW(UnsupportedType,
87 "Unsupported Type in UMFPack (only double and std::complex<double> supported)");
The specialized Dumux macro and tag for the ISTL registry to choose the solver and preconditioner at ...
DUMUX_REGISTER_SOLVER("loopsolver", Dumux::MultiTypeBlockMatrixSolverTag, defaultIterativeSolverCreator< Dune::LoopSolver >())