PSCF v1.4.0
SimulatorFactory.cu
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 <rpg/system/System.h>
10
11// Subclasses of Simulator
12#include <rpg/fts/montecarlo/McSimulator.h>
13#include <rpg/fts/brownian/BdSimulator.h>
14
15namespace Pscf {
16namespace Rpg {
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
53 // Explicit instantiation definitions
54 template class SimulatorFactory<1>;
55 template class SimulatorFactory<2>;
56 template class SimulatorFactory<3>;
57
58}
59}
Brownian dynamics simulator for PS-FTS.
Monte Carlo simulator for PS-FTS.
Factory for subclasses of Simulator.
SimulatorFactory(System< D > &system)
Constructor.
Simulator< D > * factory(const std::string &className) const
Method to create any Simulator supplied with PSCF.
Field theoretic simulator (base class).
Main class, representing a complete physical system.
Simulator< D > * trySubfactories(const std::string &className) const
Definition Factory.h:425
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.