PSCF v1.5.0
McMoveFactory.tpp
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2026, David Morse (morse012@um.edu) and co-authors
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "McMoveFactory.h"
9
10#include <rp/fts/montecarlo/McSimulator.h>
11
12// Subclasses of McMove
13#include <rp/fts/montecarlo/RealMove.h>
14#include <rp/fts/montecarlo/ForceBiasMove.h>
15#include <rp/fts/montecarlo/BdMove.h>
16#include <rp/fts/montecarlo/ShiftMove.h>
17
18namespace Pscf {
19namespace Rp {
20
21 using namespace Util;
22
23 /*
24 * Constructor
25 */
26 template <int D, class T>
28 : simulatorPtr_(&simulator)
29 {}
30
31 /*
32 * Return a pointer to a instance of McMove subclass className.
33 */
34 template <int D, class T>
36 McMoveFactory<D,T>::factory(const std::string &className) const
37 {
38 McMove<D,T>* ptr = 0;
39
40 // Try subfactories first
41 ptr = trySubfactories(className);
42 if (ptr) return ptr;
43
44 // Try to match classname
45 if (className == "RealMove") {
46 ptr = new RealMove<D,T>(*simulatorPtr_);
47 } else if (className == "ForceBiasMove") {
48 ptr = new ForceBiasMove<D,T>(*simulatorPtr_);
49 } else if (className == "BdMove") {
50 ptr = new BdMove<D,T>(*simulatorPtr_);
51 } else if (className == "ShiftMove") {
52 ptr = new ShiftMove<D,T>(*simulatorPtr_);
53 }
54
55 return ptr;
56 }
57
58}
59}
BdMove(McSimulator< D, T > &simulator)
Constructor.
Definition BdMove.tpp:35
McMoveFactory(McSimulator< D, T > &simulator)
Constructor.
McMove< D, T > * factory(const std::string &className) const
Method to create any McMove supplied with PSCF.
McMove is an abstract base class for Monte Carlo moves.
Definition McMove.h:50
Monte-Carlo simulation coordinator.
Definition McSimulator.h:55
RealMove(McSimulator< D, T > &simulator)
Constructor.
Definition RealMove.tpp:32
McMove< D, T > * trySubfactories(const std::string &className) const
Definition Factory.h:427
Code for programs that simulate real-valued periodic fields.
Definition param_pc.dox:2
PSCF package top-level namespace.