Chombo + EB
3.0
|
Multidimensional array class. More...
#include <CHArray.H>
Classes | |
struct | Array_impl |
Public Member Functions | |
CHArray () | |
Default constructor. More... | |
CHArray (const DimT &dim6, const DimT &dim5, const DimT &dim4, const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) | |
Construct with dimensions. More... | |
CHArray (const DimT &dim5, const DimT &dim4, const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) | |
CHArray (const DimT &dim4, const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) | |
CHArray (const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) | |
CHArray (const DimT &dim2, const DimT &dim1, const DimT &dim0) | |
CHArray (const DimT &dim1, const DimT &dim0) | |
CHArray (const DimT &dim0) | |
CHArray (const IntVect &iv, const DimT &dimc1, const DimT &dimc0) | |
CHArray (const IntVect &iv, const DimT &dimc0) | |
CHArray (const DimT &dimc1, const DimT &dimc0, const IntVect &iv) | |
CHArray (const DimT &dimc0, const IntVect &iv) | |
CHArray (const Box &box, const DimT &dimc1, const DimT &dimc0) | |
CHArray (const Box &box, const DimT &dimc0) | |
CHArray (const DimT &dimc1, const DimT &dimc0, const Box &box) | |
CHArray (const DimT &dimc0, const Box &box) | |
void | define (const DimT &dim6, const DimT &dim5, const DimT &dim4, const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) |
Define the dimensions. More... | |
void | define (const DimT &dim5, const DimT &dim4, const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) |
void | define (const DimT &dim4, const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) |
void | define (const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) |
void | define (const DimT &dim2, const DimT &dim1, const DimT &dim0) |
void | define (const DimT &dim1, const DimT &dim0) |
void | define (const DimT &dim0) |
void | define (const IntVect &iv, const DimT &dimc1, const DimT &dimc0) |
void | define (const IntVect &iv, const DimT &dimc0) |
void | define (const DimT &dimc1, const DimT &dimc0, const IntVect &iv) |
void | define (const DimT &dimc0, const IntVect &iv) |
void | define (const Box &box, const DimT &dimc1, const DimT &dimc0) |
void | define (const Box &box, const DimT &dimc0) |
void | define (const DimT &dimc1, const DimT &dimc0, const Box &box) |
void | define (const DimT &dimc0, const Box &box) |
void | define (void *const addr, const DimT &dim6, const DimT &dim5, const DimT &dim4, const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) |
Define the dimensions and allocate on 'addr'. More... | |
void | define (void *const addr, const DimT &dim5, const DimT &dim4, const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) |
void | define (void *const addr, const DimT &dim4, const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) |
void | define (void *const addr, const DimT &dim3, const DimT &dim2, const DimT &dim1, const DimT &dim0) |
void | define (void *const addr, const DimT &dim2, const DimT &dim1, const DimT &dim0) |
void | define (void *const addr, const DimT &dim1, const DimT &dim0) |
void | define (void *const addr, const DimT &dim0) |
void | define (void *const addr, const IntVect &iv, const DimT &dimc1, const DimT &dimc0) |
void | define (void *const addr, const IntVect &iv, const DimT &dimc0) |
void | define (void *const addr, const DimT &dimc1, const DimT &dimc0, const IntVect &iv) |
void | define (void *const addr, const DimT &dimc0, const IntVect &iv) |
void | define (void *const addr, const Box &box, const DimT &dimc1, const DimT &dimc0) |
void | define (void *const addr, const Box &box, const DimT &dimc0) |
void | define (void *const addr, const DimT &dimc1, const DimT &dimc0, const Box &box) |
void | define (void *const addr, const DimT &dimc0, const Box &box) |
void | undefine () |
Deallocate the array. More... | |
template<typename T2 > | |
CHArray & | operator= (const T2 &val) |
Assign a constant to the array. More... | |
T & | operator() (const ArSp::IIx_t i6, const ArSp::IIx_t i5, const ArSp::IIx_t i4, const ArSp::IIx_t i3, const ArSp::IIx_t i2, const ArSp::IIx_t i1, const ArSp::IIx_t i0) |
Access an element. More... | |
T & | operator() (const ArSp::IIx_t i5, const ArSp::IIx_t i4, const ArSp::IIx_t i3, const ArSp::IIx_t i2, const ArSp::IIx_t i1, const ArSp::IIx_t i0) |
T & | operator() (const ArSp::IIx_t i4, const ArSp::IIx_t i3, const ArSp::IIx_t i2, const ArSp::IIx_t i1, const ArSp::IIx_t i0) |
T & | operator() (const ArSp::IIx_t i3, const ArSp::IIx_t i2, const ArSp::IIx_t i1, const ArSp::IIx_t i0) |
T & | operator() (const ArSp::IIx_t i2, const ArSp::IIx_t i1, const ArSp::IIx_t i0) |
T & | operator() (const ArSp::IIx_t i1, const ArSp::IIx_t i0) |
T & | operator() (const ArSp::IIx_t i0) |
T & | operator() (const IntVect &iv, const ArSp::IIx_t c1, const ArSp::IIx_t c0) |
T & | operator() (const IntVect &iv, const ArSp::IIx_t c0) |
T & | operator() (const ArSp::IIx_t c1, const ArSp::IIx_t c0, const IntVect &iv) |
T & | operator() (const ArSp::IIx_t c0, const IntVect &iv) |
const T & | operator() (const ArSp::IIx_t i6, const ArSp::IIx_t i5, const ArSp::IIx_t i4, const ArSp::IIx_t i3, const ArSp::IIx_t i2, const ArSp::IIx_t i1, const ArSp::IIx_t i0) const |
Constant access to an element. More... | |
const T & | operator() (const ArSp::IIx_t i5, const ArSp::IIx_t i4, const ArSp::IIx_t i3, const ArSp::IIx_t i2, const ArSp::IIx_t i1, const ArSp::IIx_t i0) const |
const T & | operator() (const ArSp::IIx_t i4, const ArSp::IIx_t i3, const ArSp::IIx_t i2, const ArSp::IIx_t i1, const ArSp::IIx_t i0) const |
const T & | operator() (const ArSp::IIx_t i3, const ArSp::IIx_t i2, const ArSp::IIx_t i1, const ArSp::IIx_t i0) const |
const T & | operator() (const ArSp::IIx_t i2, const ArSp::IIx_t i1, const ArSp::IIx_t i0) const |
const T & | operator() (const ArSp::IIx_t i1, const ArSp::IIx_t i0) const |
const T & | operator() (const ArSp::IIx_t i0) const |
const T & | operator() (const IntVect &iv, const ArSp::IIx_t c1, const ArSp::IIx_t c0) const |
const T & | operator() (const IntVect &iv, const ArSp::IIx_t c0) const |
const T & | operator() (const ArSp::IIx_t c1, const ArSp::IIx_t c0, const IntVect &iv) const |
const T & | operator() (const ArSp::IIx_t c0, const IntVect &iv) const |
Alloc & | getAllocator () |
Get the allocator. More... | |
T * | begin () |
Access extents of the memory allocated for the array. More... | |
const T * | begin () const |
T * | end () |
const T * | end () const |
ArSp::USz_t | size () const |
Overall size of the array. More... | |
ArSp::USz_t | size (const unsigned dim) const |
Size of a dimension (0 is dimension with contiguous storage) More... | |
ArSp::IIx_t | lowerBound (const unsigned dim) const |
Lower bound of a dimension (0 is dimension with contiguous storage) More... | |
ArSp::IIx_t | upperBound (const unsigned dim) const |
Upper bound of a dimension (0 is dimension with contiguous storage) More... | |
bool | isAllocated () const |
Memory has been allocated. More... | |
bool | isUsable () const |
Memory has been allocated and size is > 0. More... | |
Private Types | |
typedef ArSp::ArTr< Rank, ArConf >::DimT | DimT |
typedef ArSp::ArTr< Rank, ArConf >::IndexerT | Indexer |
Private Member Functions | |
CHArray (const CHArray &) | |
CHArray & | operator= (const CHArray &) |
Private Attributes | |
Array_impl | m_arrayImpl |
Data + allocation/deallocation. More... | |
Multidimensional array class.
T | Type of element |
Rank | Rank of the array |
ArConf | Configuration of the indexing. Allowable values are: ArZeroRow - Row-ordered indexing with lower bound = 0 ArZeroCol - Column-ordered indexing with lower bound = 0 (DEFAULT) ArRangeRow - Row-ordered indexing with subscript ranges ArRangeCol - Column-ordered indexing with subscript ranges |
Alloc | Allocator for the array |
Example
* * CHArray<int, 3> A(2, 2, 2); * A = 2; * A(0, 0, 0) = 4; * std::cout << A << std::endl; * CHArray<double, 2> B; * B.define(3, 4); * B(2, 3) = 5.5; *
One can also use subscript ranges but the array has to be configured to support this. Ranges are specified with CHRange in place of a size. Any integer types are converted to CHRange(0, int-1). E.g.,
* CHArray<int, 3, ArRangeRow> C(CHRange(-1,0), 2, 2); * C = 2; * C(-1, 0, 0) = 4; *
IntVects are allowed for specifying some of the dimensions so that this class can be used with boxes, e.g:
* * CHArray<int, SpaceDim+1> A(box.size(), 1) *
The indices of the IntVect are rearranged so that the first index is always closest to contiguous memory no matter if the actual memory layout is row- ordered or column-ordered. In other words, the first index of the IntVect always has the lowest stride. As such, the allocated memory can be accessed by iterating over the box in Chombo Fortran. Whether the remaining indices (or components) are left or right of the IntVect and the storage order determine if the components are distributed across the IntVects (like with a BaseFab) or are contiguous in each IntVect. The effect is natural; for row storage, components on the right will lead to contigous memory. E.g.,
* typedef CHArray<int, SpaceDim+1, ArZeroRow> CHArrayRS; * typedef CHArray<int, SpaceDim+1, ArZeroCol> CHArrayCS; * const IntVect iv(2, 2); * CHArrayRS ARS_IVComp(iv, 2); * CHArrayRS ARS_CompIV(2, iv); * CHArrayCS ACS_IVComp(iv, 2); * CHArrayCS ACS_CompIV(2, iv); * int ic = 1; * for (int j = 0; j != 2; ++j) * for (int i = 0; i != 2; ++i) // Column storage! * { * const IntVect ixv(i, j); * ARS_IVComp(ixv, 0) = ic; * ARS_IVComp(ixv, 1) = -ic; * ARS_CompIV(0, ixv) = ic; * ARS_CompIV(1, ixv) = -ic; * ACS_IVComp(ixv, 0) = ic; * ACS_IVComp(ixv, 1) = -ic; * ACS_CompIV(0, ixv) = ic; * ACS_CompIV(1, ixv) = -ic; * ++ic; * } * * std::cout << "ARS_IVComp: " << ARS_IVComp << std::endl; * std::cout << "ARS_CompIV: " << ARS_CompIV << std::endl; * std::cout << "ACS_IVComp: " << ACS_IVComp << std::endl; * std::cout << "ACS_CompIV: " << ACS_CompIV << std::endl; *
will produce
* $ ARS_IVComp: 1 -1 2 -2 3 -3 4 -4 * $ ARS_CompIV: 1 2 3 4 -1 -2 -3 -4 * $ ACS_IVComp: 1 2 3 4 -1 -2 -3 -4 * $ ACS_CompIV: 1 -1 2 -2 3 -3 4 -4 *
Note that the IntVects simply expand to dimensions and there is nothing to ensure that you access in the array in the same manner you defined it (i.e., switching the order of the IntVect and the component)!
IntVects are always zero-based and there is no way to specify a range of IntVects. However, one can use Boxes instead of IntVects to define the array but only if the array is configured with subscript ranges (ArConf = ArRangeRow or ArRangeCol)
* Box box(IntVect(-1,-1), IntVect(1, 1)); * CHArray<int, SpaceDim+1, ArRangeRow> AB(box, 2); * AB = 1; * AB(IntVect(-1, -1), 0) = 2; * std::cout << AB << std::endl; *
|
private |
|
private |
|
inline |
Default constructor.
|
inline |
Construct with dimensions.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
|
inline |
Define the dimensions.
Referenced by ArSp::ArrayOfMatrixAlloc::allocate().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
References ArSp::sizeOfDim().
|
inline |
References D_DEFIV, and IntVect::product().
|
inline |
References D_DEFIV, and IntVect::product().
|
inline |
References D_DEFIV, and IntVect::product().
|
inline |
References D_DEFIV, and IntVect::product().
|
inline |
References D_DEFBOX, IntVect::product(), and Box::size().
|
inline |
References D_DEFBOX, IntVect::product(), and Box::size().
|
inline |
References D_DEFBOX, IntVect::product(), and Box::size().
|
inline |
References D_DEFBOX, IntVect::product(), and Box::size().
|
inline |
Define the dimensions and allocate on 'addr'.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
References ArSp::sizeOfDim().
|
inline |
References D_DEFIV, and IntVect::product().
|
inline |
References D_DEFIV, and IntVect::product().
|
inline |
References D_DEFIV, and IntVect::product().
|
inline |
References D_DEFIV, and IntVect::product().
|
inline |
References D_DEFBOX, IntVect::product(), and Box::size().
|
inline |
References D_DEFBOX, IntVect::product(), and Box::size().
|
inline |
References D_DEFBOX, IntVect::product(), and Box::size().
|
inline |
References D_DEFBOX, IntVect::product(), and Box::size().
|
inline |
Deallocate the array.
References CH_assert.
|
inline |
Assign a constant to the array.
References CH_assert, and IntVect::p().
|
inline |
Access an element.
References CH_assert.
|
inline |
References CH_assert.
|
inline |
References CH_assert.
|
inline |
References CH_assert.
|
inline |
References CH_assert.
|
inline |
References CH_assert.
|
inline |
References CH_assert.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Constant access to an element.
References CH_assert.
|
inline |
References CH_assert.
|
inline |
References CH_assert.
|
inline |
References CH_assert.
|
inline |
References CH_assert.
|
inline |
References CH_assert.
|
inline |
References CH_assert.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the allocator.
|
inline |
Access extents of the memory allocated for the array.
Referenced by operator<<().
|
inline |
|
inline |
Referenced by operator<<().
|
inline |
|
inline |
Overall size of the array.
Referenced by operator<<().
|
inline |
Size of a dimension (0 is dimension with contiguous storage)
References CH_assert.
|
inline |
Lower bound of a dimension (0 is dimension with contiguous storage)
References CH_assert.
|
inline |
Upper bound of a dimension (0 is dimension with contiguous storage)
References CH_assert.
|
inline |
Memory has been allocated.
Referenced by operator<<().
|
inline |
Memory has been allocated and size is > 0.
References IntVect::operator=().
|
private |
|
private |
Data + allocation/deallocation.