WenoGridHelpers.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <array>
7 #include <cstddef>
8 
9 /// \cond
10 class DataVector;
11 template <size_t>
12 class Direction;
13 template <size_t>
14 class Element;
15 template <size_t>
16 class Mesh;
17 /// \endcond
18 
19 namespace SlopeLimiters {
20 namespace Weno_detail {
21 
22 // Check that an element has just one neighbor in a particular direction, and
23 // that this neighbor has the same refinement level as the element.
24 template <size_t VolumeDim>
25 bool check_element_has_one_similar_neighbor_in_direction(
26  const Element<VolumeDim>& element,
27  const Direction<VolumeDim>& direction) noexcept;
28 
29 // Compute the coordinate positions of a neighbor element's grid points in the
30 // logical coordinates of the local element.
31 //
32 // However, the results are organized to match the expected input of a
33 // RegularGridInterpolator constructor:
34 // - The coordinates are given as an array of 1D coordinate values.
35 // - For any dimension where the local and neighbor meshes share the same 1D
36 // submesh, the array is empty. (This tells the RegularGridInterpolator that
37 // no interpolation needs to be done in this dimension.)
38 //
39 // Limitations:
40 // - No support for h-refinement. It is ASSERT'ed that the element has only one
41 // neighbor in the specified direction, and that this neighbor is of the same
42 // refinement level as the local element.
43 // - Assumes a uniform rectilinear grid. No support for elements of different
44 // sizes (as could occur if all elements have the same refinement level but
45 // different blocks have different physical size), or curvilinear elements.
46 // This is not checked.
47 template <size_t VolumeDim>
48 std::array<DataVector, VolumeDim> neighbor_grid_points_in_local_logical_coords(
49  const Mesh<VolumeDim>& local_mesh, const Mesh<VolumeDim>& neighbor_mesh,
50  const Element<VolumeDim>& element,
51  const Direction<VolumeDim>& direction_to_neighbor) noexcept;
52 
53 // Compute the coordinate positions of the local element's grid points in the
54 // logical coordinates of the a neighbor element.
55 //
56 // See documentation of `neighbor_grid_points_in_local_logical_coords` for
57 // further details and limitations.
58 template <size_t VolumeDim>
59 std::array<DataVector, VolumeDim> local_grid_points_in_neighbor_logical_coords(
60  const Mesh<VolumeDim>& local_mesh, const Mesh<VolumeDim>& neighbor_mesh,
61  const Element<VolumeDim>& element,
62  const Direction<VolumeDim>& direction_to_neighbor) noexcept;
63 
64 } // namespace Weno_detail
65 } // namespace SlopeLimiters
Holds the number of grid points, basis, and quadrature in each direction of the computational grid...
Definition: Mesh.hpp:49
A particular Side along a particular coordinate Axis.
Definition: Direction.hpp:23
Things relating to slope limiting.
Definition: Krivodonova.hpp:52
A spectral element with knowledge of its neighbors.
Definition: Element.hpp:29
Stores a collection of function values.
Definition: DataVector.hpp:42