PSCF v1.1
pspc/field/CFieldContainer.h
1#ifndef PSPC_C_FIELD_CONTAINER_H
2#define PSPC_C_FIELD_CONTAINER_H
3
4/*
5* PSCF - Polymer Self-Consistent Field Theory
6*
7* Copyright 2016 - 2022, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include <util/containers/DArray.h> // member template
12#include <pspc/field/RField.h> // member template parameter
13
14namespace Pscf {
15namespace Pspc {
16
17 using namespace Util;
18
37 template <int D>
39 {
40
41 public:
42
47
52
60 void setNMonomer(int nMonomer);
61
67 void allocateRGrid(IntVec<D> const & dimensions);
68
72 void deallocateRGrid();
73
79 void allocateBasis(int nBasis);
80
84 void deallocateBasis();
85
95 void allocate(int nMonomer, int nBasis, IntVec<D> const & dimensions);
96
101 { return basis_; }
102
109 { return basis_; }
110
116 DArray<double> & basis(int monomerId)
117 { return basis_[monomerId]; }
118
124 DArray<double> const & basis(int monomerId) const
125 { return basis_[monomerId]; }
126
131 { return rgrid_; }
132
136 DArray< RField<D> > const & rgrid() const
137 { return rgrid_; }
138
144 RField<D> & rgrid(int monomerId)
145 { return rgrid_[monomerId]; }
146
152 RField<D> const & rgrid(int monomerId) const
153 { return rgrid_[monomerId]; }
154
158 bool isAllocatedRGrid() const
159 { return isAllocatedRGrid_; }
160
164 bool isAllocatedBasis() const
165 { return isAllocatedBasis_; }
166
167 private:
168
169 /*
170 * Array of fields in symmetry-adapted basis format
171 *
172 * Element basis_[i] is an array that contains the components
173 * of the field associated with monomer i, in a symmetry-adapted
174 * Fourier basis expansion.
175 */
176 DArray< DArray<double> > basis_;
177
178 /*
179 * Array of fields in real-space grid (r-grid) format
180 *
181 * Element basis_[i] is an RField<D> that contains values of the
182 * field associated with monomer i on the nodes of a regular mesh.
183 */
184 DArray< RField<D> > rgrid_;
185
186 /*
187 * Number of monomer types.
188 */
189 int nMonomer_;
190
191 /*
192 * Has memory been allocated for fields in r-grid format?
193 */
194 bool isAllocatedRGrid_;
195
196 /*
197 * Has memory been allocated for fields in basis format?
198 */
199 bool isAllocatedBasis_;
200
201 };
202
203 #ifndef PSPC_FIELD_CONTAINER_TPP
204 // Suppress implicit instantiation
205 extern template class CFieldContainer<1>;
206 extern template class CFieldContainer<2>;
207 extern template class CFieldContainer<3>;
208 #endif
209
210} // namespace Pspc
211} // namespace Pscf
212#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition: IntVec.h:27
A list of c fields stored in both basis and r-grid format.
void deallocateBasis()
De-allocate fields in basis format.
RField< D > & rgrid(int monomerId)
Get field for one monomer type in r-grid format (non-const)
void setNMonomer(int nMonomer)
Set stored value of nMonomer.
DArray< DArray< double > > & basis()
Get array of all fields in basis format (non-const).
bool isAllocatedRGrid() const
Has memory been allocated for fields in r-grid format?
bool isAllocatedBasis() const
Has memory been allocated for fields in basis format?
void allocate(int nMonomer, int nBasis, IntVec< D > const &dimensions)
Allocate memory for both r-grid and basis field formats.
void allocateRGrid(IntVec< D > const &dimensions)
Allocate or re-allocate memory for fields in rgrid format.
DArray< double > & basis(int monomerId)
Get the field for one monomer type in basis format (non-const).
DArray< DArray< double > > const & basis() const
Get array of all fields in basis format (const)
DArray< RField< D > > const & rgrid() const
Get array of all fields in r-grid format (const).
DArray< double > const & basis(int monomerId) const
Get the field for one monomer type in basis format (const)
void deallocateRGrid()
De-allocate fields in rgrid format.
RField< D > const & rgrid(int monomerId) const
Get field for one monomer type in r-grid format (const).
void allocateBasis(int nBasis)
Allocate or re-allocate memory for fields in basis format.
DArray< RField< D > > & rgrid()
Get array of all fields in r-grid format (non-const).
Field of real double precision values on an FFT mesh.
Definition: RField.h:29
Dynamically allocatable contiguous array template.
Definition: DArray.h:32
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.
Definition: accumulators.mod:1