PSCF v1.4.0
fts/analyzer/AverageAnalyzer.h
1#ifndef RP_AVERAGE_ANALYZER_H
2#define RP_AVERAGE_ANALYZER_H
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <util/accumulators/Average.h> // member
12#include <iostream>
13
14namespace Pscf {
15namespace Rp {
16
17 using namespace Util;
18
39 template <int D, class T>
40 class AverageAnalyzer : public T::Analyzer
41 {
42
43 public:
44
45 // Protected constructor and destructor (see below).
46
57 virtual void readParameters(std::istream& in);
58
64 virtual void setup();
65
71 virtual void sample(long iStep);
72
82 virtual void output();
83
91 int nSamplePerOutput() const;
92
93 protected:
94
96 std::ofstream outputFile_;
97
100
101 // Protected member functions
102
109 AverageAnalyzer(typename T::Simulator& simulator,
110 typename T::System& system);
111
115 ~AverageAnalyzer() = default;
116
120 virtual double compute() = 0;
121
128 virtual void outputValue(int step, double value);
129
130 private:
131
133 int nSamplePerOutput_;
134
135 using AnalyzerT = typename T::Analyzer;
136
137 };
138
139 // Inline functions
140
141 // Get nSamplePerOutput.
142 template <int D, class T> inline
144 { return nSamplePerOutput_; }
145
146}
147}
148#endif
int nSamplePerOutput() const
Get value of nSamplePerOutput.
~AverageAnalyzer()=default
Destructor.
virtual void outputValue(int step, double value)
Output a sampled or block average value.
virtual void sample(long iStep)
Compute a sampled value and update the accumulator.
virtual void readParameters(std::istream &in)
Read interval, outputFileName and (optionally) nSamplePerOutput.
AverageAnalyzer(typename T::Simulator &simulator, typename T::System &system)
Constructor.
virtual void output()
Write final results to file after a simulation.
std::ofstream outputFile_
Output file stream.
virtual void setup()
Setup before loop.
virtual double compute()=0
Compute value of sampled quantity.
Calculates the average and variance of a sampled property.
Definition Average.h:44
Class templates for real-valued periodic fields.
PSCF package top-level namespace.