PSCF v1.5.0
TrajectoryWriter.h
1#ifndef RP_TRAJECTORY_WRITER_H
2#define RP_TRAJECTORY_WRITER_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 template
12
13#include <iostream>
14#include <fstream>
15
16namespace Pscf {
17namespace Rp {
18
30 template <int D, class T>
31 class TrajectoryWriter : public Analyzer<D,T>
32 {
33
34 public:
35
44
48 ~TrajectoryWriter() = default;
49
55 void readParameters(std::istream& in) override;
56
60 void setup() override;
61
67 void sample(long iStep) override;
68
72 void output() override;
73
74 protected:
75
81 void writeHeader(std::ofstream& out);
82
89 void writeFrame(std::ofstream& out, long iStep);
90
91 private:
92
94 std::ofstream outputFile_;
95
97 long nSample_;
98
100 long isInitialized_;
101
102 // Inherited protected member functions (selected).
103 using Analyzer<D,T>::simulator;
104 using Analyzer<D,T>::system;
105 };
106
107}
108}
109#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
Base class for field theoretic PS-FTS simulator.
Definition Simulator.h:93
Base class template for classes that represent a complete system.
void setup() override
Setup before main simulation loop.
~TrajectoryWriter()=default
Destructor.
void output() override
Close trajectory file after run.
TrajectoryWriter(Simulator< D, T > &simulator, System< D, T > &system)
Constructor.
void writeFrame(std::ofstream &out, long iStep)
Write data that should appear in every frame.
void readParameters(std::istream &in) override
Read interval and output file name.
void sample(long iStep) override
Write a frame/snapshot to the trajectory file.
void writeHeader(std::ofstream &out)
Write data that should appear once, at beginning of the file.
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.