PSCF v1.3
cpu/WaveList.h
1#ifndef PRDC_CPU_WAVE_LIST_H
2#define PRDC_CPU_WAVE_LIST_H
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 <prdc/cpu/RField.h>
12#include <prdc/crystal/UnitCell.h>
13
14#include <pscf/mesh/Mesh.h>
15#include <pscf/math/IntVec.h>
16
17#include <util/containers/DArray.h>
18
19namespace Pscf {
20namespace Prdc {
21namespace Cpu {
22
23 using namespace Util;
24
45 template <int D>
47 {
48 public:
49
55 WaveList(bool isRealField = true);
56
60 ~WaveList();
61
68 void allocate(Mesh<D> const & m, UnitCell<D> const & c);
69
76 void clearUnitCellData();
77
92
96 void computeKSq();
97
101 void computedKSq();
102
112 DArray< IntVec<D> > const & minImages() const;
113
122 RField<D> const & kSq() const;
123
141 RField<D> const & dKSq(int i) const;
142
149 DArray< RField<D> > const & dKSq() const;
150
162 DArray<bool> const & implicitInverse() const;
163
167 bool isAllocated() const
168 { return isAllocated_; }
169
173 bool hasMinImages() const
174 { return hasMinImages_; }
175
179 bool hasKSq() const
180 { return hasKSq_; }
181
185 bool hasdKSq() const
186 { return hasdKSq_; }
187
191 bool isRealField() const
192 { return isRealField_; }
193
194 private:
195
196 // Array containing minimum images for each wave.
197 DArray< IntVec<D> > minImages_;
198
200 RField<D> kSq_;
201
203 DArray< RField<D> > dKSq_;
204
206 DArray<bool> implicitInverse_;
207
215 IntVec<D> kMeshDimensions_;
216
224 int kSize_;
225
227 bool isAllocated_;
228
230 bool hasMinImages_;
231
233 bool hasKSq_;
234
236 bool hasdKSq_;
237
239 bool isRealField_;
240
242 UnitCell<D> const * unitCellPtr_;
243
245 Mesh<D> const * meshPtr_;
246
248 UnitCell<D> const & unitCell() const
249 { return *unitCellPtr_; }
250
252 Mesh<D> const & mesh() const
253 { return *meshPtr_; }
254
255 };
256
257 // Get the array of minimum images on the device by reference.
258 template <int D>
259 inline
261 {
262 UTIL_CHECK(hasMinImages_);
263 return minImages_;
264 }
265
266 // Get the kSq array on the device by reference.
267 template <int D>
268 inline
270 {
271 UTIL_CHECK(hasKSq_);
272 return kSq_;
273 }
274
275 // Get dKSq for unit cell parameter array i.
276 template <int D>
277 inline
278 RField<D> const & WaveList<D>::dKSq(int i) const
279 {
280 UTIL_CHECK(hasdKSq_);
281 return dKSq_[i];
282 }
283
284 // Get entire dKSq container.
285 template <int D>
286 inline
288 {
289 UTIL_CHECK(hasdKSq_);
290 return dKSq_;
291 }
292
293 // Get the implicitInverse array by reference.
294 template <int D>
295 inline
297 {
298 UTIL_CHECK(isAllocated_);
299 UTIL_CHECK(isRealField_);
300 return implicitInverse_;
301 }
302
303 #ifndef PRDC_CPU_WAVE_LIST_TPP
304 // Suppress implicit instantiation
305 extern template class WaveList<1>;
306 extern template class WaveList<2>;
307 extern template class WaveList<3>;
308 #endif
309
310} // Cpu
311} // Prdc
312} // Pscf
313#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Description of a regular grid of points in a periodic domain.
Definition Mesh.h:61
Field of real double precision values on an FFT mesh.
Definition cpu/RField.h:29
Class to calculate and store properties of wavevectors.
void clearUnitCellData()
Clear all internal data that depends on lattice parameters.
DArray< IntVec< D > > const & minImages() const
Get the array of minimum image vectors by const reference.
void computedKSq()
Compute derivatives of |k|^2 w/ respect to unit cell parameters.
WaveList(bool isRealField=true)
Constructor.
void computeMinimumImages()
Compute minimum images of wavevectors.
bool hasMinImages() const
Have minimum images been computed?
void allocate(Mesh< D > const &m, UnitCell< D > const &c)
Allocate memory and set association with a Mesh and UnitCell object.
void computeKSq()
Compute sq.
bool isRealField() const
Does this WaveList correspond to real-valued fields?
bool hasKSq() const
Has the kSq array been computed?
RField< D > const & kSq() const
Get the kSq array on the device by const reference.
bool isAllocated() const
Has memory been allocated for arrays?
bool hasdKSq() const
Has the dKSq array been computed?
DArray< RField< D > > const & dKSq() const
Get all derivatives of kSq with respect to unit cell parameters.
DArray< bool > const & implicitInverse() const
Get the implicitInverse array by reference.
Base template for UnitCell<D> classes, D=1, 2 or 3.
Definition UnitCell.h:56
Dynamically allocatable contiguous array template.
Definition DArray.h:32
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Definition global.h:68
Fields and FFTs for periodic boundary conditions (CPU)
Definition CField.cpp:12
Periodic fields and crystallography.
Definition CField.cpp:11
PSCF package top-level namespace.
Definition param_pc.dox:1