PSCF v1.4.0
cpu/CField.h
1#ifndef PRDC_CPU_C_FIELD_H
2#define PRDC_CPU_C_FIELD_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 CField : 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 CField();
48
56 CField(const CField& other);
57
63 virtual ~CField();
64
76 CField& operator = (const CField& other);
77
86
90 virtual void deallocate();
91
95 const IntVec<D>& meshDimensions() const;
96
103 template <class Archive>
104 void serialize(Archive& ar, const unsigned int version);
105
106 private:
107
108 // Vector containing number of grid points in each direction.
109 IntVec<D> meshDimensions_;
110
111 using FftwDArray<fftw_complex>::allocate;
112
113 };
114
115 /*
116 * Return mesh dimensions by constant reference.
117 */
118 template <int D>
120 { return meshDimensions_; }
121
122 /*
123 * Serialize a Field to/from an Archive.
124 */
125 template <int D>
126 template <class Archive>
127 void CField<D>::serialize(Archive& ar, const unsigned int version)
128 {
130 ar & meshDimensions_;
131 }
132
133 // Explicit instantiation declarations
134 extern template class CField<1>;
135 extern template class CField<2>;
136 extern template class CField<3>;
137
138}
139}
140}
141#endif
An IntVec<D, T> is a D-component vector of elements of integer type T.
Definition IntVec.h:27
Field of complex double precision values on an FFT mesh.
Definition cpu/CField.h:29
virtual ~CField()
Destructor.
const IntVec< D > & meshDimensions() const
Return mesh dimensions by constant reference.
Definition cpu/CField.h:119
void allocate(const IntVec< D > &meshDimensions)
Allocate the underlying C array for an FFT grid.
CField & operator=(const CField &other)
Assignment operator.
void serialize(Archive &ar, const unsigned int version)
Serialize a Field to/from an Archive.
Definition cpu/CField.h:127
double RealType
Type of real and imaginary parts of a complex value.
Definition cpu/CField.h:40
virtual void deallocate()
Deallocate underlying C array and clear mesh dimensions.
CField()
Default constructor.
void serialize(Archive &ar, const unsigned int version)
Serialize a FftwDArray to/from an Archive.
Definition FftwDArray.h:115
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.