DASH  0.3.0
dash::halo::StencilPoint< NumDimensions, CoeffT > Class Template Reference

Stencil point with raletive coordinates for N dimensions e.g. More...

#include <Stencil.h>

Public Types

using coefficient_t = CoeffT
 

Public Member Functions

 StencilPoint ()
 Default Contructor. More...
 
template<typename... Values>
constexpr StencilPoint (typename std::enable_if< sizeof...(Values)==NumDimensions - 1, spoint_value_t >::type value, Values... values)
 Constructor. More...
 
template<typename... Values>
constexpr StencilPoint (typename std::enable_if< sizeof...(Values)==NumDimensions - 1, CoeffT >::type coefficient, spoint_value_t value, Values... values)
 Constructor. More...
 
int max () const
 Returns maximum distance to center over all dimensions. More...
 
template<typename ElementCoordsT >
ElementCoordsT stencil_coords (ElementCoordsT &coords) const
 Returns coordinates adjusted by stencil point. More...
 
template<typename ElementCoordsT , typename ViewSpecT >
std::pair< ElementCoordsT, bool > stencil_coords_check (ElementCoordsT coords, const ViewSpecT &view) const
 Returns coordinates adjusted by a stencil point and a boolean to indicate a if the adjusted coordinate points to elements out of the given ViewSpecpossible (inside: true, else: false). More...
 
template<typename ElementCoordsT , typename ViewSpecT >
std::pair< ElementCoordsT, bool > stencil_coords_check_abort (ElementCoordsT coords, const ViewSpecT &view) const
 Returns coordinates adjusted by a stencil point and a boolean to indicate a if the adjusted coordinate points to elements out of the given ViewSpec: possible (inside: true, else: false). More...
 
CoeffT coefficient () const
 Returns the coefficient for this stencil point. More...
 
constexpr const std::array< spoint_value_t, NumDimensions > & values () const
 Return value with all dimensions as array of NumDimensions elements. More...
 
spoint_value_t dim (dim_t dimension) const
 The value in the given dimension. More...
 
constexpr spoint_value_t operator[] (size_t dimension) const
 Subscript operator, access to value in dimension given by index. More...
 
spoint_value_t & operator[] (size_t dimension)
 Subscript assignment operator, access to value in dimension given by index. More...
 
constexpr bool operator== (const self_t &other) const
 Equality comparison operator. More...
 
constexpr bool operator!= (const self_t &other) const
 Equality comparison operator. More...
 
constexpr dim_t rank () const
 The number of dimensions of the value. More...
 

Static Public Member Functions

template<typename ElementCoordsT >
static ElementCoordsT stencil_coords (ElementCoordsT coords, const StencilPoint< NumDimensions, CoeffT > &stencilp)
 Returns coordinates adjusted by a given stencil point. More...
 
static constexpr dim_t ndim ()
 The number of dimensions of the value. More...
 

Detailed Description

template<dim_t NumDimensions, typename CoeffT = double>
class dash::halo::StencilPoint< NumDimensions, CoeffT >

Stencil point with raletive coordinates for N dimensions e.g.

StencilPoint<2>(-1,-1) -> north west

Examples:
ex.11.halo-stencil/main.cpp.

Definition at line 19 of file Stencil.h.

Constructor & Destructor Documentation

◆ StencilPoint() [1/3]

template<dim_t NumDimensions, typename CoeffT = double>
dash::halo::StencilPoint< NumDimensions, CoeffT >::StencilPoint ( )
inline

Default Contructor.

All stencil point values are 0 and default coefficient = 1.0.

Definition at line 33 of file Stencil.h.

33  {
34  for(dim_t d = 0; d < NumDimensions; ++d) {
35  this->_values[d] = 0;
36  }
37  }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39

◆ StencilPoint() [2/3]

template<dim_t NumDimensions, typename CoeffT = double>
template<typename... Values>
constexpr dash::halo::StencilPoint< NumDimensions, CoeffT >::StencilPoint ( typename std::enable_if< sizeof...(Values)==NumDimensions - 1, spoint_value_t >::type  value,
Values...  values 
)
inline

Constructor.

Custom stencil point values for all dimensions and default coefficient = 1.0.

Definition at line 46 of file Stencil.h.

50  : Base_t::Dimensional(value, (spoint_value_t) values...) {}
constexpr const std::array< spoint_value_t, NumDimensions > & values() const
Return value with all dimensions as array of NumDimensions elements.
Definition: Dimensional.h:142

◆ StencilPoint() [3/3]

template<dim_t NumDimensions, typename CoeffT = double>
template<typename... Values>
constexpr dash::halo::StencilPoint< NumDimensions, CoeffT >::StencilPoint ( typename std::enable_if< sizeof...(Values)==NumDimensions - 1, CoeffT >::type  coefficient,
spoint_value_t  value,
Values...  values 
)
inline

Constructor.

Custom values and custom coefficient.

Definition at line 58 of file Stencil.h.

62  : Base_t::Dimensional(value, (spoint_value_t) values...),
63  _coefficient(coefficient) {}
constexpr const std::array< spoint_value_t, NumDimensions > & values() const
Return value with all dimensions as array of NumDimensions elements.
Definition: Dimensional.h:142
CoeffT coefficient() const
Returns the coefficient for this stencil point.
Definition: Stencil.h:139

Member Function Documentation

◆ coefficient()

template<dim_t NumDimensions, typename CoeffT = double>
CoeffT dash::halo::StencilPoint< NumDimensions, CoeffT >::coefficient ( ) const
inline

Returns the coefficient for this stencil point.

Definition at line 139 of file Stencil.h.

References dash::halo::StencilPoint< NumDimensions, CoeffT >::coefficient().

Referenced by dash::halo::StencilPoint< NumDimensions, CoeffT >::coefficient().

139 { return _coefficient; }

◆ dim()

spoint_value_t dash::Dimensional< spoint_value_t , NumDimensions >::dim ( dim_t  dimension) const
inlineinherited

The value in the given dimension.

Parameters
dimensionThe dimension
Returns
The value in the given dimension

Definition at line 152 of file Dimensional.h.

152  {
153  DASH_ASSERT_LT(
154  dimension, NumDimensions,
155  "Dimension for Dimensional::extent() must be lower than " <<
156  NumDimensions);
157  return _values[dimension];
158  }

◆ max()

template<dim_t NumDimensions, typename CoeffT = double>
int dash::halo::StencilPoint< NumDimensions, CoeffT >::max ( ) const
inline

Returns maximum distance to center over all dimensions.

Definition at line 69 of file Stencil.h.

69  {
70  int max = 0;
71  for(dim_t d = 0; d < NumDimensions; ++d)
72  max = std::max(max, (int) std::abs(this->_values[d]));
73  return max;
74  }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
int max() const
Returns maximum distance to center over all dimensions.
Definition: Stencil.h:69

◆ ndim()

static constexpr dim_t dash::Dimensional< spoint_value_t , NumDimensions >::ndim ( )
inlinestaticinherited

The number of dimensions of the value.

Definition at line 207 of file Dimensional.h.

207  {
208  return NumDimensions;
209  }

◆ operator!=()

constexpr bool dash::Dimensional< spoint_value_t , NumDimensions >::operator!= ( const self_t other) const
inlineinherited

Equality comparison operator.

Definition at line 193 of file Dimensional.h.

193  {
194  return !(*this == other);
195  }

◆ operator==()

constexpr bool dash::Dimensional< spoint_value_t , NumDimensions >::operator== ( const self_t other) const
inlineinherited

Equality comparison operator.

Definition at line 186 of file Dimensional.h.

186  {
187  return this == &other || _values == other._values;
188  }

◆ operator[]() [1/2]

constexpr spoint_value_t dash::Dimensional< spoint_value_t , NumDimensions >::operator[] ( size_t  dimension) const
inlineinherited

Subscript operator, access to value in dimension given by index.

Alias for dim.

Parameters
dimensionThe dimension
Returns
The value in the given dimension

Definition at line 167 of file Dimensional.h.

167  {
168  return _values[dimension];
169  }

◆ operator[]() [2/2]

spoint_value_t & dash::Dimensional< spoint_value_t , NumDimensions >::operator[] ( size_t  dimension)
inlineinherited

Subscript assignment operator, access to value in dimension given by index.

Alias for dim.

Parameters
dimensionThe dimension
Returns
A reference to the value in the given dimension

Definition at line 179 of file Dimensional.h.

179  {
180  return _values[dimension];
181  }

◆ rank()

constexpr dim_t dash::Dimensional< spoint_value_t , NumDimensions >::rank ( ) const
inlineinherited

The number of dimensions of the value.

Definition at line 200 of file Dimensional.h.

200  {
201  return NumDimensions;
202  }

◆ stencil_coords() [1/2]

template<dim_t NumDimensions, typename CoeffT = double>
template<typename ElementCoordsT >
ElementCoordsT dash::halo::StencilPoint< NumDimensions, CoeffT >::stencil_coords ( ElementCoordsT &  coords) const
inline

Returns coordinates adjusted by stencil point.

Definition at line 80 of file Stencil.h.

80  {
82  }
ElementCoordsT stencil_coords(ElementCoordsT &coords) const
Returns coordinates adjusted by stencil point.
Definition: Stencil.h:80

◆ stencil_coords() [2/2]

template<dim_t NumDimensions, typename CoeffT = double>
template<typename ElementCoordsT >
static ElementCoordsT dash::halo::StencilPoint< NumDimensions, CoeffT >::stencil_coords ( ElementCoordsT  coords,
const StencilPoint< NumDimensions, CoeffT > &  stencilp 
)
inlinestatic

Returns coordinates adjusted by a given stencil point.

Definition at line 88 of file Stencil.h.

90  {
91  for(dim_t d = 0; d < NumDimensions; ++d) {
92  coords[d] += stencilp[d];
93  }
94 
95  return coords;
96  }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39

◆ stencil_coords_check()

template<dim_t NumDimensions, typename CoeffT = double>
template<typename ElementCoordsT , typename ViewSpecT >
std::pair<ElementCoordsT, bool> dash::halo::StencilPoint< NumDimensions, CoeffT >::stencil_coords_check ( ElementCoordsT  coords,
const ViewSpecT &  view 
) const
inline

Returns coordinates adjusted by a stencil point and a boolean to indicate a if the adjusted coordinate points to elements out of the given ViewSpecpossible (inside: true, else: false).

Definition at line 104 of file Stencil.h.

105  {
106  bool halo = false;
107  for(dim_t d = 0; d < NumDimensions; ++d) {
108  coords[d] += this->_values[d];
109  if(coords[d] < view.offset(d) || coords[d] >= view.offset(d) + view.extent(d))
110  halo = true;
111  }
112 
113  return std::make_pair(coords, halo);
114  }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39

◆ stencil_coords_check_abort()

template<dim_t NumDimensions, typename CoeffT = double>
template<typename ElementCoordsT , typename ViewSpecT >
std::pair<ElementCoordsT, bool> dash::halo::StencilPoint< NumDimensions, CoeffT >::stencil_coords_check_abort ( ElementCoordsT  coords,
const ViewSpecT &  view 
) const
inline

Returns coordinates adjusted by a stencil point and a boolean to indicate a if the adjusted coordinate points to elements out of the given ViewSpec: possible (inside: true, else: false).

If one dimension points to an element outside the ViewSpec this method returns immediately the unfinished adjusted coordinate and true. Otherwise the adjusted coordinate and false is returned,

Definition at line 125 of file Stencil.h.

126  {
127  for(dim_t d = 0; d < NumDimensions; ++d) {
128  coords[d] += this->_values[d];
129  if(coords[d] < view.offset(d) || coords[d] >= view.offset(d) + view.extent(d))
130  return std::make_pair(coords, true);
131  }
132 
133  return std::make_pair(coords, false);
134  }
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39

◆ values()

constexpr const std::array<spoint_value_t , NumDimensions>& dash::Dimensional< spoint_value_t , NumDimensions >::values ( ) const
inlineinherited

Return value with all dimensions as array of NumDimensions elements.

Definition at line 142 of file Dimensional.h.

142  {
143  return _values;
144  }

The documentation for this class was generated from the following file: