PSCF v1.4.0
AnalyzerManager.tpp
1#ifndef RP_ANALYZER_MANAGER_TPP
2#define RP_ANALYZER_MANAGER_TPP
3
4#include "AnalyzerManager.h"
5#include <util/param/Factory.h>
6#include <util/param/ParamComposite.h>
7
8namespace Pscf {
9namespace Rp {
10
11 using namespace Util;
12
13 /*
14 * Constructor.
15 */
16 template <int D, class T>
17 AnalyzerManager<D,T>::AnalyzerManager(typename T::Simulator& simulator,
18 typename T::System& system)
19 : Base(),
20 simulatorPtr_(&simulator),
21 systemPtr_(&system)
22 { ParamComposite::setClassName("AnalyzerManager"); }
23
24 /*
25 * Return a pointer to a new AnalyzerFactory object.
26 */
27 template <int D, class T>
29 const
30 { return new AnalyzerFactoryT(*simulatorPtr_, *systemPtr_); }
31
32 /*
33 * Read body of parameter file block.
34 */
35 template <int D, class T>
37 {
38 AnalyzerT::baseInterval = 1;
39 ParamComposite::readOptional(in, "baseInterval",
40 AnalyzerT::baseInterval);
42 }
43
44 /*
45 * Call setup method of each analyzer.
46 */
47 template <int D, class T>
49 {
50 for (int i = 0; i < Base::size(); ++i) {
51 (*this)[i].setup();
52 }
53 }
55 /*
56 * Call sample method of each analyzer.
57 */
58 template <int D, class T>
60 {
61 int baseInterval = AnalyzerT::baseInterval;
62 UTIL_CHECK(baseInterval > 0);
63 UTIL_CHECK(iStep % baseInterval == 0);
64 for (int i = 0; i < Base::size(); ++i) {
65 (*this)[i].sample(iStep);
66 }
67 }
68
69 /*
70 * Call output method of each analyzer.
71 */
72 template <int D, class T>
74 {
75 for (int i = 0; i < Base::size(); ++i) {
76 (*this)[i].output();
77 }
78 }
79
80}
81}
82#endif
void sample(long iStep)
Call the sample function of each Analyzer.
AnalyzerManager(typename T::Simulator &simulator, typename T::System &system)
Constructor.
void readParameters(std::istream &in) override
Read body of parameter file block.
void setup()
Call the setup function of each Analyzer.
void output()
Call the output function of each analyzer.
Factory template.
Definition Factory.h:34
virtual Factory< T::Analyzer > * newDefaultFactory() const
Definition Manager.h:541
virtual void readParameters(std::istream &in)
void setClassName(const char *className)
Set class name string.
ScalarParam< Type > & readOptional(std::istream &in, const char *label, Type &value)
Add and read a new optional ScalarParam < Type > object.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Class templates for real-valued periodic fields.
PSCF package top-level namespace.