PSCF v1.2
|
Rpg implementation of the Anderson Mixing compressor. More...
#include <AmCompressor.h>
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). | |
![]() | |
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. | |
![]() | |
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 | |
![]() | |
std::string | errorType_ |
Type of error criterion used to test convergence. | |
Rpg implementation of the Anderson Mixing compressor.
Definition at line 34 of file rpg/fts/compressor/AmCompressor.h.
Pscf::Rpg::AmCompressor< D >::AmCompressor | ( | System< D > & | system | ) |
Constructor.
system | System object associated with this compressor. |
Definition at line 25 of file rpg/fts/compressor/AmCompressor.tpp.
Pscf::Rpg::AmCompressor< D >::~AmCompressor | ( | ) |
Destructor.
Definition at line 32 of file rpg/fts/compressor/AmCompressor.tpp.
void Pscf::Rpg::AmCompressor< D >::readParameters | ( | std::istream & | in | ) |
Read all parameters and initialize.
in | input filestream |
Definition at line 37 of file rpg/fts/compressor/AmCompressor.tpp.
|
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
isContinuation | true 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().
int Pscf::Rpg::AmCompressor< D >::compress | ( | ) |
Compress to obtain partial saddle point w+.
Definition at line 77 of file rpg/fts/compressor/AmCompressor.tpp.
|
virtual |
Compute mixing parameter lambda.
Reimplemented from Pscf::AmIteratorTmpl< Compressor< D >, DeviceArray< cudaReal > >.
Definition at line 212 of file rpg/fts/compressor/AmCompressor.tpp.
int Pscf::Rpg::AmCompressor< D >::mdeCounter | ( | ) |
Return how many times MDE has been solved.
void Pscf::Rpg::AmCompressor< D >::outputTimers | ( | std::ostream & | out | ) |
Return compressor times contributions.
Definition at line 222 of file rpg/fts/compressor/AmCompressor.tpp.
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.
|
inlineprotected |
Add and read a new optional ScalarParam < Type > object.
This is equivalent to ScalarParam<Type>(in, label, value, false).
in | input stream for reading |
label | Label string |
value | reference to new ScalarParam< Type > |
Definition at line 319 of file ParamComposite.h.