PSCF v1.4.0
EnvironmentFactory.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 "EnvironmentFactory.h"
9#include "FilmEnvironment.h"
10
11namespace Pscf {
12namespace Rpc {
13
14 using namespace Util;
15
16 /*
17 * Constructor
18 */
19 template <int D>
21 : sysPtr_(&system)
22 {}
23
24 /*
25 * Return a pointer to a instance of Environment subclass className.
26 */
27 template <int D>
29 EnvironmentFactory<D>::factory(std::string const& className) const
30 {
31 Environment* ptr = nullptr;
32
33 // Try subfactories first
34 ptr = trySubfactories(className);
35 if (ptr) return ptr;
36
37 // Try to match classname
38 if (className == "FilmEnvironment") {
39 ptr = new FilmEnvironment<D>(*sysPtr_);
40 }
41
42 return ptr;
43 }
44
45}
46}
47
48// Explicit instantiation definitions
49namespace Pscf {
50namespace Rpc {
51 template class EnvironmentFactory<1>;
52 template class EnvironmentFactory<2>;
53 template class EnvironmentFactory<3>;
54}
55}
Base class mask and external field generator for variable-cell SCFT.
Definition Environment.h:59
Environment * factory(const std::string &className) const
Method to create any Environment supplied with PSCF.
EnvironmentFactory(System< D > &system)
Constructor.
Class defining mask & external fields for thin-film systems.
A complete physical system.
Environment * 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.