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

Analyze averages and block averages of a single real variable. More...

#include <AverageAnalyzer.h>

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

Public Member Functions

virtual void readParameters (std::istream &in)
 Read interval, outputFileName and (optionally) nSamplePerOutput.
virtual void setup ()
 Setup before loop.
virtual void sample (long iStep)
 Compute a sampled value and update the accumulator.
virtual void output ()
 Write final results to file after a simulation.
int nSamplePerOutput () const
 Get value of nSamplePerOutput.

Protected Member Functions

 AverageAnalyzer (typename T::Simulator &simulator, typename T::System &system)
 Constructor.
 ~AverageAnalyzer ()=default
 Destructor.
virtual double compute ()=0
 Compute value of sampled quantity.
virtual void outputValue (int step, double value)
 Output a sampled or block average value.

Protected Attributes

std::ofstream outputFile_
 Output file stream.
Average accumulator_
 Average object.

Detailed Description

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

Analyze averages and block averages of a single real variable.

This class evaluates the average of a single sampled real variables, and optionally writes values or block averages to a data file during a simulation. It is intended for use as a base class for any Analyzer that computes and evaluates an average for a single physical variable.

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

Template parameters:

Definition at line 40 of file fts/analyzer/AverageAnalyzer.h.

Constructor & Destructor Documentation

◆ AverageAnalyzer()

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

Constructor.

Parameters
simulatorparent Simulator object
systemparent System object

Definition at line 27 of file AverageAnalyzer.tpp.

◆ ~AverageAnalyzer()

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

Destructor.

Member Function Documentation

◆ readParameters()

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

Read interval, outputFileName and (optionally) nSamplePerOutput.

The optional variable nSamplePerOutput defaults to 1, which causes every sampled value to be written to file. Setting nSamplePerOutput = 0 suppresses output of block averages to file.

Parameters
ininput parameter file

Definition at line 37 of file AverageAnalyzer.tpp.

References accumulator_, outputFile_, and Util::ParamComposite::readOptional().

◆ setup()

template<int D, class T>
void Pscf::Rp::AverageAnalyzer< D, T >::setup ( )
virtual

Setup before loop.

Opens an output file, if nSamplePerOutput > 0.

Definition at line 60 of file AverageAnalyzer.tpp.

References accumulator_.

◆ sample()

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

Compute a sampled value and update the accumulator.

Parameters
iStepMD time step index

Definition at line 67 of file AverageAnalyzer.tpp.

◆ output()

template<int D, class T>
void Pscf::Rp::AverageAnalyzer< D, T >::output ( )
virtual

Write final results to file after a simulation.

Write an average value. If the simulation does not have a ramp, it also writes an estimate of the error on the average and information estimates from hierarchichal block averages about how that estimate was obtained. Information about error analysis is suppressed when a ramp exists.

Definition at line 105 of file AverageAnalyzer.tpp.

References outputFile_.

◆ nSamplePerOutput()

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

Get value of nSamplePerOutput.

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

Definition at line 143 of file fts/analyzer/AverageAnalyzer.h.

◆ compute()

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

Compute value of sampled quantity.

◆ outputValue()

template<int D, class T>
void Pscf::Rp::AverageAnalyzer< D, T >::outputValue ( int step,
double value )
protectedvirtual

Output a sampled or block average value.

Parameters
stepvalue for step counter
valuevalue of physical observable

Definition at line 93 of file AverageAnalyzer.tpp.

References outputFile_, and UTIL_CHECK.

Member Data Documentation

◆ outputFile_

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

Output file stream.

Definition at line 96 of file fts/analyzer/AverageAnalyzer.h.

Referenced by output(), outputValue(), and readParameters().

◆ accumulator_

template<int D, class T>
Average Pscf::Rp::AverageAnalyzer< D, T >::accumulator_
protected

Average object.

Definition at line 99 of file fts/analyzer/AverageAnalyzer.h.

Referenced by readParameters(), and setup().


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