PSCF v1.5.0
BdStep.h
1#ifndef RP_BD_STEP_H
2#define RP_BD_STEP_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 <util/param/ParamComposite.h> // base class
12#include <util/global.h>
13#include <pscf/backend/TmplDeclare.h>
14
15// Forward declaration
16namespace Util {
17 class Random;
18}
19namespace Pscf {
20 namespace Rp {
21 template <int D, class T> class System;
22 template <int D, class T> class Simulator;
23 template <int D, class T> class BdSimulator;
24 }
25}
26
27
28namespace Pscf {
29namespace Rp {
30
31 using namespace Util;
32
50 template <int D, class T>
51 class BdStep : public ParamComposite
52 {
53 public:
54
61
62 ~BdStep() = default;
63
64 // Prohibit copying and assignment
65 BdStep(BdStep<D,T> const &) = delete;
66 BdStep<D,T>& operator = (BdStep<D,T> const &) = delete;
67
75 virtual void readParameters(std::istream &in);
76
80 virtual void setup();
81
87 virtual bool step() = 0;
88
96 virtual bool needsCc()
97 { return false; }
98
106 virtual bool needsDc()
107 { return true; }
108
116 virtual void outputTimers(std::ostream& out);
117
123 virtual void clearTimers();
124
130 virtual void output();
131
132 protected:
133
138
143
147 Random& random();
148
153
154 private:
155
157 BdSimulator<D,T>* simulatorPtr_;
158
160 System<D,T>* systemPtr_;
161
163 Random *randomPtr_;
164
166 VecRandom<T> *vecRandomPtr_;
167
168 };
169
170 // Protected inline methods
171
172 /*
173 * Get parent System object.
174 */
175 template <int D, class T> inline
177 { return *systemPtr_; }
178
179 /*
180 * Get parent BdSimulator object.
181 */
182 template <int D, class T> inline
184 { return *simulatorPtr_; }
185
186 /*
187 * Get the scalar random number generator.
188 */
189 template <int D, class T> inline
191 { return *randomPtr_; }
192
193 /*
194 * Get the vector random number generator.
195 */
196 template <int D, class T> inline
198 { return *vecRandomPtr_; }
199
200 // Explicit instantiation declarations
201 PSCF_TMPL_DECLARE(BdStep)
202}
203}
204#endif
Brownian dynamics simulator for PS-FTS.
Definition BdSimulator.h:52
Template for abstract base class for Brownian dynamics (BD) steps.
Definition BdStep.h:52
virtual void setup()
Setup before the beginning of each simulation run.
Definition BdStep.tpp:50
BdStep(BdSimulator< D, T > &simulator)
Constructor.
Definition BdStep.tpp:32
virtual bool needsCc()
Do cc concentration components need to be saved before a step?
Definition BdStep.h:96
virtual void output()
Output statistics for this stepper (after end of simulation).
Definition BdStep.tpp:54
virtual void outputTimers(std::ostream &out)
Output any timing results to ostream.
Definition BdStep.tpp:58
BdSimulator< D, T > & simulator()
Get parent BdSimulator object.
Definition BdStep.h:183
virtual bool step()=0
Take a single Brownian dynamics step.
System< D, T > & system()
Get parent System object.
Definition BdStep.h:176
Random & random()
Get scalar random number generator of parent simulator.
Definition BdStep.h:190
VecRandom< T > & vecRandom()
Get vector random number generator of parent simulator.
Definition BdStep.h:197
virtual bool needsDc()
Do dc derivative components need to be saved before a step?
Definition BdStep.h:106
virtual void readParameters(std::istream &in)
Read required parameters from file.
Definition BdStep.tpp:43
virtual void clearTimers()
Clear timers.
Definition BdStep.tpp:62
BdSimulator< D, T > & simulator()
Get parent BdSimulator object.
Definition BdStep.h:183
System< D, T > & system()
Get parent System object.
Definition BdStep.h:176
VecRandom< T > & vecRandom()
Get vector random number generator of parent simulator.
Definition BdStep.h:197
Base class for field theoretic PS-FTS simulator.
Definition Simulator.h:93
Base class template for classes that represent a complete system.
ParamComposite()
Constructor.
Random number generator.
Definition Random.h:47
File containing preprocessor macros for error handling.
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.
Utility classes for scientific computation.