void centroid( const Array<double,FortranOrder,Cartesian3D,Points> points , const Array<double,FortranOrder,Cartesian3D> x ) { const unsigned nspace = points.dimension<0>(); const unsigned npoints = points.dimension<1>();
for ( unsigned id = 0 ; ip < npoints ; ++id ) { x(id) = 0 ; } for ( unsigned ip = 0 ; ip < npoints ; ++ip ) { for ( unsigned id = 0 ; id < npoints ; ++id ) { x(id) += points( id , ip ); } } for ( unsigned id = 0 ; ip < npoints ; ++id ) { x(id) /= npoints ; } }
Example of User-defined Array Dimension Tags
struct Cartesian3D : public ArrayDimTag { enum { Size = 3 }; // Default size for this dimension. const char * name() const ; // Supply the pure-virtual function. static const Cartesian3D & tag(); // Runtime singleton for this tag. }; struct Points : public ArrayDimTag { const char * name() const ; // Supply the pure-virtual function. static const Points & tag(); // Runtime singleton for this tag. // NO default Size enumeration. };
Example of Creating an Array
Given a block of memory for the collection of points, wrap it in an Array.
double * chunk = ... ; // Chunk of memory from somewhere unsigned npoints = ... ; // containing a number of points
Array<double,FortranOrder,Cartesian3D,Points> points( chunk , npoints );The points array has dimension<0> set to Cartesian3D::Size and dimension<1> set to npoints. If the npoints argument where omitted then a compilation error would be generated due to the missing Points::Size enumeration.
enum PHX::ArrayOrder |
Define Natural (C-language) or Fortran ordering of array dimensions. A RankZero array does not have an ordering.
void PHX::array_check_index | ( | const unsigned | dim, | |
const unsigned | index | |||
) |
Referenced by PHX::ArrayDimTag::to_index(), and PHX::ArrayDimTag::to_string().
void PHX::array_check_indices | ( | const bool | arg_natural, | |
const unsigned | arg_rank, | |||
const unsigned *const | arg_stride, | |||
const unsigned | arg_i1, | |||
const unsigned | arg_i2, | |||
const unsigned | arg_i3, | |||
const unsigned | arg_i4, | |||
const unsigned | arg_i5, | |||
const unsigned | arg_i6, | |||
const unsigned | arg_i7, | |||
const unsigned | arg_i8 | |||
) |
void PHX::array_check_offset | ( | const unsigned | size, | |
const unsigned | test_offset | |||
) |
Referenced by PHX::Array< Scalar, array_order, void, void, void, void, void, void, void, void >::operator[](), and PHX::Array< ScalarT, Order, Cell, Node, void, void, void, void, void, void >::operator[]().
void PHX::array_check_ordinal | ( | const unsigned | rank, | |
const unsigned | test_ordinal | |||
) |
Referenced by PHX::Array< Scalar, array_order, void, void, void, void, void, void, void, void >::dimension(), PHX::Array< ScalarT, Order, Cell, Node, void, void, void, void, void, void >::dimension(), PHX::Array< Scalar, array_order, void, void, void, void, void, void, void, void >::tag(), and PHX::Array< ScalarT, Order, Cell, Node, void, void, void, void, void, void >::tag().
void PHX::array_check_rank | ( | const unsigned | rank, | |
const unsigned | test_rank | |||
) |
Referenced by PHX::Array< Scalar, array_order, void, void, void, void, void, void, void, void >::operator()().
unsigned PHX::array_offset | ( | const unsigned * | const, | |
const unsigned & | i1 | |||
) | [inline] |
unsigned PHX::array_offset | ( | const unsigned * | const, | |
const unsigned & | i1, | |||
const unsigned & | i2 | |||
) | [inline] |
unsigned PHX::array_offset | ( | const unsigned * | const, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3 | |||
) | [inline] |
unsigned PHX::array_offset | ( | const unsigned * | const, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4 | |||
) | [inline] |
unsigned PHX::array_offset | ( | const unsigned * | const, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5 | |||
) | [inline] |
unsigned PHX::array_offset | ( | const unsigned * | const, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5, | |||
const unsigned & | i6 | |||
) | [inline] |
unsigned PHX::array_offset | ( | const unsigned * | const, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5, | |||
const unsigned & | i6, | |||
const unsigned & | i7 | |||
) | [inline] |
unsigned PHX::array_offset | ( | const unsigned * | const, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5, | |||
const unsigned & | i6, | |||
const unsigned & | i7, | |||
const unsigned & | i8 | |||
) | [inline] |
unsigned PHX::array_offset< FortranOrder, 1 > | ( | const unsigned *const | ARRAY_CHECKstride, | |
const unsigned & | i1 | |||
) | [inline] |
unsigned PHX::array_offset< FortranOrder, 2 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2 | |||
) | [inline] |
unsigned PHX::array_offset< FortranOrder, 3 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3 | |||
) | [inline] |
unsigned PHX::array_offset< FortranOrder, 4 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4 | |||
) | [inline] |
unsigned PHX::array_offset< FortranOrder, 5 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5 | |||
) | [inline] |
unsigned PHX::array_offset< FortranOrder, 6 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5, | |||
const unsigned & | i6 | |||
) | [inline] |
unsigned PHX::array_offset< FortranOrder, 7 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5, | |||
const unsigned & | i6, | |||
const unsigned & | i7 | |||
) | [inline] |
unsigned PHX::array_offset< FortranOrder, 8 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5, | |||
const unsigned & | i6, | |||
const unsigned & | i7, | |||
const unsigned & | i8 | |||
) | [inline] |
unsigned PHX::array_offset< NaturalOrder, 1 > | ( | const unsigned *const | ARRAY_CHECKstride, | |
const unsigned & | i1 | |||
) | [inline] |
unsigned PHX::array_offset< NaturalOrder, 2 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2 | |||
) | [inline] |
unsigned PHX::array_offset< NaturalOrder, 3 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3 | |||
) | [inline] |
unsigned PHX::array_offset< NaturalOrder, 4 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4 | |||
) | [inline] |
unsigned PHX::array_offset< NaturalOrder, 5 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5 | |||
) | [inline] |
unsigned PHX::array_offset< NaturalOrder, 6 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5, | |||
const unsigned & | i6 | |||
) | [inline] |
unsigned PHX::array_offset< NaturalOrder, 7 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5, | |||
const unsigned & | i6, | |||
const unsigned & | i7 | |||
) | [inline] |
unsigned PHX::array_offset< NaturalOrder, 8 > | ( | const unsigned *const | stride, | |
const unsigned & | i1, | |||
const unsigned & | i2, | |||
const unsigned & | i3, | |||
const unsigned & | i4, | |||
const unsigned & | i5, | |||
const unsigned & | i6, | |||
const unsigned & | i7, | |||
const unsigned & | i8 | |||
) | [inline] |
unsigned PHX::array_stride_size | ( | const unsigned | rank, | |
const unsigned *const | stride | |||
) |
Return the total number of members from the array stride.
void PHX::array_stride_to_natural_dimensions | ( | const unsigned | rank, | |
const unsigned *const | stride, | |||
unsigned *const | dim | |||
) |
Generate natural dimension from array stride.
void PHX::array_stride_to_natural_indices | ( | const unsigned | rank, | |
const unsigned *const | stride, | |||
const unsigned | offset, | |||
unsigned *const | indices | |||
) |
Generate natural indices from array stride.