PSCF v1.4.0
SimulatorFactory.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 "SimulatorFactory.h"
9//#include <rpc/system/System.h>
10
11// Subclasses of Simulator
12#include <rpc/fts/montecarlo/McSimulator.h>
13#include <rpc/fts/brownian/BdSimulator.h>
14
15namespace Pscf {
16namespace Rpc {
17
18 using namespace Util;
19
20 /*
21 * Constructor
22 */
23 template <int D>
25 : systemPtr_(&system)
26 {}
27
28 /*
29 * Return a pointer to a instance of Simulator subclass className.
30 */
31 template <int D>
32 Simulator<D>* SimulatorFactory<D>::factory(const std::string &className)
33 const
34 {
35 Simulator<D>* ptr = 0;
36
37 // Try subfactories first
38 ptr = trySubfactories(className);
39 if (ptr) return ptr;
40
41 // Try to match classname
42 if (className == "McSimulator" || className == "Simulator") {
43 ptr = new McSimulator<D>(*systemPtr_);
44 } else
45 if (className == "BdSimulator") {
46 ptr = new BdSimulator<D>(*systemPtr_);
47 }
48
49 return ptr;
50 }
51
52 // Explicit instantiation definitions
53 template class SimulatorFactory<1>;
54 template class SimulatorFactory<2>;
55 template class SimulatorFactory<3>;
56
57}
58}
Brownian dynamics simulator for PS-FTS.
Monte Carlo simulator for PS-FTS.
Factory for subclasses of Simulator.
Simulator< D > * factory(const std::string &className) const
Method to create any Simulator supplied with PSCF.
SimulatorFactory(System< D > &system)
Constructor.
Field theoretic simulator (base class).
A complete physical system.
Simulator< 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.