Skip to content

Commit

Permalink
Move angular ordering to SphericalHarmonics
Browse files Browse the repository at this point in the history
  • Loading branch information
knelli2 committed Sep 11, 2024
1 parent b245c4f commit 6d36d01
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
#include "IO/Observer/Actions/GetLockPointer.hpp"
#include "IO/Observer/ObserverComponent.hpp"
#include "IO/Observer/ReductionActions.hpp"
#include "NumericalAlgorithms/SphericalHarmonics/AngularOrdering.hpp"
#include "NumericalAlgorithms/SpinWeightedSphericalHarmonics/SwshCoefficients.hpp"
#include "NumericalAlgorithms/SpinWeightedSphericalHarmonics/SwshCollocation.hpp"
#include "Parallel/GlobalCache.hpp"
#include "Parallel/Invoke.hpp"
#include "ParallelAlgorithms/Interpolation/InterpolationTargetDetail.hpp"
#include "ParallelAlgorithms/Interpolation/Protocols/PostInterpolationCallback.hpp"
#include "ParallelAlgorithms/Interpolation/Targets/AngularOrdering.hpp"
#include "ParallelAlgorithms/Interpolation/Targets/Sphere.hpp"
#include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
#include "Utilities/ConstantExpressions.hpp"
Expand Down Expand Up @@ -133,7 +133,7 @@ struct DumpBondiSachsOnWorldtube
Parallel::get<Tags::Sphere<InterpolationTargetTag>>(cache);
const auto& filename_prefix = Parallel::get<Cce::Tags::FilePrefix>(cache);

if (sphere.angular_ordering != intrp::AngularOrdering::Cce) {
if (sphere.angular_ordering != ylm::AngularOrdering::Cce) {
ERROR(
"To use the DumpBondiSachsOnWorldtube post interpolation callback, "
"the angular ordering of the Spheres must be Cce, not "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Distributed under the MIT License.
// See LICENSE.txt for details.

#include "ParallelAlgorithms/Interpolation/Targets/AngularOrdering.hpp"
#include "NumericalAlgorithms/SphericalHarmonics/AngularOrdering.hpp"

#include <string>

#include "Options/Options.hpp"
#include "Options/ParseOptions.hpp"
#include "Utilities/ErrorHandling/Error.hpp"

namespace intrp {
namespace ylm {
std::ostream& operator<<(std::ostream& os, const AngularOrdering ordering) {
switch (ordering) {
case AngularOrdering::Strahlkorper:
Expand All @@ -20,17 +20,17 @@ std::ostream& operator<<(std::ostream& os, const AngularOrdering ordering) {
ERROR("Unknown AngularOrdering type");
}
}
} // namespace intrp
} // namespace ylm

template <>
intrp::AngularOrdering
Options::create_from_yaml<intrp::AngularOrdering>::create<void>(
ylm::AngularOrdering
Options::create_from_yaml<ylm::AngularOrdering>::create<void>(
const Options::Option& options) {
const auto ordering = options.parse_as<std::string>();
if (ordering == "Strahlkorper") {
return intrp::AngularOrdering::Strahlkorper;
return ylm::AngularOrdering::Strahlkorper;
} else if (ordering == "Cce") {
return intrp::AngularOrdering::Cce;
return ylm::AngularOrdering::Cce;
}
PARSE_ERROR(options.context(),
"AngularOrdering must be 'Strahlkorper' or 'Cce'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct create_from_yaml;
} // namespace Options
/// \endcond

namespace intrp {
namespace ylm {
/*!
* \brief Label for the ordering of spherical harmonic points on a sphere
*
Expand All @@ -23,17 +23,17 @@ namespace intrp {
*/
enum class AngularOrdering { Strahlkorper, Cce };
std::ostream& operator<<(std::ostream& os, AngularOrdering ordering);
} // namespace intrp
} // namespace ylm

template <>
struct Options::create_from_yaml<intrp::AngularOrdering> {
struct Options::create_from_yaml<ylm::AngularOrdering> {
template <typename Metavariables>
static intrp::AngularOrdering create(const Options::Option& options) {
static ylm::AngularOrdering create(const Options::Option& options) {
return create<void>(options);
}
};

template <>
intrp::AngularOrdering
Options::create_from_yaml<intrp::AngularOrdering>::create<void>(
ylm::AngularOrdering
Options::create_from_yaml<ylm::AngularOrdering>::create<void>(
const Options::Option& options);
2 changes: 2 additions & 0 deletions src/NumericalAlgorithms/SphericalHarmonics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ add_spectre_library(${LIBRARY})
spectre_target_sources(
${LIBRARY}
PRIVATE
AngularOrdering.cpp
ChangeCenterOfStrahlkorper.cpp
RealSphericalHarmonics.cpp
SpherepackIterator.cpp
Expand All @@ -23,6 +24,7 @@ spectre_target_headers(
${LIBRARY}
INCLUDE_DIRECTORY ${CMAKE_SOURCE_DIR}/src
HEADERS
AngularOrdering.hpp
ChangeCenterOfStrahlkorper.hpp
RealSphericalHarmonics.hpp
SpherepackIterator.hpp
Expand Down
2 changes: 0 additions & 2 deletions src/ParallelAlgorithms/Interpolation/Targets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
spectre_target_sources(
${LIBRARY}
PRIVATE
AngularOrdering.cpp
KerrHorizon.cpp
LineSegment.cpp
SpecifiedPoints.cpp
Expand All @@ -16,7 +15,6 @@ spectre_target_headers(
${LIBRARY}
INCLUDE_DIRECTORY ${CMAKE_SOURCE_DIR}/src
HEADERS
AngularOrdering.hpp
KerrHorizon.hpp
LineSegment.hpp
SpecifiedPoints.hpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace intrp::OptionHolders {
KerrHorizon::KerrHorizon(size_t l_max_in, std::array<double, 3> center_in,
double mass_in,
std::array<double, 3> dimensionless_spin_in,
const intrp::AngularOrdering angular_ordering_in,
const ylm::AngularOrdering angular_ordering_in,
const Options::Context& context)
: l_max(l_max_in),
center(center_in),
Expand Down
10 changes: 5 additions & 5 deletions src/ParallelAlgorithms/Interpolation/Targets/KerrHorizon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "DataStructures/DataBox/Tag.hpp"
#include "DataStructures/Tensor/TypeAliases.hpp"
#include "DataStructures/Transpose.hpp"
#include "NumericalAlgorithms/SphericalHarmonics/AngularOrdering.hpp"
#include "NumericalAlgorithms/SphericalHarmonics/Spherepack.hpp"
#include "NumericalAlgorithms/SphericalHarmonics/Strahlkorper.hpp"
#include "NumericalAlgorithms/SphericalHarmonics/Tags.hpp"
Expand All @@ -18,7 +19,6 @@
#include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
#include "ParallelAlgorithms/Interpolation/Protocols/ComputeTargetPoints.hpp"
#include "ParallelAlgorithms/Interpolation/Tags.hpp"
#include "ParallelAlgorithms/Interpolation/Targets/AngularOrdering.hpp"
#include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/KerrHorizon.hpp"
#include "Utilities/PrettyType.hpp"
#include "Utilities/ProtocolHelpers.hpp"
Expand Down Expand Up @@ -73,7 +73,7 @@ struct KerrHorizon {
"Dimensionless spin of black hole"};
};
struct AngularOrdering {
using type = intrp::AngularOrdering;
using type = ylm::AngularOrdering;
static constexpr Options::String help = {
"Chooses theta,phi ordering in 2d array"};
};
Expand All @@ -85,7 +85,7 @@ struct KerrHorizon {

KerrHorizon(size_t l_max_in, std::array<double, 3> center_in, double mass_in,
std::array<double, 3> dimensionless_spin_in,
intrp::AngularOrdering angular_ordering_in,
ylm::AngularOrdering angular_ordering_in,
const Options::Context& context = {});

KerrHorizon() = default;
Expand All @@ -102,7 +102,7 @@ struct KerrHorizon {
std::array<double, 3> center{};
double mass{};
std::array<double, 3> dimensionless_spin{};
intrp::AngularOrdering angular_ordering;
ylm::AngularOrdering angular_ordering;
};

bool operator==(const KerrHorizon& lhs, const KerrHorizon& rhs);
Expand Down Expand Up @@ -193,7 +193,7 @@ struct KerrHorizon : tt::ConformsTo<intrp::protocols::ComputeTargetPoints> {
const tmpl::type_<Metavariables>& /*meta*/) {
const auto& kerr_horizon =
db::get<Tags::KerrHorizon<InterpolationTargetTag>>(box);
if (kerr_horizon.angular_ordering == intrp::AngularOrdering::Strahlkorper) {
if (kerr_horizon.angular_ordering == ylm::AngularOrdering::Strahlkorper) {
return db::get<ylm::Tags::CartesianCoords<Frame>>(box);
} else {
const auto& strahlkorper = db::get<ylm::Tags::Strahlkorper<Frame>>(box);
Expand Down
2 changes: 1 addition & 1 deletion src/ParallelAlgorithms/Interpolation/Targets/Sphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct SphereVisitor {

Sphere::Sphere(const size_t l_max_in, const std::array<double, 3> center_in,
const typename Radius::type& radius_in,
const intrp::AngularOrdering angular_ordering_in,
const ylm::AngularOrdering angular_ordering_in,
const Options::Context& context)
: l_max(l_max_in),
center(center_in),
Expand Down
10 changes: 5 additions & 5 deletions src/ParallelAlgorithms/Interpolation/Targets/Sphere.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@

#include "DataStructures/DataBox/DataBox.hpp"
#include "DataStructures/Transpose.hpp"
#include "NumericalAlgorithms/SphericalHarmonics/AngularOrdering.hpp"
#include "NumericalAlgorithms/SphericalHarmonics/Strahlkorper.hpp"
#include "NumericalAlgorithms/SphericalHarmonics/Tags.hpp"
#include "Options/String.hpp"
#include "Parallel/GlobalCache.hpp"
#include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
#include "ParallelAlgorithms/Interpolation/Protocols/ComputeTargetPoints.hpp"
#include "ParallelAlgorithms/Interpolation/Tags.hpp"
#include "ParallelAlgorithms/Interpolation/Targets/AngularOrdering.hpp"
#include "Utilities/Algorithm.hpp"
#include "Utilities/ErrorHandling/Assert.hpp"
#include "Utilities/PrettyType.hpp"
Expand Down Expand Up @@ -70,7 +70,7 @@ struct Sphere {
static constexpr Options::String help = {"Radius of the sphere(s)"};
};
struct AngularOrdering {
using type = intrp::AngularOrdering;
using type = ylm::AngularOrdering;
static constexpr Options::String help = {
"Chooses theta,phi ordering in 2d array"};
};
Expand All @@ -79,7 +79,7 @@ struct Sphere {
"An arbitrary number of spherical surface."};
Sphere(const size_t l_max_in, const std::array<double, 3> center_in,
const typename Radius::type& radius_in,
intrp::AngularOrdering angular_ordering_in,
ylm::AngularOrdering angular_ordering_in,
const Options::Context& context = {});

Sphere() = default;
Expand All @@ -90,7 +90,7 @@ struct Sphere {
size_t l_max{0};
std::array<double, 3> center{std::numeric_limits<double>::signaling_NaN()};
std::set<double> radii;
intrp::AngularOrdering angular_ordering;
ylm::AngularOrdering angular_ordering;
};

bool operator==(const Sphere& lhs, const Sphere& rhs);
Expand Down Expand Up @@ -180,7 +180,7 @@ struct Sphere : tt::ConformsTo<intrp::protocols::ComputeTargetPoints> {

// If the angular ordering is Strahlkorper then we don't have to do
// anything to the coords because they are already in the right order
if (sphere.angular_ordering == intrp::AngularOrdering::Cce) {
if (sphere.angular_ordering == ylm::AngularOrdering::Cce) {
const auto physical_extents =
strahlkorper.ylm_spherepack().physical_extents();
auto transposed_coords =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void test(const std::string& filename_prefix,
num_points_single_sphere);

// Options for Sphere
const intrp::AngularOrdering angular_ordering = intrp::AngularOrdering::Cce;
const ylm::AngularOrdering angular_ordering = ylm::AngularOrdering::Cce;
const std::array<double, 3> center = {{0.05, 0.06, 0.07}};
intrp::OptionHolders::Sphere sphere_opts(l_max, center, radii,
angular_ordering);
Expand All @@ -157,8 +157,8 @@ void test(const std::string& filename_prefix,
// Check the error
CHECK_THROWS_WITH(
([&box, &radii, &center, &filename_prefix]() {
const intrp::AngularOrdering local_angular_ordering =
intrp::AngularOrdering::Strahlkorper;
const ylm::AngularOrdering local_angular_ordering =
ylm::AngularOrdering::Strahlkorper;
intrp::OptionHolders::Sphere local_sphere_opts(l_max, center, radii,
local_angular_ordering);
Parallel::GlobalCache<metavars> local_cache{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void test_interpolate_on_element(
tuples::get<intrp::Tags::Sphere<target_tag>>(init_tuple) =
intrp::OptionHolders::Sphere{ell, std::array{x_center, 0.0, 0.0},
std::vector<double>{1.0, 2.5},
intrp::AngularOrdering::Cce};
ylm::AngularOrdering::Cce};
}

// Emplace target component.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void test_callback_function(const gsl::not_null<Generator*> gen) {
tmpl::list<::gr::Tags::SpacetimeMetric<DataVector, 3>,
gh::Tags::Phi<DataVector, 3>, gh::Tags::Pi<DataVector, 3>>;
using target = typename test_metavariables<LocalTimeStepping>::Target;
const intrp::AngularOrdering angular_ordering = intrp::AngularOrdering::Cce;
const ylm::AngularOrdering angular_ordering = ylm::AngularOrdering::Cce;
const double radius = 3.6;
const std::array<double, 3> center = {{0.05, 0.06, 0.07}};
// Options for Sphere
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
set(LIBRARY "Test_SphericalHarmonics")

set(LIBRARY_SOURCES
Test_AngularOrdering.cpp
Test_ChangeCenterOfStrahlkorper.cpp
Test_RealSphericalHarmonics.cpp
Test_Spherepack.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
#include <string>

#include "Framework/TestCreation.hpp"
#include "ParallelAlgorithms/Interpolation/Targets/AngularOrdering.hpp"
#include "NumericalAlgorithms/SphericalHarmonics/AngularOrdering.hpp"
#include "Utilities/GetOutput.hpp"

namespace intrp {
SPECTRE_TEST_CASE(
"Unit.NumericalAlgorithms.InterpolationTarget.AngularOrdering", "[Unit]") {
namespace ylm {
SPECTRE_TEST_CASE("Unit.NumericalAlgorithms.SphericalHarmonics.AngularOrdering",
"[Unit]") {
CHECK(get_output(AngularOrdering::Cce) == "Cce");
CHECK(get_output(AngularOrdering::Strahlkorper) == "Strahlkorper");
CHECK(TestHelpers::test_creation<AngularOrdering>("Cce") ==
AngularOrdering::Cce);
CHECK(TestHelpers::test_creation<AngularOrdering>("Strahlkorper") ==
AngularOrdering::Strahlkorper);
}
} // namespace intrp
} // namespace ylm
1 change: 0 additions & 1 deletion tests/Unit/ParallelAlgorithms/Interpolation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ set(LIBRARY "Test_ParallelInterpolation")

set(LIBRARY_SOURCES
Test_AddTemporalIdsToInterpolationTarget.cpp
Test_AngularOrdering.cpp
Test_CleanUpInterpolator.cpp
Test_ComputeDestVars.cpp
Test_ElementReceiveInterpPoints.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#include "Framework/TestCreation.hpp"
#include "Helpers/DataStructures/DataBox/TestHelpers.hpp"
#include "Helpers/ParallelAlgorithms/Interpolation/InterpolationTargetTestHelpers.hpp"
#include "NumericalAlgorithms/SphericalHarmonics/AngularOrdering.hpp"
#include "Parallel/Phase.hpp"
#include "ParallelAlgorithms/Interpolation/Protocols/InterpolationTargetTag.hpp"
#include "ParallelAlgorithms/Interpolation/Targets/AngularOrdering.hpp"
#include "ParallelAlgorithms/Interpolation/Targets/KerrHorizon.hpp"
#include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
#include "Time/Tags/TimeStepId.hpp"
Expand Down Expand Up @@ -57,7 +57,7 @@ struct KerrHorizonTargetTag

template <InterpTargetTestHelpers::ValidPoints ValidPoints>
void test_interpolation_target_kerr_horizon(
const intrp::AngularOrdering angular_ordering) {
const ylm::AngularOrdering angular_ordering) {
// Constants used in this test.
// We use l_max=18 to get enough points that the surface is
// represented to roundoff error; for smaller l_max we would need to
Expand Down Expand Up @@ -125,7 +125,7 @@ void test_interpolation_target_kerr_horizon(
const double two_pi_over_n_phi = 2.0 * M_PI / n_phi;
tnsr::I<DataVector, 3, Frame::Inertial> points(n_theta * n_phi);
size_t s = 0;
if (angular_ordering == intrp::AngularOrdering::Strahlkorper) {
if (angular_ordering == ylm::AngularOrdering::Strahlkorper) {
for (size_t i_phi = 0; i_phi < n_phi; ++i_phi) {
const double phi = two_pi_over_n_phi * i_phi;
for (size_t i_theta = 0; i_theta < n_theta; ++i_theta) {
Expand Down Expand Up @@ -166,14 +166,14 @@ SPECTRE_TEST_CASE("Unit.NumericalAlgorithms.InterpolationTarget.KerrHorizon",
"[Unit]") {
domain::creators::register_derived_with_charm();
test_interpolation_target_kerr_horizon<
InterpTargetTestHelpers::ValidPoints::All>(intrp::AngularOrdering::Cce);
InterpTargetTestHelpers::ValidPoints::All>(ylm::AngularOrdering::Cce);
test_interpolation_target_kerr_horizon<
InterpTargetTestHelpers::ValidPoints::All>(
intrp::AngularOrdering::Strahlkorper);
ylm::AngularOrdering::Strahlkorper);
test_interpolation_target_kerr_horizon<
InterpTargetTestHelpers::ValidPoints::Some>(
intrp::AngularOrdering::Strahlkorper);
ylm::AngularOrdering::Strahlkorper);
test_interpolation_target_kerr_horizon<
InterpTargetTestHelpers::ValidPoints::None>(
intrp::AngularOrdering::Strahlkorper);
ylm::AngularOrdering::Strahlkorper);
}
Loading

0 comments on commit 6d36d01

Please sign in to comment.