Skip to content

Commit

Permalink
Remove CCE ability to read metric worldtube data
Browse files Browse the repository at this point in the history
  • Loading branch information
knelli2 committed Jan 18, 2025
1 parent e6984e5 commit 8af65a9
Show file tree
Hide file tree
Showing 17 changed files with 140 additions and 280 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/DeployStaticExecutables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ jobs:
sed -i 's/CceR0257/Tests\/BondiSachsCceR0200/g' \
./CceExecutables/CharacteristicExtract.yaml
sed -i 's/H5IsBondiData: False/H5IsBondiData: True/g' \
./CceExecutables/CharacteristicExtract.yaml
cd ./CceExecutables/
Expand Down
4 changes: 0 additions & 4 deletions docs/Tutorials/CCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,6 @@ a bit on why we chose some of those parameters.
we also recommend running CCE over several worldtube radii and checking which
is the best based on the Bianchi identity violations. There isn't necessarily
a "best radius" to extract waveforms at.
- If the worldtube data is in the [Bondi-Sachs](#bondi_sachs) form, set
`Cce.H5IsBondiData` to `True`. If the worldtube data is the
[cartesian_metric](#cartesian_metric_and_derivatives) form, set
`Cce.H5IsBondiData` to `False`.

### Initial data on the null hypersurface

Expand Down
118 changes: 37 additions & 81 deletions src/Evolution/Systems/Cce/OptionTags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <cstddef>
#include <limits>
#include <optional>
#include <stdexcept>

#include "DataStructures/ComplexDataVector.hpp"
#include "DataStructures/ComplexModalVector.hpp"
Expand Down Expand Up @@ -118,8 +119,7 @@ struct StandaloneExtractionRadius {
static constexpr Options::String help{
"Extraction radius of the CCE system for a standalone run. This may be "
"set to \"Auto\" to infer the radius from the filename (often used for "
"SpEC worldtube data). This option is unused if `H5IsBondiData` is "
"`true`, and should be \"Auto\" for such runs."};
"SpEC worldtube data)."};
using group = Cce;
};

Expand Down Expand Up @@ -168,27 +168,6 @@ struct H5Interpolator {
using group = Cce;
};

struct H5IsBondiData {
using type = bool;
static constexpr Options::String help{
"true for boundary data in Bondi form, false for metric data. Metric "
"data is more readily available from Cauchy simulations, so historically "
"has been the typical format provided by SpEC simulations. Bondi data is "
"much more efficient for storage size and performance, but both must be "
"supported for compatibility with current CCE data sources."};
using group = Cce;
};

struct FixSpecNormalization {
using type = bool;
static constexpr Options::String help{
"Set to true if corrections for SpEC data impurities should be applied "
"automatically based on the `VersionHist.ver` data set in the H5. "
"Typically, this should be set to true if the metric data is created "
"from SpEC, and false otherwise."};
using group = Cce;
};

struct AnalyticSolution {
using type = std::unique_ptr<Solutions::WorldtubeData>;
static constexpr Options::String help{
Expand Down Expand Up @@ -319,45 +298,35 @@ struct H5WorldtubeBoundaryDataManager : db::SimpleTag {
using option_tags =
tmpl::list<OptionTags::LMax, OptionTags::BoundaryDataFilename,
OptionTags::H5LookaheadTimes, OptionTags::H5Interpolator,
OptionTags::H5IsBondiData, OptionTags::FixSpecNormalization,
OptionTags::StandaloneExtractionRadius>;

static constexpr bool pass_metavariables = false;
static type create_from_options(
const size_t l_max, const std::string& filename,
const size_t number_of_lookahead_times,
const std::unique_ptr<intrp::SpanInterpolator>& interpolator,
const bool h5_is_bondi_data, const bool fix_spec_normalization,
const std::optional<double> extraction_radius) {
if (h5_is_bondi_data) {
if (static_cast<bool>(extraction_radius)) {
const std::string text_radius_str = Cce::get_text_radius(filename);
try {
// If this doesn't throw an exception, then an extraction radius was
// supplied in the filename. We don't actually need the value.
const double text_radius = std::stod(text_radius_str);
(void)text_radius;
if (extraction_radius.has_value()) {
Parallel::printf(
"Warning: Option ExtractionRadius is set to a specific value and "
"H5IsBondiData is set to `true` -- the ExtractionRadius will not "
"be used, because all radius information is specified in the input "
"file for the Bondi worldtube data format. It is recommended to "
"set `ExtractionRadius` to `\"Auto\"` to make the input file "
"clearer.\n");
"there is an extraction radius in the H5 filename. The value in "
"the file name will be ignored.It is recommended to set "
"`ExtractionRadius` to `\"Auto\"` if the H5 filename has the "
"extraction radius in it to make the input file clearer.\n");
}
return std::make_unique<BondiWorldtubeDataManager>(
std::make_unique<BondiWorldtubeH5BufferUpdater<ComplexModalVector>>(
filename, extraction_radius),
l_max, number_of_lookahead_times, interpolator->get_clone());
} else {
Parallel::printf(
"\nDEPRECATION WARNING: Reading worldtube H5 files that are in the "
"Metric data format (i.e. cartesian components of the metric and "
"derivs expressed in modal coefficients) is deprecated. Convert your "
"data to the Bondi modal format using the 'PreprocessCceWorldtube' "
"executable. See https://spectre-code.org/tutorial_cce.html for "
"details. Support for reading the Metric data format will be "
"dropped in January 2025.\n");
return std::make_unique<MetricWorldtubeDataManager>(
std::make_unique<MetricWorldtubeH5BufferUpdater<ComplexModalVector>>(
filename, extraction_radius),
l_max, number_of_lookahead_times, interpolator->get_clone(),
fix_spec_normalization);
} catch (const std::invalid_argument&) {
}

return std::make_unique<BondiWorldtubeDataManager>(
std::make_unique<BondiWorldtubeH5BufferUpdater<ComplexModalVector>>(
filename, extraction_radius),
l_max, number_of_lookahead_times, interpolator->get_clone());
}
};

Expand Down Expand Up @@ -453,26 +422,20 @@ struct StartTimeFromFile : Tags::StartTime, db::SimpleTag {
using type = double;
using option_tags =
tmpl::list<OptionTags::StartTime, OptionTags::BoundaryDataFilename,
OptionTags::H5IsBondiData>;
OptionTags::StandaloneExtractionRadius>;

static constexpr bool pass_metavariables = false;
static double create_from_options(const std::optional<double> start_time,
const std::string& filename,
const bool is_bondi_data) {
if (start_time) {
static double create_from_options(
const std::optional<double> start_time, const std::string& filename,
const std::optional<double>& extraction_radius) {
if (start_time.has_value()) {
return *start_time;
}
if (is_bondi_data) {
BondiWorldtubeH5BufferUpdater<ComplexModalVector> h5_boundary_updater{
filename};
const auto& time_buffer = h5_boundary_updater.get_time_buffer();
return time_buffer[0];
} else {
MetricWorldtubeH5BufferUpdater<ComplexModalVector> h5_boundary_updater{
filename};
const auto& time_buffer = h5_boundary_updater.get_time_buffer();
return time_buffer[0];
}

BondiWorldtubeH5BufferUpdater<ComplexModalVector> h5_boundary_updater{
filename, extraction_radius};
const auto& time_buffer = h5_boundary_updater.get_time_buffer();
return time_buffer[0];
}
};

Expand Down Expand Up @@ -504,26 +467,19 @@ struct EndTimeFromFile : Tags::EndTime, db::SimpleTag {
using type = double;
using option_tags =
tmpl::list<OptionTags::EndTime, OptionTags::BoundaryDataFilename,
OptionTags::H5IsBondiData>;
OptionTags::StandaloneExtractionRadius>;

static constexpr bool pass_metavariables = false;
static double create_from_options(const std::optional<double> end_time,
const std::string& filename,
const bool is_bondi_data) {
static double create_from_options(
const std::optional<double> end_time, const std::string& filename,
const std::optional<double>& extraction_radius) {
if (end_time) {
return *end_time;
}
if (is_bondi_data) {
BondiWorldtubeH5BufferUpdater<ComplexModalVector> h5_boundary_updater{
filename};
const auto& time_buffer = h5_boundary_updater.get_time_buffer();
return time_buffer[time_buffer.size() - 1];
} else {
MetricWorldtubeH5BufferUpdater<ComplexModalVector> h5_boundary_updater{
filename};
const auto& time_buffer = h5_boundary_updater.get_time_buffer();
return time_buffer[time_buffer.size() - 1];
}
BondiWorldtubeH5BufferUpdater<ComplexModalVector> h5_boundary_updater{
filename, extraction_radius};
const auto& time_buffer = h5_boundary_updater.get_time_buffer();
return time_buffer[time_buffer.size() - 1];
}
};

Expand Down
6 changes: 0 additions & 6 deletions tests/InputFiles/Cce/CharacteristicExtract.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,11 @@ Cce:
# ExtractionRadius: 257
BoundaryDataFilename: CceR0257.h5
ExtractionRadius: Auto
# Assume data is metric & derivs. This is wrong for SpECTRE & SpEC
# output, but likely correct for other codes.
H5IsBondiData: False
# How we interpolate the worldtube data in time for CCE.
H5Interpolator:
BarycentricRationalSpanInterpolator:
MinOrder: 10
MaxOrder: 10
# Unless you are using data from an old version of the Spectral Einstein Code,
# leave FixSpecNormalization as False.
FixSpecNormalization: False

# Loads this many time steps in from the HDF5 files at once. Fewer file system
# accesses improve performance, but requires more RAM.
Expand Down
6 changes: 0 additions & 6 deletions tests/InputFiles/Cce/KleinGordonCharacteristicExtract.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,11 @@ Cce:
BoundaryDataFilename: CceR0257.h5
KleinGordonBoundaryDataFilename: CceR0257.h5
ExtractionRadius: Auto
# Assume data is metric & derivs. This is wrong for SpECTRE & SpEC
# output, but likely correct for other codes.
H5IsBondiData: False
# How we interpolate the worldtube data in time for CCE.
H5Interpolator:
BarycentricRationalSpanInterpolator:
MinOrder: 10
MaxOrder: 10
# Unless you are using data from an old version of the Spectral Einstein Code,
# leave FixSpecNormalization as False.
FixSpecNormalization: False

# Loads this many time steps in from the HDF5 files at once. Fewer file system
# accesses improve performance, but requires more RAM.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ SPECTRE_TEST_CASE("Unit.Evolution.Systems.Cce.Actions.H5BoundaryCommunication",
Tags::H5WorldtubeBoundaryDataManager::create_from_options(
l_max, filename, buffer_size,
std::make_unique<intrp::BarycentricRationalSpanInterpolator>(3u, 4u),
false, false, std::optional<double>{}));
std::optional<double>{}));

// this should run the initializations
for (size_t i = 0; i < 5; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void test_klein_gordon_h5_initialization(const gsl::not_null<Generator*> gen) {
Tags::H5WorldtubeBoundaryDataManager::create_from_options(
l_max, filename, buffer_size,
std::make_unique<intrp::BarycentricRationalSpanInterpolator>(3u, 4u),
false, false, std::optional<double>{}),
std::optional<double>{}),
Tags::KleinGordonH5WorldtubeBoundaryDataManager::create_from_options(
l_max, filename, buffer_size,
std::make_unique<intrp::BarycentricRationalSpanInterpolator>(3u, 4u),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void test_h5_initialization(const gsl::not_null<Generator*> gen) {
Tags::H5WorldtubeBoundaryDataManager::create_from_options(
l_max, filename, buffer_size,
std::make_unique<intrp::BarycentricRationalSpanInterpolator>(3u, 4u),
false, false, std::optional<double>{}));
std::optional<double>{}));

// this should run the initialization
for (size_t i = 0; i < 3; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void test_klein_gordon_h5_boundary_communication(
Tags::H5WorldtubeBoundaryDataManager::create_from_options(
l_max, filename, buffer_size,
std::make_unique<intrp::BarycentricRationalSpanInterpolator>(3u, 4u),
false, false, std::optional<double>{}),
std::optional<double>{}),
Tags::KleinGordonH5WorldtubeBoundaryDataManager::create_from_options(
l_max, filename, buffer_size,
std::make_unique<intrp::BarycentricRationalSpanInterpolator>(3u, 4u),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ SPECTRE_TEST_CASE("Unit.Evolution.Systems.Cce.Actions.RequestBoundaryData",
l_max, filename, buffer_size,
std::make_unique<intrp::BarycentricRationalSpanInterpolator>(3_st,
4_st),
false, false, std::optional<double>{}));
std::optional<double>{}));

// this should run the initializations
for (size_t i = 0; i < 5; ++i) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void test_klein_gordon_boundary_data(const gsl::not_null<Generator*> gen) {
Tags::H5WorldtubeBoundaryDataManager::create_from_options(
l_max, filename, buffer_size,
std::make_unique<intrp::BarycentricRationalSpanInterpolator>(3u, 4u),
false, false, std::optional<double>{}),
std::optional<double>{}),
Tags::KleinGordonH5WorldtubeBoundaryDataManager::create_from_options(
l_max, filename, buffer_size,
std::make_unique<intrp::BarycentricRationalSpanInterpolator>(3u, 4u),
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Evolution/Systems/Cce/Test_OptionTags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ SPECTRE_TEST_CASE("Unit.Evolution.Systems.Cce.OptionTags", "[Unit][Cce]") {
}
Cce::TestHelpers::write_test_file(
gr::Solutions::KerrSchild{1.0, {{0.2, 0.2, 0.2}}, {{0.0, 0.0, 0.0}}},
filename, 4.0, 100.0, 0.0, 0.1, 8);
filename, 4.0, 100.0, 0.1, 0.1, 8);

CHECK(Cce::Tags::H5WorldtubeBoundaryDataManager::create_from_options(
8, filename, 3, std::make_unique<intrp::CubicSpanInterpolator>(),
false, true, std::nullopt)
std::nullopt)
->get_l_max() == 8);

CHECK(Cce::Tags::FilePrefix::create_from_options("Shrek 2") == "Shrek 2");
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Evolution/Systems/Cce/Test_WorldtubeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,9 @@ void test_metric_worldtube_buffer_updater_impl(
if (file_system::check_if_file_exists(filename)) {
file_system::rm(filename, true);
}
TestHelpers::write_test_file<T>(solution, filename, target_time,
extraction_radius, frequency, amplitude,
file_l_max);
TestHelpers::write_test_file<T, false>(solution, filename, target_time,
extraction_radius, frequency,
amplitude, file_l_max);

// request an appropriate buffer
auto buffer_updater =
Expand Down
Loading

0 comments on commit 8af65a9

Please sign in to comment.