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