PSCF v1.2
FieldGenerator.cpp
1/*
2* PSCF - Polymer Self-Consistent Field Theory
3*
4* Copyright 2016 - 2022, The Regents of the University of Minnesota
5* Distributed under the terms of the GNU General Public License.
6*/
7
8#include "FieldGenerator.h"
9
10namespace Pscf
11{
12
13 // Constructor
15 : type_(None),
16 isDependent_(false)
17 {}
18
19 // Destructor
22
23 // Allocate, check compatibility, calculate, and store the field(s)
25 {
26 allocate();
28 if (!isGenerated()) {
29 generate();
30 } else {
31 update();
32 }
33 }
34
35 // Check whether system has changed and update the field(s) if necessary
37 {
38 bool needed = updateNeeded();
39 if (!needed) {
40 // update not needed, do nothing
41 return;
42 } else {
43 generate();
44 }
45 }
46
47}
virtual void checkCompatibility()=0
Check that the system is compatible with these fields.
FieldGenerator()
Constructor.
void setup()
Allocate, check compatibility, calculate, and store the field(s)
~FieldGenerator()
Destructor.
virtual bool isGenerated() const =0
Check whether the field(s) have been generated.
virtual void generate()=0
Generate the field(s) and store where the Iterator can access.
void update()
Check whether system has changed and update the field(s) if necessary.
virtual void allocate()=0
Allocate container(s) necessary to generate and store field(s)
virtual bool updateNeeded() const =0
Check whether system has changed such that the field(s) need updating.
PSCF package top-level namespace.
Definition param_pc.dox:1