PSCF v1.3
rpg/fts/simulator/SimState.tpp
1#ifndef RPG_SIM_STATE_TPP
2#define RPG_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 Rpg {
15
16 using namespace Util;
17 using namespace Pscf::Prdc::Cuda;
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
56 if (needsCc){
57 cc.allocate(nMonomer);
58 for (int i = 0; i < nMonomer; ++i) {
59 cc[i].allocate(dimensions);
60 }
61 }
62 if (needsDc){
63 dc.allocate(nMonomer-1);
64 for (int i = 0; i < nMonomer - 1; ++i) {
65 dc[i].allocate(dimensions);
66 }
67 }
68
69 isAllocated = true;
70 }
71
72}
73}
74#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Fields, FFTs, and utilities for periodic boundary conditions (CUDA)
Definition Reduce.cpp:14
SCFT and PS-FTS with real periodic fields (GPU)
PSCF package top-level namespace.
Definition param_pc.dox:1
bool needsDc
If dc fields needs to be saved.
bool isAllocated
Has memory be allocated for the w field?
double hamiltonian
Monte-Carlo Hamiltonian value.
bool needsHamiltonian
If hamiltonian needs to be saved.
double fieldHamiltonian
Monte-Carlo field part contribution to Hamiltonian value.
DArray< RField< D > > cc
Eigenvector components of c fields on a real space grid.
DArray< RField< D > > wc
Chemical potential fields, r-grid format, indexed by eigenvector.
void allocate(int nMonomer, IntVec< D > const &dimensions)
Allocate memory for fields.
double idealHamiltonian
Monte-Carlo ideal gas contribution to Hamiltonian value.
DArray< RField< D > > w
Chemical potential fields, r-grid format, indexed by monomer.
DArray< RField< D > > dc
Components of functional derivatives of the Hamiltonian fields on a real space grid.
bool hasData
Is this struct being used to store data?
bool needsCc
If cc fields needs to be saved.