PSCF v1.5.0
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 - 2026, David Morse (morse012@um.edu) and co-authors
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <rp/fts/analyzer/Analyzer.h> // base class
12#include <util/accumulators/Average.h> // member
13
14#include <pscf/backend/TmplDeclare.h>
15#include <iostream>
16
17namespace Pscf {
18namespace Rp {
19
20 using namespace Util;
21
37 template <int D, class T>
38 class AverageAnalyzer : public Analyzer<D,T>
39 {
40
41 public:
42
43 // Protected constructor and destructor (see below).
44
55 virtual void readParameters(std::istream& in);
56
62 virtual void setup();
63
69 virtual void sample(long iStep);
70
80 virtual void output();
81
89 int nSamplePerOutput() const;
90
91 protected:
92
93 // Protected member functions
94
103
107 ~AverageAnalyzer() = default;
108
112 virtual double compute() = 0;
113
120 virtual void outputValue(int step, double value);
121
122 // Protected member variables
123
125 std::ofstream outputFile_;
126
129
130 private:
131
133 int nSamplePerOutput_;
134
135 using AnalyzerT = Analyzer<D,T>;
136
137 };
138
139 // Inline function
140
141 // Get nSamplePerOutput.
142 template <int D, class T> inline
144 { return nSamplePerOutput_; }
145
146 // Explicit instantiation declarations
147 PSCF_TMPL_DECLARE(AverageAnalyzer)
148
149} // namespace Rp
150} // namespace Pscf
151#endif
Analyzer(Simulator< D, T > &simulator, System< D, T > &system)
Constructor.
Definition Analyzer.tpp:31
Simulator< D, T > & simulator()
Get the parent Simulator by reference.
Definition Analyzer.h:233
System< D, T > & system()
Get the parent System by reference.
Definition Analyzer.h:243
Analyze averages and block averages of a single real variable.
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.
Average accumulator_
Average object.
AverageAnalyzer(Simulator< D, T > &simulator, System< D, T > &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.
Base class for field theoretic PS-FTS simulator.
Definition Simulator.h:93
Base class template for classes that represent a complete system.
Calculates the average and variance of a sampled property.
Definition Average.h:44
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.