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;
40 class BoundaryCondition;
41 } // namespace domain::BoundaryConditions
42 /// \endcond
43 
44 // Test that the Blocks in the Domain are constructed correctly.
45 //
46 // The boundary conditions test assumes that the
47 // `TestHelpers::domain::BoundaryConditions::TestBoundaryCondition` class is
48 // used as the concrete boundary condition.
49 template <size_t VolumeDim, typename TargetFrameGridOrInertial>
50 void test_domain_construction(
51  const Domain<VolumeDim>& domain,
53  expected_block_neighbors,
55  expected_external_boundaries,
57  Frame::Logical, TargetFrameGridOrInertial, VolumeDim>>>& expected_maps,
59  const std::unordered_map<
61  functions_of_time = {},
64  expected_grid_to_inertial_maps = {},
66  VolumeDim,
68  expected_boundary_conditions = {});
69 
70 // Test that two neighboring Blocks abut each other.
71 template <size_t VolumeDim>
72 void test_physical_separation(
73  const std::vector<Block<VolumeDim>>& blocks,
75  const std::unordered_map<
77  functions_of_time = {}) noexcept;
78 
79 // Given a vector of Blocks, tests that the determinant of the Jacobian is
80 // positive at all corners of those Blocks.
81 template <size_t VolumeDim>
82 void test_det_jac_positive(
83  const std::vector<Block<VolumeDim>>& blocks,
85  const std::unordered_map<
87  functions_of_time = {}) noexcept;
88 
89 // Fraction of the logical volume of a block covered by an element
90 // The sum of this over all the elements of a block should be one
91 template <size_t VolumeDim>
92 boost::rational<size_t> fraction_of_block_volume(
93  const ElementId<VolumeDim>& element_id) noexcept;
94 
95 // Test that the Elements of the initial domain are connected and cover the
96 // computational domain, as well as that neighboring Elements' refinement
97 // levels do not differ too much.
98 template <size_t VolumeDim>
99 void test_initial_domain(const Domain<VolumeDim>& domain,
101  initial_refinement_levels) noexcept;
102 
103 // Euclidean basis vector along the given `Direction` and in the given
104 // `Frame::Inertial` frame.
105 template <typename DataType, size_t SpatialDim>
106 tnsr::i<DataType, SpatialDim> euclidean_basis_vector(
107  const Direction<SpatialDim>& direction,
108  const DataType& used_for_size) noexcept;
109 
110 template <typename DataType, size_t SpatialDim>
111 tnsr::i<DataType, SpatialDim> unit_basis_form(
112  const Direction<SpatialDim>& direction,
113  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:51
cstddef
domain::BoundaryConditions
Domain support for applying boundary conditions
Definition: BoundaryCondition.hpp:14
array
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:46
Domain
A wrapper around a vector of Blocks that represent the computational domain.
Definition: Domain.hpp:40
memory
DirectionMap
Definition: DirectionMap.hpp:15
limits
TypeAliases.hpp
Block
Definition: Block.hpp:44
Frame::Logical
Definition: IndexType.hpp:42
std::unique_ptr
unordered_map
std::numeric_limits
string