PSCF v1.3
rpc/fts/simulator/SimState.tpp
1#ifndef RPC_SIM_STATE_TPP
2#define RPC_SIM_STATE_TPP
3
4/*
5* PSCF - Polymer Self-Consistent Field
6*
7* Copyright 2015 - 2025, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include "SimState.h"
12
13namespace Pscf {
14namespace Rpc {
15
16 using namespace Util;
17 using namespace Pscf::Prdc::Cpu;
18
19 /*
20 * Constructor.
21 */
22 template <int D>
24 : w(),
25 wc(),
26 hamiltonian(0.0),
29 needsCc(false),
30 needsDc(false),
31 needsHamiltonian(false),
32 hasData(false),
33 isAllocated(false)
34 {}
35
36 /*
37 * Destructor.
38 */
39 template <int D>
42
43 /*
44 * Allocate memory for w fields.
45 */
46 template <int D>
47 void SimState<D>::allocate(int nMonomer, IntVec<D> const & dimensions)
48 {
49 w.allocate(nMonomer);
50 wc.allocate(nMonomer);
51 for (int i = 0; i < nMonomer; ++i) {
52 w[i].allocate(dimensions);
53 wc[i].allocate(dimensions);
54 }
55 if (needsCc){
56 cc.allocate(nMonomer);
57 for (int i = 0; i < nMonomer; ++i) {
58 cc[i].allocate(dimensions);
59 }
60 }
61 if (needsDc){
62 dc.allocate(nMonomer-1);
63 for (int i = 0; i < nMonomer - 1; ++i) {
64 dc[i].allocate(dimensions);
65 }
66 }
67 isAllocated = true;
68 }
69
70}
71}
72#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Fields and FFTs for periodic boundary conditions (CPU)
Definition CField.cpp:12
Real periodic fields, SCFT and PS-FTS (CPU).
Definition param_pc.dox:2
PSCF package top-level namespace.
Definition param_pc.dox:1
bool hasData
Does this object currently store data?
double fieldHamiltonian
Quadratic field contribution to Hamiltonian value.
bool needsHamiltonian
True iff Hamiltonian components need to be saved.
DArray< RField< D > > cc
Eigenvector components of c fields on a real space grid.
bool needsDc
True iff dc fields need to be saved.
void allocate(int nMonomer, IntVec< D > const &dimensions)
Allocate memory for fields.
DArray< RField< D > > dc
Functional derivatives of the Hamiltonian on a real space grid.
double idealHamiltonian
Ideal gas contribution to Hamiltonian.
DArray< RField< D > > wc
Chemical potential fields, r-grid format, indexed by eigenvector.
bool needsCc
True iff cc fields need to be saved.
bool isAllocated
Has memory been allocated for the fields?
DArray< RField< D > > w
Chemical potential fields, r-grid format, indexed by monomer.
double hamiltonian
Field theoretic Hamiltonian value (total).