Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 :
8 : #include "DataStructures/Index.hpp"
9 : #include "Domain/Structure/Direction.hpp"
10 : #include "Domain/Structure/Side.hpp"
11 :
12 : /// \ingroup ComputationalDomainGroup
13 : /// \brief Finds the index in the perpendicular dimension of an element boundary
14 : ///
15 : /// Optionally provide an `offset` to find an index offset from the element
16 : /// boundary.
17 : template <size_t Dim>
18 1 : size_t index_to_slice_at(const Index<Dim>& extents,
19 : const Direction<Dim>& direction,
20 : const size_t offset = 0) {
21 : return direction.side() == Side::Lower
22 : ? offset
23 : : extents[direction.dimension()] - 1 - offset;
24 : }
|