1#ifndef RPG_AVERAGE_ANALYZER_TPP
2#define RPG_AVERAGE_ANALYZER_TPP
11#include "AverageAnalyzer.h"
13#include <rpg/system/System.h>
14#include <rpg/fts/simulator/Simulator.h>
16#include <util/format/Int.h>
17#include <util/format/Dbl.h>
18#include <util/misc/FileMaster.h>
19#include <util/misc/ioUtil.h>
55 nSamplePerOutput_ = 1;
57 if (nSamplePerOutput_ > 0) {
59 system().fileMaster().openOutputFile(fileName, outputFile_);
86 if (nSamplePerOutput_ > 0) {
88 int beginStep = iStep - (nSamplePerOutput_ - 1)*
interval();
103 outputFile_ <<
Int(step);
104 outputFile_ <<
Dbl(value);
115 if (outputFile_.is_open()) {
118 std::string fileName;
123 system().fileMaster().openOutputFile(fileName, outputFile_);
130 system().fileMaster().openOutputFile(fileName, outputFile_);
132 outputFile_ <<
"Average = ";
133 outputFile_ <<
Dbl(ave);
136 outputFile_ <<
" +- " <<
Dbl(err, 10, 3);
145 "-------------------------------------------------------------------";
146 outputFile_ << line << std::endl;
148 outputFile_ << std::endl;
virtual void readParameters(std::istream &in)
Read parameters from archive.
const std::string & outputFileName() const
Return outputFileName string.
Analyzer()
Default constructor.
int interval() const
Get interval value.
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
Average accumulator_
Average object.
virtual void readParameters(std::istream &in)
Read interval, outputFileName and (optionally) nSamplePerOutput.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
virtual void sample(long iStep)
Compute a sampled value and update the accumulator.
AverageAnalyzer(Simulator< D > &simulator, System< D > &system)
Constructor.
virtual double compute()=0
Compute value of sampled quantity.
virtual void setup()
Setup before loop.
virtual void outputValue(int step, double value)
Output a sampled or block average value.
virtual ~AverageAnalyzer()
Destructor.
Simulator< D > & simulator()
Return reference to parent simulator.
System< D > & system()
Return reference to parent system.
virtual void output()
Write final results to file after a simulation.
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.
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.