11#include <boost/program_options.hpp>
16namespace po = boost::program_options;
18static string_view
constexpr USAGE{
19 R
"(Causal Dynamical Triangulations in C++ using CGAL.
21Copyright (c) 2014 Adam Getchell
23A program that generates d-dimensional triangulated spacetimes
24with a defined causal structure. Specify the topology of the triangulation
25(spherical or toroidal), the desired number of simplices, and the
26desired number of timeslices.
28Usage:./initialize (--spherical | --toroidal) -n SIMPLICES -t TIMESLICES
30 [--init INITIAL RADIUS]
31 [--foliate FOLIATION SPACING]
34Optional arguments are in square brackets.
37./initialize --spherical --simplices 32000 --timeslices 11 --init 1.0 --foliate 1.0 --output
38./initialize -s -n32000 -t11 -i1.0 -f1.0 -o
42auto main(
int const argc,
char*
const argv[]) ->
int
45 std::string
const intro{USAGE};
51 double initial_radius;
52 double foliation_spacing;
55 po::options_description description(intro);
56 description.add_options()(
"help,h",
"Show this message")(
57 "version,v",
"Show program version")(
"spherical,s",
"Spherical topology")(
58 "toroidal,e",
"Toroidal topology")(
"simplices,n",
59 po::value<long long>(&simplices),
60 "Approximate number of simplices")(
61 "timeslices,t", po::value<long long>(×lices),
62 "Number of timeslices")(
63 "dimensions,d", po::value<long long>(&dimensions)->default_value(3),
64 "Dimensionality")(
"init,i",
65 po::value<double>(&initial_radius)->default_value(1.0),
67 "foliate,f", po::value<double>(&foliation_spacing)->default_value(1.0),
68 "Foliation spacing")(
"output,o",
"Save triangulation into OFF file");
70 po::variables_map args;
71 po::store(po::parse_command_line(argc, argv, description), args);
74 if (args.count(
"help"))
76 cout << description <<
"\n";
80 if (args.count(
"version"))
82 fmt::print(
"CDT initializer version 1.0\n");
86 if (args.count(
"spherical")) { topology = topology_type::SPHERICAL; }
87 else if (args.count(
"toroidal")) { topology = topology_type::TOROIDAL; }
90 fmt::print(
"Topology not specified.\n");
94 if (args.count(
"simplices"))
96 simplices = args[
"simplices"].as<
long long>();
100 fmt::print(
"Number of simplices not specified.\n");
104 if (args.count(
"timeslices"))
106 timeslices = args[
"timeslices"].as<
long long>();
110 fmt::print(
"Number of timeslices not specified.\n");
114 if (args.count(
"output")) { save_file =
true; }
115 else { save_file =
false; }
121 fmt::print(
"Topology is {}\n", utilities::topology_to_str(topology));
122 fmt::print(
"Number of dimensions = {}\n", dimensions);
123 fmt::print(
"Number of desired simplices = {}\n", simplices);
124 fmt::print(
"Number of desired timeslices = {}\n", timeslices);
125 fmt::print(
"Initial radius = {}\n", initial_radius);
126 fmt::print(
"Foliation spacing = {}\n", foliation_spacing);
128 if (save_file) { fmt::print(
"Output will be saved.\n"); }
130 if (simplices < 2 || timeslices < 2)
132 throw invalid_argument(
133 "Simplices and timeslices should be greater or equal to 2.");
138 case topology_type::SPHERICAL:
146 swap(populated_universe, universe);
148 else {
throw invalid_argument(
"Currently, dimensions cannot be >3."); }
150 case topology_type::TOROIDAL:
151 throw invalid_argument(
"Toroidal triangulations not yet supported.");
155 fmt::print(
"Final number of simplices: {}\n", universe.
N3());
159catch (invalid_argument
const& InvalidArgument)
161 spdlog::critical(
"{}\n", InvalidArgument.what());
162 spdlog::critical(
"Invalid parameter ... Exiting.\n");
167 spdlog::critical(
"Something went wrong ... Exiting.\n");
Data structures for manifolds.
std::int_fast32_t Int_precision
void write_file(std::filesystem::path const &filename, TriangulationType triangulation)
Write triangulation to file.
topology_type
clang-15 does not support std::format
void print() const
Print manifold.
void print_volume_per_timeslice() const
Print the codimension 1 volume of simplices (faces) per timeslice.