#include <ISTLSolverSystem.hpp>

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

Public Types

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

Public Member Functions

 ISTLSolverSystem (const Simulator &simulator, const FlowLinearSolverParameters &parameters, bool forceSerial=false)
 
 ISTLSolverSystem (const Simulator &simulator)
 
void prepare (const SparseMatrixAdapter &M, Vector &b) override
 
void prepare (const Matrix &M, Vector &b) override
 
bool solve (Vector &x) override
 
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)
 
virtual void prepare (const Matrix &M, GetPropType< TypeTag, Properties::GlobalEqVector > &b)=0
 Prepare the solver with the given matrix and right-hand side vector. More...
 
virtual void prepare (const GetPropType< TypeTag, Properties::SparseMatrixAdapter > &M, GetPropType< TypeTag, Properties::GlobalEqVector > &b)=0
 Prepare the solver with the given sparse matrix and right-hand side vector. More...
 
void setResidual (Vector &) override
 
virtual void setResidual (GetPropType< TypeTag, Properties::GlobalEqVector > &b)=0
 Set the residual vector. More...
 
void getResidual (Vector &b) const override
 
virtual void getResidual (GetPropType< TypeTag, Properties::GlobalEqVector > &b) const=0
 Get the residual vector. More...
 
void setMatrix (const SparseMatrixAdapter &) override
 
virtual void setMatrix (const GetPropType< TypeTag, Properties::SparseMatrixAdapter > &M)=0
 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 ()
 
virtual bool solve (GetPropType< TypeTag, Properties::GlobalEqVector > &x)=0
 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 Scalar = GetPropType< TypeTag, Properties::Scalar >
 
using Vector = GetPropType< TypeTag, Properties::GlobalEqVector >
 
using SparseMatrixAdapter = GetPropType< TypeTag, Properties::SparseMatrixAdapter >
 
using Matrix = typename SparseMatrixAdapter::IstlMatrix
 
using Simulator = GetPropType< TypeTag, Properties::Simulator >
 
using Indices = GetPropType< TypeTag, Properties::Indices >
 
using CommunicationType = Dune::OwnerOverlapCopyCommunication< int, int >
 
using Parent = ISTLSolver< TypeTag >
 
using GridView = GetPropType< TypeTag, Properties::GridView >
 
using WellModel = GetPropType< TypeTag, Properties::WellModel >
 
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 ElementChunksType = ElementChunks< GridView, Dune::Partitions::All >
 
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_
 
std::unique_ptr< ElementChunksTypeelement_chunks_
 

Static Protected Attributes

static constexpr std::size_t pressureIndex = Indices::pressureSwitchIdx
 
static constexpr bool isIncompatibleWithCprw = enablePolymerMolarWeight
 
static constexpr auto _0 = Dune::Indices::_0
 
static constexpr auto _1 = Dune::Indices::_1
 

Member Typedef Documentation

◆ AbstractOperatorType

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

◆ AbstractPreconditionerType

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

◆ AbstractSolverType

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

◆ AssembledLinearOperatorType

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

◆ Comm

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

◆ CommunicationType

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

◆ ElementChunksType

template<class TypeTag >
using Opm::ISTLSolver< TypeTag >::ElementChunksType = ElementChunks<GridView, Dune::Partitions::All>
protectedinherited

◆ ElementContext

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

◆ ElementMapper

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

◆ GridView

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

◆ Indices

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

◆ Matrix

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

◆ Parent

template<class TypeTag >
using Opm::ISTLSolverSystem< TypeTag >::Parent = ISTLSolver<TypeTag>
protected

◆ Scalar

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

◆ Simulator

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

◆ SparseMatrixAdapter

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

◆ ThreadManager

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

◆ Vector

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

◆ WellModel

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

◆ WellModelOperator

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

Member Enumeration Documentation

◆ anonymous enum

template<class TypeTag >
anonymous enum
protected
Enumerator
enablePolymerMolarWeight 

Constructor & Destructor Documentation

◆ ISTLSolverSystem() [1/2]

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

◆ ISTLSolverSystem() [2/2]

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

Member Function Documentation

◆ checkConvergence() [1/2]

◆ checkConvergence() [2/2]

static bool Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapter > , GetPropType< TypeTag, Properties::GlobalEqVector > >::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.

◆ comm()

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

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< GetPropType< TypeTag, Properties::SparseMatrixAdapter >, GetPropType< TypeTag, Properties::GlobalEqVector > >.

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

◆ eraseMatrix()

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

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< GetPropType< TypeTag, Properties::SparseMatrixAdapter >, GetPropType< TypeTag, Properties::GlobalEqVector > >.

◆ getMatrix() [1/2]

◆ getMatrix() [2/2]

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

◆ getResidual() [1/2]

virtual void Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapter > , GetPropType< TypeTag, Properties::GlobalEqVector > >::getResidual ( GetPropType< TypeTag, Properties::GlobalEqVector > &  b) const
pure virtualinherited

Get the residual vector.

This method retrieves the current residual vector from the solver.

Parameters
bThe vector to store the residual.

◆ getResidual() [2/2]

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

◆ getSolveCount()

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

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< GetPropType< TypeTag, Properties::SparseMatrixAdapter >, GetPropType< TypeTag, Properties::GlobalEqVector > >.

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

◆ getWeightsCalculator()

◆ initialize()

◆ initPrepare()

◆ isNlddLocalSolver()

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

◆ isParallel()

◆ iterations()

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

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< GetPropType< TypeTag, Properties::SparseMatrixAdapter >, GetPropType< TypeTag, Properties::GlobalEqVector > >.

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

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

◆ numAvailableSolvers()

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

◆ parallelInformation()

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

◆ prepare() [1/4]

virtual void Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapter > , GetPropType< TypeTag, Properties::GlobalEqVector > >::prepare ( const GetPropType< TypeTag, Properties::SparseMatrixAdapter > &  M,
GetPropType< TypeTag, Properties::GlobalEqVector > &  b 
)
pure virtualinherited

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().

◆ prepare() [2/4]

virtual void Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapter > , GetPropType< TypeTag, Properties::GlobalEqVector > >::prepare ( const Matrix M,
GetPropType< TypeTag, Properties::GlobalEqVector > &  b 
)
pure virtualinherited

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.

◆ prepare() [3/4]

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

◆ prepare() [4/4]

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

◆ prepareFlexibleSolver()

◆ registerParameters()

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

◆ resetSolveCount()

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

◆ setActiveSolver()

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

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< GetPropType< TypeTag, Properties::SparseMatrixAdapter >, GetPropType< TypeTag, Properties::GlobalEqVector > >.

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)
inlineinherited

◆ setMatrix() [1/2]

virtual void Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapter > , GetPropType< TypeTag, Properties::GlobalEqVector > >::setMatrix ( const GetPropType< TypeTag, Properties::SparseMatrixAdapter > &  M)
pure virtualinherited

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().

◆ setMatrix() [2/2]

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

◆ setResidual() [1/2]

virtual void Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapter > , GetPropType< TypeTag, Properties::GlobalEqVector > >::setResidual ( GetPropType< TypeTag, Properties::GlobalEqVector > &  b)
pure virtualinherited

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().

◆ setResidual() [2/2]

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

◆ shouldCreateSolver()

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

◆ solve() [1/2]

virtual bool Opm::AbstractISTLSolver< GetPropType< TypeTag, Properties::SparseMatrixAdapter > , GetPropType< TypeTag, Properties::GlobalEqVector > >::solve ( GetPropType< TypeTag, Properties::GlobalEqVector > &  x)
pure virtualinherited

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:

◆ solve() [2/2]

Member Data Documentation

◆ _0

template<class TypeTag >
constexpr auto Opm::ISTLSolverSystem< TypeTag >::_0 = Dune::Indices::_0
staticconstexprprotected

◆ _1

template<class TypeTag >
constexpr auto Opm::ISTLSolverSystem< TypeTag >::_1 = Dune::Indices::_1
staticconstexprprotected

◆ activeSolverNum_

◆ comm_

◆ domainIndex_

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

◆ element_chunks_

template<class TypeTag >
std::unique_ptr<ElementChunksType> Opm::ISTLSolver< TypeTag >::element_chunks_
protectedinherited

◆ flexibleSolver_

◆ forceSerial_

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

◆ interiorRows_

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

◆ isIncompatibleWithCprw

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

◆ iterations_

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

◆ matrix_

◆ overlapRows_

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

◆ parallelInformation_

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

◆ parameters_

◆ pressureIndex

template<class TypeTag >
constexpr std::size_t Opm::ISTLSolverSystem< TypeTag >::pressureIndex = Indices::pressureSwitchIdx
staticconstexprprotected

◆ prm_

◆ rhs_

◆ simulator_

◆ solveCount_

◆ useWellConn_

template<class TypeTag >
bool Opm::ISTLSolver< TypeTag >::useWellConn_
protectedinherited

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