PSCF v1.5.0
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 - 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/simulator/Simulator.h>
12#include <pscf/backend/TmplDeclare.h>
13
14#include <util/global.h>
15
16#include <iostream>
17#include <string>
18
19// Forward declaration
20namespace Util {
21 template <class T> class Factory;
22}
23namespace Pscf {
24 namespace Rp {
25 template <int D, class T> class System;
26 template <int D, class T> class BdStep;
27 template <int D, class T> class Analyzer;
28 template <int D, class T> class AnalyzerManager;
29 template <int D, class T> class TrajectoryReader;
30 }
31}
32
33
34namespace Pscf {
35namespace Rp {
36
37 using namespace Util;
38
50 template <int D, class T>
51 class BdSimulator : public Simulator<D,T>
52 {
53
54 public:
55
58
65
70
71 // Prohibit copying or assignment.
72 BdSimulator(BdSimulator<D,T> const &) = delete;
73 BdSimulator<D,T>& operator = (BdSimulator<D,T> const &) = delete;
74
80 virtual void readParameters(std::istream &in);
81
85
94 void simulate(int nStep);
95
109 virtual void analyze(int min, int max,
110 std::string classname,
111 std::string filename);
112
116
120 bool hasBdStep() const;
121
126
131
136
141
143
144 protected:
145
148
151
152 // Inherited protected function (selected)
153 using Simulator<D,T>::state;
154
155 // Inherited protected data members (selected)
156 using Simulator<D,T>::iStep_;
157 using Simulator<D,T>::iTotalStep_;
158
159 private:
160
162 using AnalyzerT = Analyzer<D,T>;
163
167 AnalyzerManager<D,T>* analyzerManagerPtr_;
168
172 BdStep<D,T>* bdStepPtr_;
173
177 Factory< BdStep<D,T> >* bdStepFactoryPtr_;
178
182 Factory< TrajectoryReader<D,T> >* trajectoryReaderFactoryPtr_;
183
184 // Private member function
185
196 void setup(int nStep, bool isSimulation);
197
198 };
199
200 // Inline member functions
201
202 // Does this BdSimulator have a BdStep?
203 template <int D, class T> inline
205 { return (bool)bdStepPtr_; }
206
207 // Get the BdStep.
208 template <int D, class T> inline
210 {
211 UTIL_CHECK(bdStepPtr_);
212 return *bdStepPtr_;
213 }
214
215 // Get the AnalyzerManager (const).
216 template <int D, class T> inline
219 { return *analyzerManagerPtr_; }
220
221 // Get the AnalyzerManager (non-const).
222 template <int D, class T> inline
224 { return *analyzerManagerPtr_; }
225
226 // Explicit instantiation declarations
227 PSCF_TMPL_DECLARE(BdSimulator)
228
229}
230}
231#endif
Manager for a list of Analyzer objects.
Abstract base for periodic output and/or analysis actions.
Definition Analyzer.h:49
Brownian dynamics simulator for PS-FTS.
Definition BdSimulator.h:52
virtual void readParameters(std::istream &in)
Read parameter file block.
BdSimulator< D, T > BdSimulatorT
Alias for BdSimulator class in program-level namespace.
AnalyzerManager< D, T > & analyzerManager()
Get the AnalyzerManager (const).
Simulator< D, T > SimulatorT
Alias for Simulator class in program-level namespace.
BdStep< D, T > & bdStep()
Get the BdStep by non-const reference.
virtual void analyze(int min, int max, std::string classname, std::string filename)
Read and analyze a trajectory file.
BdSimulator(System< D, T > &system)
Constructor.
bool hasBdStep() const
Does this BdSimulator have a BdStep object?
void simulate(int nStep)
Perform a field theoretic Brownian dynamics (BD) simulation.
Factory< TrajectoryReader< D, T > > & trajectoryReaderFactory()
Get the trajectory reader factory by reference.
Template for abstract base class for Brownian dynamics (BD) steps.
Definition BdStep.h:52
Simulator(System< D, T > &system)
Constructor.
Definition Simulator.tpp:53
System< D, T > & system()
Get the parent system by reference.
Definition Simulator.h:944
long iTotalStep_
Step counter - total number of attempted BD or MC steps.
Definition Simulator.h:811
SimState< D, T > & state()
Get the SimState stored internal state by reference.
Definition Simulator.h:1031
long iStep_
Step counter - number of steps for which the compressor converged.
Definition Simulator.h:806
Base class template for classes that represent a complete system.
Trajectory file reader (abstract base class).
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
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.
Utility classes for scientific computation.