PSCF v1.4.0
SimState.tpp
1#ifndef RP_SIM_STATE_TPP
2#define RP_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#include <pscf/math/IntVec.h>
13
14namespace Pscf {
15namespace Rp {
16
17 /*
18 * Constructor.
19 */
20 template <int D, class FT>
22 : w(),
23 wc(),
24 hamiltonian(0.0),
27 needsCc(false),
28 needsDc(false),
29 needsHamiltonian(false),
30 hasData(false),
31 isAllocated(false)
32 {}
33
34 /*
35 * Allocate memory for w fields.
36 */
37 template <int D, class FT>
38 void SimState<D,FT>::allocate(int nMonomer, IntVec<D> const & dimensions)
39 {
40 w.allocate(nMonomer);
41 wc.allocate(nMonomer);
42 for (int i = 0; i < nMonomer; ++i) {
43 w[i].allocate(dimensions);
44 wc[i].allocate(dimensions);
45 }
46 if (needsCc){
47 cc.allocate(nMonomer);
48 for (int i = 0; i < nMonomer; ++i) {
49 cc[i].allocate(dimensions);
50 }
51 }
52 if (needsDc){
53 dc.allocate(nMonomer-1);
54 for (int i = 0; i < nMonomer - 1; ++i) {
55 dc[i].allocate(dimensions);
56 }
57 }
58 isAllocated = true;
59 }
60
61}
62}
63#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Class templates for real-valued periodic fields.
PSCF package top-level namespace.
DArray< FT > w
Chemical potential fields, r-grid format, indexed by monomer.
DArray< FT > cc
Eigenvector components of c fields on a real space grid.
bool needsCc
True iff cc fields need to be saved.
DArray< FT > wc
Chemical potential fields, r-grid format, indexed by eigenvector.
double idealHamiltonian
Ideal gas contribution to Hamiltonian.
bool hasData
Does this object currently store data?
double fieldHamiltonian
Quadratic field contribution to Hamiltonian value.
DArray< FT > dc
Functional derivatives of the Hamiltonian on a real space grid.
void allocate(int nMonomer, IntVec< D > const &dimensions)
Allocate memory for stored fields.
Definition SimState.tpp:38
bool isAllocated
Has memory been allocated for the fields?
bool needsHamiltonian
True iff Hamiltonian components need to be saved.
SimState()
Constructor.
Definition SimState.tpp:21
double hamiltonian
Field theoretic Hamiltonian value (total).
bool needsDc
True iff dc fields need to be saved.