27#ifndef EWOMS_SUPER_LU_BACKEND_HH
28#define EWOMS_SUPER_LU_BACKEND_HH
32#include <dune/common/fmatrix.hh>
33#include <dune/common/version.hh>
34#include <dune/istl/superlu.hh>
36#include <opm/material/common/Unused.hpp>
38#include <opm/models/linear/istlsparsematrixbackend.hh>
46struct SuperLULinearSolver {};
52template <
class Scalar,
class TypeTag,
class Matrix,
class Vector>
59template <
class TypeTag>
62 using Scalar = GetPropType<TypeTag, Properties::Scalar>;
63 using Simulator = GetPropType<TypeTag, Properties::Simulator>;
64 using SparseMatrixAdapter = GetPropType<TypeTag, Properties::SparseMatrixAdapter>;
65 using Matrix =
typename SparseMatrixAdapter::block_type;
67 static_assert(std::is_same<SparseMatrixAdapter, IstlSparseMatrixAdapter<MatrixBlock>::value,
68 "The SuperLU linear solver backend requires the IstlSparseMatrixAdapter");
71 SuperLUBackend(Simulator&)
74 static void registerParameters()
76 Parameters::Register<Parameters::LinearSolverVerbosity>
77 (
"The verbosity level of the linear solver");
89 void prepare(
const SparseMatrixAdapter& M,
const Vector& b)
92 void setResidual(
const Vector& b)
95 void getResidual(Vector& b)
const
98 void setMatrix(
const SparseMatrixAdapter& M)
101 bool solve(Vector& x)
102 {
return SuperLUSolve_<Scalar, TypeTag, Matrix, Vector>::solve_(*M_, x, *b_); }
109template <
class Scalar,
class TypeTag,
class Matrix,
class Vector>
113 static bool solve_(
const Matrix& A, Vector& x,
const Vector& b)
117 int verbosity = Parameters::Get<Parameters::LinearSolverVerbosity>();
118 Dune::InverseOperatorResult result;
119 Dune::SuperLU<Matrix> solver(A, verbosity > 0);
120 solver.apply(x, bTmp, result);
122 if (result.converged) {
125 for (
unsigned i = 0; i < x.size(); ++i) {
126 const auto& xi = x[i];
127 for (
unsigned j = 0; j < Vector::block_type::dimension; ++j)
130 result.converged = std::isfinite(tmp);
133 return result.converged;
142template <
class TypeTag,
class Matrix,
class Vector>
143class SuperLUSolve_<__float128, TypeTag, Matrix, Vector>
146 static bool solve_(
const Matrix& A,
150 static const int numEq = getPropValue<TypeTag, Properties::NumEq>();
151 using DoubleEqVector = Dune::FieldVector<double, numEq>;
152 using DoubleEqMatrix = Dune::FieldMatrix<double, numEq, numEq>;
153 using DoubleVector = Dune::BlockVector<DoubleEqVector>;
154 using DoubleMatrix = Dune::BCRSMatrix<DoubleEqMatrix>;
157 DoubleVector bDouble(b);
158 DoubleVector xDouble(x);
159 DoubleMatrix ADouble(A);
162 SuperLUSolve_<double, TypeTag, Matrix, Vector>::solve_(ADouble,
179template<
class TypeTag>
180struct LinearSolverVerbosity<TypeTag, TTag::SuperLULinearSolver>
181{
static constexpr int value = 0; };
183template<
class TypeTag>
184struct LinearSolverBackend<TypeTag, TTag::SuperLULinearSolver>
185{
using type = Opm::Linear::SuperLUBackend<TypeTag>; };
Declares the properties required by the black oil model.
Definition: bicgstabsolver.hh:42
The generic type tag for problems using the immiscible multi-phase model.
Definition: blackoilmodel.hh:74
Definition: blackoilmodel.hh:72
This file provides the infrastructure to retrieve run-time parameters.
UndefinedProperty type
Definition: linalgproperties.hh:38