PSCF v1.2
Pscf::Rpg::AmCompressor< D > Class Template Reference

Rpg implementation of the Anderson Mixing compressor. More...

#include <AmCompressor.h>

Inheritance diagram for Pscf::Rpg::AmCompressor< D >:
Pscf::AmIteratorTmpl< Compressor< D >, DeviceArray< cudaReal > >

Public Member Functions

 AmCompressor (System< D > &system)
 Constructor.
 
 ~AmCompressor ()
 Destructor.
 
void readParameters (std::istream &in)
 Read all parameters and initialize.
 
void setup (bool isContinuation)
 Initialize just before entry to iterative loop.
 
int compress ()
 Compress to obtain partial saddle point w+.
 
double computeLambda (double r)
 Compute mixing parameter lambda.
 
int mdeCounter ()
 Return how many times MDE has been solved.
 
void outputTimers (std::ostream &out)
 Return compressor times contributions.
 
void clearTimers ()
 Clear all timers (reset accumulated time to zero).
 
- Public Member Functions inherited from Pscf::AmIteratorTmpl< Compressor< D >, DeviceArray< cudaReal > >
 AmIteratorTmpl ()
 Constructor.
 
 ~AmIteratorTmpl ()
 Destructor.
 
void readParameters (std::istream &in)
 Read all parameters and initialize.
 
int solve (bool isContinuation=false)
 Iterate to a solution.
 
void outputTimers (std::ostream &out)
 Log output timing results.
 
void clearTimers ()
 Clear timers.
 
std::string errorType () const
 Obtain error type.
 

Protected Member Functions

template<typename Type >
ScalarParam< Type > & readOptional (std::istream &in, const char *label, Type &value)
 Add and read a new optional ScalarParam < Type > object.
 
- Protected Member Functions inherited from Pscf::AmIteratorTmpl< Compressor< D >, DeviceArray< cudaReal > >
void setMaxItr (int maxItr)
 Set value of maxItr.
 
void setMaxHist (int maxHist)
 Set value of maxHist (number of retained previous states)
 
void setErrorType (std::string errorType)
 Set and validate value of errorType string.
 
void readErrorType (std::istream &in)
 Read and validate the optional errorType string parameter.
 
virtual bool isValidErrorType ()
 Checks if a string is a valid error type.
 
virtual double norm (DeviceArray< cudaReal > const &hist)
 Find the L2 norm of a vector.
 
void allocateAM ()
 Allocate memory required by AM algorithm, if necessary.
 
virtual void clear ()
 Clear information about history.
 
virtual double computeError (DeviceArray< cudaReal > &residTrial, DeviceArray< cudaReal > &fieldTrial, std::string errorType, int verbose)
 Compute and return error used to test for convergence.
 
double computeError (int verbose)
 Compute and return error used to test for convergence.
 
DeviceArray< cudaReal > const & residual () const
 Return the current residual vector by const reference.
 
DeviceArray< cudaReal > const & field () const
 Return the current field or state vector by const reference.
 
int verbose () const
 Verbosity level, allowed values 0, 1, or 2.
 
int totalItr ()
 Return the total number of iterations needed to converge.
 
double timerTotal ()
 Get total time.
 
double timerMDE ()
 Get time solving modified diffusion equation (MDE).
 
double timerAM ()
 Get total time for AM algorithm, excluding MDE solution.
 
double timerResid ()
 Get time computing residual.
 
double timerError ()
 Get time evaluating scalar error.
 
double timerCoeff ()
 Get time evaluating Anderson mixing coefficients.
 
double timerOmega ()
 Get time updating w fields.
 
bool isAllocatedAM () const
 Have data structures required by the AM algorithm been allocated?
 
ScalarParam< Type > & read (std::istream &in, const char *label, Type &value)
 Add and read a new required ScalarParam < Type > object.
 
ScalarParam< Type > & readOptional (std::istream &in, const char *label, Type &value)
 Add and read a new optional ScalarParam < Type > object.
 

Additional Inherited Members

- Protected Attributes inherited from Pscf::AmIteratorTmpl< Compressor< D >, DeviceArray< cudaReal > >
std::string errorType_
 Type of error criterion used to test convergence.
 

Detailed Description

template<int D>
class Pscf::Rpg::AmCompressor< D >

Rpg implementation of the Anderson Mixing compressor.

Definition at line 34 of file rpg/fts/compressor/AmCompressor.h.

Constructor & Destructor Documentation

◆ AmCompressor()

template<int D>
Pscf::Rpg::AmCompressor< D >::AmCompressor ( System< D > & system)

Constructor.

Parameters
systemSystem object associated with this compressor.

Definition at line 25 of file rpg/fts/compressor/AmCompressor.tpp.

◆ ~AmCompressor()

template<int D>
Pscf::Rpg::AmCompressor< D >::~AmCompressor ( )

Destructor.

Definition at line 32 of file rpg/fts/compressor/AmCompressor.tpp.

Member Function Documentation

◆ readParameters()

template<int D>
void Pscf::Rpg::AmCompressor< D >::readParameters ( std::istream & in)

Read all parameters and initialize.

Parameters
ininput filestream

Definition at line 37 of file rpg/fts/compressor/AmCompressor.tpp.

◆ setup()

template<int D>
void Pscf::Rpg::AmCompressor< D >::setup ( bool isContinuation)
virtual

Initialize just before entry to iterative loop.

This function is called by the solve function before entering the loop over iterations. Store the current values of the fields at the beginning of iteration

Parameters
isContinuationtrue iff continuation within a sweep

Reimplemented from Pscf::AmIteratorTmpl< Compressor< D >, DeviceArray< cudaReal > >.

Definition at line 49 of file rpg/fts/compressor/AmCompressor.tpp.

References Pscf::Prdc::Cuda::VecOp::eqV().

◆ compress()

template<int D>
int Pscf::Rpg::AmCompressor< D >::compress ( )

Compress to obtain partial saddle point w+.

Returns
0 for convergence, 1 for failure

Definition at line 77 of file rpg/fts/compressor/AmCompressor.tpp.

◆ computeLambda()

template<int D>
double Pscf::Rpg::AmCompressor< D >::computeLambda ( double r)
virtual

Compute mixing parameter lambda.

Reimplemented from Pscf::AmIteratorTmpl< Compressor< D >, DeviceArray< cudaReal > >.

Definition at line 212 of file rpg/fts/compressor/AmCompressor.tpp.

◆ mdeCounter()

template<int D>
int Pscf::Rpg::AmCompressor< D >::mdeCounter ( )

Return how many times MDE has been solved.

◆ outputTimers()

template<int D>
void Pscf::Rpg::AmCompressor< D >::outputTimers ( std::ostream & out)

Return compressor times contributions.

Definition at line 222 of file rpg/fts/compressor/AmCompressor.tpp.

◆ clearTimers()

template<int D>
void Pscf::Rpg::AmCompressor< D >::clearTimers ( )

Clear all timers (reset accumulated time to zero).

Definition at line 231 of file rpg/fts/compressor/AmCompressor.tpp.

◆ readOptional()

template<int D>
template<typename Type >
ScalarParam< Type > & Util::ParamComposite::readOptional ( std::istream & in,
const char * label,
Type & value )
inlineprotected

Add and read a new optional ScalarParam < Type > object.

This is equivalent to ScalarParam<Type>(in, label, value, false).

Parameters
ininput stream for reading
labelLabel string
valuereference to new ScalarParam< Type >

Definition at line 319 of file ParamComposite.h.


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