27#ifndef EWOMS_SUPER_LU_BACKEND_HH
28#define EWOMS_SUPER_LU_BACKEND_HH
32#include <opm/models/linear/istlsparsematrixbackend.hh>
36#include <opm/material/common/Unused.hpp>
38#include <dune/istl/superlu.hh>
39#include <dune/common/fmatrix.hh>
40#include <dune/common/version.hh>
43struct SuperLULinearSolver {};
48template <
class Scalar,
class TypeTag,
class Matrix,
class Vector>
55template <
class TypeTag>
58 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
59 using Simulator = GetPropType<TypeTag, Properties::Simulator>;
60 using SparseMatrixAdapter = GetPropType<TypeTag, Properties::SparseMatrixAdapter>;
61 using Matrix =
typename SparseMatrixAdapter::block_type;
63 static_assert(std::is_same<SparseMatrixAdapter, IstlSparseMatrixAdapter<MatrixBlock>::value,
64 "The SuperLU linear solver backend requires the IstlSparseMatrixAdapter");
67 SuperLUBackend(Simulator&)
70 static void registerParameters()
72 Parameters::registerParam<TypeTag, Properties::LinearSolverVerbosity>
73 (
"The verbosity level of the linear solver");
85 void prepare(
const SparseMatrixAdapter& M,
const Vector& b)
88 void setResidual(
const Vector& b)
91 void getResidual(Vector& b)
const
94 void setMatrix(
const SparseMatrixAdapter& M)
98 {
return SuperLUSolve_<Scalar, TypeTag, Matrix, Vector>::solve_(*M_, x, *b_); }
105template <
class Scalar,
class TypeTag,
class Matrix,
class Vector>
109 static bool solve_(
const Matrix& A, Vector& x,
const Vector& b)
113 int verbosity = Parameters::get<TypeTag, Properties::LinearSolverVerbosity>();
114 Dune::InverseOperatorResult result;
115 Dune::SuperLU<Matrix> solver(A, verbosity > 0);
116 solver.apply(x, bTmp, result);
118 if (result.converged) {
121 for (
unsigned i = 0; i < x.size(); ++i) {
122 const auto& xi = x[i];
123 for (
unsigned j = 0; j < Vector::block_type::dimension; ++j)
126 result.converged = std::isfinite(tmp);
129 return result.converged;
138template <
class TypeTag,
class Matrix,
class Vector>
139class SuperLUSolve_<__float128, TypeTag, Matrix, Vector>
142 static bool solve_(
const Matrix& A,
146 static const int numEq = getPropValue<TypeTag, Properties::NumEq>();
147 using DoubleEqVector = Dune::FieldVector<double, numEq>;
148 using DoubleEqMatrix = Dune::FieldMatrix<double, numEq, numEq>;
149 using DoubleVector = Dune::BlockVector<DoubleEqVector>;
150 using DoubleMatrix = Dune::BCRSMatrix<DoubleEqMatrix>;
153 DoubleVector bDouble(b);
154 DoubleVector xDouble(x);
155 DoubleMatrix ADouble(A);
158 SuperLUSolve_<double, TypeTag, Matrix, Vector>::solve_(ADouble,
175template<
class TypeTag>
176struct LinearSolverVerbosity<TypeTag, TTag::SuperLULinearSolver> {
static constexpr int value = 0; };
177template<
class TypeTag>
178struct LinearSolverBackend<TypeTag, TTag::SuperLULinearSolver> {
using type = Opm::Linear::SuperLUBackend<TypeTag>; };
Declares the properties required by the black oil model.
The generic type tag for problems using the immiscible multi-phase model.
Definition: blackoilmodel.hh:74
Definition: blackoilmodel.hh:72
Definition: blackoilboundaryratevector.hh:37
This file provides the infrastructure to retrieve run-time parameters.
UndefinedProperty type
Definition: linalgproperties.hh:38