Dune Core Modules (unstable)

conjugate gradient method More...

#include <dune/istl/solvers.hh>

Public Types

typedef X domain_type
 Type of the domain of the operator to be inverted.
 
typedef X range_type
 Type of the range of the operator to be inverted.
 
typedef X::field_type field_type
 The field type of the operator.
 
typedef FieldTraits< field_type >::real_type real_type
 The real type of the field type (is the same if using real numbers, but differs for std::complex)
 
typedef Simd::Scalar< real_typescalar_real_type
 scalar type underlying the field_type
 

Public Member Functions

 CGSolver (const LinearOperator< X, X > &op, Preconditioner< X, X > &prec, scalar_real_type reduction, int maxit, int verbose, bool condition_estimate)
 Constructor to initialize a CG solver. More...
 
 CGSolver (const LinearOperator< X, X > &op, const ScalarProduct< X > &sp, Preconditioner< X, X > &prec, scalar_real_type reduction, int maxit, int verbose, bool condition_estimate)
 Constructor to initialize a CG solver. More...
 
 CGSolver (std::shared_ptr< const LinearOperator< X, X > > op, std::shared_ptr< ScalarProduct< X > > sp, std::shared_ptr< Preconditioner< X, X > > prec, scalar_real_type reduction, int maxit, int verbose, bool condition_estimate)
 Constructor to initialize a CG solver. More...
 
void apply (X &x, X &b, InverseOperatorResult &res) override
 Apply inverse operator. More...
 
void apply (X &x, X &b, double reduction, InverseOperatorResult &res) override
 Apply inverse operator with given reduction factor. More...
 
SolverCategory::Category category () const override
 Category of the solver (see SolverCategory::Category)
 

Protected Member Functions

void printHeader (std::ostream &s) const
 helper function for printing header of solver output
 
void printOutput (std::ostream &s, const CountType &iter, const DataType &norm, const DataType &norm_old) const
 helper function for printing solver output
 
void printOutput (std::ostream &s, const CountType &iter, const DataType &norm) const
 helper function for printing solver output
 

Detailed Description

template<class X>
class Dune::CGSolver< X >

conjugate gradient method

Constructor & Destructor Documentation

◆ CGSolver() [1/3]

template<class X >
Dune::CGSolver< X >::CGSolver ( const LinearOperator< X, X > &  op,
Preconditioner< X, X > &  prec,
scalar_real_type  reduction,
int  maxit,
int  verbose,
bool  condition_estimate 
)
inline

Constructor to initialize a CG solver.

Parameters
condition_estimateWhether to calculate an estimate of the condition number. The estimate is given in the InverseOperatorResult returned by apply(). This is only supported for float and double field types.

◆ CGSolver() [2/3]

template<class X >
Dune::CGSolver< X >::CGSolver ( const LinearOperator< X, X > &  op,
const ScalarProduct< X > &  sp,
Preconditioner< X, X > &  prec,
scalar_real_type  reduction,
int  maxit,
int  verbose,
bool  condition_estimate 
)
inline

Constructor to initialize a CG solver.

Parameters
condition_estimateWhether to calculate an estimate of the condition number. The estimate is given in the InverseOperatorResult returned by apply(). This is only supported for float and double field types.

◆ CGSolver() [3/3]

template<class X >
Dune::CGSolver< X >::CGSolver ( std::shared_ptr< const LinearOperator< X, X > >  op,
std::shared_ptr< ScalarProduct< X > >  sp,
std::shared_ptr< Preconditioner< X, X > >  prec,
scalar_real_type  reduction,
int  maxit,
int  verbose,
bool  condition_estimate 
)
inline

Constructor to initialize a CG solver.

Parameters
condition_estimateWhether to calculate an estimate of the condition number. The estimate is given in the InverseOperatorResult returned by apply(). This is only supported for float and double field types.

Member Function Documentation

◆ apply() [1/2]

void Dune::IterativeSolver< X, X >::apply ( X &  x,
X &  b,
double  reduction,
InverseOperatorResult res 
)
inlineoverridevirtualinherited

Apply inverse operator with given reduction factor.

apply inverse operator, with given convergence criteria.

Warning
Right hand side b may be overwritten!
Parameters
xThe left hand side to store the result in.
bThe right hand side
reductionThe minimum defect reduction to achieve.
resObject to store the statistics about applying the operator.
Exceptions
SolverAbortWhen the solver detects a problem and cannot continue

Implements Dune::InverseOperator< X, X >.

Reimplemented in Dune::RestartedGMResSolver< X, X >.

◆ apply() [2/2]

template<class X >
void Dune::CGSolver< X >::apply ( X &  x,
X &  b,
InverseOperatorResult res 
)
inlineoverridevirtual

Apply inverse operator.

Apply inverse operator,.

Warning
Note: right hand side b may be overwritten!
Parameters
xThe left hand side to store the result in.
bThe right hand side
resObject to store the statistics about applying the operator.
Exceptions
SolverAbortWhen the solver detects a problem and cannot continue
Note
Currently, the CGSolver aborts when a NaN or infinite defect is detected. However, -ffinite-math-only (implied by -ffast-math) can inhibit a result from becoming NaN that really should be NaN. E.g. numeric_limits<double>::quiet_NaN()*0.0==0.0 with gcc-5.3 -ffast-math.

Implements Dune::InverseOperator< X, X >.

References Dune::Simd::cond(), and Dune::BCRSMatrix< B, A >::row_wise.


The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)