PSCF v1.4.0
fts/brownian/BdSimulator.h
1#ifndef RP_BD_SIMULATOR_H
2#define RP_BD_SIMULATOR_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/global.h>
12#include <iostream>
13#include <string>
14
15// Forward declaration
16namespace Util {
17 template <class T> class Factory;
18}
19
20namespace Pscf {
21namespace Rp {
22
23 using namespace Util;
24
41 template <int D, class T>
42 class BdSimulator : public T::Simulator
43 {
44
45 public:
46
47 // Protected constructor and destructor (see below).
48
49 // Not copyable or assignable.
50 BdSimulator(BdSimulator<D,T> const &) = delete;
51 BdSimulator<D,T>& operator = (BdSimulator<D,T> const &) = delete;
52
55
61 virtual void readParameters(std::istream &in);
62
66
75 void simulate(int nStep);
76
90 virtual void analyze(int min, int max,
91 std::string classname,
92 std::string filename);
93
97
101 bool hasBdStep() const;
102
106 typename T::BdStep& bdStep();
107
111 typename T::AnalyzerManager& analyzerManager();
112
116 typename T::AnalyzerManager const& analyzerManager() const;
117
122
124
125 protected:
126
128 using SystemT = typename T::System;
129
131 using SimulatorT = typename T::Simulator;
132
134 using BdSimulatorT = typename T::BdSimulator;
135
142 BdSimulator(SystemT& system, BdSimulatorT& bdSimulator);
143
147 ~BdSimulator();
148
149 // Inherited protected function (selected)
150 using SimulatorT::state;
151
152 // Inherited protected data members (selected)
153 using SimulatorT::iStep_;
154 using SimulatorT::iTotalStep_;
155
156 private:
157
159 using AnalyzerT = typename T::Analyzer;
160
164 typename T::AnalyzerManager* analyzerManagerPtr_;
165
169 typename T::BdStep* bdStepPtr_;
170
174 Factory< typename T::BdStep >* bdStepFactoryPtr_;
175
179 Factory< typename T::TrajectoryReader >* trajectoryReaderFactoryPtr_;
180
181 // Private member function
182
188 void setup(int nStep);
189
190 };
191
192 // Inline member functions
193
194 // Does this BdSimulator have a BdStep?
195 template <int D, class T> inline
197 { return (bool)bdStepPtr_; }
198
199 // Get the BdStep.
200 template <int D, class T> inline
201 typename T::BdStep& BdSimulator<D,T>::bdStep()
202 {
203 UTIL_CHECK(bdStepPtr_);
204 return *bdStepPtr_;
205 }
206
207 // Get the AnalyzerManager (const).
208 template <int D, class T> inline
209 typename T::AnalyzerManager const&
211 { return *analyzerManagerPtr_; }
212
213 // Get the AnalyzerManager (non-const).
214 template <int D, class T> inline
215 typename T::AnalyzerManager& BdSimulator<D,T>::analyzerManager()
216 { return *analyzerManagerPtr_; }
217
218}
219}
220#endif
virtual void readParameters(std::istream &in)
Read parameter file block.
T::BdStep & bdStep()
Get the BdStep by non-const reference.
T::AnalyzerManager & analyzerManager()
Get the AnalyzerManager (const).
typename T::BdSimulator BdSimulatorT
Alias for BdSimulator class in program-level namespace.
Factory< typename T::TrajectoryReader > & trajectoryReaderFactory()
Get the trajectory reader factory by reference.
~BdSimulator()
Destructor.
typename T::System SystemT
Alias for System class in program-level namespace.
virtual void analyze(int min, int max, std::string classname, std::string filename)
Read and analyze a trajectory file.
typename T::Simulator SimulatorT
Alias for Simulator class in program-level namespace.
bool hasBdStep() const
Does this BdSimulator have a BdStep object?
void simulate(int nStep)
Perform a field theoretic Brownian dynamics (BD) simulation.
Factory template.
Definition Factory.h:34
File containing preprocessor macros for error handling.
#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.
Utility classes for scientific computation.