Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Euclid::GridContainer::GridIndexHelper< AxesTypes > Class Template Reference

Helper class for converting multi-dimensional grid coordinates to the index of a long data array and vice versa. More...

#include <GridIndexHelper.h>

Collaboration diagram for Euclid::GridContainer::GridIndexHelper< AxesTypes >:
Collaboration graph
[legend]

Public Member Functions

 GridIndexHelper (const std::tuple< GridAxis< AxesTypes >... > &axes_tuple)
 
 GridIndexHelper (GridIndexHelper< AxesTypes... > &&)=default
 Default move constructor and assignment operator.
 
GridIndexHelperoperator= (GridIndexHelper< AxesTypes... > &&)=default
 
virtual ~GridIndexHelper ()=default
 Default destructor.
 
size_t axisIndex (size_t axis, size_t array_index) const
 
size_t totalIndex (decltype(std::declval< GridAxis< AxesTypes > >().size())... coords) const
 
size_t totalIndexChecked (decltype(std::declval< GridAxis< AxesTypes > >().size())... coords) const
 
template<typename Coord >
void checkAllFixedAreZero (const std::map< size_t, size_t > &fixed_indices, Coord coord) const
 Checks if any of the given coordinates is fixed and not zero.
 
template<typename Coord , typename... RestCoords>
void checkAllFixedAreZero (const std::map< size_t, size_t > &fixed_indices, Coord coord, RestCoords... rest_coords) const
 Checks if any of the given coordinates is fixed and not zero.
 

Public Attributes

std::vector< size_t > m_axes_sizes
 
std::vector< size_t > m_axes_index_factors
 
std::vector< std::stringm_axes_names
 

Detailed Description

template<typename... AxesTypes>
class Euclid::GridContainer::GridIndexHelper< AxesTypes >

Helper class for converting multi-dimensional grid coordinates to the index of a long data array and vice versa.

The assumption for the mapping is that the first axis is assumed to vary the fastest and the last the slowest. All indices and coordinates are zero based (start from zero). This class exists mainly to be used internally for the GridContainer iterator operations, but it is considered part of the public interface of the GridContainer module and can be used by any class which wants to perform such conversions. Use of this class in such cases is recommended for performance reasons.

Template Parameters
AxesTypesThe types of the GridContainer axes

Definition at line 54 of file GridIndexHelper.h.

Constructor & Destructor Documentation

◆ GridIndexHelper() [1/2]

template<typename... AxesTypes>
Euclid::GridContainer::GridIndexHelper< AxesTypes >::GridIndexHelper ( const std::tuple< GridAxis< AxesTypes >... > &  axes_tuple)
explicit

Constructs a new GridIndexHelper instance for making conversions for a GridContainer with the given axes. For avoiding the long template syntax consider using the makeGridIndexHelper() factory method instead.

Parameters
axes_tupleThe information about the axes of the GridContainer

◆ GridIndexHelper() [2/2]

template<typename... AxesTypes>
Euclid::GridContainer::GridIndexHelper< AxesTypes >::GridIndexHelper ( GridIndexHelper< AxesTypes... > &&  )
default

Default move constructor and assignment operator.

◆ ~GridIndexHelper()

template<typename... AxesTypes>
virtual Euclid::GridContainer::GridIndexHelper< AxesTypes >::~GridIndexHelper ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ axisIndex()

template<typename... AxesTypes>
size_t Euclid::GridContainer::GridIndexHelper< AxesTypes >::axisIndex ( size_t  axis,
size_t  array_index 
) const

Returns the coordinate of the GridContainer axis with the given index which corresponds to the given index of a one dimensional array containing all the GridContainer elements.

Parameters
axisThe axis to get the index for
array_indexThe index of the one dimensional array
Returns
the coordinate of the axis

◆ checkAllFixedAreZero() [1/2]

template<typename... AxesTypes>
template<typename Coord >
void Euclid::GridContainer::GridIndexHelper< AxesTypes >::checkAllFixedAreZero ( const std::map< size_t, size_t > &  fixed_indices,
Coord  coord 
) const

Checks if any of the given coordinates is fixed and not zero.

◆ checkAllFixedAreZero() [2/2]

template<typename... AxesTypes>
template<typename Coord , typename... RestCoords>
void Euclid::GridContainer::GridIndexHelper< AxesTypes >::checkAllFixedAreZero ( const std::map< size_t, size_t > &  fixed_indices,
Coord  coord,
RestCoords...  rest_coords 
) const

Checks if any of the given coordinates is fixed and not zero.

◆ operator=()

template<typename... AxesTypes>
GridIndexHelper & Euclid::GridContainer::GridIndexHelper< AxesTypes >::operator= ( GridIndexHelper< AxesTypes... > &&  )
default

◆ totalIndex()

template<typename... AxesTypes>
size_t Euclid::GridContainer::GridIndexHelper< AxesTypes >::totalIndex ( decltype(std::declval< GridAxis< AxesTypes > >().size())...  coords) const

Returns the index of a one dimensional array which corresponds to the given GridContainer coordinates. This method does not perform any bound checks.

Parameters
coordsThe GridContainer coordinates
Returns
the one dimensional array index

◆ totalIndexChecked()

template<typename... AxesTypes>
size_t Euclid::GridContainer::GridIndexHelper< AxesTypes >::totalIndexChecked ( decltype(std::declval< GridAxis< AxesTypes > >().size())...  coords) const

Returns the index of a one dimensional array which corresponds to the given GridContainer coordinates. This method performs bound checks.

Parameters
coordsThe GridContainer coordinates
Returns
the one dimensional array index
Exceptions
Elements::Exceptionif any coordinate is out of bound

Member Data Documentation

◆ m_axes_index_factors

template<typename... AxesTypes>
std::vector<size_t> Euclid::GridContainer::GridIndexHelper< AxesTypes >::m_axes_index_factors

Definition at line 114 of file GridIndexHelper.h.

◆ m_axes_names

template<typename... AxesTypes>
std::vector<std::string> Euclid::GridContainer::GridIndexHelper< AxesTypes >::m_axes_names

Definition at line 115 of file GridIndexHelper.h.

◆ m_axes_sizes

template<typename... AxesTypes>
std::vector<size_t> Euclid::GridContainer::GridIndexHelper< AxesTypes >::m_axes_sizes

Definition at line 113 of file GridIndexHelper.h.


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