Helpers.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 #include <vector>
9 
10 #include "DataStructures/Index.hpp"
11 #include "Domain/ElementId.hpp"
12 #include "Domain/Mesh.hpp"
13 #include "Domain/OrientationMap.hpp"
15 #include "Utilities/Gsl.hpp"
16 
17 /// Items for initializing the DataBox%es of parallel components
18 namespace Initialization {
19 
20 /// \brief Construct the initial Mesh of an Element.
21 ///
22 /// \details When constructing the Mesh of an Element, pass its id, and use the
23 /// default argument for orientation. When constructing the mesh of a
24 /// neighboring Element (when constructing mortars), pass the id and orientation
25 /// of the neighbor.
26 ///
27 /// \param initial_extents the initial extents of each Block in the Domain
28 /// \param element_id id of an Element or its neighbor
29 /// \param orientation OrientationMap of (neighboring) `element_id`
30 template <size_t Dim>
32  const std::vector<std::array<size_t, Dim>>& initial_extents,
33  const ElementId<Dim>& element_id,
34  const OrientationMap<Dim>& orientation = {}) noexcept {
35  const auto& unoriented_extents = initial_extents[element_id.block_id()];
36  Index<Dim> extents;
37  for (size_t i = 0; i < Dim; ++i) {
38  extents[i] = gsl::at(unoriented_extents, orientation(i));
39  }
40  return {extents.indices(), Spectral::Basis::Legendre,
41  Spectral::Quadrature::GaussLobatto};
42 }
43 
44 } // namespace Initialization
Items for initializing the DataBoxes of parallel components.
Definition: ConservativeSystem.hpp:21
Holds the number of grid points, basis, and quadrature in each direction of the computational grid...
Definition: Mesh.hpp:49
Defines class ElementId.
Defines class template Index.
Mesh< Dim > element_mesh(const std::vector< std::array< size_t, Dim >> &initial_extents, const ElementId< Dim > &element_id, const OrientationMap< Dim > &orientation={}) noexcept
Construct the initial Mesh of an Element.
Definition: Helpers.hpp:31
Defines the class template Mesh.
An integer multi-index.
Definition: Index.hpp:28
Defines functions and classes from the GSL.
constexpr T & at(std::array< T, N > &arr, Size index)
Retrieve a entry from a container, with checks in Debug mode that the index being retrieved is valid...
Definition: Gsl.hpp:124