PSCF v1.4.0
fts/brownian/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 - 2025, The Regents of the University of Minnesota
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
14// Forward declaration
15namespace Util {
16 class Random;
17}
18
19namespace Pscf {
20namespace Rp {
21
22 using namespace Util;
23
51 template <int D, class T>
52 class BdStep : public ParamComposite
53 {
54 public:
55
56 // Protected constructor and destructor (see below).
57
58 // Not copyable or assignable.
59 BdStep(BdStep<D,T> const &) = delete;
60 BdStep<D,T>& operator = (BdStep<D,T> const &) = delete;
61
69 virtual void readParameters(std::istream &in);
70
74 virtual void setup();
75
81 virtual bool step() = 0;
82
90 virtual bool needsCc()
91 { return false; }
92
100 virtual bool needsDc()
101 { return true; }
102
110 virtual void outputTimers(std::ostream& out);
111
117 virtual void clearTimers();
118
124 virtual void output();
125
126 protected:
127
133 BdStep(typename T::BdSimulator& simulator);
134
135 ~BdStep() = default;
136
140 typename T::System& system();
141
145 typename T::BdSimulator& simulator();
146
151
155 typename T::VecRandom& vecRandom();
156
157 private:
158
160 typename T::BdSimulator* simulatorPtr_;
161
163 typename T::System* systemPtr_;
164
166 Random *randomPtr_;
167
169 typename T::VecRandom *vecRandomPtr_;
170
171 };
172
173 // Protected inline methods
174
175 /*
176 * Get parent System object.
177 */
178 template <int D, class T> inline
179 typename T::System& BdStep<D,T>::system()
180 { return *systemPtr_; }
181
182 /*
183 * Get parent BdSimulator object.
184 */
185 template <int D, class T> inline
186 typename T::BdSimulator& BdStep<D,T>::simulator()
187 { return *simulatorPtr_; }
188
189 /*
190 * Get the scalar random number generator.
191 */
192 template <int D, class T> inline
194 { return *randomPtr_; }
195
196 /*
197 * Get the vector random number generator.
198 */
199 template <int D, class T> inline
200 typename T::VecRandom& BdStep<D,T>::vecRandom()
201 { return *vecRandomPtr_; }
202
203}
204}
205#endif
Template for abstract base class for Brownian dynamics (BD) steps.
virtual void setup()
Setup before the beginning of each simulation run.
Definition BdStep.tpp:41
T::BdSimulator & simulator()
Get parent BdSimulator object.
virtual bool needsCc()
Do cc concentration components need to be saved before a step?
T::VecRandom & vecRandom()
Get vector random number generator of parent simulator.
T::System & system()
Get parent System object.
virtual void output()
Output statistics for this stepper (after end of simulation).
Definition BdStep.tpp:45
virtual void outputTimers(std::ostream &out)
Output any timing results to ostream.
Definition BdStep.tpp:49
virtual bool step()=0
Take a single Brownian dynamics step.
Random & random()
Get scalar random number generator of parent simulator.
virtual bool needsDc()
Do dc derivative components need to be saved before a step?
virtual void readParameters(std::istream &in)
Read required parameters from file.
Definition BdStep.tpp:34
virtual void clearTimers()
Clear timers.
Definition BdStep.tpp:53
ParamComposite()
Constructor.
Random number generator.
Definition Random.h:47
File containing preprocessor macros for error handling.
Class templates for real-valued periodic fields.
PSCF package top-level namespace.
Utility classes for scientific computation.