#include <ISTLSolver.hpp>

Inheritance diagram for Opm::ISTLSolver< TypeTag >:
Inheritance graph

Public Types

using AssembledLinearOperatorType = Dune::AssembledLinearOperator< Matrix, Vector, Vector >
 

Public Member Functions

 ISTLSolver (const Simulator &simulator, const FlowLinearSolverParameters &parameters, bool forceSerial=false)
 
 ISTLSolver (const Simulator &simulator)
 
void initialize ()
 
void eraseMatrix () override
 Signals that the memory for the matrix internally in the solver could be erased. More...
 
void setActiveSolver (const int num) override
 Set the active solver by its index. More...
 
int numAvailableSolvers () const override
 Get the number of available solvers. More...
 
void initPrepare (const Matrix &M, Vector &b)
 
void prepare (const SparseMatrixAdapter &M, Vector &b) override
 Prepare the solver with the given sparse matrix and right-hand side vector. More...
 
void prepare (const Matrix &M, Vector &b) override
 Prepare the solver with the given matrix and right-hand side vector. More...
 
void setResidual (Vector &) override
 Set the residual vector. More...
 
void getResidual (Vector &b) const override
 Get the residual vector. More...
 
void setMatrix (const SparseMatrixAdapter &) override
 Set the matrix for the solver. More...
 
int getSolveCount () const override
 Get the count of how many times the solver has been called. More...
 
void resetSolveCount ()
 
bool solve (Vector &x) override
 Solve the system of equations Ax = b. More...
 
int iterations () const override
 
const std::any & parallelInformation () const
 
const CommunicationTypecomm () const override
 Get the communication object used by the solver. More...
 
void setDomainIndex (const int index)
 
bool isNlddLocalSolver () const
 

Static Public Member Functions

static void registerParameters ()
 

Protected Types

enum  { enablePolymerMolarWeight = getPropValue<TypeTag, Properties::EnablePolymerMW>() }
 
using GridView = GetPropType< TypeTag, Properties::GridView >
 
using Scalar = GetPropType< TypeTag, Properties::Scalar >
 
using SparseMatrixAdapter = GetPropType< TypeTag, Properties::SparseMatrixAdapter >
 
using Vector = GetPropType< TypeTag, Properties::GlobalEqVector >
 
using Indices = GetPropType< TypeTag, Properties::Indices >
 
using WellModel = GetPropType< TypeTag, Properties::WellModel >
 
using Simulator = GetPropType< TypeTag, Properties::Simulator >
 
using Matrix = typename SparseMatrixAdapter::IstlMatrix
 
using ThreadManager = GetPropType< TypeTag, Properties::ThreadManager >
 
using ElementContext = GetPropType< TypeTag, Properties::ElementContext >
 
using AbstractSolverType = Dune::InverseOperator< Vector, Vector >
 
using AbstractOperatorType = Dune::AssembledLinearOperator< Matrix, Vector, Vector >
 
using AbstractPreconditionerType = Dune::PreconditionerWithUpdate< Vector, Vector >
 
using WellModelOperator = WellModelAsLinearOperator< WellModel, Vector, Vector >
 
using ElementMapper = GetPropType< TypeTag, Properties::ElementMapper >
 
using CommunicationType = Dune::OwnerOverlapCopyCommunication< int, int >
 
using Comm = Dune::OwnerOverlapCopyCommunication< int, int >
 

Protected Member Functions

bool checkConvergence (const Dune::InverseOperatorResult &result) const
 
bool isParallel () const
 
void prepareFlexibleSolver ()
 
bool shouldCreateSolver () const
 
std::function< Vector()> getWeightsCalculator (const PropertyTree &prm, const Matrix &matrix, std::size_t pressIndex) const
 
MatrixgetMatrix ()
 
const MatrixgetMatrix () const
 

Static Protected Member Functions

static bool checkConvergence (const Dune::InverseOperatorResult &result, const FlowLinearSolverParameters &parameters)
 Check the convergence of the linear solver. More...
 

Protected Attributes

const Simulatorsimulator_
 
int iterations_
 
int solveCount_
 
std::any parallelInformation_
 
Matrixmatrix_
 
Vectorrhs_
 
int activeSolverNum_ = 0
 
std::vector< detail::FlexibleSolverInfo< Matrix, Vector, CommunicationType > > flexibleSolver_
 
std::vector< int > overlapRows_
 
std::vector< int > interiorRows_
 
int domainIndex_ = -1
 
bool useWellConn_
 
std::vector< FlowLinearSolverParametersparameters_
 
bool forceSerial_ = false
 
std::vector< PropertyTreeprm_
 
std::shared_ptr< CommunicationTypecomm_
 

Static Protected Attributes

static constexpr std::size_t pressureIndex = GetPropType<TypeTag, Properties::Indices>::pressureSwitchIdx
 
static constexpr bool isIncompatibleWithCprw = enablePolymerMolarWeight
 

Detailed Description

template<class TypeTag>
class Opm::ISTLSolver< TypeTag >

This class solves the fully implicit black-oil system by solving the reduced system (after eliminating well variables) as a block-structured matrix (one block for all cell variables) for a fixed number of cell variables np .

Member Typedef Documentation

◆ AbstractOperatorType

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::AbstractOperatorType = Dune::AssembledLinearOperator<Matrix, Vector, Vector>
protected

◆ AbstractPreconditionerType

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::AbstractPreconditionerType = Dune::PreconditionerWithUpdate<Vector, Vector>
protected

◆ AbstractSolverType

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::AbstractSolverType = Dune::InverseOperator<Vector, Vector>
protected

◆ AssembledLinearOperatorType

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::AssembledLinearOperatorType = Dune::AssembledLinearOperator< Matrix, Vector, Vector >

◆ Comm

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::Comm = Dune::OwnerOverlapCopyCommunication<int, int>
protected

◆ CommunicationType

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::CommunicationType = Dune::OwnerOverlapCopyCommunication<int,int>
protected

◆ ElementContext

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::ElementContext = GetPropType<TypeTag, Properties::ElementContext>
protected

◆ ElementMapper

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::ElementMapper = GetPropType<TypeTag, Properties::ElementMapper>
protected

◆ GridView

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::GridView = GetPropType<TypeTag, Properties::GridView>
protected

◆ Indices

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::Indices = GetPropType<TypeTag, Properties::Indices>
protected

◆ Matrix

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::Matrix = typename SparseMatrixAdapter::IstlMatrix
protected

◆ Scalar

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::Scalar = GetPropType<TypeTag, Properties::Scalar>
protected

◆ Simulator

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::Simulator = GetPropType<TypeTag, Properties::Simulator>
protected

◆ SparseMatrixAdapter

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::SparseMatrixAdapter = GetPropType<TypeTag, Properties::SparseMatrixAdapter>
protected

◆ ThreadManager

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::ThreadManager = GetPropType<TypeTag, Properties::ThreadManager>
protected

◆ Vector

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::Vector = GetPropType<TypeTag, Properties::GlobalEqVector>
protected

◆ WellModel

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::WellModel = GetPropType<TypeTag, Properties::WellModel>
protected

◆ WellModelOperator

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::WellModelOperator = WellModelAsLinearOperator<WellModel, Vector, Vector>
protected

Member Enumeration Documentation

◆ anonymous enum

template<class TypeTag >
anonymous enum
protected
Enumerator
enablePolymerMolarWeight 

Constructor & Destructor Documentation

◆ ISTLSolver() [1/2]

template<class TypeTag >
Opm::ISTLSolver< TypeTag >::ISTLSolver ( const Simulator simulator,
const FlowLinearSolverParameters parameters,
bool  forceSerial = false 
)
inline

Construct a system solver.

Parameters
[in]simulatorThe opm-models simulator object
[in]parametersExplicit parameters for solver setup, do not read them from command line parameters.
[in]forceSerialIf true, will set up a serial linear solver only, local to the current rank, instead of creating a parallel (MPI distributed) linear solver.

References Opm::ISTLSolver< TypeTag >::initialize().

◆ ISTLSolver() [2/2]

template<class TypeTag >
Opm::ISTLSolver< TypeTag >::ISTLSolver ( const Simulator simulator)
inlineexplicit

Construct a system solver.

Parameters
[in]simulatorThe opm-models simulator object

References Opm::ISTLSolver< TypeTag >::initialize(), Opm::ISTLSolver< TypeTag >::parameters_, and Opm::ISTLSolver< TypeTag >::simulator_.

Member Function Documentation

◆ checkConvergence() [1/2]

template<class TypeTag >
bool Opm::ISTLSolver< TypeTag >::checkConvergence ( const Dune::InverseOperatorResult &  result) const
inlineprotected

◆ checkConvergence() [2/2]

template<class TypeTag >
static bool Opm::AbstractISTLSolver< TypeTag >::checkConvergence ( const Dune::InverseOperatorResult &  result,
const FlowLinearSolverParameters parameters 
)
inlinestaticprotectedinherited

Check the convergence of the linear solver.

This method checks if the linear solver has converged based on the result and parameters.

Parameters
resultThe result of the linear solver.
parametersThe parameters used for the linear solver.
Returns
true if the solver has converged, false otherwise.

References Opm::FlowLinearSolverParameters::ignoreConvergenceFailure_, and Opm::FlowLinearSolverParameters::relaxed_linear_solver_reduction_.

Referenced by Opm::ISTLSolver< TypeTag >::checkConvergence().

◆ comm()

template<class TypeTag >
const CommunicationType * Opm::ISTLSolver< TypeTag >::comm ( ) const
inlineoverridevirtual

Get the communication object used by the solver.

This method returns a pointer to the communication object used by the solver.

Returns
A pointer to the communication object.

Implements Opm::AbstractISTLSolver< TypeTag >.

References Opm::ISTLSolver< TypeTag >::comm_.

◆ eraseMatrix()

template<class TypeTag >
void Opm::ISTLSolver< TypeTag >::eraseMatrix ( )
inlineoverridevirtual

Signals that the memory for the matrix internally in the solver could be erased.

Note
This call could be ignored by the solver, but it is a hint that the solver does not need the matrix anymore.

Implements Opm::AbstractISTLSolver< TypeTag >.

◆ getMatrix() [1/2]

◆ getMatrix() [2/2]

template<class TypeTag >
const Matrix & Opm::ISTLSolver< TypeTag >::getMatrix ( ) const
inlineprotected

◆ getResidual()

template<class TypeTag >
void Opm::ISTLSolver< TypeTag >::getResidual ( Vector b) const
inlineoverridevirtual

Get the residual vector.

This method retrieves the current residual vector from the solver.

Parameters
bThe vector to store the residual.

Implements Opm::AbstractISTLSolver< TypeTag >.

Reimplemented in Opm::ISTLSolverGpuBridge< TypeTag >.

References Opm::ISTLSolver< TypeTag >::rhs_.

◆ getSolveCount()

template<class TypeTag >
int Opm::ISTLSolver< TypeTag >::getSolveCount ( ) const
inlineoverridevirtual

Get the count of how many times the solver has been called.

This method returns the number of times the solve() method has been called.

Returns
The count of solve calls.

Implements Opm::AbstractISTLSolver< TypeTag >.

References Opm::ISTLSolver< TypeTag >::solveCount_.

◆ getWeightsCalculator()

template<class TypeTag >
std::function< Vector()> Opm::ISTLSolver< TypeTag >::getWeightsCalculator ( const PropertyTree prm,
const Matrix matrix,
std::size_t  pressIndex 
) const
inlineprotected

◆ initialize()

◆ initPrepare()

◆ isNlddLocalSolver()

template<class TypeTag >
bool Opm::ISTLSolver< TypeTag >::isNlddLocalSolver ( ) const
inline

◆ isParallel()

◆ iterations()

template<class TypeTag >
int Opm::ISTLSolver< TypeTag >::iterations ( ) const
inlineoverridevirtual

Solve the system of linear equations Ax = b, with A being the combined derivative matrix of the residual and b being the residual itself.

Parameters
[in]residualresidual object containing A and b.
Returns
the solution x

Implements Opm::AbstractISTLSolver< TypeTag >.

References Opm::ISTLSolver< TypeTag >::iterations_.

Referenced by Opm::ISTLSolver< TypeTag >::shouldCreateSolver().

◆ numAvailableSolvers()

template<class TypeTag >
int Opm::ISTLSolver< TypeTag >::numAvailableSolvers ( ) const
inlineoverridevirtual

Get the number of available solvers.

Returns
The number of solvers that can be used.

Implements Opm::AbstractISTLSolver< TypeTag >.

References Opm::ISTLSolver< TypeTag >::flexibleSolver_.

◆ parallelInformation()

template<class TypeTag >
const std::any & Opm::ISTLSolver< TypeTag >::parallelInformation ( ) const
inline

◆ prepare() [1/2]

template<class TypeTag >
void Opm::ISTLSolver< TypeTag >::prepare ( const Matrix M,
Vector b 
)
inlineoverridevirtual

Prepare the solver with the given matrix and right-hand side vector.

This method initializes the solver with the provided matrix and vector, preparing it for solving the system of equations.

Parameters
MThe matrix representing the system of equations.
bThe right-hand side vector.

Implements Opm::AbstractISTLSolver< TypeTag >.

Reimplemented in Opm::ISTLSolverGpuBridge< TypeTag >.

References Opm::ISTLSolver< TypeTag >::initPrepare(), and Opm::ISTLSolver< TypeTag >::prepareFlexibleSolver().

◆ prepare() [2/2]

template<class TypeTag >
void Opm::ISTLSolver< TypeTag >::prepare ( const SparseMatrixAdapter M,
Vector b 
)
inlineoverridevirtual

Prepare the solver with the given sparse matrix and right-hand side vector.

This method initializes the solver with the provided sparse matrix and vector, preparing it for solving the system of equations.

Parameters
MThe sparse matrix representing the system of equations.
bThe right-hand side vector.
Note
This method should be called in addition to setResidual() and setMatrix() before calling solve().

Implements Opm::AbstractISTLSolver< TypeTag >.

References Opm::ISTLSolver< TypeTag >::prepare().

Referenced by Opm::ISTLSolverGpuBridge< TypeTag >::prepare(), and Opm::ISTLSolver< TypeTag >::prepare().

◆ prepareFlexibleSolver()

◆ registerParameters()

template<class TypeTag >
static void Opm::ISTLSolver< TypeTag >::registerParameters ( )
inlinestatic

◆ resetSolveCount()

template<class TypeTag >
void Opm::ISTLSolver< TypeTag >::resetSolveCount ( )
inline

◆ setActiveSolver()

template<class TypeTag >
void Opm::ISTLSolver< TypeTag >::setActiveSolver ( const int  num)
inlineoverridevirtual

Set the active solver by its index.

Parameters
numThe index of the solver to set as active.
Note
The index corresponds to the order in which solvers are registered.

Implements Opm::AbstractISTLSolver< TypeTag >.

References Opm::ISTLSolver< TypeTag >::activeSolverNum_, Opm::ISTLSolver< TypeTag >::parameters_, Opm::ISTLSolver< TypeTag >::prm_, Opm::ISTLSolver< TypeTag >::simulator_, and Opm::to_string().

◆ setDomainIndex()

template<class TypeTag >
void Opm::ISTLSolver< TypeTag >::setDomainIndex ( const int  index)
inline

◆ setMatrix()

template<class TypeTag >
void Opm::ISTLSolver< TypeTag >::setMatrix ( const SparseMatrixAdapter M)
inlineoverridevirtual

Set the matrix for the solver.

This method sets the matrix that the solver will use to solve the system of equations.

Parameters
MThe sparse matrix adapter containing the matrix data.
Note
This method should be called in addition to prepare() and setResidual() before calling solve().

Implements Opm::AbstractISTLSolver< TypeTag >.

Reimplemented in Opm::ISTLSolverGpuBridge< TypeTag >.

◆ setResidual()

template<class TypeTag >
void Opm::ISTLSolver< TypeTag >::setResidual ( Vector b)
inlineoverridevirtual

Set the residual vector.

This method sets the residual vector for the solver.

Parameters
bThe residual vector to set.
Note
This method should be called in addition to prepare() and setMatrix() before calling solve().

Implements Opm::AbstractISTLSolver< TypeTag >.

Reimplemented in Opm::ISTLSolverGpuBridge< TypeTag >.

◆ shouldCreateSolver()

template<class TypeTag >
bool Opm::ISTLSolver< TypeTag >::shouldCreateSolver ( ) const
inlineprotected

◆ solve()

template<class TypeTag >
bool Opm::ISTLSolver< TypeTag >::solve ( Vector x)
inlineoverridevirtual

Solve the system of equations Ax = b.

This method solves the linear system represented by the matrix A and the right-hand side vector b, storing the solution in vector x.

Parameters
xThe vector to store the solution.
Returns
true if the solver converged, false otherwise.

Before this function is called, the following function calls should have been made:

Implements Opm::AbstractISTLSolver< TypeTag >.

Reimplemented in Opm::ISTLSolverGpuBridge< TypeTag >.

References Opm::ISTLSolver< TypeTag >::activeSolverNum_, Opm::ISTLSolver< TypeTag >::checkConvergence(), Opm::ISTLSolver< TypeTag >::comm_, Opm::ISTLSolver< TypeTag >::flexibleSolver_, Opm::ISTLSolver< TypeTag >::getMatrix(), Opm::ISTLSolver< TypeTag >::iterations_, Opm::ISTLSolver< TypeTag >::prm_, Opm::ISTLSolver< TypeTag >::rhs_, Opm::ISTLSolver< TypeTag >::simulator_, Opm::ISTLSolver< TypeTag >::solveCount_, and Opm::Helper::writeSystem().

Referenced by Opm::ISTLSolverGpuBridge< TypeTag >::solve().

Member Data Documentation

◆ activeSolverNum_

◆ comm_

◆ domainIndex_

template<class TypeTag >
int Opm::ISTLSolver< TypeTag >::domainIndex_ = -1
protected

◆ flexibleSolver_

◆ forceSerial_

template<class TypeTag >
bool Opm::ISTLSolver< TypeTag >::forceSerial_ = false
protected

◆ interiorRows_

template<class TypeTag >
std::vector<int> Opm::ISTLSolver< TypeTag >::interiorRows_
protected

◆ isIncompatibleWithCprw

template<class TypeTag >
constexpr bool Opm::ISTLSolver< TypeTag >::isIncompatibleWithCprw = enablePolymerMolarWeight
staticconstexprprotected

◆ iterations_

template<class TypeTag >
int Opm::ISTLSolver< TypeTag >::iterations_
mutableprotected

◆ matrix_

◆ overlapRows_

template<class TypeTag >
std::vector<int> Opm::ISTLSolver< TypeTag >::overlapRows_
protected

◆ parallelInformation_

template<class TypeTag >
std::any Opm::ISTLSolver< TypeTag >::parallelInformation_
protected

◆ parameters_

◆ pressureIndex

template<class TypeTag >
constexpr std::size_t Opm::ISTLSolver< TypeTag >::pressureIndex = GetPropType<TypeTag, Properties::Indices>::pressureSwitchIdx
staticconstexprprotected

◆ prm_

◆ rhs_

◆ simulator_

◆ solveCount_

◆ useWellConn_


The documentation for this class was generated from the following files: