netxsimdg
|
A class that holds the array data for the model. More...
#include <ModelArray.hpp>
Classes | |
struct | DimensionSpec |
Public Types | |
typedef std::map< Type, std::vector< Dimension > > | TypeDimensions |
typedef Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic, majority > | DataType |
typedef DataType::RowXpr | Component |
typedef DataType::ConstRowXpr | ConstComponent |
typedef std::vector< size_t > | MultiDim |
Public Member Functions | |
ModelArray () | |
ModelArray (const Type type) | |
Construct a ModelArray of the given type and name. | |
ModelArray (const ModelArray &) | |
Copy constructor. | |
ModelArray & | operator= (const ModelArray &) |
Copy assignment operator. | |
ModelArray & | operator= (const double &val) |
Assigns a double value to all elements of the object. | |
ModelArray & | operator+= (const ModelArray &b) |
In place addition of another ModelArray. | |
ModelArray & | operator-= (const ModelArray &b) |
In place subtraction of another ModelArray. | |
ModelArray & | operator*= (const ModelArray &b) |
In place multiplication by another ModelArray. | |
ModelArray & | operator/= (const ModelArray &b) |
In place division by another ModelArray. | |
ModelArray & | operator+= (double b) |
In place addition of a double. | |
ModelArray & | operator-= (double b) |
In place subtraction of a double. | |
ModelArray & | operator*= (double b) |
In place multiplication by a double. | |
ModelArray & | operator/= (double b) |
In place division by a double. | |
ModelArray | operator+ (const ModelArray &) const |
Returns a ModelArray containing the per-element sum of the object and the provided ModelArray. | |
ModelArray | operator- (const ModelArray &) const |
Returns a ModelArray containing the per-element difference between the object and the provided ModelArray. | |
ModelArray | operator* (const ModelArray &) const |
Returns a ModelArray containing the per-element product of the object and the provided ModelArray. | |
ModelArray | operator/ (const ModelArray &) const |
Returns a ModelArray containing the per-element ratio between the object and the provided ModelArray. | |
ModelArray | operator- () const |
ModelArray | operator+ (const double &) const |
Returns a ModelArray with a constant added to every element of the object. | |
ModelArray | operator- (const double &) const |
Returns a ModelArray with a constant subtracted from every element of the object. | |
ModelArray | operator* (const double &) const |
Returns a ModelArray with every element of the object multiplied by a constant. | |
ModelArray | operator/ (const double &) const |
Returns a ModelArray with every element of the object divided by a constant. | |
ModelArray | max (double max) const |
Calculates element-wise maximum of the data and the given scalar value. | |
ModelArray | min (double min) const |
Calculates element-wise minimum of the data and the given scalar value. | |
ModelArray | max (const ModelArray &maxArr) const |
Calculates element-wise maximum of the data and the given second array. | |
ModelArray | min (const ModelArray &minArr) const |
Calculates element-wise minimum of the data and the given second array. | |
ModelArray & | clampAbove (double max) |
Clamps the values in the array to the given maximum. | |
ModelArray & | clampBelow (double min) |
Clamps the values in the array to the given minimum. | |
ModelArray & | clampAbove (const ModelArray &maxArr) |
Clamps the values in the array to maximum values in the given array. | |
ModelArray & | clampBelow (const ModelArray &minArr) |
Clamps the values in the array to minimum values in the given array. | |
size_t | nDimensions () const |
Returns the number of dimensions of this type of ModelArray. | |
const MultiDim & | dimensions () const |
Returns a vector<size_t> of the size of each dimension of this type of ModelArray. | |
size_t | size () const |
Returns the total number of elements of this type of ModelArray. | |
size_t | trueSize () const |
Returns the size of the data array of this object. | |
const double * | getData () const |
Returns a read-only pointer to the underlying data buffer. | |
const DataType & | data () const |
Returns a const reference to the Eigen data. | |
Type | getType () const |
Returns the (enum of) the ModelArray::Type of this. | |
void | setDimensions (const MultiDim &dims) |
Sets the number and size of the dimensions of this type of ModelArray. | |
void | resize () |
Conditionally updates the size of the object data buffer to match the class specification. | |
void | setData (double value) |
Sets the value of every element in the object to the provided value. | |
void | setData (const double *pData) |
Reads and sets data from a raw buffer of double data. | |
void | setData (const DataType &data) |
Reads and sets data from an instance of the underlying data class (Eigen::Array). | |
void | setData (const ModelArray &source) |
Reads and sets data from another ModelArray. | |
const double & | operator[] (size_t i) const |
Returns the data at the specified one dimensional index. | |
const double & | operator[] (const MultiDim &dims) const |
Returns the data at the indices. | |
template<typename... Args> | |
const double & | operator() (Args... args) const |
Returns the data at the given set of indices. | |
double & | operator[] (size_t i) |
Returns the data at the specified one dimensional index. | |
double & | operator[] (const MultiDim &) |
Returns the data at the indices. | |
template<typename... Args> | |
double & | operator() (Args... args) |
Returns the specified point from a ModelArray. | |
void | setNComponents (size_t nComp) |
Sets the number of components for this array's type. | |
Component | components (size_t i) |
Accesses the full Discontinuous Galerkin coefficient vector at the indexed location. | |
const ConstComponent | components (size_t i) const |
Component | components (const MultiDim &loc) |
Accesses the full Discontinuous Galerkin coefficient vector at the specified location. | |
const ConstComponent | components (const MultiDim &loc) const |
double & | zIndexAndLayer (size_t hIndex, size_t layer) |
Special access function for ZFields. | |
const double & | zIndexAndLayer (size_t hIndex, size_t layer) const |
Special access function for ZFields, const version. | |
size_t | indexFromLocation (const MultiDim &loc) const |
Returns the index for a given set of multi-dimensional location for this array's type. | |
MultiDim | locationFromIndex (size_t index) const |
Returns the multi-dimensional location for a given index for this array's type. | |
size_t | nComponents () const |
Returns the number of discontinuous Galerkin components held in this type of ModelArray. | |
bool | hasDoF () const |
Returns whether this type of ModelArray has additional discontinuous Galerkin components. | |
Static Public Member Functions | |
static size_t | nDimensions (Type type) |
Returns the number of dimensions of the specified type of ModelArray. | |
static const MultiDim & | dimensions (Type type) |
Returns a vector<size_t> of the size of each dimension of the specified type of ModelArray. | |
static size_t | size (Type type) |
Returns the total number of elements of the specified type of ModelArray. | |
static void | setDimensions (Type, const MultiDim &) |
Sets the number and size of the dimensions of a specified type of ModelArray. | |
static void | setDimension (Dimension dim, size_t length) |
Sets the length of an individual dimension before propagating it to the defined array types. | |
static void | setNComponents (std::map< Type, size_t > cMap) |
Sets the number of components for DG & CG array types. | |
static void | setNComponents (Type type, size_t nComp) |
Sets the number of components for a single D/CG array type. | |
static size_t | indexFromLocation (Type type, const MultiDim &loc) |
Returns the index for a given set of multi-dimensional location for the given Type. | |
static MultiDim | locationFromIndex (Type type, size_t index) |
Returns the multi-dimensional location for a given index for the given Type. | |
static size_t | nComponents (const Type type) |
Returns the number of discontinuous Galerkin components held in the specified type of ModelArray. | |
static bool | hasDoF (const Type type) |
Returns whether the specified type of ModelArray has additional discontinuous Galerkin components. | |
Static Public Attributes | |
static const int | N_DEFINED_DIMENSIONS = static_cast<int>(Dimension::COUNT) |
static TypeDimensions | typeDimensions |
The dimensions that make up each defined type. Defined in ModelArrayDetails.cpp. | |
static std::map< Dimension, DimensionSpec > | definedDimensions |
The name and length of each dimension that is defined. | |
static const std::map< Type, std::string > | typeNames |
The name of each type of ModelArray. | |
static const std::map< Type, Dimension > | componentMap |
Protected Member Functions | |
size_t | zLayerIndex (size_t hIndex, size_t layer) const |
Special access function for ZFields, common implementation version. | |
Protected Attributes | |
Type | type |
A class that holds the array data for the model.
This class holds n-dimensional data for the model. It is designed to be a light (not transparent) wrapper around Eigen::Array. The underlying Array is two dimensional, with the first dimension acting like the one dimensional vector backing an n-dimensional array type. All of the n dimensional indexing is collapsed onto the first dimension. Any access to components for Discontinuous Galerkin variables is done through the second dimension. For finite volume variables, there is one component in the second dimension.
Sizes and dimensionality as calculated by the static and member functions only pertain to the grid, with the DG components being ignored. For a degree-2 DG variable the size in memory would be 6 times that reported by the size() function.
Definition at line 47 of file ModelArray.hpp.
DataType::RowXpr Nextsim::ModelArray::Component |
Definition at line 74 of file ModelArray.hpp.
DataType::ConstRowXpr Nextsim::ModelArray::ConstComponent |
Definition at line 75 of file ModelArray.hpp.
Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic, majority> Nextsim::ModelArray::DataType |
Definition at line 72 of file ModelArray.hpp.
std::vector<size_t> Nextsim::ModelArray::MultiDim |
Definition at line 218 of file ModelArray.hpp.
std::map<Type, std::vector<Dimension> > Nextsim::ModelArray::TypeDimensions |
Definition at line 61 of file ModelArray.hpp.
Nextsim::ModelArray::ModelArray | ( | ) |
Construct an unnamed ModelArray of Type::H
Definition at line 88 of file ModelArrayDetails.cpp.
Nextsim::ModelArray::ModelArray | ( | const Type | type | ) |
Construct a ModelArray of the given type and name.
type | The ModelArray::Type for the new object. |
name | The name of the new object. |
Definition at line 23 of file ModelArray.cpp.
Nextsim::ModelArray::ModelArray | ( | const ModelArray & | orig | ) |
Copy constructor.
Definition at line 30 of file ModelArray.cpp.
|
inlinevirtual |
Definition at line 90 of file ModelArray.hpp.
ModelArray & Nextsim::ModelArray::clampAbove | ( | const ModelArray & | maxArr | ) |
Clamps the values in the array to maximum values in the given array.
maxArr | the array of clamp maximum target values. |
Definition at line 159 of file ModelArray.cpp.
ModelArray & Nextsim::ModelArray::clampAbove | ( | double | max | ) |
Clamps the values in the array to the given maximum.
max | the maximum value of the final array. |
Definition at line 147 of file ModelArray.cpp.
ModelArray & Nextsim::ModelArray::clampBelow | ( | const ModelArray & | minArr | ) |
Clamps the values in the array to minimum values in the given array.
minArr | the array of clamp minimum target values. |
Definition at line 165 of file ModelArray.cpp.
ModelArray & Nextsim::ModelArray::clampBelow | ( | double | min | ) |
Clamps the values in the array to the given minimum.
min | the minimum value of the final array. |
Definition at line 153 of file ModelArray.cpp.
ModelArray::Component Nextsim::ModelArray::components | ( | const MultiDim & | loc | ) |
Accesses the full Discontinuous Galerkin coefficient vector at the specified location.
dims | indexing argument of the target point. |
Definition at line 219 of file ModelArray.cpp.
const ModelArray::ConstComponent Nextsim::ModelArray::components | ( | const MultiDim & | loc | ) | const |
Definition at line 224 of file ModelArray.cpp.
|
inline |
Accesses the full Discontinuous Galerkin coefficient vector at the indexed location.
i | one-dimensional index of the target point. |
Definition at line 461 of file ModelArray.hpp.
|
inline |
Definition at line 463 of file ModelArray.hpp.
|
inline |
Returns a const reference to the Eigen data.
Definition at line 239 of file ModelArray.hpp.
|
inline |
Returns a vector<size_t> of the size of each dimension of this type of ModelArray.
Definition at line 225 of file ModelArray.hpp.
|
inlinestatic |
Returns a vector<size_t> of the size of each dimension of the specified type of ModelArray.
Definition at line 227 of file ModelArray.hpp.
|
inline |
Returns a read-only pointer to the underlying data buffer.
Definition at line 236 of file ModelArray.hpp.
|
inline |
Returns the (enum of) the ModelArray::Type of this.
Definition at line 241 of file ModelArray.hpp.
|
inline |
Returns whether this type of ModelArray has additional discontinuous Galerkin components.
Definition at line 541 of file ModelArray.hpp.
|
static |
Returns whether the specified type of ModelArray has additional discontinuous Galerkin components.
Definition at line 93 of file ModelArrayDetails.cpp.
|
inline |
Returns the index for a given set of multi-dimensional location for this array's type.
loc | The multi-dimensional location to return the index for. |
Definition at line 505 of file ModelArray.hpp.
|
static |
Returns the index for a given set of multi-dimensional location for the given Type.
type | The type to act on. |
loc | The multi-dimensional location to return the index for. |
Definition at line 235 of file ModelArray.cpp.
|
inline |
Returns the multi-dimensional location for a given index for this array's type.
index | The index to return the multi-dimensional location for. |
Definition at line 520 of file ModelArray.hpp.
|
static |
Returns the multi-dimensional location for a given index for the given Type.
type | The type to act on. |
index | The index to return the multi-dimensional location for. |
Definition at line 246 of file ModelArray.cpp.
ModelArray Nextsim::ModelArray::max | ( | const ModelArray & | maxArr | ) | const |
Calculates element-wise maximum of the data and the given second array.
maxArr | the array containing the maximum values. |
Definition at line 133 of file ModelArray.cpp.
ModelArray Nextsim::ModelArray::max | ( | double | max | ) | const |
Calculates element-wise maximum of the data and the given scalar value.
max | the maximum value of the resultant array. |
Definition at line 119 of file ModelArray.cpp.
ModelArray Nextsim::ModelArray::min | ( | const ModelArray & | minArr | ) | const |
Calculates element-wise minimum of the data and the given second array.
minArr | the array containing the minimum values. |
Definition at line 140 of file ModelArray.cpp.
ModelArray Nextsim::ModelArray::min | ( | double | min | ) | const |
Calculates element-wise minimum of the data and the given scalar value.
min | the minimum value of the resultant array. |
Definition at line 126 of file ModelArray.cpp.
|
inline |
Returns the number of discontinuous Galerkin components held in this type of ModelArray.
Definition at line 532 of file ModelArray.hpp.
|
inlinestatic |
Returns the number of discontinuous Galerkin components held in the specified type of ModelArray.
Definition at line 535 of file ModelArray.hpp.
|
inline |
Returns the number of dimensions of this type of ModelArray.
Definition at line 221 of file ModelArray.hpp.
|
inlinestatic |
Returns the number of dimensions of the specified type of ModelArray.
Definition at line 223 of file ModelArray.hpp.
|
inline |
Returns the specified point from a ModelArray.
If the object holds discontinuous Galerkin components, only the cell averaged value is returned. Non-const version.
Definition at line 423 of file ModelArray.hpp.
|
inline |
Returns the data at the given set of indices.
Definition at line 392 of file ModelArray.hpp.
ModelArray Nextsim::ModelArray::operator* | ( | const double & | x | ) | const |
Returns a ModelArray with every element of the object multiplied by a constant.
Definition at line 94 of file ModelArray.cpp.
ModelArray Nextsim::ModelArray::operator* | ( | const ModelArray & | multiplier | ) | const |
Returns a ModelArray containing the per-element product of the object and the provided ModelArray.
Definition at line 63 of file ModelArray.cpp.
|
inline |
In place multiplication by another ModelArray.
Definition at line 115 of file ModelArray.hpp.
|
inline |
In place multiplication by a double.
Definition at line 140 of file ModelArray.hpp.
ModelArray Nextsim::ModelArray::operator+ | ( | const double & | x | ) | const |
Returns a ModelArray with a constant added to every element of the object.
Definition at line 82 of file ModelArray.cpp.
ModelArray Nextsim::ModelArray::operator+ | ( | const ModelArray & | addend | ) | const |
Returns a ModelArray containing the per-element sum of the object and the provided ModelArray.
Definition at line 51 of file ModelArray.cpp.
|
inline |
In place addition of another ModelArray.
Definition at line 103 of file ModelArray.hpp.
|
inline |
In place addition of a double.
Definition at line 128 of file ModelArray.hpp.
ModelArray Nextsim::ModelArray::operator- | ( | ) | const |
Definition at line 75 of file ModelArray.cpp.
ModelArray Nextsim::ModelArray::operator- | ( | const double & | x | ) | const |
Returns a ModelArray with a constant subtracted from every element of the object.
Definition at line 88 of file ModelArray.cpp.
ModelArray Nextsim::ModelArray::operator- | ( | const ModelArray & | subtrahend | ) | const |
Returns a ModelArray containing the per-element difference between the object and the provided ModelArray.
Definition at line 57 of file ModelArray.cpp.
|
inline |
In place subtraction of another ModelArray.
Definition at line 109 of file ModelArray.hpp.
|
inline |
In place subtraction of a double.
Definition at line 134 of file ModelArray.hpp.
ModelArray Nextsim::ModelArray::operator/ | ( | const double & | x | ) | const |
Returns a ModelArray with every element of the object divided by a constant.
Definition at line 100 of file ModelArray.cpp.
ModelArray Nextsim::ModelArray::operator/ | ( | const ModelArray & | divisor | ) | const |
Returns a ModelArray containing the per-element ratio between the object and the provided ModelArray.
Definition at line 69 of file ModelArray.cpp.
|
inline |
In place division by another ModelArray.
Definition at line 121 of file ModelArray.hpp.
|
inline |
In place division by a double.
Definition at line 146 of file ModelArray.hpp.
ModelArray & Nextsim::ModelArray::operator= | ( | const double & | val | ) |
Assigns a double value to all elements of the object.
val | The value to be assigned. |
Definition at line 44 of file ModelArray.cpp.
ModelArray & Nextsim::ModelArray::operator= | ( | const ModelArray & | orig | ) |
Copy assignment operator.
Definition at line 36 of file ModelArray.cpp.
double & Nextsim::ModelArray::operator[] | ( | const MultiDim & | dims | ) |
Returns the data at the indices.
The argument is a list of dimension indices (actually a std::vector<size_t>). The number of dimensions provided can be lower than that of the ModelArray type. If the object holds discontinuous Galerkin components, only the cell averaged value is returned. Here the data is a reference and so can be used for assignment.
dims | The indices of the target point. |
Definition at line 214 of file ModelArray.cpp.
const double & Nextsim::ModelArray::operator[] | ( | const MultiDim & | dims | ) | const |
Returns the data at the indices.
The argument is a list of dimension indices (actually a std::vector<size_t>). The number of dimensions provided can be lower than that of the ModelArray type. If the object holds discontinuous Galerkin components, only the cell averaged value is returned. Here the data is a const reference.
dims | The indices of the target point. |
Definition at line 209 of file ModelArray.cpp.
|
inline |
Returns the data at the specified one dimensional index.
The argument is used to directly index the data buffer. If the object holds discontinuous Galerkin components, only the cell averaged value is returned. Here the data is a reference and so can be used for assignment.
i | The one dimensional index of the target point. |
Definition at line 407 of file ModelArray.hpp.
|
inline |
Returns the data at the specified one dimensional index.
The argument is used to directly index the data buffer. If the object holds discontinuous Galerkin components, only the cell averaged value is returned. Here the data is a const reference.
i | The one dimensional index of the target point. |
Definition at line 375 of file ModelArray.hpp.
|
inline |
Conditionally updates the size of the object data buffer to match the class specification.
Definition at line 277 of file ModelArray.hpp.
void Nextsim::ModelArray::setData | ( | const DataType & | data | ) |
Reads and sets data from an instance of the underlying data class (Eigen::Array).
data | The data object to be copied from. |
Definition at line 183 of file ModelArray.cpp.
void Nextsim::ModelArray::setData | ( | const double * | pData | ) |
Reads and sets data from a raw buffer of double data.
The given pointer is the address of the first element read. Subsequent doubles in memory are read until every element in the object has been read. Ensure the provided buffer contains sufficient data to fill every element of the object, as no further bounds checking is performed.
pData | The pointer to the data buffer to be read. |
Definition at line 177 of file ModelArray.cpp.
void Nextsim::ModelArray::setData | ( | const ModelArray & | source | ) |
Reads and sets data from another ModelArray.
This function reads the data buffer only, and performs no bounds checking on the ModelArray argument. Unlike the assignment operator or copy constructor, it does not change the size or type of the object.
source | The object to be copied from. |
Definition at line 185 of file ModelArray.cpp.
void Nextsim::ModelArray::setData | ( | double | value | ) |
Sets the value of every element in the object to the provided value.
value | The new value for every element. |
Definition at line 171 of file ModelArray.cpp.
|
static |
Sets the length of an individual dimension before propagating it to the defined array types.
dim | The dimension to be altered. |
length | The new length of the dimension. |
Definition at line 203 of file ModelArray.cpp.
|
inline |
Sets the number and size of the dimensions of this type of ModelArray.
Sets the number and size of the dimensions of this type of ModelArray. The data buffer of this object is then resized to match the new definition.
dim | The per-dimension size to be set. |
Definition at line 260 of file ModelArray.hpp.
|
static |
Sets the number and size of the dimensions of a specified type of ModelArray.
type | The type of array the dimensions are to be specified for. |
dim | The per-dimension size to be set. |
Definition at line 187 of file ModelArray.cpp.
|
inline |
Sets the number of components for this array's type.
nComp | the number of components to be set. |
Definition at line 453 of file ModelArray.hpp.
|
static |
Sets the number of components for DG & CG array types.
cMap | a map from ModelArray::Type to the number of components. |
Definition at line 196 of file ModelArray.cpp.
|
inlinestatic |
Sets the number of components for a single D/CG array type.
type | the DG or CG array type to set the number of components for. |
nComp | the number of components to be set. |
Definition at line 441 of file ModelArray.hpp.
|
inline |
Returns the total number of elements of this type of ModelArray.
Definition at line 229 of file ModelArray.hpp.
|
inlinestatic |
Returns the total number of elements of the specified type of ModelArray.
Definition at line 231 of file ModelArray.hpp.
|
inline |
Returns the size of the data array of this object.
Definition at line 233 of file ModelArray.hpp.
|
inline |
Special access function for ZFields.
@detail Index a ZField using an index from an HField of the same horizontal extent and a layer index for the final dimension.
hIndex | the equivalent positional index in an HField array |
layer | the vertical layer to be accessed |
Definition at line 482 of file ModelArray.hpp.
|
inline |
Special access function for ZFields, const version.
@detail Index a ZField using an index from an HField of the same horizontal extent and a layer index for the final dimension.
hIndex | the equivalent positional index in an HField array |
layer | the vertical layer to be accessed |
Definition at line 495 of file ModelArray.hpp.
|
inlineprotected |
Special access function for ZFields, common implementation version.
@detail Index a ZField using an index from an HField of the same horizontal extent and a layer index for the final dimension.
hIndex | the equivalent positional index in an HField array |
layer | the vertical layer to be accessed |
Definition at line 558 of file ModelArray.hpp.
|
static |
Definition at line 70 of file ModelArray.hpp.
|
static |
The name and length of each dimension that is defined.
Definition at line 66 of file ModelArray.hpp.
|
static |
Definition at line 55 of file ModelArray.hpp.
|
protected |
Definition at line 547 of file ModelArray.hpp.
|
static |
The dimensions that make up each defined type. Defined in ModelArrayDetails.cpp.
Definition at line 64 of file ModelArray.hpp.
|
static |
The name of each type of ModelArray.
Definition at line 68 of file ModelArray.hpp.