PSCF v1.1
pspg/iterator/IteratorFactory.tpp
1#ifndef PSPG_ITERATOR_FACTORY_TPP
2#define PSPG_ITERATOR_FACTORY_TPP
3
4#include "IteratorFactory.h"
5
6// Subclasses of Iterator
7#include "AmIteratorBasis.h"
8#include "AmIteratorGrid.h"
9
10namespace Pscf {
11namespace Pspg {
12
13 using namespace Util;
14
15 /*
16 * Constructor
17 */
18 template <int D>
20 : sysPtr_(&system)
21 {}
22
23 /*
24 * Return a pointer to a instance of Iterator subclass className.
25 */
26 template <int D>
27 Iterator<D>* IteratorFactory<D>::factory(const std::string &className) const
28 {
29 Iterator<D>* ptr = 0;
30
31 // Try subfactories first
32 ptr = trySubfactories(className);
33 if (ptr) return ptr;
34
35 // Try to match classname
36 if (className == "Iterator" || className == "AmIteratorBasis") {
37 ptr = new AmIteratorBasis<D>(*sysPtr_);
38 } else
39 if (className == "AmIteratorGrid") {
40 ptr = new AmIteratorGrid<D>(*sysPtr_);
41 }
42
43 return ptr;
44 }
45
46}
47}
48#endif
Pspg implementation of the Anderson Mixing iterator.
Pspg implementation of the Anderson Mixing iterator.
IteratorFactory(System< D > &system)
Constructor.
Iterator< D > * factory(const std::string &className) const
Method to create any Iterator supplied with PSCF.
Base class for iterative solvers for SCF equations.
Main class in SCFT simulation of one system.
Definition: pspg/System.h:71
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1