DomainTestHelpers.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <array>
7 #include <boost/rational.hpp>
8 #include <cstddef>
9 #include <limits>
10 #include <memory>
11 #include <unordered_map>
12 #include <unordered_set>
13 #include <vector>
14 
16 
17 /// \cond
18 template <size_t VolumeDim>
19 class Block;
20 template <size_t VolumeDim>
21 class BlockNeighbor;
22 namespace domain {
23 template <typename SourceFrame, typename TargetFrame, size_t Dim>
24 class CoordinateMapBase;
25 namespace FunctionsOfTime {
26 class FunctionOfTime;
27 } // namespace FunctionsOfTime
28 } // namespace domain
29 class DataVector;
30 template <size_t VolumeDim>
31 class Direction;
32 template <size_t VolumeDim, typename T>
33 class DirectionMap;
34 template <size_t VolumeDim>
35 class Domain;
36 template <size_t VolumeDim>
37 class ElementId;
38 /// \endcond
39 
40 // Test that the Blocks in the Domain are constructed correctly.
41 template <size_t VolumeDim, typename TargetFrameGridOrInertial>
42 void test_domain_construction(
45  expected_block_neighbors,
47  expected_external_boundaries,
49  Frame::Logical, TargetFrameGridOrInertial, VolumeDim>>>& expected_maps,
51  const std::unordered_map<
53  functions_of_time = {},
56  expected_grid_to_inertial_maps = {}) noexcept;
57 
58 // Test that two neighboring Blocks abut each other.
59 template <size_t VolumeDim>
60 void test_physical_separation(
61  const std::vector<Block<VolumeDim>>& blocks) noexcept;
62 
63 // Fraction of the logical volume of a block covered by an element
64 // The sum of this over all the elements of a block should be one
65 template <size_t VolumeDim>
66 boost::rational<size_t> fraction_of_block_volume(
67  const ElementId<VolumeDim>& element_id) noexcept;
68 
69 // Test that the Elements of the initial domain are connected and cover the
70 // computational domain, as well as that neighboring Elements are at the same
71 // refinement level.
72 template <size_t VolumeDim>
73 void test_initial_domain(const Domain<VolumeDim>& domain,
75  initial_refinement_levels) noexcept;
76 
77 // Euclidean basis vector along the given `Direction` and in the given
78 // `Frame::Inertial` frame.
79 template <typename DataType, size_t SpatialDim>
80 tnsr::i<DataType, SpatialDim> euclidean_basis_vector(
81  const Direction<SpatialDim>& direction,
82  const DataType& used_for_size) noexcept;
83 
84 template <typename DataType, size_t SpatialDim>
85 tnsr::i<DataType, SpatialDim> unit_basis_form(
86  const Direction<SpatialDim>& direction,
87  const tnsr::II<DataType, SpatialDim>& inv_spatial_metric) noexcept;
Definition: BlockId.hpp:16
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:46
An ElementId uniquely labels an Element.
Definition: ElementId.hpp:49
An optimized map with Direction keys.
Definition: DirectionMap.hpp:15
A particular Side along a particular coordinate Axis.
Definition: Direction.hpp:23
Definition: IndexType.hpp:42
Defines a list of useful type aliases for tensors.
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:38
Stores a collection of function values.
Definition: DataVector.hpp:42
Information about the neighbor of a host Block in a particular direction.
Definition: BlockNeighbor.hpp:25
A Block<VolumeDim> is a region of a VolumeDim-dimensional computational domain that defines the root ...
Definition: Block.hpp:43