1#ifndef __DUNE_ACFEM_SOLVER_SELECTOR_HH__
2#define __DUNE_ACFEM_SOLVER_SELECTOR_HH__
5#include <dune/fem/operator/linear/istloperator.hh>
6#include <dune/fem/solver/istlinverseoperators.hh>
7#include <dune/fem/operator/linear/petscoperator.hh>
8#include <dune/fem/solver/petscinverseoperators.hh>
9#include <dune/fem/operator/linear/spoperator.hh>
10#include <dune/fem/solver/krylovinverseoperators.hh>
12#include "discretefunctionselector.hh"
13#include "../models/modeltraits.hh"
25 template<
class DiscreteFunction>
26 struct DiscreteFunctionTraits;
28 template<
class DiscreteSpace>
29 struct DiscreteFunctionTraits<Fem::AdaptiveDiscreteFunction<DiscreteSpace> >
31 static constexpr SolverFamily family = SolverFamily::FEM;
34 template<
class DiscreteSpace>
35 struct DiscreteFunctionTraits<Fem::ISTLBlockVectorDiscreteFunction<DiscreteSpace> >
37 static constexpr SolverFamily family = SolverFamily::ISTL;
40 template<
class DiscreteSpace>
41 struct DiscreteFunctionTraits<Fem::PetscDiscreteFunction<DiscreteSpace> >
43 static constexpr SolverFamily family = SolverFamily::PETSC;
89 template<
class DiscreteFunction,
class Model>
94 "Model should better be a model ...");
96 using DiscreteFunctionType = DiscreteFunction;
98 static constexpr SolverFamily family = DiscreteFunctionTraits<DiscreteFunctionType>::family;
106 : SolverType::MINRES )
107 : SolverType::GMRES ;
109 template<SolverFamily fam,
bool dummy = false>
110 struct OperatorSelector;
113 struct OperatorSelector<SolverFamily::ISTL, dummy>
115 using LinearOperatorType = Fem::ISTLLinearOperator<DiscreteFunctionType, DiscreteFunctionType>;
117 using LinearInverseOperatorType = Fem::ISTLInverseOperator<DiscreteFunctionType>;
122 struct OperatorSelector<SolverFamily::PETSC, dummy>
125 Fem::PetscLinearOperator<DiscreteFunctionType, DiscreteFunctionType>
130 Fem::PetscInverseOperator<DiscreteFunctionType, LinearOperatorType>
131 LinearInverseOperatorType;
136 struct OperatorSelector<SolverFamily::FEM, dummy>
139 Fem::SparseRowLinearOperator<DiscreteFunctionType, DiscreteFunctionType>
142 static_assert(solverType != SolverType::MINRES,
"MinRes solver not available in bare dune fem.");
144 using LinearInverseOperatorType = Fem::KrylovInverseOperator<DiscreteFunctionType>;
147 typedef typename OperatorSelector<family>::LinearOperatorType LinearOperatorType;
148 typedef typename OperatorSelector<family>::LinearInverseOperatorType LinearInverseOperatorType;
151 template<
class SolverSelector>
152 void chooseDefaultSolverMethod(
const Dune::Fem::SolverParameter& solverParams)
154 std::string prefix = solverParams.keyPrefix();
155 if(!Fem::Parameter::exists(prefix +
"method"))
157 if constexpr (SolverSelector::solverType == SolverType::CG)
158 Fem::Parameter::append(prefix +
"method",
"cg");
159 else if constexpr (SolverSelector::solverType == SolverType::GMRES)
160 Fem::Parameter::append(prefix +
"method",
"gmres");
161 else if constexpr (SolverSelector::solverType == SolverType::MINRES)
162 Fem::Parameter::append(prefix +
"method",
"minres");
SolverType
Define some symbolic constants for SolverSelector and "parse" some preprocessort defines.
Definition: solverselector.hh:50
ModelIntrospection::template IsModel< Model > IsPDEModel
std::true_type if Model is derived from ModelBase.
Definition: modeltraits.hh:894
Default expression traits definition is a recursion in order to ease disambiguation.
Definition: expressiontraits.hh:54
Select one appropriate (linear) solver depending on whether the model is symmetric and/or semidefinit...
Definition: solverselector.hh:91