24 template <
typename Data>
98 Data
const *
cField()
const;
106 template <
class Archive>
107 void serialize(Archive& ar,
const unsigned int version);
134 template <
typename Data>
136 {
return capacity_; }
141 template <
typename Data>
146 assert(i < capacity_);
153 template <
typename Data>
158 assert(i < capacity_);
165 template <
typename Data>
172 template <
typename Data>
180 template <
typename Data>
182 {
return (
bool)data_; }
187 template <
typename Data>
188 template <
class Archive>
192 if (Archive::is_saving()) {
193 capacity = capacity_;
196 if (Archive::is_loading()) {
197 if (!isAllocated()) {
202 if (capacity != capacity_) {
208 for (
int i = 0; i < capacity_; ++i) {
Base class template for a field defined on a spatial grid.
Field< T > & operator=(Field< T > const &other)
Assignment operator.
int capacity() const
Return allocated size.
Data * data_
Pointer to an array of Data elements.
Data & operator[](int i)
Get an element by non-const reference.
void serialize(Archive &ar, const unsigned int version)
Serialize a Field to/from an Archive.
bool isAllocated() const
Return true if the Field has been allocated, false otherwise.
Field()
Default constructor.
Data * cField()
Return pointer to underlying C array.
int capacity_
Allocated size of the data_ array.
int capacity() const
Return allocated size.
Data & operator[](int i)
Get an element by non-const reference.
void allocate(int capacity)
Allocate the underlying C array.
void deallocate()
Dellocate 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_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
C++ namespace for polymer self-consistent field theory (PSCF).
Utility classes for scientific computation.