Shortcuts

Template Function ripple::offset_to_aos

Function Documentation

template<typename SpatialImpl, typename ...Indices>
auto ripple::offset_to_aos(const MultidimSpace<SpatialImpl> &space, size_t element_size, Indices&&... indices) -> size_t

Returns the offset to the element at the index defined by the indices for each of the dimension in a space defined by the space.

The element_size is the number of elements in the array type, if the data stored the underlying type in the array.

For example, for a 2D velocity array for types T and the underlying storage for the space allocates T, the element_size would be 2. For complex types which store the whole type, for example if Vec<T, 2> is stored rather than raw T, then the element_size would be 1. This allows for the caller to compute the offset based on the way the data has been stored.

For the case that the u, v data is allocated as type T, the storage would look as follows:

Here element_size would be 2, since to compute the offset it’s required that the horizontal size be know. In the above example, with n=10, element_size=2, indices=(0, 1) would return an offset of 20, while indices=(3, 0) would return an offset of 6.

For the case that the u, v data is allocated as type Vec<T, 2, contiguous_owned_t>, the storage would look as follows:

Here element_size would be 1, since the underlying storage allocated the complex type contiguously. . In the above example, with n=10, element_size=1, indices=(0, 1) would return an offset of 10, while indices=(3, 0) would return an offset of 3.

Parameters
  • space: The multidimensional space to get the offset in.

  • element_size: The size of the elements stored in the space.

  • indices: The indicies for the element in the space.

Template Parameters
  • SpatialImpl: The implementation of the spatial interface.

  • Indices: The types of the indices.

Docs

Access comprehensive developer documentation for Ripple

View Docs

Tutorials

Get tutorials to help with understand all features

View Tutorials

Examples

Find examples to help get started

View Examples