1#ifndef PSCF_FIELD_CHECK_TPP
2#define PSCF_FIELD_CHECK_TPP
11#include <pscf/math/IntVec.h>
12#include <util/containers/DArray.h>
22 template <
int D,
class FT>
29 for (
int i = 0; i < n; ++i) {
37 template <
int D,
class FT>
41 if (field.isAllocated()) {
42 UTIL_CHECK(field.meshDimensions() == dimensions);
44 field.allocate(dimensions);
51 template <
int D,
class FT>
57 int nMonomerFields = fields.
capacity();
60 for (
int i = 0; i < nMonomer; ++i) {
62 UTIL_CHECK(fields[i].meshDimensions() == dimensions);
66 for (
int i = 0; i < nMonomer; ++i) {
75 template <
int D,
class FT>
84 dimensions = fields[0].meshDimensions();
85 for (
int i = 0; i < nMonomer; ++i) {
87 UTIL_CHECK(fields[i].meshDimensions() == dimensions);
98 for (
int i = 0; i < n; ++i) {
112 int nMonomerArrays = arrays.
capacity();
115 for (
int i = 0; i < nMonomer; ++i) {
121 for (
int i = 0; i < nMonomer; ++i) {
141 for (
int i = 0; i < nMonomer; ++i) {
147 template <
class OAT,
class IAT>
156 for (
int i = 0; i < n; ++i) {
161 template <
class HAT,
class DAT>
170 for (
int i = 0; i < n; ++i) {
172 host[i].associate(device[i]);
181 for (
int i = 0; i < n; ++i) {
182 host[i].dissociate();
An IntVec<D, T> is a D-component vector of elements of integer type T.
int capacity() const
Return allocated size.
bool isAllocated() const
Does this array have associated data?
Dynamically allocatable contiguous array template.
void allocate(int capacity)
Allocate the underlying C array.
File containing preprocessor macros for error handling.
#define UTIL_CHECK(condition)
Assertion macro suitable for serial or parallel production code.
void checkAllocateArrays(DArray< AT > &arrays, int nMonomer, int capacity)
Check allocation of a DArray of 1D arrays, allocate if necessary.
void inspectArrays(DArray< AT > const &arrays, int &nMonomer, int &capacity)
Inspect dimensions of a DArray of 1D arrays, each of type AT.
void checkAllocateField(FT &field, IntVec< D > const &dimensions)
Check allocation of a single field, 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 copyArrays(DArray< OAT > &out, DArray< IAT > const &in)
Copy a DArray of 1D arrays.
void associateArrays(DArray< HAT > &host, DArray< DAT > &device)
Associate host arrays with backend arrays.
void dissociateArrays(DArray< HAT > &host)
Dissociate an array of host arrays.
void inspectFields(DArray< FT > const &fields, int &nMonomer, IntVec< D > &dimensions)
Inspect dimensions of a DArray of fields, each of type FT.
PSCF package top-level namespace.
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.