PSCF v1.4.0
Pscf::Rp::AmCompressor< D, T, V > Class Template Reference

Anderson mixing compressor. More...

#include <AmCompressor.h>

Inheritance diagram for Pscf::Rp::AmCompressor< D, T, V >:
Pscf::AmIteratorTmpl< T::Compressor, V >

Public Types

using VectorT = V
 Type for state and residual vectors.

Public Member Functions

void readParameters (std::istream &in) override
 Read all parameters and initialize.
void setup (bool isContinuation) override
 Initialize just before entry to iterative loop.
int compress () override
 Compress to obtain partial saddle point w+.
void outputTimers (std::ostream &out) const override
 Return compressor times contributions.
void clearTimers () override
 Clear all timers and mde counter.
Public Member Functions inherited from Pscf::AmIteratorTmpl< T::Compressor, V >
 AmIteratorTmpl ()
 Constructor.
 ~AmIteratorTmpl ()
 Destructor.
int solve (bool isContinuation=false)
 Iterate to a solution.
void outputTimers (std::ostream &out) const
 Log output timing results.
void clearTimers ()
 Clear timers.

Protected Types

using CompressorT = typename T::Compressor
 Compressor type.

Protected Member Functions

 AmCompressor (typename T::System &system)
 Constructor.
 ~AmCompressor ()=default
 Destructor.
Protected Member Functions inherited from Pscf::AmIteratorTmpl< T::Compressor, V >
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.
void readMixingParameters (std::istream &in, bool useLambdaRamp=true)
 Read optional parameters used in default correction algorithm.
void allocateAM ()
 Allocate memory required by AM algorithm, if necessary.
bool isAllocatedAM () const
 Have data structures required by the AM algorithm been allocated?
virtual void clear ()
 Clear information about history.
virtual double computeError (V &residTrial, V &stateTrial, std::string errorType, int verbose)
 Compute and return error used to test for convergence.
double lambdaRampFactor ()
 Compute ramped prefactor of mixing parameter lambda.
virtual double computeLambda ()
 Compute mixing parameter for correction step of Anderson mixing.
int verbose () const
 Verbosity level, allowed values 0, 1, or 2.
std::string errorType () const
 Get error type string.
V const & residual () const
 Get the current residual vector by const reference.
V const & state () const
 Return the current state vector by const reference.
int totalItr ()
 Return the total number of iterations needed to converge.
double timerTotal ()
 Get total time.
double timerMDE ()
 Get time spent solving the modified diffusion equation (MDE).
double timerAM ()
 Get total time for AM algorithm, excluding MDE solution.
double timerResid ()
 Get time spent computing residual.
double timerError ()
 Get time evaluating scalar error.
double timerCoeff ()
 Get time spent evaluating Anderson mixing coefficients.
double timerOmega ()
 Get time spent updating w states.

Additional Inherited Members

Protected Attributes inherited from Pscf::AmIteratorTmpl< T::Compressor, V >
double epsilon_
 Error tolerance.
int maxItr_
 Maximum number of iterations to attempt.
int maxHist_
 Maximum number of basis vectors in AM algorithm.
int verbose_
 Verbosity level.
std::string errorType_
 Type of error criterion used to test convergence.

Detailed Description

template<int D, class T, class V>
class Pscf::Rp::AmCompressor< D, T, V >

Anderson mixing compressor.

Specializations of this class template are used as base classes for two closely analogous class templates, both also named AmCompressor, that are defined in Rpc and Rpg namespaces and used in the pscf_rpc and pscf_rpg programs, respectively.

Template parameters:

  • D : dimension of space (D=1, 2, or 3)
  • T : Types class (Rpc::Types<D> or Rpg::Types<D>)
  • V : 1D array type used for state and residual vectors
See also
Manual Page

Definition at line 38 of file fts/compressor/AmCompressor.h.

Member Typedef Documentation

◆ VectorT

template<int D, class T, class V>
using Pscf::Rp::AmCompressor< D, T, V >::VectorT = V

Type for state and residual vectors.

Definition at line 45 of file fts/compressor/AmCompressor.h.

◆ CompressorT

template<int D, class T, class V>
using Pscf::Rp::AmCompressor< D, T, V >::CompressorT = typename T::Compressor
protected

Compressor type.

Definition at line 99 of file fts/compressor/AmCompressor.h.

Constructor & Destructor Documentation

◆ AmCompressor()

template<int D, class T, class V>
Pscf::Rp::AmCompressor< D, T, V >::AmCompressor ( typename T::System & system)
protected

Constructor.

Parameters
systemparent System object

Definition at line 28 of file AmCompressor.tpp.

References Util::ParamComposite::setClassName().

◆ ~AmCompressor()

template<int D, class T, class V>
Pscf::Rp::AmCompressor< D, T, V >::~AmCompressor ( )
protecteddefault

Destructor.

Member Function Documentation

◆ readParameters()

◆ setup()

template<int D, class T, class V>
void Pscf::Rp::AmCompressor< D, T, V >::setup ( bool isContinuation)
overridevirtual

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< T::Compressor, V >.

Definition at line 56 of file AmCompressor.tpp.

References Util::Log::file(), and Pscf::AmIteratorTmpl< CompressorT, VectorT >::setup().

◆ compress()

template<int D, class T, class V>
int Pscf::Rp::AmCompressor< D, T, V >::compress ( )
override

Compress to obtain partial saddle point w+.

Returns
0 for convergence, 1 for failure

Definition at line 87 of file AmCompressor.tpp.

References Util::Log::file(), Pscf::AmIteratorTmpl< CompressorT, VectorT >::solve(), and Pscf::AmIteratorTmpl< T::Compressor, V >::solve().

◆ outputTimers()

template<int D, class T, class V>
void Pscf::Rp::AmCompressor< D, T, V >::outputTimers ( std::ostream & out) const
override

Return compressor times contributions.

Parameters
outoutput stream

Definition at line 99 of file AmCompressor.tpp.

References Pscf::AmIteratorTmpl< CompressorT, VectorT >::outputTimers().

◆ clearTimers()

template<int D, class T, class V>
void Pscf::Rp::AmCompressor< D, T, V >::clearTimers ( )
override

Clear all timers and mde counter.

Definition at line 110 of file AmCompressor.tpp.

References Pscf::AmIteratorTmpl< CompressorT, VectorT >::clearTimers().


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