TestHelpers.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <unordered_set>
8 
12 #include "Domain/Structure/OrientationMap.hpp"
13 
14 namespace TestHelpers {
15 namespace Limiters {
16 
17 // Construct a Neighbors object with one neighboring element.
18 template <size_t VolumeDim>
19 Neighbors<VolumeDim> make_neighbor_with_id(const size_t id) noexcept {
21  OrientationMap<VolumeDim>{}};
22 }
23 
24 // Construct an Element with one neighboring element in each direction.
25 //
26 // The optional argument specifies directions to external boundaries, i.e.,
27 // directions where there is no neighboring element.
28 template <size_t VolumeDim>
29 Element<VolumeDim> make_element(
31  directions_of_external_boundaries = {}) noexcept {
32  typename Element<VolumeDim>::Neighbors_t neighbors;
33  for (const auto dir : Direction<VolumeDim>::all_directions()) {
34  // Element has neighbors in directions with internal boundaries
35  if (directions_of_external_boundaries.count(dir) == 0) {
36  const size_t index =
37  1 + 2 * dir.dimension() + (dir.side() == Side::Upper ? 1 : 0);
38  neighbors[dir] = make_neighbor_with_id<VolumeDim>(index);
39  }
40  }
41  return Element<VolumeDim>{ElementId<VolumeDim>{0}, neighbors};
42 }
43 
44 } // namespace Limiters
45 } // namespace TestHelpers
Limiters
Things relating to limiting.
Definition: HwenoImpl.cpp:111
unordered_set
Direction
Definition: Direction.hpp:23
Element
Definition: Element.hpp:29
ElementId
An ElementId uniquely labels an Element.
Definition: ElementId.hpp:49
ElementId.hpp
cstddef
Neighbors.hpp
Neighbors
Definition: Neighbors.hpp:28
Element.hpp
DirectionMap< VolumeDim, Neighbors< VolumeDim > >