1#ifndef PRDC_FIELD_CHECK_TPP
2#define PRDC_FIELD_CHECK_TPP
11#include <pscf/math/IntVec.h>
12#include <util/containers/DArray.h>
23 template <
int D,
class FT>
30 for (
int i = 0; i < n; ++i) {
38 template <
int D,
class FT>
42 if (field.isAllocated()) {
43 UTIL_CHECK(field.meshDimensions() == dimensions);
45 field.allocate(dimensions);
52 template <
int D,
class FT>
58 int nMonomerFields = fields.
capacity();
61 for (
int i = 0; i < nMonomer; ++i) {
63 UTIL_CHECK(fields[i].meshDimensions() == dimensions);
67 for (
int i = 0; i < nMonomer; ++i) {
76 template <
int D,
class FT>
85 dimensions = fields[0].meshDimensions();
86 for (
int i = 0; i < nMonomer; ++i) {
88 UTIL_CHECK(fields[i].meshDimensions() == dimensions);
99 for (
int i = 0; i < n; ++i) {
113 int nMonomerArrays = arrays.
capacity();
116 for (
int i = 0; i < nMonomer; ++i) {
122 for (
int i = 0; i < nMonomer; ++i) {
142 for (
int i = 0; i < nMonomer; ++i) {
148 template <
class OAT,
class IAT>
153 for (
int i = 0; i < n; ++i) {
156 UTIL_CHECK(in[i].capacity() == out[i].capacity());
An IntVec<D, T> is a D-component vector of elements of integer type T.
int capacity() const
Return allocated size.
Dynamically allocatable contiguous array template.
void allocate(int capacity)
Allocate the underlying C array.
bool isAllocated() const
Return true if this DArray has been allocated, false otherwise.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
void copyArrays(DArray< OAT > &out, DArray< IAT > const &in)
Copy a DArray of 1D arrays.
void inspectArrays(DArray< AT > const &arrays, int &nMonomer, int &capacity)
Inspect dimensions of a DArray of 1D arrays, each of type AT.
void inspectFields(DArray< FT > const &fields, int &nMonomer, IntVec< D > &dimensions)
Inspect dimensions of a DArray of fields, each of type FT.
void checkAllocateArrays(DArray< AT > &arrays, int nMonomer, int capacity)
Check allocation of a DArray of 1D arrays, allocate if necessary.
void checkAllocateFields(DArray< FT > &fields, int nMonomer, IntVec< D > const &dimensions)
Check allocation of an array of fields, allocate if necessary.
void checkAllocateField(FT &field, IntVec< D > const &dimensions)
Check allocation of a single field, allocate if necessary.
Periodic fields and crystallography.
void allocateArrays(DArray< AT > &arrays, int n, int capacity)
Allocate an array of arrays.
void allocateFields(DArray< FT > &fields, int n, IntVec< D > const &dimension)
Allocate a DArray of fields.
PSCF package top-level namespace.