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 // Fraction of the logical volume of a block covered by an element
80 // The sum of this over all the elements of a block should be one
81 template <size_t VolumeDim>
82 boost::rational<size_t> fraction_of_block_volume(
83  const ElementId<VolumeDim>& element_id) noexcept;
84 
85 // Test that the Elements of the initial domain are connected and cover the
86 // computational domain, as well as that neighboring Elements' refinement
87 // levels do not differ too much.
88 template <size_t VolumeDim>
89 void test_initial_domain(const Domain<VolumeDim>& domain,
91  initial_refinement_levels) noexcept;
92 
93 // Euclidean basis vector along the given `Direction` and in the given
94 // `Frame::Inertial` frame.
95 template <typename DataType, size_t SpatialDim>
96 tnsr::i<DataType, SpatialDim> euclidean_basis_vector(
97  const Direction<SpatialDim>& direction,
98  const DataType& used_for_size) noexcept;
99 
100 template <typename DataType, size_t SpatialDim>
101 tnsr::i<DataType, SpatialDim> unit_basis_form(
102  const Direction<SpatialDim>& direction,
103  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:50
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