26 #ifndef EWOMS_SUPER_LU_BACKEND_HH
27 #define EWOMS_SUPER_LU_BACKEND_HH
34 #include <dune/istl/superlu.hh>
35 #include <dune/common/fmatrix.hh>
38 namespace Properties {
52 template <
class Scalar,
class TypeTag,
class Problem,
class Matrix,
class Vector>
59 template <
class TypeTag>
66 SuperLUBackend(const Problem &problem) : problem_(problem)
69 static void registerParameters()
72 "The verbosity level of the linear solver");
75 template <
class Matrix,
class Vector>
76 bool solve(
const Matrix &A, Vector &x,
const Vector &b)
77 {
return SuperLUSolve_<Scalar, TypeTag, Problem, Matrix, Vector>::solve_(problem_, A, x, b); }
80 const Problem &problem_;
83 template <
class Scalar,
class TypeTag,
class Problem,
class Matrix,
class Vector>
87 static bool solve_(
const Problem &problem,
const Matrix &A, Vector &x,
const Vector &b)
92 Dune::InverseOperatorResult result;
93 Dune::SuperLU<Matrix> solver(A, verbosity > 0);
94 solver.apply(x, bTmp, result);
96 if (result.converged) {
99 for (
unsigned i = 0; i < x.size(); ++i) {
100 const auto &xi = x[i];
101 for (
int j = 0; j < Vector::block_type::dimension; ++j)
104 result.converged = std::isfinite(tmp);
107 return result.converged;
115 #if DUNE_VERSION_NEWER(DUNE_COMMON, 2,4) && HAVE_QUAD
116 template <
class TypeTag,
class Problem,
class Matrix,
class Vector>
117 class SuperLUSolve_<__float128, TypeTag, Problem, Matrix, Vector>
120 static bool solve_(
const Problem &problem,
126 typedef Dune::FieldVector<double, numEq> DoubleEqVector;
127 typedef Dune::FieldMatrix<double, numEq, numEq> DoubleEqMatrix;
128 typedef Dune::BlockVector<DoubleEqVector> DoubleVector;
129 typedef Dune::BCRSMatrix<DoubleEqMatrix> DoubleMatrix;
132 DoubleVector bDouble(b);
133 DoubleVector xDouble(x);
134 DoubleMatrix ADouble(A);
137 SuperLUSolve_<double, TypeTag, Problem, Matrix, Vector>::solve_(problem,
154 namespace Properties {
155 SET_INT_PROP(SuperLULinearSolver, LinearSolverVerbosity, 0);
157 Ewoms::Linear::SuperLUBackend<TypeTag>);
161 #endif // HAVE_SUPERLU
Copy of dune-istl's linear solvers with added support for pluggable convergence criteria.
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:485
SET_INT_PROP(NumericModel, GridGlobalRefinements, 0)
NEW_PROP_TAG(Grid)
The type of the DUNE grid.
This file provides the infrastructure to retrieve run-time parameters.
SET_TYPE_PROP(NumericModel, Scalar, double)
Set the default type of scalar values to double.
Definition: baseauxiliarymodule.hh:35
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:64
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:95