13#include <doctest/doctest.h>
20using namespace foliated_triangulations;
22static inline auto constexpr RADIUS_2 = 2.0 * std::numbers::inv_sqrt3_v<double>;
24SCENARIO(
"Construct a tetrahedron in a Delaunay triangulation" *
25 doctest::test_suite(
"tetrahedron"))
27 using Point = Point_t<3>;
28 GIVEN(
"A vector of 4 vertices.")
36 vector<std::size_t> timevalues{1, 2, 2, 2};
37 auto causal_vertices = make_causal_vertices<3>(vertices, timevalues);
38 WHEN(
"A triangulation is constructed using the vector.")
42 THEN(
"The triangulation has dimension 3.")
44 REQUIRE_EQ(triangulation.dimension(), 3);
47 THEN(
"The triangulation has 4 vertices.")
49 REQUIRE_EQ(triangulation.number_of_vertices(), 4);
52 THEN(
"The triangulation has 6 edges.")
54 REQUIRE_EQ(triangulation.number_of_finite_edges(), 6);
57 THEN(
"The triangulation has 4 faces.")
59 REQUIRE_EQ(triangulation.number_of_finite_facets(), 4);
62 THEN(
"The triangulation has 1 cell.")
64 REQUIRE_EQ(triangulation.number_of_finite_cells(), 1);
67 THEN(
"The triangulation is Delaunay.")
69 REQUIRE(triangulation.is_delaunay());
72 THEN(
"The triangulation data structure is valid.")
74 REQUIRE(triangulation.is_tds_valid());
77 THEN(
"The vertices are valid.")
79 REQUIRE(triangulation.check_all_vertices());
85SCENARIO(
"Find distances between points of the tetrahedron" *
86 doctest::test_suite(
"tetrahedron"))
88 using Point = Point_t<3>;
89 using Causal_vertices = Causal_vertices_t<3>;
92 GIVEN(
"Points in a tetrahedron.")
94 auto origin = Point{0, 0, 0};
96 auto v_1 = Point{1, 0, 0};
97 auto v_2 = Point{0, 1, 0};
98 auto v_3 = Point{0, 0, 1};
99 auto v_4 = Point{RADIUS_2, RADIUS_2, RADIUS_2};
100 Causal_vertices causal_vertices;
101 causal_vertices.emplace_back(v_1, 1);
102 causal_vertices.emplace_back(v_2, 1);
103 causal_vertices.emplace_back(v_3, 1);
104 causal_vertices.emplace_back(v_4, 2);
105 WHEN(
"The Foliated triangulation is constructed with these points.")
108 squared_distance
constexpr r_2;
109 THEN(
"The triangulation is initialized correctly.")
111 REQUIRE(triangulation.is_initialized());
113 THEN(
"The squared distances of vertices from origin are correct.")
115 fmt::print(
"v_1 is {}\n", utilities::point_to_str(v_1));
116 fmt::print(
"v_2 is {}\n", utilities::point_to_str(v_2));
117 fmt::print(
"v_3 is {}\n", utilities::point_to_str(v_3));
118 fmt::print(
"v_4 is {}\n", utilities::point_to_str(v_4));
120 auto d_1 = r_2(origin, v_1);
121 fmt::print(
"The squared distance between v_1 and the origin is {}\n",
123 CHECK_EQ(d_1, doctest::Approx(1.0));
125 auto d_2 = r_2(origin, v_2);
126 fmt::print(
"The squared distance between v_2 and the origin is {}\n",
128 CHECK_EQ(d_2, doctest::Approx(1.0));
130 auto d_3 = r_2(origin, v_3);
131 fmt::print(
"The squared distance between v_3 and the origin is {}\n",
133 CHECK_EQ(d_3, doctest::Approx(1.0));
135 auto d_4 = r_2(origin, v_4);
136 fmt::print(
"The squared distance between v_4 and the origin is {}\n",
138 CHECK_EQ(d_4, doctest::Approx(4.0));
140 THEN(
"The squared distance between radius=1 vertices are 2.")
142 auto d_1 = r_2(v_1, v_2);
143 CHECK_EQ(d_1, doctest::Approx(2.0));
144 fmt::print(
"The squared distance between v_1 and v_2 is {}\n", d_1);
145 auto d_2 = r_2(v_1, v_3);
146 CHECK_EQ(d_2, doctest::Approx(2.0));
147 fmt::print(
"The squared distance between v_1 and v_3 is {}\n", d_2);
148 auto d_3 = r_2(v_2, v_3);
149 CHECK_EQ(d_3, doctest::Approx(2.0));
150 fmt::print(
"The squared distance between v_2 and v_3 is {}\n", d_3);
152 THEN(
"All vertices have correct timevalues.")
154 CHECK(triangulation.check_all_vertices());
156 auto print = [&triangulation](Vertex_handle_t<3>
const& vertex) {
158 "Vertex ({}) with timevalue of {} has a squared radius of {} and "
159 "a squared expected radius of {} with an expected timevalue of "
161 utilities::point_to_str(vertex->point()), vertex->info(),
162 squared_radius<3>(vertex),
163 std::pow(triangulation.expected_radius(vertex), 2),
164 triangulation.expected_timevalue(vertex));
166 ranges::for_each(triangulation.get_vertices(), print);
172SCENARIO(
"Construct a foliated tetrahedron in a foliated triangulation" *
173 doctest::test_suite(
"tetrahedron"))
175 using Point = Point_t<3>;
177 GIVEN(
"A vector of vertices and a vector of timevalues.")
183 Point{RADIUS_2, RADIUS_2, RADIUS_2}
185 vector<std::size_t> timevalue{1, 1, 1, 2};
187 WHEN(
"A foliated triangulation is constructed using the vectors.")
189 auto causal_vertices = make_causal_vertices<3>(Vertices, timevalue);
192 THEN(
"The triangulation is initialized correctly.")
194 REQUIRE(triangulation.is_initialized());
197 THEN(
"The triangulation has dimension 3.")
199 REQUIRE_EQ(triangulation.dimension(), 3);
202 THEN(
"The triangulation has 4 vertices.")
204 REQUIRE_EQ(triangulation.number_of_vertices(), 4);
207 THEN(
"The triangulation has 6 edges.")
209 REQUIRE_EQ(triangulation.number_of_finite_edges(), 6);
212 THEN(
"The triangulation has 4 faces.")
214 REQUIRE_EQ(triangulation.number_of_finite_facets(), 4);
217 THEN(
"The triangulation has 1 cell.")
219 REQUIRE_EQ(triangulation.number_of_finite_cells(), 1);
222 THEN(
"Timevalues are correct.")
224 CHECK(triangulation.check_all_vertices());
227 THEN(
"The cell info is correct.")
229 auto cell = triangulation.get_delaunay().finite_cells_begin();
230 CHECK_EQ(expected_cell_type<3>(cell), Cell_type::THREE_ONE);
232 triangulation.print_cells();
235 THEN(
"There is one (3,1) simplex.")
237 REQUIRE_EQ(triangulation.get_three_one().size(), 1);
240 THEN(
"There are no (2,2) simplices.")
242 REQUIRE(triangulation.get_two_two().empty());
245 THEN(
"There are no (1,3) simplices.")
247 REQUIRE(triangulation.get_one_three().empty());
250 THEN(
"There are 3 timelike edges.")
252 REQUIRE_EQ(triangulation.N1_TL(), 3);
255 THEN(
"There are 3 spacelike edges.")
257 REQUIRE_EQ(triangulation.N1_SL(), 3);
Create foliated spherical triangulations.
SCENARIO("Perform bistellar flip on Delaunay triangulation" *doctest::test_suite("bistellar"))
3D Foliated triangulation