1#ifndef RPC_AVERAGE_LIST_ANALYZER_TPP
2#define RPC_AVERAGE_LIST_ANALYZER_TPP
11#include "AverageListAnalyzer.h"
13#include <rpc/system/System.h>
14#include <util/format/Int.h>
15#include <util/format/Dbl.h>
16#include <util/misc/FileMaster.h>
17#include <util/misc/ioUtil.h>
36 hasAccumulators_(false)
53 nSamplePerOutput_ = 1;
130 accumulators_.allocate(
nValue);
134 hasAccumulators_ =
true;
138 for (
int i = 0; i < nValue_; ++i) {
139 accumulators_[i].setNSamplePerBlock(nSamplePerOutput_);
153 for (
int i = 0; i < nValue_; ++i) {
154 accumulators_[i].clear();
165 UTIL_CHECK(accumulators_.capacity() == nValue_);
168 for (
int i = 0; i <
nValue(); ++i) {
169 double data =
value(i);
170 accumulators_[i].sample(data);
174 if (nSamplePerOutput_ > 0) {
175 if (accumulators_[0].isBlockComplete()) {
177 int beginStep = iStep - (nSamplePerOutput_ - 1)*
interval();
179 for (
int i = 0; i <
nValue(); ++i) {
180 UTIL_CHECK(accumulators_[i].isBlockComplete());
181 double block = accumulators_[i].blockAverage();
206 for (
int i = 0; i < nValue_; ++i) {
207 length = names_[i].length();
208 if (length > nameWidth) {
218 for (
int i = 0; i < nValue_; ++i) {
219 ave = accumulators_[i].average();
220 err = accumulators_[i].blockingError();
221 outputFile_ <<
" " << std::left << std::setw(nameWidth)
232 "---------------------------------------------------------------------";
233 for (
int i = 0; i < nValue_; ++i) {
248 for (
int i = 0; i < nValue_; ++i) {
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
virtual void readParameters(std::istream &in)
Read parameters from archive.
const std::string & outputFileName() const
Return outputFileName string.
int interval() const
Get interval value.
Analyzer()
Default constructor.
void updateAccumulators(long iStep)
Add current value to accumulator, output block average if needed.
void clearAccumulators()
Clear internal state of all accumulators.
std::ofstream outputFile_
Output file stream.
int nSamplePerOutput() const
Get value of nSamplePerOutput.
AverageListAnalyzer(Simulator< D > &simulator, System< D > &system)
Constructor.
void initializeAccumulators(int nValue)
Instantiate Average accumulators and set nValue.
virtual void setup()
Setup before loop.
virtual void output()
Write final results to file after a simulation.
double value(int i) const
Get current value of a specific variable.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
const std::string & name(int i) const
Get name associated with value.
int nValue() const
Get number of variables.
System< D > & system()
Return reference to parent system.
virtual void compute()=0
Compute value of sampled quantities.
void setName(int i, std::string name)
Set name of variable.
virtual void sample(long iStep)
Compute a sampled value and update the accumulator.
virtual ~AverageListAnalyzer()
Destructor.
void outputAccumulators()
Write results of statistical analysis to files.
Simulator< D > & simulator()
Return reference to parent Simulator.
virtual void readParameters(std::istream &in)
Read interval, outputFileName and (optionally) nSamplePerOutput.
Field theoretic simulator (base class).
Main class, representing one complete system.
Wrapper for a double precision number, for formatted ostream output.
Wrapper for an int, for formatted ostream output.
virtual void writeParam(std::ostream &out) const
Write all parameters to an output stream.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Real periodic fields, SCFT and PS-FTS (CPU).
PSCF package top-level namespace.