1#ifndef RPC_W_FIELD_CONTAINER_TPP
2#define RPC_W_FIELD_CONTAINER_TPP
11#include "WFieldContainer.h"
12#include <rpc/field/FieldIo.h>
34 isAllocatedRGrid_(false),
35 isAllocatedBasis_(false),
52 { fieldIoPtr_ = &fieldIo; }
75 if (isAllocatedRGrid_) {
80 meshDimensions_ = meshDimensions;
82 for (
int i = 0; i < D; ++i) {
84 meshSize_ *= meshDimensions[i];
88 rgrid_.allocate(nMonomer_);
89 for (
int i = 0; i < nMonomer_; ++i) {
90 rgrid_[i].allocate(meshDimensions);
92 isAllocatedRGrid_ =
true;
104 for (
int i = 0; i < nMonomer_; ++i) {
105 rgrid_[i].deallocate();
110 isAllocatedRGrid_ =
false;
123 if (isAllocatedBasis_) {
129 basis_.allocate(nMonomer_);
130 for (
int i = 0; i < nMonomer_; ++i) {
131 basis_[i].allocate(nBasis);
133 isAllocatedBasis_ =
true;
145 for (
int i = 0; i < nMonomer_; ++i) {
146 basis_[i].deallocate();
150 isAllocatedBasis_ =
false;
160 setNMonomer(nMonomer);
161 allocateRGrid(meshDimensions);
162 allocateBasis(nBasis);
175 for (
int i = 0; i < nMonomer_; ++i) {
180 for (
int j = 0; j < nBasis_; ++j) {
186 fieldIoPtr_->convertBasisToRGrid(basis_, rgrid_);
202 for (
int i = 0; i < nMonomer_; ++i) {
207 for (
int j = 0; j < meshSize_; ++j) {
214 fieldIoPtr_->convertRGridToBasis(rgrid_, basis_);
218 isSymmetric_ = isSymmetric;
234 fieldIoPtr_->readFieldsBasis(in, basis_, unitCell);
237 fieldIoPtr_->convertBasisToRGrid(basis_, rgrid_);
256 fieldIoPtr_->readFieldsBasis(filename, basis_, unitCell);
259 fieldIoPtr_->convertBasisToRGrid(basis_, rgrid_);
283 fieldIoPtr_->readFieldsRGrid(in, rgrid_, unitCell);
286 fieldIoPtr_->convertRGridToBasis(rgrid_, basis_);
290 isSymmetric_ = isSymmetric;
311 fieldIoPtr_->readFieldsRGrid(filename, rgrid_, unitCell);
314 fieldIoPtr_->convertRGridToBasis(rgrid_, basis_);
318 isSymmetric_ = isSymmetric;
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.
Base template for UnitCell<D> classes, D=1, 2 or 3.
File input/output operations and format conversions for fields.
void allocate(int nMonomer, int nBasis, IntVec< D > const &dimensions)
Allocate memory for all fields.
void allocateRGrid(IntVec< D > const &dimensions)
Allocate or re-allocate memory for fields in rgrid format.
void readBasis(std::istream &in, UnitCell< D > &unitCell)
Read field component values from input stream, in symmetrized Fourier format.
void deallocateBasis()
De-allocate fields in basis format.
void allocateBasis(int nBasis)
Allocate or re-allocate memory for fields in basis format.
void deallocateRGrid()
De-allocate fields in rgrid format.
WFieldContainer()
Constructor.
void setFieldIo(FieldIo< D > const &fieldIo)
Create association with FieldIo (store pointer).
void setRGrid(DArray< RField< D > > const &fields, bool isSymmetric=false)
Set fields values in real-space (r-grid) format.
void readRGrid(std::istream &in, UnitCell< D > &unitCell, bool isSymmetric=false)
Reads fields from an input stream in real-space (r-grid) format.
void setBasis(DArray< DArray< double > > const &fields)
Set field component values, in symmetrized Fourier format.
~WFieldContainer()
Destructor.
void setNMonomer(int nMonomer)
Set stored value of nMonomer.
int capacity() const
Return allocated size.
Dynamically allocatable contiguous array template.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
Fields and FFTs for periodic boundary conditions (CPU)
Periodic fields and crystallography.
PSCF package top-level namespace.
Utility classes for scientific computation.