OptionTags.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <limits>
8 #include <optional>
9 
10 #include "DataStructures/DataBox/Tag.hpp"
11 #include "Evolution/Systems/Cce/AnalyticBoundaryDataManager.hpp"
12 #include "Evolution/Systems/Cce/AnalyticSolutions/WorldtubeData.hpp"
13 #include "Evolution/Systems/Cce/Initialize/InitializeJ.hpp"
14 #include "Evolution/Systems/Cce/InterfaceManagers/GhInterfaceManager.hpp"
15 #include "Evolution/Systems/Cce/InterfaceManagers/GhInterpolationStrategies.hpp"
16 #include "Evolution/Systems/Cce/InterfaceManagers/GhLockstep.hpp"
17 #include "Evolution/Systems/Cce/WorldtubeDataManager.hpp"
18 #include "NumericalAlgorithms/Interpolation/SpanInterpolator.hpp"
19 #include "Options/Auto.hpp"
20 #include "Options/Options.hpp"
21 #include "Parallel/Printf.hpp"
22 
23 namespace Cce {
24 namespace OptionTags {
25 
26 /// %Option group
27 struct Cce {
28  static constexpr Options::String help = {
29  "Options for the Cce evolution system"};
30 };
31 
32 /// %Option group
33 struct Filtering {
34  static constexpr Options::String help = {"Options for the filtering in Cce"};
35  using group = Cce;
36 };
37 
38 struct LMax {
39  using type = size_t;
40  static constexpr Options::String help{
41  "Maximum l value for spin-weighted spherical harmonics"};
42  using group = Cce;
43 };
44 
45 struct FilterLMax {
46  using type = size_t;
47  static constexpr Options::String help{"l mode cutoff for angular filtering"};
48  using group = Filtering;
49 };
50 
52  using type = double;
53  static constexpr Options::String help{
54  "alpha parameter in exponential radial filter"};
55  using group = Filtering;
56 };
57 
59  using type = size_t;
60  static constexpr Options::String help{
61  "Half-power of the exponential radial filter argument"};
62  using group = Filtering;
63 };
64 
66  using type = size_t;
67  static constexpr Options::String help{"Maximum l value for swsh output"};
68  using group = Cce;
69 };
70 
72  using type = size_t;
73  static constexpr Options::String help{
74  "Number of radial grid points in the spherical domain"};
75  using group = Cce;
76 };
77 
79  using type = double;
80  static constexpr Options::String help{"Extraction radius of the CCE system."};
81  using group = Cce;
82 };
83 
85  static std::string name() noexcept { return "ExtractionRadius"; }
87 
88  static constexpr Options::String help{
89  "Extraction radius of the CCE system for a standalone run. This may be "
90  "set to \"Auto\" to infer the radius from the filename (often used for "
91  "SpEC worldtube data). This option is unused if `H5IsBondiData` is "
92  "`true`, and should be \"Auto\" for such runs."};
93  using group = Cce;
94 };
95 
96 struct EndTime {
98  static constexpr Options::String help{"End time for the Cce Evolution."};
99  static type suggested_value() noexcept { return {}; }
100  using group = Cce;
101 };
102 
103 struct StartTime {
104  using type = Options::Auto<double>;
105  static constexpr Options::String help{
106  "Cce Start time (default to earliest possible time)."};
107  static type suggested_value() noexcept { return {}; }
108  using group = Cce;
109 };
110 
112  using type = double;
113  static constexpr Options::String help{
114  "Target time step size for Cce Evolution"};
115  using group = Cce;
116 };
117 
119  using type = std::string;
120  static constexpr Options::String help{
121  "H5 file to read the wordltube data from."};
122  using group = Cce;
123 };
124 
126  using type = size_t;
127  static constexpr Options::String help{
128  "Number of times steps from the h5 to cache each read."};
129  static size_t suggested_value() noexcept { return 200; }
130  using group = Cce;
131 };
132 
135  static constexpr Options::String help{
136  "The interpolator for imported h5 worldtube data."};
137  using group = Cce;
138 };
139 
141  using type = bool;
142  static constexpr Options::String help{
143  "true for boundary data in Bondi form, false for metric data. Metric "
144  "data is more readily available from Cauchy simulations, so historically "
145  "has been the typical format provided by SpEC simulations. Bondi data is "
146  "much more efficient for storage size and performance, but both must be "
147  "supported for compatibility with current CCE data sources."};
148  using group = Cce;
149 };
150 
152  using type = bool;
153  static constexpr Options::String help{
154  "Set to true if corrections for SpEC data impurities should be applied "
155  "automatically based on the `VersionHist.ver` data set in the H5. "
156  "Typically, this should be set to true if the metric data is created "
157  "from SpEC, and false otherwise."};
158  using group = Cce;
159 };
160 
163  static constexpr Options::String help{
164  "Analytic worldtube data for tests of CCE."};
165  using group = Cce;
166 };
167 
170  static constexpr Options::String help{
171  "Class to manage worldtube data from a GH system."};
172  using group = Cce;
173 };
174 
176  static std::string name() noexcept { return "ScriInterpOrder"; }
177  using type = size_t;
178  static constexpr Options::String help{
179  "Order of time interpolation at scri+."};
180  static size_t suggested_value() noexcept { return 5; }
181  using group = Cce;
182 };
183 
185  using type = size_t;
186  static constexpr Options::String help{
187  "Number of scri output points per timestep."};
188  static size_t suggested_value() noexcept { return 1; }
189  using group = Cce;
190 };
191 
192 struct InitializeJ {
194  static constexpr Options::String help{
195  "The initialization for the first hypersurface for J"};
196  using group = Cce;
197 };
198 
199 } // namespace OptionTags
200 
201 namespace InitializationTags {
203  using type = size_t;
204  using option_tags = tmpl::list<OptionTags::ScriInterpolationOrder>;
205 
206  static constexpr bool pass_metavariables = false;
207  static size_t create_from_options(
208  const size_t scri_plus_interpolation_order) noexcept {
209  return scri_plus_interpolation_order;
210  }
211 };
212 
214  using type = double;
215  using option_tags = tmpl::list<OptionTags::TargetStepSize>;
216 
217  static constexpr bool pass_metavariables = false;
218  static double create_from_options(const double target_step_size) noexcept {
219  return target_step_size;
220  }
221 };
222 
224  using type = double;
225  using option_tags = tmpl::list<OptionTags::ExtractionRadius>;
226 
227  static constexpr bool pass_metavariables = false;
228  static double create_from_options(const double extraction_radius) noexcept {
229  return extraction_radius;
230  }
231 };
232 
234  using type = size_t;
235  using option_tags = tmpl::list<OptionTags::ScriOutputDensity>;
236 
237  static constexpr bool pass_metavariables = false;
238  static size_t create_from_options(const size_t scri_output_density) noexcept {
239  return scri_output_density;
240  }
241 };
242 } // namespace InitializationTags
243 
244 namespace Tags {
245 /// A tag that constructs a `MetricWorldtubeDataManager` from options
248  using option_tags =
253 
254  static constexpr bool pass_metavariables = false;
255  static type create_from_options(
256  const size_t l_max, const std::string& filename,
257  const size_t number_of_lookahead_times,
258  const std::unique_ptr<intrp::SpanInterpolator>& interpolator,
259  const bool h5_is_bondi_data, const bool fix_spec_normalization,
260  const std::optional<double> extraction_radius) noexcept {
261  if (h5_is_bondi_data) {
262  if (static_cast<bool>(extraction_radius)) {
264  "Warning: Option ExtractionRadius is set to a specific value and "
265  "H5IsBondiData is set to `true` -- the ExtractionRadius will not "
266  "be used, because all radius information is specified in the input "
267  "file for the Bondi worldtube data format. It is recommended to "
268  "set `ExtractionRadius` to `\"Auto\"` to make the input file "
269  "clearer.");
270  }
271  return std::make_unique<BondiWorldtubeDataManager>(
272  std::make_unique<BondiWorldtubeH5BufferUpdater>(filename,
273  extraction_radius),
274  l_max, number_of_lookahead_times, interpolator->get_clone());
275  } else {
276  return std::make_unique<MetricWorldtubeDataManager>(
277  std::make_unique<MetricWorldtubeH5BufferUpdater>(filename,
278  extraction_radius),
279  l_max, number_of_lookahead_times, interpolator->get_clone(),
280  fix_spec_normalization);
281  }
282  }
283 };
284 
286  using type = size_t;
287  using option_tags = tmpl::list<OptionTags::LMax>;
288 
289  static constexpr bool pass_metavariables = false;
290  static size_t create_from_options(const size_t l_max) noexcept {
291  return l_max;
292  }
293 };
294 
297  using type = size_t;
298  using option_tags = tmpl::list<OptionTags::NumberOfRadialPoints>;
299 
300  static constexpr bool pass_metavariables = false;
301  static size_t create_from_options(
302  const size_t number_of_radial_points) noexcept {
303  return number_of_radial_points;
304  }
305 };
306 
308  using type = size_t;
309  using option_tags = tmpl::list<OptionTags::ObservationLMax>;
310 
311  static constexpr bool pass_metavariables = false;
312  static size_t create_from_options(const size_t observation_l_max) noexcept {
313  return observation_l_max;
314  }
315 };
316 
318  using type = size_t;
319  using option_tags = tmpl::list<OptionTags::FilterLMax>;
320 
321  static constexpr bool pass_metavariables = false;
322  static size_t create_from_options(const size_t filter_l_max) noexcept {
323  return filter_l_max;
324  }
325 };
326 
328  using type = double;
329  using option_tags = tmpl::list<OptionTags::RadialFilterAlpha>;
330 
331  static constexpr bool pass_metavariables = false;
332  static double create_from_options(const double radial_filter_alpha) noexcept {
333  return radial_filter_alpha;
334  }
335 };
336 
338  using type = size_t;
339  using option_tags = tmpl::list<OptionTags::RadialFilterHalfPower>;
340 
341  static constexpr bool pass_metavariables = false;
342  static size_t create_from_options(
343  const size_t radial_filter_half_power) noexcept {
344  return radial_filter_half_power;
345  }
346 };
347 
348 /// \brief Represents the start time of a bounded CCE evolution, determined
349 /// either from option specification or from the file
350 ///
351 /// \details If no start time is specified in the input file (so the option
352 /// `OptionTags::StartTime` is set to "Auto"), this will find the start time
353 /// from the provided H5 file. If `OptionTags::StartTime` takes any other value,
354 /// it will be used directly as the start time for the CCE evolution instead.
356  using type = double;
357  using option_tags =
360 
361  static constexpr bool pass_metavariables = false;
362  static double create_from_options(const std::optional<double> start_time,
363  const std::string& filename,
364  const bool is_bondi_data) noexcept {
365  if (start_time) {
366  return *start_time;
367  }
368  if (is_bondi_data) {
369  BondiWorldtubeH5BufferUpdater h5_boundary_updater{filename};
370  const auto& time_buffer = h5_boundary_updater.get_time_buffer();
371  return time_buffer[0];
372  } else {
373  MetricWorldtubeH5BufferUpdater h5_boundary_updater{filename};
374  const auto& time_buffer = h5_boundary_updater.get_time_buffer();
375  return time_buffer[0];
376  }
377  }
378 };
379 
380 /// \brief Represents the start time of a bounded CCE evolution that must be
381 /// supplied in the input file (for e.g. analytic tests).
383  using type = double;
384  using option_tags = tmpl::list<OptionTags::StartTime>;
385 
386  static constexpr bool pass_metavariables = false;
387  static double create_from_options(
388  const std::optional<double> start_time) noexcept {
389  if (not start_time.has_value()) {
390  ERROR(
391  "The start time must be explicitly specified for the tag "
392  "`SpecifiedStartTime`");
393  }
394  return *start_time;
395  }
396 };
397 
398 /// \brief Represents the final time of a bounded CCE evolution, determined
399 /// either from option specification or from the file
400 ///
401 /// \details If no end time is specified in the input file (so the option
402 /// `OptionTags::EndTime` is set to "Auto"), this will find the end time
403 /// from the provided H5 file. If `OptionTags::EndTime` takes any other value,
404 /// it will be used directly as the final time for the CCE evolution instead.
406  using type = double;
407  using option_tags =
410 
411  static constexpr bool pass_metavariables = false;
412  static double create_from_options(const std::optional<double> end_time,
413  const std::string& filename,
414  const bool is_bondi_data) {
415  if (end_time) {
416  return *end_time;
417  }
418  if (is_bondi_data) {
419  BondiWorldtubeH5BufferUpdater h5_boundary_updater{filename};
420  const auto& time_buffer = h5_boundary_updater.get_time_buffer();
421  return time_buffer[time_buffer.size() - 1];
422  } else {
423  MetricWorldtubeH5BufferUpdater h5_boundary_updater{filename};
424  const auto& time_buffer = h5_boundary_updater.get_time_buffer();
425  return time_buffer[time_buffer.size() - 1];
426  }
427  }
428 };
429 
430 /// \brief Represents the final time of a CCE evolution that should just proceed
431 /// until it receives no more boundary data and becomes quiescent.
433  using type = double;
434  using option_tags = tmpl::list<>;
435 
436  static constexpr bool pass_metavariables = false;
437  static double create_from_options() noexcept {
439  }
440 };
441 
442 /// \brief Represents the final time of a bounded CCE evolution that must be
443 /// supplied in the input file (for e.g. analytic tests).
445  using type = double;
446  using option_tags = tmpl::list<OptionTags::EndTime>;
447 
448  static constexpr bool pass_metavariables = false;
449  static double create_from_options(
450  const std::optional<double> end_time) noexcept {
451  if (not end_time.has_value()) {
452  ERROR(
453  "The end time must be explicitly specified for the tag "
454  "`SpecifiedEndTime`");
455  }
456  return *end_time;
457  }
458 };
459 
462  using option_tags = tmpl::list<OptionTags::GhInterfaceManager>;
463 
464  static constexpr bool pass_metavariables = false;
466  create_from_options(
468  interface_manager) noexcept {
469  return interface_manager->get_clone();
470  }
471 };
472 
473 /// \brief Intended for use in the const global cache to communicate to the
474 /// sending elements when they should be sending worldtube data for CCE to the
475 /// interpolator.
476 ///
477 /// \details This tag is not specifiable by independent options in the yaml, and
478 /// instead is entirely determined by the choice of interface manager, which
479 /// sets by virtual member function the interpolation strategy that is
480 /// compatible with the interface manager. The choice to extract this
481 /// information at option-parsing is to avoid needing to pass any information
482 /// from the interpolation manager that is typically stored in the
483 /// `WorldtubeBoundary` component \ref DataBoxGroup to the components that
484 /// provide data for CCE.
487  using option_tags = tmpl::list<OptionTags::GhInterfaceManager>;
488 
489  static constexpr bool pass_metavariables = false;
490  static InterfaceManagers::InterpolationStrategy create_from_options(
492  interface_manager) noexcept {
493  return interface_manager->get_interpolation_strategy();
494  }
495 };
496 
497 /// Base tag for first-hypersurface initialization procedure
499 
500 /// Tag for first-hypersurface initialization procedure specified by input
501 /// options.
504  using option_tags = tmpl::list<OptionTags::InitializeJ>;
505 
506  static constexpr bool pass_metavariables = false;
507  static std::unique_ptr<::Cce::InitializeJ::InitializeJ> create_from_options(
509  initialize_j) noexcept {
510  return initialize_j->get_clone();
511  }
512 };
513 
514 // Tags that generates an `Cce::InitializeJ::InitializeJ` derived class from an
515 // analytic solution.
518  using option_tags =
519  tmpl::list<OptionTags::AnalyticSolution, OptionTags::StartTime>;
520  static constexpr bool pass_metavariables = false;
521  static std::unique_ptr<::Cce::InitializeJ::InitializeJ> create_from_options(
523  const std::optional<double> start_time) noexcept {
524  return worldtube_data->get_initialize_j(*start_time);
525  }
526 };
527 
528 /// A tag that constructs a `AnalyticBoundaryDataManager` from options
531  using option_tags = tmpl::list<OptionTags::ExtractionRadius, OptionTags::LMax,
533 
534  static constexpr bool pass_metavariables = false;
535  static Cce::AnalyticBoundaryDataManager create_from_options(
536  const double extraction_radius, const size_t l_max,
538  worldtube_data) noexcept {
539  return ::Cce::AnalyticBoundaryDataManager(l_max, extraction_radius,
540  worldtube_data->get_clone());
541  }
542 };
543 
544 /// Represents whether the news should be provided at noninertial times.
545 ///
546 /// \details Currently, this is only useful for analytic solutions for which the
547 /// inertial-time news is difficult to compute.
549  using type = bool;
550  using option_tags =
551  tmpl::list<OptionTags::AnalyticSolution>;
552  static constexpr bool pass_metavariables = false;
553  static bool create_from_options(
555  worldtube_data) noexcept {
556  return worldtube_data->use_noninertial_news();
557  }
558 };
559 } // namespace Tags
560 } // namespace Cce
Cce::MetricWorldtubeH5BufferUpdater
A WorldtubeBufferUpdater specialized to the CCE input worldtube H5 file produced by SpEC.
Definition: WorldtubeBufferUpdater.hpp:175
std::string
Cce::OptionTags::AnalyticSolution
Definition: OptionTags.hpp:161
Cce::InitializationTags::ScriOutputDensity
Definition: OptionTags.hpp:233
Cce::OptionTags::ScriOutputDensity
Definition: OptionTags.hpp:184
Cce::Tags::InterfaceManagerInterpolationStrategy
Intended for use in the const global cache to communicate to the sending elements when they should be...
Definition: OptionTags.hpp:485
Cce::Tags::NumberOfRadialPoints
Definition: OptionTags.hpp:295
Options.hpp
Parallel::printf
void printf(const std::string &format, Args &&... args)
Print an atomic message to stdout with C printf usage.
Definition: Printf.hpp:103
Cce::OptionTags::ObservationLMax
Definition: OptionTags.hpp:65
Cce::OptionTags::H5LookaheadTimes
Definition: OptionTags.hpp:125
Cce::OptionTags::LMax
Definition: OptionTags.hpp:38
db::SimpleTag
Mark a struct as a simple tag by inheriting from this.
Definition: Tag.hpp:36
Cce::OptionTags::StandaloneExtractionRadius
Definition: OptionTags.hpp:84
Cce::OptionTags::FilterLMax
Definition: OptionTags.hpp:45
Cce::OptionTags::StartTime
Definition: OptionTags.hpp:103
Cce::OptionTags::EndTime
Definition: OptionTags.hpp:96
Cce::OptionTags::TargetStepSize
Definition: OptionTags.hpp:111
Cce::BondiWorldtubeH5BufferUpdater
A WorldtubeBufferUpdater specialized to the CCE input worldtube H5 file produced by the reduced SpEC ...
Definition: WorldtubeBufferUpdater.hpp:261
Cce::Tags::EndTime
Definition: Tags.hpp:310
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:37
Cce::Tags::SpecifiedEndTime
Represents the final time of a bounded CCE evolution that must be supplied in the input file (for e....
Definition: OptionTags.hpp:444
Cce::Tags::ObservationLMax
Definition: OptionTags.hpp:307
Cce::OptionTags::H5IsBondiData
Definition: OptionTags.hpp:140
Cce::Tags::InitializeJBase
Base tag for first-hypersurface initialization procedure.
Definition: OptionTags.hpp:498
Printf.hpp
std::numeric_limits::infinity
T infinity(T... args)
Cce::OptionTags::Cce
Option group
Definition: OptionTags.hpp:27
Spectral::Swsh::Tags::NumberOfRadialPointsBase
Base Tag for the number of radial grid points in the three-dimensional representation of radially con...
Definition: SwshTags.hpp:209
cstddef
Cce::OptionTags::ExtractionRadius
Definition: OptionTags.hpp:78
Spectral::Swsh::Tags::LMaxBase
Base Tag for the maximum spin-weighted spherical harmonic l; sets angular resolution.
Definition: SwshTags.hpp:197
Cce::InitializationTags::TargetStepSize
Definition: OptionTags.hpp:213
Cce::OptionTags::RadialFilterHalfPower
Definition: OptionTags.hpp:58
Cce::Tags::NoEndTime
Represents the final time of a CCE evolution that should just proceed until it receives no more bound...
Definition: OptionTags.hpp:432
Cce::OptionTags::FixSpecNormalization
Definition: OptionTags.hpp:151
Cce::Tags::AnalyticBoundaryDataManager
A tag that constructs a AnalyticBoundaryDataManager from options.
Definition: OptionTags.hpp:529
Cce::Tags::EndTimeFromFile
Represents the final time of a bounded CCE evolution, determined either from option specification or ...
Definition: OptionTags.hpp:405
db::BaseTag
Mark a (usually) empty struct as a base tag by inheriting from this.
Definition: Tag.hpp:69
Options::Auto
A class indicating that a parsed value can be automatically computed instead of specified.
Definition: Auto.hpp:33
Cce::AnalyticBoundaryDataManager
A boundary data manager that constructs the desired boundary data into the Variables from the data pr...
Definition: AnalyticBoundaryDataManager.hpp:38
Cce::Tags::RadialFilterAlpha
Definition: OptionTags.hpp:327
Cce::Tags::GhInterfaceManager
Definition: OptionTags.hpp:460
Cce
The set of utilities for performing Cauchy characteristic evolution and Cauchy characteristic matchin...
Definition: CharacteristicExtractFwd.hpp:6
limits
Cce::Tags::FilterLMax
Definition: OptionTags.hpp:317
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
Cce::Tags::InitializeJ
Tag for first-hypersurface initialization procedure specified by input options.
Definition: OptionTags.hpp:502
Cce::Tags::RadialFilterHalfPower
Definition: OptionTags.hpp:337
Cce::Tags::H5WorldtubeBoundaryDataManager
A tag that constructs a MetricWorldtubeDataManager from options.
Definition: OptionTags.hpp:246
Cce::Tags::OutputNoninertialNews
Represents whether the news should be provided at noninertial times.
Definition: OptionTags.hpp:548
Cce::OptionTags::InitializeJ
Definition: OptionTags.hpp:192
Cce::OptionTags::ScriInterpolationOrder
Definition: OptionTags.hpp:175
Cce::OptionTags::RadialFilterAlpha
Definition: OptionTags.hpp:51
optional
Cce::Tags::LMax
Definition: OptionTags.hpp:285
Cce::OptionTags::H5Interpolator
Definition: OptionTags.hpp:133
Cce::OptionTags::Filtering
Option group
Definition: OptionTags.hpp:33
Cce::OptionTags::GhInterfaceManager
Definition: OptionTags.hpp:168
Cce::OptionTags::NumberOfRadialPoints
Definition: OptionTags.hpp:71
Cce::InitializationTags::ScriInterpolationOrder
Definition: OptionTags.hpp:202
Cce::Tags::SpecifiedStartTime
Represents the start time of a bounded CCE evolution that must be supplied in the input file (for e....
Definition: OptionTags.hpp:382
std::unique_ptr< intrp::SpanInterpolator >
Cce::Tags::StartTimeFromFile
Represents the start time of a bounded CCE evolution, determined either from option specification or ...
Definition: OptionTags.hpp:355
Cce::Tags::StartTime
Definition: Tags.hpp:312
Cce::Tags::AnalyticInitializeJ
Definition: OptionTags.hpp:516
Cce::InterfaceManagers::InterpolationStrategy
InterpolationStrategy
Enumeration of possibilities for the collection of worldtube data that will be collected by the inter...
Definition: GhInterpolationStrategies.hpp:31
Cce::InitializationTags::ExtractionRadius
Definition: OptionTags.hpp:223
Cce::OptionTags::BoundaryDataFilename
Definition: OptionTags.hpp:118