-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathGeometry_test.cpp
177 lines (168 loc) · 6.9 KB
/
Geometry_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*******************************************************************************
Causal Dynamical Triangulations in C++ using CGAL
Copyright © 2018 Adam Getchell
******************************************************************************/
/// @file Geometry_test.cpp
/// @brief Tests of new geometry data structure
/// @author Adam Getchell
#include "Geometry.hpp"
#include <doctest/doctest.h>
using namespace std;
using namespace foliated_triangulations;
SCENARIO("Geometry special member and swap properties" *
doctest::test_suite("geometry"))
{
spdlog::debug("Geometry special member and swap properties.\n");
GIVEN("A 3-dimensional geometry.")
{
WHEN("Special members are examined.")
{
THEN("It is trivially destructible.")
{
REQUIRE(is_trivially_destructible_v<Geometry_3>);
spdlog::debug("It is trivially destructible.\n");
}
THEN("It is no-throw default constructible.")
{
REQUIRE(is_nothrow_default_constructible_v<Geometry_3>);
spdlog::debug("It is no-throw default constructible.\n");
}
THEN("It is no-throw copy constructible.")
{
REQUIRE(is_nothrow_copy_constructible_v<Geometry_3>);
spdlog::debug("It is no-throw copy constructible.\n");
}
THEN("It is no-throw copy assignable.")
{
REQUIRE(is_nothrow_copy_assignable_v<Geometry_3>);
spdlog::debug("It is no-throw copy assignable.\n");
}
THEN("It is no-throw move constructible.")
{
REQUIRE(is_nothrow_move_constructible_v<Geometry_3>);
spdlog::debug("It is no-throw move constructible.\n");
}
THEN("It is no-throw move assignable.")
{
REQUIRE(is_nothrow_move_assignable_v<Geometry_3>);
spdlog::debug("It is no-throw move assignable.\n");
}
THEN("It is no-throw swappable.")
{
REQUIRE(is_nothrow_swappable_v<Geometry_3>);
spdlog::debug("It is no-throw swappable.\n");
}
}
}
}
SCENARIO("3-Geometry classification" * doctest::test_suite("geometry"))
{
spdlog::debug("3-Geometry classification.\n");
GIVEN("A small 3-dimensional geometry.")
{
WHEN("It is constructed with a Delaunay triangulation.")
{
auto constexpr desired_simplices = 72;
auto constexpr desired_timeslices = 3;
FoliatedTriangulation_3 const triangulation(desired_simplices,
desired_timeslices);
Geometry_3 geometry(triangulation);
THEN("The Delaunay triangulation is described by the geometry.")
{
fmt::print("There are {} simplices ...\n", geometry.N3);
fmt::print(
"There are {} (3,1) simplices and {} (2,2) simplices and {} (1,3) "
"simplices.\n",
geometry.N3_31, geometry.N3_22, geometry.N3_13);
CHECK_GT(geometry.N3, 2);
CHECK_EQ(geometry.N3, static_cast<Int_precision>(
triangulation.number_of_finite_cells()));
CHECK_EQ(geometry.N3_31, static_cast<Int_precision>(
triangulation.get_three_one().size()));
CHECK_EQ(geometry.N3_13, static_cast<Int_precision>(
triangulation.get_one_three().size()));
CHECK_EQ(geometry.N3_31 + geometry.N3_22 + geometry.N3_13, geometry.N3);
CHECK_EQ(geometry.N3_22, static_cast<Int_precision>(
triangulation.get_two_two().size()));
CHECK_EQ(geometry.N2, static_cast<Int_precision>(
triangulation.number_of_finite_facets()));
CHECK_EQ(geometry.N1, static_cast<Int_precision>(
triangulation.number_of_finite_edges()));
CHECK_NE(geometry.N1_TL, 0);
CHECK_NE(geometry.N1_SL, 0);
CHECK_EQ(geometry.N1, geometry.N1_TL + geometry.N1_SL);
CHECK_EQ(geometry.N0, static_cast<Int_precision>(
triangulation.number_of_vertices()));
// Human verification
fmt::print("There are {} edges.\n", geometry.N1);
fmt::print("There are {} timelike edges and {} spacelike edges.\n",
geometry.N1_TL, geometry.N1_SL);
#ifndef NDEBUG
triangulation.print_cells();
triangulation.print_edges();
#endif
fmt::print(
"There are {} vertices with a max timevalue of {} and a min "
"timevalue of {}.\n",
geometry.N0, triangulation.max_time(), triangulation.min_time());
triangulation.print_volume_per_timeslice();
}
}
}
}
SCENARIO("3-Geometry initialization" * doctest::test_suite("geometry"))
{
spdlog::debug("3-Geometry initialization.\n");
GIVEN("A 3-dimensional geometry.")
{
WHEN("It is default constructed.")
{
THEN("All data members are zero-initialized.")
{
Geometry_3 constexpr geometry;
REQUIRE_EQ(geometry.N3, 0);
REQUIRE_EQ(geometry.N3_31, 0);
REQUIRE_EQ(geometry.N3_13, 0);
REQUIRE_EQ(geometry.N3_22, 0);
REQUIRE_EQ(geometry.N2, 0);
REQUIRE_EQ(geometry.N1, 0);
REQUIRE_EQ(geometry.N1_TL, 0);
REQUIRE_EQ(geometry.N1_SL, 0);
REQUIRE_EQ(geometry.N0, 0);
}
}
WHEN("It is constructed with a triangulation.")
{
auto constexpr desired_simplices = 640;
auto constexpr desired_timeslices = 4;
FoliatedTriangulation_3 const triangulation(desired_simplices,
desired_timeslices);
Geometry_3 const geometry(triangulation);
THEN(
"The properties of the Delaunay triangulation are saved in geometry "
"info.")
{
CHECK_EQ(geometry.N3, static_cast<Int_precision>(
triangulation.number_of_finite_cells()));
CHECK_EQ(geometry.N3_31, static_cast<Int_precision>(
triangulation.get_three_one().size()));
CHECK_EQ(geometry.N3_13, static_cast<Int_precision>(
triangulation.get_one_three().size()));
CHECK_EQ(geometry.N3_31 + geometry.N3_22 + geometry.N3_13, geometry.N3);
CHECK_EQ(geometry.N3_22, static_cast<Int_precision>(
triangulation.get_two_two().size()));
CHECK_EQ(geometry.N2, static_cast<Int_precision>(
triangulation.number_of_finite_facets()));
CHECK_EQ(geometry.N1, static_cast<Int_precision>(
triangulation.number_of_finite_edges()));
CHECK_NE(geometry.N1_TL, 0);
CHECK_NE(geometry.N1_SL, 0);
CHECK_EQ(geometry.N1_TL + geometry.N1_SL, geometry.N1);
CHECK_EQ(geometry.N0, static_cast<Int_precision>(
triangulation.number_of_vertices()));
triangulation.print();
triangulation.print_volume_per_timeslice();
}
}
}
}