Skip to content

Commit 3262220

Browse files
committed
Merge branch 'hotfix/0.1.3'
2 parents 140ff7b + cf61911 commit 3262220

File tree

6 files changed

+87
-63
lines changed

6 files changed

+87
-63
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,16 @@ set_tests_properties (CDT-3Dtriangle
162162
PROPERTIES
163163
PASS_REGULAR_EXPRESSION "Triangle inequalities violated ... Exiting.")
164164

165+
# Minimum run
166+
add_test(CDT-MinimalS3 cdt --s -n2 -t2 -a0.6 -k1.1 -l0.1 -p10 -c1)
167+
set_tests_properties(CDT-MinimalS3
168+
PROPERTIES
169+
PASS_REGULAR_EXPRESSION "Writing to file S3")
165170
#Run an S3
166171
add_test(CDT-S3Runs cdt --s -n640 -t4 -a0.6 -k1.1 -l0.1 -p10 -c1)
167172
set_tests_properties(CDT-S3Runs
168173
PROPERTIES
169-
PASS_REGULAR_EXPRESSION "Writing to file S")
174+
PASS_REGULAR_EXPRESSION "Writing to file S3")
170175
#cdt - gv
171176
#This program takes a file to load into GemoView for visualization
172177
#add_test(CDT - GeomView cdt - gv)

src/Measurements.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ template <typename T>
2727
auto VolumePerTimeslice(T&& manifold) -> decltype(manifold)
2828
{
2929
#ifndef NDEBUG
30-
std::cout << __PRETTY_FUNCTION__ << " called." << std::endl;
30+
std::cout << __PRETTY_FUNCTION__ << " called.\n";
3131
#endif
3232

33-
// manifold.update();
33+
// manifold.update();
3434
print_results(manifold);
3535

3636
std::multimap<intmax_t, Facet> spacelike_facets;
@@ -45,30 +45,30 @@ auto VolumePerTimeslice(T&& manifold) -> decltype(manifold)
4545
// Now the index of the facet in the cell
4646
auto index_of_facet = fit->second;
4747
#ifdef DETAILED_DEBUGGING
48-
std::cout << "Facet index is " << index_of_facet << std::endl;
48+
std::cout << "Facet index is " << index_of_facet << "\n";
4949
#endif
5050
std::set<intmax_t> facet_timevalues;
5151
// The vertices of the facet are the ones that aren't the index
5252
for (auto i = 0; i < 4; ++i) {
5353
if (i != index_of_facet) {
5454
#ifdef DETAILED_DEBUGGING
5555
std::cout << "Vertex[" << i << "] has timevalue "
56-
<< cell->vertex(i)->info() << std::endl;
56+
<< cell->vertex(i)->info() << "\n";
5757
#endif
5858
facet_timevalues.insert(std::move(cell->vertex(i)->info()));
5959
}
6060
}
6161
// If we have a 1-element set then all timevalues on that facet are equal
6262
if (facet_timevalues.size() == 1) {
6363
#ifdef DETAILED_DEBUGGING
64-
std::cout << "Timevalue is " << facet_timevalues.front() << std::endl;
64+
std::cout << "Timevalue is " << facet_timevalues.front() << "\n";
6565
#endif
6666
spacelike_facets.insert({*facet_timevalues.begin(), *fit});
6767
}
6868
}
6969
#ifndef NDEBUG
7070
std::cout << "Number of spacelike faces is " << spacelike_facets.size()
71-
<< std::endl;
71+
<< "\n";
7272
#endif
7373

7474
// Determine which timevalues are populated
@@ -79,12 +79,12 @@ auto VolumePerTimeslice(T&& manifold) -> decltype(manifold)
7979

8080
auto min_timevalue = *timevalues.cbegin();
8181
auto max_timevalue = *timevalues.crbegin();
82-
std::cout << "Minimum timevalue is " << min_timevalue << std::endl;
83-
std::cout << "Maximum timevalue is " << max_timevalue << std::endl;
82+
std::cout << "Minimum timevalue is " << min_timevalue << "\n";
83+
std::cout << "Maximum timevalue is " << max_timevalue << "\n";
8484

8585
for (auto j = min_timevalue; j <= max_timevalue; ++j) {
8686
std::cout << "Timeslice " << j << " has " << spacelike_facets.count(j)
87-
<< " spacelike faces." << std::endl;
87+
<< " spacelike faces.\n";
8888
}
8989

9090
// Save values in GeomInfo struct

src/Metropolis.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Metropolis : public MoveAlgorithm
8383
: MoveAlgorithm(passes, checkpoint), Alpha_(Alpha), K_(K), Lambda_(Lambda)
8484
{
8585
#ifndef NDEBUG
86-
std::cout << __PRETTY_FUNCTION__ << " called." << std::endl;
86+
std::cout << __PRETTY_FUNCTION__ << " called.\n";
8787
#endif
8888
}
8989

@@ -152,8 +152,8 @@ class Metropolis : public MoveAlgorithm
152152
mpfr_clears(r1, r2, a1, nullptr);
153153

154154
#ifndef NDEBUG
155-
std::cout << "TotalMoves() = " << total_moves << std::endl;
156-
std::cout << "A1 is " << result << std::endl;
155+
std::cout << "TotalMoves() = " << total_moves << "\n";
156+
std::cout << "A1 is " << result << "\n";
157157
#endif
158158

159159
return result;
@@ -201,7 +201,7 @@ class Metropolis : public MoveAlgorithm
201201
// A (4,4) move changes nothing with respect to the action,
202202
// and e^0==1
203203
#ifndef NDEBUG
204-
std::cout << "A2 is 1" << std::endl;
204+
std::cout << "A2 is 1\n";
205205
#endif
206206
return static_cast<double>(1);
207207
}
@@ -235,7 +235,7 @@ class Metropolis : public MoveAlgorithm
235235
mpfr_clears(r1, a2, nullptr);
236236

237237
#ifndef NDEBUG
238-
std::cout << "A2 is " << result << std::endl;
238+
std::cout << "A2 is " << result << "\n";
239239
#endif
240240

241241
return result;
@@ -263,9 +263,9 @@ class Metropolis : public MoveAlgorithm
263263
const auto trial = static_cast<double>(trial_value);
264264

265265
#ifndef NDEBUG
266-
std::cout << __PRETTY_FUNCTION__ << " called." << std::endl;
267-
std::cout << "trial_value = " << trial_value << std::endl;
268-
std::cout << "trial = " << trial << std::endl;
266+
std::cout << __PRETTY_FUNCTION__ << " called.\n";
267+
std::cout << "trial_value = " << trial_value << "\n";
268+
std::cout << "trial = " << trial << "\n";
269269
#endif
270270

271271
if (trial <= a1 * a2) {
@@ -280,15 +280,15 @@ class Metropolis : public MoveAlgorithm
280280
}
281281

282282
#ifndef NDEBUG
283-
std::cout << __PRETTY_FUNCTION__ << " called." << std::endl;
284-
std::cout << "Attempting move." << std::endl;
285-
std::cout << "Move type = " << to_integral(move) << std::endl;
286-
std::cout << "Trial = " << trial << std::endl;
287-
std::cout << "A1 = " << a1 << std::endl;
288-
std::cout << "A2 = " << a2 << std::endl;
289-
std::cout << "A1*A2 = " << a1 * a2 << std::endl;
283+
std::cout << __PRETTY_FUNCTION__ << " called.\n";
284+
std::cout << "Attempting move.\n";
285+
std::cout << "Move type = " << to_integral(move) << "\n";
286+
std::cout << "Trial = " << trial << "\n";
287+
std::cout << "A1 = " << a1 << "\n";
288+
std::cout << "A2 = " << a2 << "\n";
289+
std::cout << "A1*A2 = " << a1 * a2 << "\n";
290290
std::cout << ((trial <= a1 * a2) ? "Move accepted." : "Move rejected.")
291-
<< std::endl;
291+
<< "\n";
292292
print_run();
293293
#endif
294294
} // attempt_move()
@@ -308,7 +308,7 @@ class Metropolis : public MoveAlgorithm
308308
auto operator()(T&& universe) -> decltype(universe)
309309
{
310310
#ifndef NDEBUG
311-
std::cout << __PRETTY_FUNCTION__ << " called." << std::endl;
311+
std::cout << __PRETTY_FUNCTION__ << " called.\n";
312312
#endif
313313
std::cout << "Starting Metropolis-Hastings algorithm ...\n";
314314
// Populate member data
@@ -332,11 +332,11 @@ class Metropolis : public MoveAlgorithm
332332
}
333333
catch (std::logic_error& LogicError)
334334
{
335-
std::cerr << LogicError.what() << std::endl;
336-
std::cerr << "Metropolis initialization failed ... Exiting." << std::endl;
335+
std::cerr << LogicError.what() << "\n";
336+
std::cerr << "Metropolis initialization failed ... Exiting.\n";
337337
}
338338

339-
std::cout << "Making random moves ..." << std::endl;
339+
std::cout << "Making random moves ...\n";
340340
// Loop through passes_
341341
for (std::intmax_t pass_number = 1; pass_number <= passes_; ++pass_number) {
342342
auto total_simplices_this_pass = CurrentTotalSimplices();
@@ -347,7 +347,7 @@ class Metropolis : public MoveAlgorithm
347347
// Pick a move to attempt
348348
auto move_choice = generate_random_signed(0, 3);
349349
#ifndef NDEBUG
350-
std::cout << "Move choice = " << move_choice << std::endl;
350+
std::cout << "Move choice = " << move_choice << "\n";
351351
#endif
352352

353353
// Convert std::intmax_t move_choice to move_type enum
@@ -357,15 +357,15 @@ class Metropolis : public MoveAlgorithm
357357

358358
// Do stuff on checkpoint_
359359
if ((pass_number % checkpoint_) == 0) {
360-
std::cout << "Pass " << pass_number << std::endl;
360+
std::cout << "Pass " << pass_number << "\n";
361361
// write results to a file
362362
write_file(universe_, topology_type::SPHERICAL, 3,
363363
universe_.geometry->number_of_cells(),
364364
universe_.geometry->max_timevalue().get());
365365
}
366366
} // End loop through passes_
367367
// output results
368-
std::cout << "Run results: " << std::endl;
368+
std::cout << "Run results: \n";
369369
print_run();
370370
return universe_;
371371
}

src/MoveAlgorithm.h

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class MoveAlgorithm
4242
: passes_(passes), checkpoint_(checkpoint)
4343
{
4444
#ifndef NDEBUG
45-
std::cout << __PRETTY_FUNCTION__ << " called." << std::endl;
45+
std::cout << __PRETTY_FUNCTION__ << " called.\n";
4646
#endif
4747
}
4848

@@ -85,7 +85,7 @@ class MoveAlgorithm
8585
void make_move(const move_type move)
8686
{
8787
#ifndef NDEBUG
88-
std::cout << __PRETTY_FUNCTION__ << " called." << std::endl;
88+
std::cout << __PRETTY_FUNCTION__ << " called.\n";
8989
#endif
9090

9191
// Make working copies
@@ -228,27 +228,25 @@ class MoveAlgorithm
228228
/// @brief Displays results of run to standard output
229229
void print_run()
230230
{
231-
std::cout << "Simplices: " << CurrentTotalSimplices() << std::endl;
231+
std::cout << "Simplices: " << CurrentTotalSimplices() << "\n";
232232
std::cout << "Timeslices: "
233-
<< this->universe_.geometry->max_timevalue().get() << std::endl;
234-
std::cout << "N3_31_13_: " << N3_31_13_ << std::endl;
235-
std::cout << "N3_22_: " << N3_22_ << std::endl;
236-
std::cout << "Timelike edges: " << N1_TL_ << std::endl;
233+
<< this->universe_.geometry->max_timevalue().get() << "\n";
234+
std::cout << "N3_31_13_: " << N3_31_13_ << "\n";
235+
std::cout << "N3_22_: " << N3_22_ << "\n";
236+
std::cout << "Timelike edges: " << N1_TL_ << "\n";
237237
std::cout << "Successful (2,3) moves: " << SuccessfulTwoThreeMoves()
238-
<< std::endl;
239-
std::cout << "Attempted (2,3) moves: " << TwoThreeMoves() << std::endl;
238+
<< "\n";
239+
std::cout << "Attempted (2,3) moves: " << TwoThreeMoves() << "\n";
240240
std::cout << "Successful (3,2) moves: " << SuccessfulThreeTwoMoves()
241-
<< std::endl;
242-
std::cout << "Attempted (3,2) moves: " << ThreeTwoMoves() << std::endl;
243-
std::cout << "Successful (2,6) moves: " << SuccessfulTwoSixMoves()
244-
<< std::endl;
245-
std::cout << "Attempted (2,6) moves: " << TwoSixMoves() << std::endl;
246-
std::cout << "Successful (6,2) moves: " << SuccessfulSixTwoMoves()
247-
<< std::endl;
248-
std::cout << "Attempted (6,2) moves: " << SixTwoMoves() << std::endl;
241+
<< "\n";
242+
std::cout << "Attempted (3,2) moves: " << ThreeTwoMoves() << "\n";
243+
std::cout << "Successful (2,6) moves: " << SuccessfulTwoSixMoves() << "\n";
244+
std::cout << "Attempted (2,6) moves: " << TwoSixMoves() << "\n";
245+
std::cout << "Successful (6,2) moves: " << SuccessfulSixTwoMoves() << "\n";
246+
std::cout << "Attempted (6,2) moves: " << SixTwoMoves() << "\n";
249247
std::cout << "Successful (4,4) moves: " << SuccessfulFourFourMoves()
250-
<< std::endl;
251-
std::cout << "Attempted (4,4) moves: " << FourFourMoves() << std::endl;
248+
<< "\n";
249+
std::cout << "Attempted (4,4) moves: " << FourFourMoves() << "\n";
252250
}
253251
}; // MoveAlgorithm
254252

src/S3ErgodicMoves.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ template <typename T>
4848
auto try_23_move(T&& universe, Cell_handle to_be_moved)
4949
{
5050
auto flipped = false;
51+
// Try every facet of the cell
5152
for (auto i = 0; i < 4; ++i) {
5253
if (universe.triangulation->flip(to_be_moved, i)) {
5354
#ifndef NDEBUG
@@ -83,17 +84,25 @@ template <typename T1, typename T2>
8384
auto make_23_move(T1&& universe, T2&& attempted_moves) -> decltype(universe)
8485
{
8586
#ifndef NDEBUG
86-
std::cout << __PRETTY_FUNCTION__ << " called.\n";
87+
std::cout << "Attempting (2,3) move.\n";
8788
#endif
8889

90+
auto movable_two_two_cells{universe.geometry->two_two};
91+
8992
auto not_flipped = true;
9093
while (not_flipped) {
94+
if (movable_two_two_cells.size() == 0) {
95+
throw std::domain_error("No (2,3) move is possible.");
96+
}
9197
// Pick out a random (2,2) which ranges from 0 to size()-1
92-
auto choice = generate_random_signed(0, universe.geometry->N3_22() - 1);
98+
auto choice = generate_random_signed(0, movable_two_two_cells.size() - 1);
9399

94100
Cell_handle to_be_moved = universe.geometry->two_two[choice];
95101
if (try_23_move(universe, to_be_moved)) not_flipped = false;
96102

103+
// Remove trial cell
104+
movable_two_two_cells.erase(movable_two_two_cells.begin() + choice);
105+
97106
// Increment the (2,3) move counter
98107
++attempted_moves[0];
99108
}
@@ -143,12 +152,17 @@ auto make_32_move(T1&& universe, T2&& attempted_moves) -> decltype(universe)
143152
std::cout << "Attempting (3,2) move.\n";
144153
#endif
145154

155+
auto movable_timelike_edges{universe.geometry->timelike_edges};
156+
146157
auto not_flipped = true;
147158
while (not_flipped) {
159+
if (movable_timelike_edges.size() == 0) {
160+
throw std::domain_error("No (3,2) move is possible.");
161+
}
148162
// Pick a random timelike edge out of the timelike_edges vector
149163
// which ranges from 0 to size()-1
150-
auto choice = generate_random_signed(0, universe.geometry->N1_TL() - 1);
151-
Edge_handle to_be_moved = universe.geometry->timelike_edges[choice];
164+
auto choice = generate_random_signed(0, movable_timelike_edges.size() - 1);
165+
Edge_handle to_be_moved = movable_timelike_edges[choice];
152166

153167
if (try_32_move(universe, to_be_moved)) {
154168
#ifndef NDEBUG
@@ -158,6 +172,8 @@ auto make_32_move(T1&& universe, T2&& attempted_moves) -> decltype(universe)
158172
}
159173
else
160174
{
175+
// Remove chosen edge to try remaining
176+
movable_timelike_edges.erase(movable_timelike_edges.begin() + choice);
161177
#ifndef NDEBUG
162178
std::cout << "Edge " << choice << " was not flippable.\n";
163179
#endif
@@ -469,6 +485,9 @@ auto find_62_movable(T&& universe, Vertex_handle candidate)
469485
template <typename T1, typename T2>
470486
auto make_62_move(T1&& universe, T2&& attempted_moves) -> decltype(universe)
471487
{
488+
#ifndef NDEBUG
489+
std::cout << "Attempting (6,2) move.\n";
490+
#endif
472491
std::vector<Vertex_handle> tds_vertices = universe.geometry->vertices;
473492
auto not_moved = true;
474493
intmax_t tds_vertices_size = tds_vertices.size();
@@ -516,6 +535,9 @@ auto make_62_move(T1&& universe, T2&& attempted_moves) -> decltype(universe)
516535
template <typename T1, typename T2>
517536
auto make_44_move(T1&& universe, T2&& attempted_moves) -> decltype(universe)
518537
{
538+
#ifndef NDEBUG
539+
std::cout << "Attempting (4,4) move.\n";
540+
#endif
519541
std::vector<Edge_handle> movable_spacelike_edges{
520542
universe.geometry->spacelike_edges};
521543

0 commit comments

Comments
 (0)