PSCF v1.5.0
IteratorFactory.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 "IteratorFactory.h"
9
10// Subclasses of Iterator
11#include <rp/scft/iterator/AmIteratorBasis.h>
12#include <rp/scft/iterator/AmIteratorGrid.h>
13
14namespace Pscf {
15namespace Rp {
16
17 using namespace Util;
18
19 /*
20 * Constructor
21 */
22 template <int D, class T>
24 : sysPtr_(&system)
25 {}
26
27 /*
28 * Return a pointer to a instance of Iterator subclass className.
29 */
30 template <int D, class T>
32 IteratorFactory<D,T>::factory(const std::string &className) const
33 {
34 Iterator<D,T>* ptr = nullptr;
35
36 // Try subfactories first
37 ptr = trySubfactories(className);
38 if (ptr) return ptr;
39
40 // Try to match classname
41 if (className == "Iterator" || className == "AmIteratorBasis"
42 || className == "AmIterator" ) {
43 ptr = new AmIteratorBasis<D,T>(*sysPtr_);
44 } else
45 if (className == "AmIteratorGrid") {
46 ptr = new AmIteratorGrid<D,T>(*sysPtr_);
47 }
48
49 return ptr;
50 }
51
52}
53}
AmIteratorBasis(System< D, T > &system)
Constructor.
AmIteratorGrid(System< D, T > &system)
Constructor.
IteratorFactory(System< D, T > &system)
Constructor.
Iterator< D, T > * factory(const std::string &className) const
Create an instance of a specified subclass of Iterator<D,T>.
Base class template for iterative solvers for SCF equations.
Base class template for classes that represent a complete system.
Iterator< 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.