27 #ifndef EWOMS_SUPER_LU_BACKEND_HH
28 #define EWOMS_SUPER_LU_BACKEND_HH
34 #include <opm/common/Unused.hpp>
36 #include <dune/istl/superlu.hh>
37 #include <dune/common/fmatrix.hh>
38 #include <dune/common/version.hh>
41 namespace Properties {
56 template <
class Scalar,
class TypeTag,
class Matrix,
class Vector>
63 template <
class TypeTag>
68 typedef typename
GET_PROP_TYPE(TypeTag, JacobianMatrix) Matrix;
69 typedef typename
GET_PROP_TYPE(TypeTag, GlobalEqVector) Vector;
72 SuperLUBackend(Simulator& simulator OPM_UNUSED)
75 static void registerParameters()
78 "The verbosity level of the linear solver");
90 void prepareMatrix(
const Matrix& M)
95 void prepareRhs(
const Matrix& M OPM_UNUSED, Vector& b)
100 bool solve(Vector& x)
101 {
return SuperLUSolve_<Scalar, TypeTag, Matrix, Vector>::solve_(*M_, x, *b_); }
108 template <
class Scalar,
class TypeTag,
class Matrix,
class Vector>
112 static bool solve_(
const Matrix& A, Vector& x,
const Vector& b)
117 Dune::InverseOperatorResult result;
118 Dune::SuperLU<Matrix> solver(A, verbosity > 0);
119 solver.apply(x, bTmp, result);
121 if (result.converged) {
124 for (
unsigned i = 0; i < x.size(); ++i) {
125 const auto& xi = x[i];
126 for (
unsigned j = 0; j < Vector::block_type::dimension; ++j)
129 result.converged = std::isfinite(tmp);
132 return result.converged;
141 template <
class TypeTag,
class Matrix,
class Vector>
142 class SuperLUSolve_<__float128, TypeTag, Matrix, Vector>
145 static bool solve_(
const Matrix& A,
150 typedef Dune::FieldVector<double, numEq> DoubleEqVector;
151 typedef Dune::FieldMatrix<double, numEq, numEq> DoubleEqMatrix;
152 typedef Dune::BlockVector<DoubleEqVector> DoubleVector;
153 typedef Dune::BCRSMatrix<DoubleEqMatrix> DoubleMatrix;
156 DoubleVector bDouble(b);
157 DoubleVector xDouble(x);
158 DoubleMatrix ADouble(A);
161 SuperLUSolve_<double, TypeTag, Matrix, Vector>::solve_(ADouble,
177 namespace Properties {
178 SET_INT_PROP(SuperLULinearSolver, LinearSolverVerbosity, 0);
180 Ewoms::Linear::SuperLUBackend<TypeTag>);
184 #endif // HAVE_SUPERLU
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
#define NEW_TYPE_TAG(...)
Define a new type tag.
Definition: propertysystem.hh:169
#define GET_PROP_TYPE(TypeTag, PropTagName)
Access the type attribute of a property for a type tag.
Definition: propertysystem.hh:486
#define SET_INT_PROP(EffTypeTagName, PropTagName,...)
Set a property to a simple constant integer value.
Definition: propertysystem.hh:345
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:68
This file provides the infrastructure to retrieve run-time parameters.
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:99
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247
#define SET_TYPE_PROP(EffTypeTagName, PropTagName,...)
Set a property which defines a type.
Definition: propertysystem.hh:377