PSCF v1.4.0
McMoveFactory.cpp
1/*
2* PSCF - Polymer Self-Consistent Field
3*
4* Copyright 2015 - 2025, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "McMoveFactory.h"
9//#include <rpc/fts/montecarlo/McSimulator.h>
10
11// Subclasses of McMove
12#include "RealMove.h"
13#include "ForceBiasMove.h"
14#include "BdMove.h"
15#include "ShiftMove.h"
16
17namespace Pscf {
18namespace Rpc {
19
20 using namespace Util;
21
22 /*
23 * Constructor
24 */
25 template <int D>
27 : simulatorPtr_(&simulator)
28 {}
29
30 /*
31 * Return a pointer to a instance of McMove subclass className.
32 */
33 template <int D>
34 McMove<D>* McMoveFactory<D>::factory(const std::string &className) const
35 {
36 McMove<D>* ptr = 0;
37
38 // Try subfactories first
39 ptr = trySubfactories(className);
40 if (ptr) return ptr;
41
42 // Try to match classname
43 if (className == "RealMove") {
44 ptr = new RealMove<D>(*simulatorPtr_);
45 } else if (className == "ForceBiasMove") {
46 ptr = new ForceBiasMove<D>(*simulatorPtr_);
47 } else if (className == "BdMove") {
48 ptr = new BdMove<D>(*simulatorPtr_);
49 } else if (className == "ShiftMove") {
50 ptr = new ShiftMove<D>(*simulatorPtr_);
51 }
52
53 return ptr;
54 }
55
56 // Explicit instantiation definitions
57 template class McMoveFactory<1>;
58 template class McMoveFactory<2>;
59 template class McMoveFactory<3>;
60}
61}
Brownian dynamics Monte-Carlo move.
ForceBiasMove attempts a Brownian dynamics move.
Factory for subclasses of McMove.
McMoveFactory(McSimulator< D > &simulator)
Constructor.
McMove< D > * factory(const std::string &className) const
Method to create any McMove supplied with PSCF.
McMove is an abstract base class for Monte Carlo moves.
Monte Carlo simulator for PS-FTS.
RealMove generates spatially uncorrelated random field changes.
ShiftMove shifts field.
McMove< D > * trySubfactories(const std::string &className) const
Definition Factory.h:425
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.