PSCF v1.3
rpc/fts/analyzer/TrajectoryWriter.h
1#ifndef RPC_TRAJECTORY_WRITER_H
2#define RPC_TRAJECTORY_WRITER_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 "Analyzer.h"
12#include <util/global.h>
13
14namespace Pscf {
15namespace Rpc {
16
17 template <int D> class System;
18 template <int D> class Simulator;
19
20 using namespace Util;
21
29 template <int D>
30 class TrajectoryWriter : public Analyzer<D>
31 {
32
33 public:
34
39
44 {}
45
51 virtual void readParameters(std::istream& in);
52
56 virtual void setup();
57
63 virtual void sample(long iStep);
64
68 virtual void output();
69
70 protected:
71
76
85 void writeHeader(std::ofstream& out);
86
93 void writeFrame(std::ofstream& out, long iStep);
94
99
104
105 private:
106
107 // Output file stream
108 std::ofstream outputFile_;
109
110 // Output filename
111 std::string filename_;
112
114 long nSample_;
115
117 long isInitialized_;
118
122 Simulator<D>* simulatorPtr_;
123
127 System<D>* systemPtr_;
128
129
130 };
131
132 // Get the parent system.
133 template <int D>
135 { return *systemPtr_; }
136
137 //Get parent Simulator object.
138 template <int D>
140 { return *simulatorPtr_; }
141
142 #ifndef RPC_TRAJECTORY_WRITER_TPP
143 // Suppress implicit instantiation
144 extern template class TrajectoryWriter<1>;
145 extern template class TrajectoryWriter<2>;
146 extern template class TrajectoryWriter<3>;
147 #endif
148
149}
150}
151#endif
Abstract base for periodic output and/or analysis actions.
bool isAtInterval(long counter) const
Return true iff counter is a multiple of the interval.
const std::string & outputFileName() const
Return outputFileName string.
Analyzer()
Default constructor.
Field theoretic simulator (base class).
Main class, representing one complete system.
Periodically write snapshots to a trajectory file.
virtual void readParameters(std::istream &in)
Read interval and output file name.
Simulator< D > & simulator()
Return reference to parent Simulator.
void writeHeader(std::ofstream &out)
Write data that should appear once, at beginning of the file.
virtual void output()
Close trajectory file after run.
void writeFrame(std::ofstream &out, long iStep)
Write data that should appear in every frame.
TrajectoryWriter(Simulator< D > &simulator, System< D > &system)
Constructor.
virtual void setup()
Clear nSample counter.
System< D > & system()
Return reference to parent system.
virtual void sample(long iStep)
Write a frame/snapshot to trajectory file.
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
void setClassName(const char *className)
Set class name string.
File containing preprocessor macros for error handling.
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.
Definition param_pc.dox:1