QuOc

 

Public Member Functions | Protected Attributes | Private Types

aol::PCGInverse< VectorType, OpType, iOpType > Class Template Reference

Preconditioned Conjugate Gradient solver. More...

#include <solver.h>

Inheritance diagram for aol::PCGInverse< VectorType, OpType, iOpType >:
aol::IterativeInverseOp< VectorType, OpType > aol::InverseOp< VectorType > aol::Op< VectorType >

List of all members.

Public Member Functions

 PCGInverse (const OpType &Op, const iOpType &ApproxInverseOp, const DataType Epsilon=1e-16, const int MaxIter=50, const StoppingMode Stop=STOPPING_UNSET, ostream &Out=cerr)
 PCGInverse (const OpType &Op, const iOpType &ApproxInverseOp, SolverInfo< DataType > &info)
DataType getResSqr () const
virtual void apply (const VectorType &Arg, VectorType &Dest) const
 Apply solver, possibly using Dest as initial guess.

Protected Attributes

const iOpType & _approxInverseOp

Private Types

typedef IterativeInverseOp
< VectorType, OpType >
::DataType 
DataType

Detailed Description

template<typename VectorType, typename OpType = Op<VectorType>, typename iOpType = Op<VectorType>>
class aol::PCGInverse< VectorType, OpType, iOpType >

Preconditioned Conjugate Gradient solver.

Class for preconditioned conjugate gradient solver. Specify approximate inverse of the Operator Op by ApproxInverseOp, e. g. DiagonalPreconditioner

Author:
Droske

Definition at line 233 of file solver.h.


Member Typedef Documentation

template<typename VectorType, typename OpType = Op<VectorType>, typename iOpType = Op<VectorType>>
typedef IterativeInverseOp<VectorType, OpType>::DataType aol::PCGInverse< VectorType, OpType, iOpType >::DataType [private]

Reimplemented from aol::IterativeInverseOp< VectorType, OpType >.

Definition at line 234 of file solver.h.


Constructor & Destructor Documentation

template<typename VectorType, typename OpType = Op<VectorType>, typename iOpType = Op<VectorType>>
aol::PCGInverse< VectorType, OpType, iOpType >::PCGInverse ( const OpType Op,
const iOpType &  ApproxInverseOp,
const DataType  Epsilon = 1e-16,
const int  MaxIter = 50,
const StoppingMode  Stop = STOPPING_UNSET,
ostream &  Out = cerr 
) [inline]

Definition at line 240 of file solver.h.

      : IterativeInverseOp< VectorType, OpType > ( Op, Epsilon, MaxIter, Stop, false, Out )
      , _approxInverseOp ( ApproxInverseOp ) {}

template<typename VectorType, typename OpType = Op<VectorType>, typename iOpType = Op<VectorType>>
aol::PCGInverse< VectorType, OpType, iOpType >::PCGInverse ( const OpType Op,
const iOpType &  ApproxInverseOp,
SolverInfo< DataType > &  info 
) [inline]

Definition at line 249 of file solver.h.

      : IterativeInverseOp< VectorType, OpType > ( Op, info )
      , _approxInverseOp ( ApproxInverseOp ) {}


Member Function Documentation

template<typename VectorType, typename OpType = Op<VectorType>, typename iOpType = Op<VectorType>>
virtual void aol::PCGInverse< VectorType, OpType, iOpType >::apply ( const VectorType &  ,
VectorType &   
) const [inline, virtual]

Apply solver, possibly using Dest as initial guess.

Implements aol::IterativeInverseOp< VectorType, OpType >.

Definition at line 259 of file solver.h.

Referenced by qc::GeneralLinearSmoothOp< ConfiguratorType >::apply(), aol::computeConditionNumberByVectorIteration(), qc::SmoothlyExtendImage(), tpcfe::CFEBlockMultigridProjectAvgConstr< CFEBlockOpType, CFEMassOpType, CMode >::solveCoarseProblem(), tpcfe::CFEMultigridProjectAvgConstr< CFEOpType, CFEMassOpType, CMode >::solveCoarseProblem(), mg::ExplicitOperatorHierarchyMultigrid< aol::Vector< RealType >, MatrixType, mg::GaussSeidelSmoother< aol::Vector< RealType >, MatrixType >, qc::RestrictOp< RealType, qc::STD_MG_RESTRICT >, qc::ProlongOp< RealType >, qc::GridDefinition >::solveCoarseProblem(), qc::ATSegmentation< ConfiguratorType >::updateU(), and qc::ATSegmentation< ConfiguratorType >::updateV().

                                                                       {
    DataType alpha_numer, alpha_denom, beta_numer, beta_denom, spn;

    VectorType g ( Arg, aol::STRUCT_COPY );
    VectorType d ( Arg, aol::STRUCT_COPY );
    VectorType h ( Arg, aol::STRUCT_COPY ); // automatically cleared

    this->_op.apply ( Dest, h );

#ifdef VERBOSE
    this->_infoPtr->getOstream() << "Solver h norm " << h.norm() << endl;
#endif

    g = h;
    g -= Arg;

    h.setZero();
    _approxInverseOp.apply ( g, h );

#ifdef VERBOSE
    this->_infoPtr->getOstream() << "h*h " << h*h << endl;
#endif

    spn = g * g;

#ifdef VERBOSE
    this->_infoPtr->getOstream() << " spn = " << spn << endl;
#endif
    d -= h;

#ifdef VERBOSE
    this->_infoPtr->getOstream() << "h*h " << h*h << endl;
#endif

    this->_infoPtr->startIterations ( Arg.normSqr(), spn, "p-cg", "l_2 norm ^2" );

    while ( ! ( this->_infoPtr->stoppingCriterionIsFulfilled() ) && ! ( this->_infoPtr->maxIterIsReached() ) && ! ( this->_infoPtr->currentResidualIsNaN() ) ) {
      this->_infoPtr->startStep();

      beta_denom = alpha_numer = g * h;

#ifdef VERBOSE
      this->_infoPtr->getOstream() << "beta_denom = " << beta_denom << endl
      << "alpha_numer = " << alpha_numer << endl;
#endif

      h.setZero();
      this->_op.apply ( d, h );
      alpha_denom = d * h;

#ifdef VERBOSE
      this->_infoPtr->getOstream() << "h * h = " << h*h << endl
      << "alpha_denom = " << alpha_denom << endl;
#endif

      Dest.addMultiple ( d, alpha_numer / alpha_denom );

      g.addMultiple ( h, alpha_numer / alpha_denom );

#ifdef VERBOSE
      this->_infoPtr->getOstream() << "g * g = " << g*g << endl;
#endif

      h.setZero();
      _approxInverseOp.apply ( g, h );
      beta_numer = g * h;

#ifdef VERBOSE
      this->_infoPtr->getOstream() << "h * h = " << h*h << endl
      << "beta_numer = " << beta_numer << endl;
#endif

      d *= ( beta_numer / beta_denom );
      d -= h;

#ifdef VERBOSE
      this->_infoPtr->getOstream() << "d * d = " << d*d << endl;
#endif

      spn = g * g;
#ifdef VERBOSE
      VectorType dummy ( Arg, aol::STRUCT_COPY );
      this->_op.apply ( Dest, dummy );
      dummy -= Arg;
      this->_infoPtr->getOstream() << "Computed residuum = " << dummy * dummy << endl;
#endif
      this->_infoPtr->finishStep ( spn );
    }

    this->_op.apply ( Dest, h );
    g = h;
    g -= Arg;
    spn = g * g;

    this->_infoPtr->finishIterations ( spn );
  }

template<typename VectorType, typename OpType = Op<VectorType>, typename iOpType = Op<VectorType>>
DataType aol::PCGInverse< VectorType, OpType, iOpType >::getResSqr (  )  const [inline]

Definition at line 255 of file solver.h.

                               {
    return this->_infoPtr->getFinalResidual();
  }


Member Data Documentation

template<typename VectorType, typename OpType = Op<VectorType>, typename iOpType = Op<VectorType>>
const iOpType& aol::PCGInverse< VectorType, OpType, iOpType >::_approxInverseOp [protected]

Definition at line 237 of file solver.h.

Referenced by aol::PCGInverse< aol::Vector< RealType > >::apply().


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

Generated on Fri Sep 9 2011 21:09:16 for QuocMesh by doxygen 1.7.1