From 2254fa1a273f48d95994348d191db822cf48bd0a Mon Sep 17 00:00:00 2001 From: Kyle Nelli Date: Mon, 7 Oct 2024 11:46:05 -0700 Subject: [PATCH] Remove ReducedWorldtubeModeRecorder And rename the file to just WorldtubeModeRecorder --- src/Evolution/Systems/Cce/CMakeLists.txt | 4 +- .../Callbacks/DumpBondiSachsOnWorldtube.hpp | 2 +- ...Recorder.cpp => WorldtubeModeRecorder.cpp} | 66 +------------------ ...Recorder.hpp => WorldtubeModeRecorder.hpp} | 21 ------ .../ReduceCceWorldtube/ReduceCceWorldtube.cpp | 2 +- .../Cce/Test_KleinGordonWorldtubeData.cpp | 2 +- .../Systems/Cce/Test_WorldtubeData.cpp | 2 +- 7 files changed, 7 insertions(+), 92 deletions(-) rename src/Evolution/Systems/Cce/{ReducedWorldtubeModeRecorder.cpp => WorldtubeModeRecorder.cpp} (72%) rename src/Evolution/Systems/Cce/{ReducedWorldtubeModeRecorder.hpp => WorldtubeModeRecorder.hpp} (74%) diff --git a/src/Evolution/Systems/Cce/CMakeLists.txt b/src/Evolution/Systems/Cce/CMakeLists.txt index 771b6c6a2e18d..acacd2708d900 100644 --- a/src/Evolution/Systems/Cce/CMakeLists.txt +++ b/src/Evolution/Systems/Cce/CMakeLists.txt @@ -18,11 +18,11 @@ spectre_target_sources( LinearSolve.cpp NewmanPenrose.cpp PrecomputeCceDependencies.cpp - ReducedWorldtubeModeRecorder.cpp ScriPlusValues.cpp SpecBoundaryData.cpp WorldtubeBufferUpdater.cpp WorldtubeDataManager.cpp + WorldtubeModeRecorder.cpp ) spectre_target_headers( @@ -44,7 +44,6 @@ spectre_target_headers( PreSwshDerivatives.hpp PrecomputeCceDependencies.hpp ReceiveTags.hpp - ReducedWorldtubeModeRecorder.hpp ScriPlusInterpolationManager.hpp ScriPlusValues.hpp SpecBoundaryData.hpp @@ -55,6 +54,7 @@ spectre_target_headers( Tags.hpp WorldtubeBufferUpdater.hpp WorldtubeDataManager.hpp + WorldtubeModeRecorder.hpp ) target_link_libraries( diff --git a/src/Evolution/Systems/Cce/Callbacks/DumpBondiSachsOnWorldtube.hpp b/src/Evolution/Systems/Cce/Callbacks/DumpBondiSachsOnWorldtube.hpp index 3592ced2975ab..32492c8e4bbef 100644 --- a/src/Evolution/Systems/Cce/Callbacks/DumpBondiSachsOnWorldtube.hpp +++ b/src/Evolution/Systems/Cce/Callbacks/DumpBondiSachsOnWorldtube.hpp @@ -20,8 +20,8 @@ #include "DataStructures/VariablesTag.hpp" #include "Evolution/Systems/Cce/BoundaryData.hpp" #include "Evolution/Systems/Cce/OptionTags.hpp" -#include "Evolution/Systems/Cce/ReducedWorldtubeModeRecorder.hpp" #include "Evolution/Systems/Cce/Tags.hpp" +#include "Evolution/Systems/Cce/WorldtubeModeRecorder.hpp" #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp" #include "IO/Observer/Actions/GetLockPointer.hpp" #include "IO/Observer/ObserverComponent.hpp" diff --git a/src/Evolution/Systems/Cce/ReducedWorldtubeModeRecorder.cpp b/src/Evolution/Systems/Cce/WorldtubeModeRecorder.cpp similarity index 72% rename from src/Evolution/Systems/Cce/ReducedWorldtubeModeRecorder.cpp rename to src/Evolution/Systems/Cce/WorldtubeModeRecorder.cpp index 267e3a18cf351..a595fe1724fef 100644 --- a/src/Evolution/Systems/Cce/ReducedWorldtubeModeRecorder.cpp +++ b/src/Evolution/Systems/Cce/WorldtubeModeRecorder.cpp @@ -1,7 +1,7 @@ // Distributed under the MIT License. // See LICENSE.txt for details. -#include "Evolution/Systems/Cce/ReducedWorldtubeModeRecorder.hpp" +#include "Evolution/Systems/Cce/WorldtubeModeRecorder.hpp" #include @@ -71,70 +71,6 @@ std::string dataset_label_for_tag< return "DuR"; } -void ReducedWorldtubeModeRecorder::append_worldtube_mode_data( - const std::string& dataset_path, const double time, - const ComplexModalVector& modes, const size_t l_max, const bool is_real) { - std::vector legend; - const size_t output_size = square(l_max + 1); - legend.reserve(is_real ? output_size + 1 : 2 * output_size + 1); - legend.emplace_back("time"); - for (int l = 0; l <= static_cast(l_max); ++l) { - for (int m = is_real ? 0 : -l; m <= l; ++m) { - legend.push_back("Re(" + std::to_string(l) + "," + std::to_string(m) + - ")"); - if (LIKELY(not is_real or m != 0)) { - legend.push_back("Im(" + std::to_string(l) + "," + std::to_string(m) + - ")"); - } - } - } - auto& output_mode_dataset = - output_file_.try_insert(dataset_path, legend, 0); - std::vector data_to_write; - if (is_real) { - data_to_write.resize(output_size + 1); - data_to_write[0] = time; - for (int l = 0; l <= static_cast(l_max); ++l) { - data_to_write[static_cast(square(l)) + 1] = - real(modes[Spectral::Swsh::goldberg_mode_index( - l_max, static_cast(l), 0)]); - for (int m = 1; m <= l; ++m) { - // this is the right order of the casts, other orders give the wrong - // answer - // NOLINTNEXTLINE(misc-misplaced-widening-cast) - data_to_write[static_cast(square(l) + 2 * m)] = - real(modes[Spectral::Swsh::goldberg_mode_index( - l_max, static_cast(l), m)]); - // this is the right order of the casts, other orders give the wrong - // answer - // NOLINTNEXTLINE(misc-misplaced-widening-cast) - data_to_write[static_cast(square(l) + 2 * m + 1)] = - imag(modes[Spectral::Swsh::goldberg_mode_index( - l_max, static_cast(l), m)]); - } - } - } else { - data_to_write.resize(2 * output_size + 1); - data_to_write[0] = time; - for (int l = 0; l <= static_cast(l_max); ++l) { - for (int m = -l; m <= l; ++m) { - data_to_write[2 * Spectral::Swsh::goldberg_mode_index( - l_max, static_cast(l), m) + - 1] = - real(modes[Spectral::Swsh::goldberg_mode_index( - l_max, static_cast(l), m)]); - data_to_write[2 * Spectral::Swsh::goldberg_mode_index( - l_max, static_cast(l), m) + - 2] = - imag(modes[Spectral::Swsh::goldberg_mode_index( - l_max, static_cast(l), m)]); - } - } - } - output_mode_dataset.append(data_to_write); - output_file_.close_current_object(); -} - WorldtubeModeRecorder::WorldtubeModeRecorder() = default; WorldtubeModeRecorder::WorldtubeModeRecorder(const size_t l_max, const std::string& h5_filename) diff --git a/src/Evolution/Systems/Cce/ReducedWorldtubeModeRecorder.hpp b/src/Evolution/Systems/Cce/WorldtubeModeRecorder.hpp similarity index 74% rename from src/Evolution/Systems/Cce/ReducedWorldtubeModeRecorder.hpp rename to src/Evolution/Systems/Cce/WorldtubeModeRecorder.hpp index 5a5082f1578c9..419133b754865 100644 --- a/src/Evolution/Systems/Cce/ReducedWorldtubeModeRecorder.hpp +++ b/src/Evolution/Systems/Cce/WorldtubeModeRecorder.hpp @@ -25,27 +25,6 @@ namespace Cce { template std::string dataset_label_for_tag(); -/// Records a compressed representation of SpEC-like worldtube data associated -/// with just the spin-weighted scalars required to perform the CCE algorithm. -struct ReducedWorldtubeModeRecorder { - public: - /// The constructor takes the filename used to create the H5File object for - /// writing the data - explicit ReducedWorldtubeModeRecorder(const std::string& filename) - : output_file_{filename} {} - - /// append to `dataset_path` the vector created by `time` followed by the - /// `modes` rearranged in ascending m-varies-fastest format. - /// - /// For real quantities, negative m and the imaginary part of m=0 are omitted. - void append_worldtube_mode_data(const std::string& dataset_path, double time, - const ComplexModalVector& modes, size_t l_max, - bool is_real = false); - - private: - h5::H5File output_file_; -}; - /*! * \brief Class that standardizes the output of our worldtube data into the * Bondi modal format that the CharacteristicExtract executable can read in. diff --git a/src/Executables/ReduceCceWorldtube/ReduceCceWorldtube.cpp b/src/Executables/ReduceCceWorldtube/ReduceCceWorldtube.cpp index f1f6356e71cfd..508f3aaaf5dde 100644 --- a/src/Executables/ReduceCceWorldtube/ReduceCceWorldtube.cpp +++ b/src/Executables/ReduceCceWorldtube/ReduceCceWorldtube.cpp @@ -15,10 +15,10 @@ #include "DataStructures/Variables.hpp" #include "DataStructures/VariablesTag.hpp" #include "Evolution/Systems/Cce/BoundaryData.hpp" -#include "Evolution/Systems/Cce/ReducedWorldtubeModeRecorder.hpp" #include "Evolution/Systems/Cce/SpecBoundaryData.hpp" #include "Evolution/Systems/Cce/Tags.hpp" #include "Evolution/Systems/Cce/WorldtubeBufferUpdater.hpp" +#include "Evolution/Systems/Cce/WorldtubeModeRecorder.hpp" #include "NumericalAlgorithms/SpinWeightedSphericalHarmonics/SwshCoefficients.hpp" #include "NumericalAlgorithms/SpinWeightedSphericalHarmonics/SwshCollocation.hpp" #include "Options/Auto.hpp" diff --git a/tests/Unit/Evolution/Systems/Cce/Test_KleinGordonWorldtubeData.cpp b/tests/Unit/Evolution/Systems/Cce/Test_KleinGordonWorldtubeData.cpp index 278c63eab3beb..9c1f6ac2e660a 100644 --- a/tests/Unit/Evolution/Systems/Cce/Test_KleinGordonWorldtubeData.cpp +++ b/tests/Unit/Evolution/Systems/Cce/Test_KleinGordonWorldtubeData.cpp @@ -5,9 +5,9 @@ #include -#include "Evolution/Systems/Cce/ReducedWorldtubeModeRecorder.hpp" #include "Evolution/Systems/Cce/WorldtubeBufferUpdater.hpp" #include "Evolution/Systems/Cce/WorldtubeDataManager.hpp" +#include "Evolution/Systems/Cce/WorldtubeModeRecorder.hpp" #include "Framework/TestHelpers.hpp" #include "Helpers/DataStructures/MakeWithRandomValues.hpp" #include "Helpers/Evolution/Systems/Cce/BoundaryTestHelpers.hpp" diff --git a/tests/Unit/Evolution/Systems/Cce/Test_WorldtubeData.cpp b/tests/Unit/Evolution/Systems/Cce/Test_WorldtubeData.cpp index 041d6c85ee705..7b79109ef2888 100644 --- a/tests/Unit/Evolution/Systems/Cce/Test_WorldtubeData.cpp +++ b/tests/Unit/Evolution/Systems/Cce/Test_WorldtubeData.cpp @@ -13,9 +13,9 @@ #include "DataStructures/Tensor/Tensor.hpp" #include "DataStructures/Tensor/TypeAliases.hpp" #include "Evolution/Systems/Cce/BoundaryData.hpp" -#include "Evolution/Systems/Cce/ReducedWorldtubeModeRecorder.hpp" #include "Evolution/Systems/Cce/WorldtubeBufferUpdater.hpp" #include "Evolution/Systems/Cce/WorldtubeDataManager.hpp" +#include "Evolution/Systems/Cce/WorldtubeModeRecorder.hpp" #include "Framework/CheckWithRandomValues.hpp" #include "Framework/SetupLocalPythonEnvironment.hpp" #include "Helpers/DataStructures/MakeWithRandomValues.hpp"