PSCF v1.4.0
cpu/RFieldDft.h
1#ifndef PRDC_CPU_R_FIELD_DFT_H
2#define PRDC_CPU_R_FIELD_DFT_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/FftwDArray.h> // base class
12#include <pscf/math/IntVec.h> // member
13#include <fftw3.h>
14
15namespace Pscf {
16namespace Prdc {
17namespace Cpu {
18
19 using namespace Util;
20 using namespace Pscf;
21
27 template <int D>
28 class RFieldDft : public FftwDArray<fftw_complex>
29 {
30
31 public:
32
33 // Type aliases
34
35 using FftwDArray<fftw_complex>::ValueType;
36
40 using RealType = double;
41
42 // Member functions
43
47 RFieldDft();
48
56 RFieldDft(RFieldDft<D> const & other);
57
63 virtual ~RFieldDft();
64
76
84 void allocate(IntVec<D> const & meshDimensions);
85
89 virtual void deallocate();
90
94 IntVec<D> const & meshDimensions() const;
95
103 IntVec<D> const & dftDimensions() const;
104
111 template <class Archive>
112 void serialize(Archive& ar, const unsigned int version);
113
114 private:
115
116 // Vector containing number of grid points in each direction.
117 IntVec<D> meshDimensions_;
118
119 // Vector containing dimensions of dft (Fourier) grid.
120 IntVec<D> dftDimensions_;
121
122 using FftwDArray<fftw_complex>::allocate;
123
124 };
125
126 /*
127 * Return mesh dimensions by constant reference.
128 */
129 template <int D>
131 { return meshDimensions_; }
132
133 /*
134 * Return dimensions of dft grid by constant reference.
135 */
136 template <int D>
138 { return dftDimensions_; }
139
140 /*
141 * Serialize a Field to/from an Archive.
142 */
143 template <int D>
144 template <class Archive>
145 void RFieldDft<D>::serialize(Archive& ar, const unsigned int version)
146 {
148 ar & meshDimensions_;
149 ar & dftDimensions_;
150 }
151
152 // Explicit instantiation declarations
153 extern template class RFieldDft<1>;
154 extern template class RFieldDft<2>;
155 extern template class RFieldDft<3>;
156
157}
158}
159}
160#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
void serialize(Archive &ar, const unsigned int version)
Serialize a FftwDArray to/from an Archive.
Definition FftwDArray.h:115
Fourier transform of a real field on an FFT mesh.
virtual void deallocate()
Deallocate underlying C array and clear mesh dimensions.
double RealType
Type of real and imaginary parts of a complex element value.
virtual ~RFieldDft()
Destructor.
IntVec< D > const & meshDimensions() const
Return vector of spatial mesh dimensions by constant reference.
void serialize(Archive &ar, const unsigned int version)
Serialize a Field to/from an Archive.
IntVec< D > const & dftDimensions() const
Return vector of dft (Fourier) grid dimensions by constant reference.
RFieldDft< D > & operator=(RFieldDft< D > const &other)
Assignment operator.
void allocate(IntVec< D > const &meshDimensions)
Allocate the underlying C array and set mesh dimensions.
RFieldDft()
Default constructor.
Fields and FFTs for periodic boundary conditions (CPU)
Definition complex.cpp:12
Periodic fields and crystallography.
Definition complex.cpp:11
PSCF package top-level namespace.