1#ifndef PRDC_MASK_TMPL_TPP
2#define PRDC_MASK_TMPL_TPP
21 template <
int D,
typename FieldIo,
typename RField>
29 isAllocatedBasis_(false),
30 isAllocatedRGrid_(false),
38 template <
int D,
typename FieldIo,
typename RField>
45 template <
int D,
typename FieldIo,
typename RField>
47 { fieldIoPtr_ = &fieldIo; }
52 template <
int D,
typename FieldIo,
typename RField>
61 basis_.allocate(nBasis);
62 isAllocatedBasis_ =
true;
68 template <
int D,
typename FieldIo,
typename RField>
75 meshDimensions_ = meshDimensions;
77 for (
int i = 0; i < D; ++i) {
79 meshSize_ *= meshDimensions[i];
83 rgrid_.allocate(meshDimensions);
84 isAllocatedRGrid_ =
true;
90 template <
int D,
typename FieldIo,
typename RField>
94 for (
int j = 0; j < nBasis_; ++j) {
97 fieldIoPtr_->convertBasisToRGrid(basis_, rgrid_);
105 template <
int D,
typename FieldIo,
typename RField>
111 fieldIoPtr_->convertRGridToBasis(rgrid_, basis_);
114 isSymmetric_ = isSymmetric;
124 template <
int D,
typename FieldIo,
typename RField>
128 fieldIoPtr_->readFieldBasis(in, basis_, unitCell);
131 fieldIoPtr_->convertBasisToRGrid(basis_, rgrid_);
144 template <
int D,
typename FieldIo,
typename RField>
148 fieldIoPtr_->readFieldBasis(filename, basis_, unitCell);
151 fieldIoPtr_->convertBasisToRGrid(basis_, rgrid_);
169 template <
int D,
typename FieldIo,
typename RField>
174 fieldIoPtr_->readFieldRGrid(in, rgrid_, unitCell);
177 fieldIoPtr_->convertRGridToBasis(rgrid_, basis_);
181 isSymmetric_ = isSymmetric;
196 template <
int D,
typename FieldIo,
typename RField>
201 fieldIoPtr_->readFieldRGrid(filename, rgrid_, unitCell);
204 fieldIoPtr_->convertRGridToBasis(rgrid_, basis_);
208 isSymmetric_ = isSymmetric;
215 template <
int D,
typename FieldIo,
typename RField>
218 if (isSymmetric() && hasData()) {
221 }
else if (!hasData()) {
225 return rGridAverage();
An IntVec<D, T> is a D-component vector of elements of integer type T.
Field of real double precision values on an FFT mesh.
double phiTot() const
Return the volume fraction of unit cell occupied by material.
void setFieldIo(FieldIo const &fieldIo)
Create association with FieldIo (store pointer).
void setBasis(DArray< double > const &field)
Set field component values, in symmetrized Fourier format.
void setRGrid(RField const &field, bool isSymmetric=false)
Set field values in real-space (r-grid) format.
void readRGrid(std::istream &in, UnitCell< D > &unitCell, bool isSymmetric=false)
Reads field from an input stream in real-space (r-grid) format.
void allocateRGrid(IntVec< D > const &dimensions)
Allocate memory for the field in rgrid format.
void allocateBasis(int nBasis)
Allocate memory for the field in basis format.
void readBasis(std::istream &in, UnitCell< D > &unitCell)
Read field from input stream in symmetrized Fourier format.
Base template for UnitCell<D> classes, D=1, 2 or 3.
int capacity() const
Return allocated size.
Dynamically allocatable contiguous array template.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
PSCF package top-level namespace.
Utility classes for scientific computation.