PSCF v1.4.0
Pscf::Rp::AverageListAnalyzer< D, T > Class Template Referenceabstract

Analyze averages and block averages of several real variables. More...

#include <AverageListAnalyzer.h>

Inheritance diagram for Pscf::Rp::AverageListAnalyzer< D, T >:

Public Member Functions

 AverageListAnalyzer (typename T::Simulator &simulator, typename T::System &system)
 Constructor.
void readParameters (std::istream &in) override
 Read interval, outputFileName and (optionally) nSamplePerOutput.
void setup () override
 Setup before loop.
void sample (long iStep) override
 Compute sampled values and update the accumulators.
void output () override
 Write final results to file after a simulation.
int nSamplePerOutput () const
 Get value of nSamplePerOutput.
int nValue () const
 Get the number of variables.
const std::string & name (int i) const
 Get name associated with a variable.
const Averageaccumulator (int i) const
 Get Average accumulator for a specific variable.

Protected Member Functions

void initializeAccumulators (int nValue)
 Initialize Average accumulators and set nValue.
void clearAccumulators ()
 Clear internal state of all accumulators.
void setName (int i, std::string name)
 Set name of variable.
void setValue (int i, double value)
 Set current value, used by compute function.
virtual void compute ()=0
 Compute values of sampled quantities.
double value (int i) const
 Get current value of a specific variable.
void updateAccumulators (long iStep)
 Add current value to accumulator, output block average if needed.
void outputAccumulators ()
 Write results of statistical analysis to files.

Protected Attributes

std::ofstream outputFile_
 Output file stream.

Detailed Description

template<int D, class T>
class Pscf::Rp::AverageListAnalyzer< D, T >

Analyze averages and block averages of several real variables.

This class template evaluates averages of several sampled real variables, and optionally writes block averages to a data file during a simulation. It is intended for use as a base class for Analyzers that evaluate averages and (optionally) block averages for several physical variables.

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

Template parameters:

  • D : dimension of space
  • T : collection of type aliases, e.g., Rpc::Types<D>

Definition at line 41 of file fts/analyzer/AverageListAnalyzer.h.

Constructor & Destructor Documentation

◆ AverageListAnalyzer()

template<int D, class T>
Pscf::Rp::AverageListAnalyzer< D, T >::AverageListAnalyzer ( typename T::Simulator & simulator,
typename T::System & system )

Constructor.

Parameters
simulatorparent Simulator object
systemparent System object

Definition at line 27 of file AverageListAnalyzer.tpp.

Member Function Documentation

◆ readParameters()

template<int D, class T>
void Pscf::Rp::AverageListAnalyzer< D, T >::readParameters ( std::istream & in)
override

Read interval, outputFileName and (optionally) nSamplePerOutput.

The optional variable nSamplePerOutput defaults to 0, which disables computation and output of block averages. Setting nSamplePerOutput = 1 outputs every sampled value.

Parameters
ininput parameter stream

Definition at line 40 of file AverageListAnalyzer.tpp.

References nSamplePerOutput(), outputFile_, Util::ParamComposite::readOptional(), and UTIL_CHECK.

◆ setup()

template<int D, class T>
void Pscf::Rp::AverageListAnalyzer< D, T >::setup ( )
override

Setup before loop.

Opens an output file, if nSamplePerOutput > 0.

Definition at line 59 of file AverageListAnalyzer.tpp.

References clearAccumulators(), and UTIL_CHECK.

◆ sample()

template<int D, class T>
void Pscf::Rp::AverageListAnalyzer< D, T >::sample ( long iStep)
override

Compute sampled values and update the accumulators.

Parameters
iStepsimulation step index

Definition at line 69 of file AverageListAnalyzer.tpp.

◆ output()

template<int D, class T>
void Pscf::Rp::AverageListAnalyzer< D, T >::output ( )
override

Write final results to file after a simulation.

Definition at line 82 of file AverageListAnalyzer.tpp.

◆ nSamplePerOutput()

template<int D, class T>
int Pscf::Rp::AverageListAnalyzer< D, T >::nSamplePerOutput ( ) const
inline

Get value of nSamplePerOutput.

If nSamplePerOutput == 0, output of block averages is disabled. For nSamplePerOutput > 0, the value is the number of sampled values averaged in each block.

Definition at line 207 of file fts/analyzer/AverageListAnalyzer.h.

Referenced by readParameters().

◆ nValue()

template<int D, class T>
int Pscf::Rp::AverageListAnalyzer< D, T >::nValue ( ) const
inline

Get the number of variables.

Definition at line 214 of file fts/analyzer/AverageListAnalyzer.h.

References UTIL_CHECK.

Referenced by initializeAccumulators(), outputAccumulators(), and updateAccumulators().

◆ name()

template<int D, class T>
const std::string & Pscf::Rp::AverageListAnalyzer< D, T >::name ( int i) const
inline

Get name associated with a variable.

Parameters
iinteger index of name/value pair

Definition at line 235 of file fts/analyzer/AverageListAnalyzer.h.

References UTIL_CHECK.

Referenced by setName().

◆ accumulator()

template<int D, class T>
const Average & Pscf::Rp::AverageListAnalyzer< D, T >::accumulator ( int i) const
inline

Get Average accumulator for a specific variable.

Parameters
iinteger index of value

Definition at line 246 of file fts/analyzer/AverageListAnalyzer.h.

References UTIL_CHECK.

◆ initializeAccumulators()

template<int D, class T>
void Pscf::Rp::AverageListAnalyzer< D, T >::initializeAccumulators ( int nValue)
protected

Initialize Average accumulators and set nValue.

Set nValue and allocate arrays with dimensions nValue.

Precondition
hasAccumulator == false
nSamplePerOutput >= 0
Parameters
nValuenumber of values

Definition at line 107 of file AverageListAnalyzer.tpp.

References nValue(), and UTIL_CHECK.

◆ clearAccumulators()

template<int D, class T>
void Pscf::Rp::AverageListAnalyzer< D, T >::clearAccumulators ( )
protected

Clear internal state of all accumulators.

Precondition
hasAccumulator == true

Definition at line 133 of file AverageListAnalyzer.tpp.

References UTIL_CHECK.

Referenced by setup().

◆ setName()

template<int D, class T>
void Pscf::Rp::AverageListAnalyzer< D, T >::setName ( int i,
std::string name )
protected

Set name of variable.

Parameters
iinteger index of variable
namename of variable number i

Definition at line 146 of file AverageListAnalyzer.tpp.

References name(), and UTIL_CHECK.

◆ setValue()

template<int D, class T>
void Pscf::Rp::AverageListAnalyzer< D, T >::setValue ( int i,
double value )
inlineprotected

Set current value, used by compute function.

Parameters
iinteger index of variable
valuecurrent value of variable

Definition at line 257 of file fts/analyzer/AverageListAnalyzer.h.

References UTIL_CHECK, and value().

◆ compute()

template<int D, class T>
virtual void Pscf::Rp::AverageListAnalyzer< D, T >::compute ( )
protectedpure virtual

Compute values of sampled quantities.

◆ value()

template<int D, class T>
double Pscf::Rp::AverageListAnalyzer< D, T >::value ( int i) const
inlineprotected

Get current value of a specific variable.

Parameters
iinteger index of variable

Definition at line 224 of file fts/analyzer/AverageListAnalyzer.h.

References UTIL_CHECK.

Referenced by setValue(), and updateAccumulators().

◆ updateAccumulators()

template<int D, class T>
void Pscf::Rp::AverageListAnalyzer< D, T >::updateAccumulators ( long iStep)
protected

Add current value to accumulator, output block average if needed.

Parameters
iStepsimulation step counter

Definition at line 157 of file AverageListAnalyzer.tpp.

References nValue(), UTIL_CHECK, and value().

◆ outputAccumulators()

template<int D, class T>
void Pscf::Rp::AverageListAnalyzer< D, T >::outputAccumulators ( )
protected

Write results of statistical analysis to files.

Definition at line 190 of file AverageListAnalyzer.tpp.

References nValue(), outputFile_, and UTIL_CHECK.

Member Data Documentation

◆ outputFile_

template<int D, class T>
std::ofstream Pscf::Rp::AverageListAnalyzer< D, T >::outputFile_
protected

Output file stream.

Definition at line 116 of file fts/analyzer/AverageListAnalyzer.h.

Referenced by outputAccumulators(), and readParameters().


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