PSCF v1.4.0
cpu/RField.h
1#ifndef PRDC_CPU_R_FIELD_H
2#define PRDC_CPU_R_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
14namespace Pscf {
15namespace Prdc {
16namespace Cpu {
17
18 using namespace Util;
19
25 template <int D>
26 class RField : public FftwDArray<double>
27 {
28
29 public:
30
31 // Public type alias
32
33 using FftwDArray<double>::ValueType;
34
35 // Public member functions
36
40 RField();
41
49 RField(const RField& other);
50
56 virtual ~RField();
57
68 RField& operator = (const RField& other);
69
77 void allocate(IntVec<D> const & meshDimensions);
78
82 virtual void deallocate();
83
87 const IntVec<D>& meshDimensions() const;
88
95 template <class Archive>
96 void serialize(Archive& ar, const unsigned int version);
97
98 private:
99
100 // Vector containing number of grid points in each direction.
101 IntVec<D> meshDimensions_;
102
103 using FftwDArray<double>::allocate;
104
105 };
106
107 /*
108 * Return mesh dimensions by constant reference.
109 */
110 template <int D>
112 { return meshDimensions_; }
113
114 /*
115 * Serialize a Field to/from an Archive.
116 */
117 template <int D>
118 template <class Archive>
119 void RField<D>::serialize(Archive& ar, const unsigned int version)
120 {
122 ar & meshDimensions_;
123 }
124
125 // Explicit instantiation declarations
126 extern template class RField<1>;
127 extern template class RField<2>;
128 extern template class RField<3>;
129
130} // namespace Cpu
131} // namespace Prdc
132} // namespace Pscf
133#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
Field of real double precision values on an FFT mesh.
Definition cpu/RField.h:27
void allocate(IntVec< D > const &meshDimensions)
Allocate the underlying C array for an FFT grid.
RField & operator=(const RField &other)
Assignment operator.
virtual ~RField()
Destructor.
void serialize(Archive &ar, const unsigned int version)
Serialize a Field to/from an Archive.
Definition cpu/RField.h:119
virtual void deallocate()
Deallocate memory and return to empty state.
RField()
Default constructor.
const IntVec< D > & meshDimensions() const
Return mesh dimensions by constant reference.
Definition cpu/RField.h:111
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.