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 <string>
12 #include <unordered_map>
13 #include <unordered_set>
14 #include <vector>
15 
17 
18 /// \cond
19 template <size_t VolumeDim>
20 class Block;
21 template <size_t VolumeDim>
22 class BlockNeighbor;
23 namespace domain {
24 template <typename SourceFrame, typename TargetFrame, size_t Dim>
25 class CoordinateMapBase;
26 namespace FunctionsOfTime {
27 class FunctionOfTime;
28 } // namespace FunctionsOfTime
29 } // namespace domain
30 class DataVector;
31 template <size_t VolumeDim>
32 class Direction;
33 template <size_t VolumeDim, typename T>
34 class DirectionMap;
35 template <size_t VolumeDim>
36 class Domain;
37 template <size_t VolumeDim>
38 class ElementId;
39 /// \endcond
40 
41 // Test that the Blocks in the Domain are constructed correctly.
42 template <size_t VolumeDim, typename TargetFrameGridOrInertial>
43 void test_domain_construction(
44  const Domain<VolumeDim>& domain,
46  expected_block_neighbors,
48  expected_external_boundaries,
50  Frame::Logical, TargetFrameGridOrInertial, VolumeDim>>>& expected_maps,
52  const std::unordered_map<
54  functions_of_time = {},
57  expected_grid_to_inertial_maps = {}) noexcept;
58 
59 // Test that two neighboring Blocks abut each other.
60 template <size_t VolumeDim>
61 void test_physical_separation(
62  const std::vector<Block<VolumeDim>>& blocks,
64  const std::unordered_map<
66  functions_of_time = {}) noexcept;
67 
68 // Fraction of the logical volume of a block covered by an element
69 // The sum of this over all the elements of a block should be one
70 template <size_t VolumeDim>
71 boost::rational<size_t> fraction_of_block_volume(
72  const ElementId<VolumeDim>& element_id) noexcept;
73 
74 // Test that the Elements of the initial domain are connected and cover the
75 // computational domain, as well as that neighboring Elements' refinement
76 // levels do not differ too much.
77 template <size_t VolumeDim>
78 void test_initial_domain(const Domain<VolumeDim>& domain,
80  initial_refinement_levels) noexcept;
81 
82 // Euclidean basis vector along the given `Direction` and in the given
83 // `Frame::Inertial` frame.
84 template <typename DataType, size_t SpatialDim>
85 tnsr::i<DataType, SpatialDim> euclidean_basis_vector(
86  const Direction<SpatialDim>& direction,
87  const DataType& used_for_size) noexcept;
88 
89 template <typename DataType, size_t SpatialDim>
90 tnsr::i<DataType, SpatialDim> unit_basis_form(
91  const Direction<SpatialDim>& direction,
92  const tnsr::II<DataType, SpatialDim>& inv_spatial_metric) noexcept;
BlockNeighbor
Definition: BlockNeighbor.hpp:25
std::string
domain::CoordinateMapBase
Abstract base class for CoordinateMap.
Definition: CoordinateMap.hpp:45
unordered_set
vector
Direction
Definition: Direction.hpp:23
ElementId
An ElementId uniquely labels an Element.
Definition: ElementId.hpp:49
cstddef
array
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:42
Domain
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:38
memory
DirectionMap
Definition: DirectionMap.hpp:15
limits
TypeAliases.hpp
Block
Definition: Block.hpp:43
Frame::Logical
Definition: IndexType.hpp:42
std::unique_ptr
unordered_map
std::numeric_limits
string