PSCF v1.4.0
fts/montecarlo/McMoveManager.h
1#ifndef RP_MC_MOVE_MANAGER_H
2#define RP_MC_MOVE_MANAGER_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/Manager.h> // base class template
12#include <util/containers/DArray.h> // member
13
14// Forward declaration
15namespace Util { class Random; }
16
17namespace Pscf {
18namespace Rp {
19
20 using namespace Util;
21
37 template <int D, class T>
38 class McMoveManager : public Manager< typename T::McMove >
39 {
40
41 public:
42
43 // Protected constructor and destructor (see below).
44
50 virtual void readParameters(std::istream &in);
51
57 void setup();
58
64 typename T::McMove& chooseMove();
65
69 void output() const;
70
77 double probability(int i) const;
78
84 void outputTimers(std::ostream& out) const;
85
89 void clearTimers();
90
94 bool needsCc();
95
99 bool needsDc();
100
101 protected:
102
109 McMoveManager(typename T::McSimulator& simulator,
110 typename T::System& system);
111
115 ~McMoveManager() = default;
116
117 private:
118
119 using McMoveT = typename T::McMove;
120 using Base = Manager< McMoveT >;
121
122 // Private data members
123
127 DArray<double> probabilities_;
128
132 typename T::McSimulator* simulatorPtr_;
133
137 typename T::System* systemPtr_;
138
142 Random* randomPtr_;
143
144 // Private member functions
145
149 virtual Factory< McMoveT >* newDefaultFactory() const;
150
151 };
152
153 // Inline functions
154
155 /*
156 * Return probability of move number i.
157 */
158 template <int D, class T> inline
160 {
161 assert(i >= 0);
162 assert(i < Base::size());
163 return probabilities_[i];
164 }
165
166}
167}
168#endif
void outputTimers(std::ostream &out) const
Write timing results to an output stream.
void output() const
Output statistics for all moves.
bool needsCc()
Decide whether any move needs to store cc fields.
double probability(int i) const
Return probability of move i.
virtual void readParameters(std::istream &in)
Read instructions for creating McMove objects.
~McMoveManager()=default
Destructor.
McMoveManager(typename T::McSimulator &simulator, typename T::System &system)
Constructor.
void clearTimers()
Clear timers.
void setup()
Initialize at beginning of system run.
bool needsDc()
Decide whether any move needs to store dc fields.
T::McMove & chooseMove()
Choose an McMove at random, using specified probabilities.
Dynamically allocatable contiguous array template.
Definition DArray.h:32
Factory template.
Definition Factory.h:34
virtual Factory< T::McMove > * newDefaultFactory() const
Definition Manager.h:541
Manager(bool uniqueNames=false)
Definition Manager.h:232
Random number generator.
Definition Random.h:47
Class templates for real-valued periodic fields.
PSCF package top-level namespace.
Utility classes for scientific computation.