diff --git a/src/DataStructures/Tensor/EagerMath/CMakeLists.txt b/src/DataStructures/Tensor/EagerMath/CMakeLists.txt index 3dc2a3b78f83..ca02c99f10b2 100644 --- a/src/DataStructures/Tensor/EagerMath/CMakeLists.txt +++ b/src/DataStructures/Tensor/EagerMath/CMakeLists.txt @@ -4,6 +4,7 @@ spectre_target_sources( ${LIBRARY} PRIVATE + FrameTransform.cpp OrthonormalOneform.cpp RaiseOrLowerIndex.cpp Trace.cpp @@ -17,6 +18,7 @@ spectre_target_headers( Determinant.hpp DeterminantAndInverse.hpp DotProduct.hpp + FrameTransform.hpp Magnitude.hpp Norms.hpp OrthonormalOneform.hpp diff --git a/src/PointwiseFunctions/GeneralRelativity/Transform.cpp b/src/DataStructures/Tensor/EagerMath/FrameTransform.cpp similarity index 82% rename from src/PointwiseFunctions/GeneralRelativity/Transform.cpp rename to src/DataStructures/Tensor/EagerMath/FrameTransform.cpp index 392215ea9bfd..9d6d1bacd3ac 100644 --- a/src/PointwiseFunctions/GeneralRelativity/Transform.cpp +++ b/src/DataStructures/Tensor/EagerMath/FrameTransform.cpp @@ -1,7 +1,7 @@ // Distributed under the MIT License. // See LICENSE.txt for details. -#include "PointwiseFunctions/GeneralRelativity/Transform.hpp" +#include "DataStructures/Tensor/EagerMath/FrameTransform.hpp" #include @@ -275,38 +275,48 @@ auto to_different_frame( return dest; } -template +template void first_index_to_different_frame( - const gsl::not_null*> dest, - const Tensor, - index_list, - SpatialIndex, - SpatialIndex>>& src, - const Jacobian& jacobian) { - for (size_t i = 0; i < VolumeDim; ++i) { - for (size_t j = i; j < VolumeDim; ++j) { // symmetry - for (size_t k = 0; k < VolumeDim; ++k) { - dest->get(k, i, j) = jacobian.get(0, k) * src.get(0, i, j); - for (size_t p = 1; p < VolumeDim; ++p) { - dest->get(k, i, j) += jacobian.get(p, k) * src.get(p, i, j); - } - } + const gsl::not_null result, const InputTensor& input, + const InverseJacobian& + inv_jacobian) { + static_assert(InputTensor::rank() > 0, + "Cannot transform scalar to different frame"); + static_assert( + std::is_same_v, + TensorMetafunctions::remove_first_index>, + "The input and result tensors must be the same except for the first " + "index"); + using first_index = tmpl::front; + static_assert( + std::is_same_v>, + "This function is currently only tested for transforming an upper " + "spatial index but can be generalized."); + for (size_t storage_index = 0; storage_index < ResultTensor::size(); + ++storage_index) { + const auto result_index = ResultTensor::get_tensor_index(storage_index); + auto input_index = result_index; + input_index[0] = 0; + result->get(result_index) = + input.get(input_index) * inv_jacobian.get(result_index[0], 0); + for (size_t d = 1; d < Dim; ++d) { + input_index[0] = d; + result->get(result_index) += + input.get(input_index) * inv_jacobian.get(result_index[0], d); } } } -template -auto first_index_to_different_frame( - const Tensor, - index_list, - SpatialIndex, - SpatialIndex>>& src, - const Jacobian& jacobian) - -> tnsr::ijj { - auto dest = make_with_value>( - src, std::numeric_limits::signaling_NaN()); - first_index_to_different_frame(make_not_null(&dest), src, jacobian); - return dest; +template +ResultTensor first_index_to_different_frame( + const InputTensor& input, + const InverseJacobian& + inv_jacobian) { + ResultTensor result{}; + first_index_to_different_frame(make_not_null(&result), input, inv_jacobian); + return result; } } // namespace transform @@ -385,36 +395,32 @@ GENERATE_INSTANTIATIONS(INSTANTIATE, (1, 2, 3), (Frame::Inertial), #undef INSTANTIATE -#undef TENSOR -#undef DTYPE - -#define INSTANTIATE(_, data) \ - template void transform::first_index_to_different_frame( \ - const gsl::not_null*> \ - dest, \ - const Tensor< \ - DataVector, tmpl::integral_list, \ - index_list, \ - SpatialIndex, \ - SpatialIndex>>& \ - src, \ - const Jacobian& \ - jacobian); \ - template auto transform::first_index_to_different_frame( \ - const Tensor< \ - DataVector, tmpl::integral_list, \ - index_list, \ - SpatialIndex, \ - SpatialIndex>>& \ - src, \ - const Jacobian& \ - jacobian) \ - ->tnsr::ijj; -GENERATE_INSTANTIATIONS(INSTANTIATE, (1, 2, 3), - (Frame::BlockLogical, Frame::ElementLogical), - (Frame::Grid, Frame::Distorted)) +#define INSTANTIATE(_, data) \ + template void transform::first_index_to_different_frame( \ + const gsl::not_null>, \ + DIM(data), UpLo::Up, SRCFRAME(data)>* > result, \ + const tnsr::TENSOR(data) < DTYPE(data), DIM(data), \ + DESTFRAME(data) > &input, \ + const InverseJacobian& inv_jacobian); \ + template auto transform::first_index_to_different_frame( \ + const tnsr::TENSOR(data) < DTYPE(data), DIM(data), \ + DESTFRAME(data) > &input, \ + const InverseJacobian& inv_jacobian) \ + ->TensorMetafunctions::prepend_spatial_index< \ + TensorMetafunctions::remove_first_index< \ + tnsr::TENSOR(data) < DTYPE(data), DIM(data), DESTFRAME(data)>>, \ + DIM(data), UpLo::Up, SRCFRAME(data) > ; +GENERATE_INSTANTIATIONS(INSTANTIATE, (1, 2, 3), (Frame::ElementLogical), + (Frame::Inertial), (double, DataVector), (I, II, Ij)) #undef DIM #undef SRCFRAME #undef DESTFRAME +#undef TENSOR +#undef DTYPE #undef INSTANTIATE diff --git a/src/PointwiseFunctions/GeneralRelativity/Transform.hpp b/src/DataStructures/Tensor/EagerMath/FrameTransform.hpp similarity index 79% rename from src/PointwiseFunctions/GeneralRelativity/Transform.hpp rename to src/DataStructures/Tensor/EagerMath/FrameTransform.hpp index c46430b730f5..e641773c6fb5 100644 --- a/src/PointwiseFunctions/GeneralRelativity/Transform.hpp +++ b/src/DataStructures/Tensor/EagerMath/FrameTransform.hpp @@ -6,6 +6,7 @@ #include #include "DataStructures/DataBox/Tag.hpp" +#include "DataStructures/Tensor/Metafunctions.hpp" #include "DataStructures/Tensor/TypeAliases.hpp" #include "Utilities/Gsl.hpp" @@ -183,45 +184,40 @@ auto to_different_frame( * \ingroup GeneralRelativityGroup * Transforms only the first index to different frame. * - * Often used for derivatives: When representing derivatives as - * tensors, the first index is typically the derivative index. - * Numerical derivatives must be computed in the logical frame or - * sometimes the grid frame (independent of the frame of the tensor - * being differentiated), and then that derivative index must later - * be transformed into the same frame as the other indices of the - * tensor. + * ## Examples for transforming some tensors + * + * ### Flux vector to logical coordinates + * + * A common example is taking the divergence of a flux vector $F^i$, where the + * index $i$ is in inertial coordinates $x^i$ and the divergence is taken in + * logical coordinates $\xi^\hat{i}$. So to transform the flux vector to logical + * coordinates before taking the divergence we do this: * - * The formula for transforming \f$T_{i\bar{\jmath}\bar{k}}\f$ is * \f{align} - * T_{\bar{\imath}\bar{\jmath}\bar{k}} &= T_{i\bar{\jmath}\bar{k}} - * \frac{\partial x^i}{\partial x^{\bar{\imath}}}, + * F^\hat{i} &= F^i \frac{\partial x^\hat{i}}{\partial x^i} * \f} - * where \f$x^i\f$ are the source coordinates and - * \f$x^{\bar{\imath}}\f$ are the destination coordinates. * - * Note that `Jacobian` is the same type as - * `InverseJacobian` and represents - * \f$\partial x^i/\partial x^{\bar{\jmath}}\f$. + * Here, $\frac{\partial x^\hat{i}}{\partial x^i}$ is the inverse Jacobian (see + * definitions in TypeAliases.hpp). * - * In principle `first_index_to_different_frame` can be - * extended/generalized to other tensor types if needed. + * Currently, this function is tested for any tensor with a first upper spatial + * index. It can be extended/generalized to other tensor types if needed. */ -template +template void first_index_to_different_frame( - const gsl::not_null*> dest, - const Tensor, - index_list, - SpatialIndex, - SpatialIndex>>& src, - const Jacobian& jacobian); - -template -auto first_index_to_different_frame( - const Tensor, - index_list, - SpatialIndex, - SpatialIndex>>& src, - const Jacobian& jacobian) - -> tnsr::ijj; + gsl::not_null result, const InputTensor& input, + const InverseJacobian& + inv_jacobian); + +template , Dim, + UpLo::Up, SourceFrame>> +ResultTensor first_index_to_different_frame( + const InputTensor& input, + const InverseJacobian& + inv_jacobian); /// @} } // namespace transform diff --git a/src/DataStructures/Variables/FrameTransform.hpp b/src/DataStructures/Variables/FrameTransform.hpp new file mode 100644 index 000000000000..98243d6c318d --- /dev/null +++ b/src/DataStructures/Variables/FrameTransform.hpp @@ -0,0 +1,59 @@ +// Distributed under the MIT License. +// See LICENSE.txt for details. + +#pragma once + +#include + +#include "DataStructures/Tensor/EagerMath/FrameTransform.hpp" +#include "DataStructures/Tensor/Metafunctions.hpp" +#include "DataStructures/Tensor/TypeAliases.hpp" +#include "DataStructures/Variables.hpp" +#include "Utilities/Gsl.hpp" + +namespace transform { + +/// Tags to represent the result of frame-transforming Variables +namespace Tags { +/// The `Tag` with the first index transformed to a different frame +template +struct TransformedFirstIndex : db::SimpleTag { + using type = TensorMetafunctions::prepend_spatial_index< + TensorMetafunctions::remove_first_index, + tmpl::front::dim, UpLo::Up, + FirstIndexFrame>; +}; +} // namespace Tags + +/// @{ +/// Transforms the first index of all tensors in the Variables to a different +/// frame +/// +/// See single-Tensor overload for details. +template +void first_index_to_different_frame( + const gsl::not_null>*> result, + const Variables>& input, + const InverseJacobian& + inv_jacobian) { + EXPAND_PACK_LEFT_TO_RIGHT( + first_index_to_different_frame(make_not_null(&get(*result)), + get(input), inv_jacobian)); +} + +template ...>>> +ResultVars first_index_to_different_frame( + const Variables>& input, + const InverseJacobian& + inv_jacobian) { + ResultVars result{input.number_of_grid_points()}; + first_index_to_different_frame(make_not_null(&result), input, inv_jacobian); + return result; +} +/// @} + +} // namespace transform diff --git a/src/ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.tpp b/src/ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.tpp index 0073afaa02c0..6d30c091bf85 100644 --- a/src/ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.tpp +++ b/src/ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.tpp @@ -13,6 +13,7 @@ #include "DataStructures/Tags/TempTensor.hpp" #include "DataStructures/TempBuffer.hpp" #include "DataStructures/Tensor/EagerMath/DeterminantAndInverse.hpp" +#include "DataStructures/Tensor/EagerMath/FrameTransform.hpp" #include "DataStructures/Tensor/Tensor.hpp" #include "DataStructures/Tensor/TypeAliases.hpp" #include "DataStructures/Variables.hpp" @@ -28,7 +29,6 @@ #include "PointwiseFunctions/GeneralRelativity/SpacetimeNormalVector.hpp" #include "PointwiseFunctions/GeneralRelativity/SpatialMetric.hpp" #include "PointwiseFunctions/GeneralRelativity/Tags.hpp" -#include "PointwiseFunctions/GeneralRelativity/Transform.hpp" #include "Utilities/ContainerHelpers.hpp" #include "Utilities/Gsl.hpp" #include "Utilities/TMPL.hpp" diff --git a/src/ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.tpp b/src/ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.tpp index cd408b0e22c2..053787ef3b7c 100644 --- a/src/ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.tpp +++ b/src/ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.tpp @@ -13,6 +13,7 @@ #include "DataStructures/Tags/TempTensor.hpp" #include "DataStructures/TempBuffer.hpp" #include "DataStructures/Tensor/EagerMath/DeterminantAndInverse.hpp" +#include "DataStructures/Tensor/EagerMath/FrameTransform.hpp" #include "DataStructures/Tensor/Tensor.hpp" #include "DataStructures/Tensor/TypeAliases.hpp" #include "DataStructures/Variables.hpp" @@ -28,7 +29,6 @@ #include "PointwiseFunctions/GeneralRelativity/SpacetimeNormalVector.hpp" #include "PointwiseFunctions/GeneralRelativity/SpatialMetric.hpp" #include "PointwiseFunctions/GeneralRelativity/Tags.hpp" -#include "PointwiseFunctions/GeneralRelativity/Transform.hpp" #include "Utilities/ContainerHelpers.hpp" #include "Utilities/Gsl.hpp" #include "Utilities/TMPL.hpp" @@ -199,11 +199,6 @@ void ComputeHorizonVolumeQuantities::apply( using inertial_metric_tag = gr::Tags::SpatialMetric; using inertial_inv_metric_tag = gr::Tags::InverseSpatialMetric; using inertial_ex_curvature_tag = gr::Tags::ExtrinsicCurvature; - using logical_deriv_metric_tag = ::Tags::TempTensor< - 6, Tensor, - index_list, - SpatialIndex<3, UpLo::Lo, TargetFrame>, - SpatialIndex<3, UpLo::Lo, TargetFrame>>>>; using deriv_metric_tag = ::Tags::Tempijj<7, 3, TargetFrame, DataVector>; using inertial_spatial_ricci_tag = gr::Tags::SpatialRicci; @@ -213,7 +208,7 @@ void ComputeHorizonVolumeQuantities::apply( tmpl::list; + deriv_metric_tag>; using full_temp_tags_list = std::conditional_t< tmpl::list_contains_v>, @@ -236,7 +231,6 @@ void ComputeHorizonVolumeQuantities::apply( auto& lapse = get(buffer); auto& shift = get(buffer); auto& spacetime_normal_vector = get(buffer); - auto& logical_deriv_metric = get(buffer); auto& deriv_metric = get(buffer); // These may or may not be temporaries, depending on if they are asked for @@ -278,11 +272,8 @@ void ComputeHorizonVolumeQuantities::apply( metric); // Differentiate 3-metric. - logical_partial_derivative(make_not_null(&logical_deriv_metric), metric, - mesh); - transform::first_index_to_different_frame(make_not_null(&deriv_metric), - logical_deriv_metric, - invjac_logical_to_target); + partial_derivative(make_not_null(&deriv_metric), metric, mesh, + invjac_logical_to_target); gr::christoffel_second_kind(make_not_null(&spatial_christoffel_second_kind), deriv_metric, inv_metric); diff --git a/src/PointwiseFunctions/AnalyticData/GrMhd/PolarMagnetizedFmDisk.hpp b/src/PointwiseFunctions/AnalyticData/GrMhd/PolarMagnetizedFmDisk.hpp index 71bbb322e5d0..02cc9660c5af 100644 --- a/src/PointwiseFunctions/AnalyticData/GrMhd/PolarMagnetizedFmDisk.hpp +++ b/src/PointwiseFunctions/AnalyticData/GrMhd/PolarMagnetizedFmDisk.hpp @@ -11,6 +11,7 @@ #include #include "DataStructures/Tensor/EagerMath/Determinant.hpp" +#include "DataStructures/Tensor/EagerMath/FrameTransform.hpp" #include "DataStructures/Tensor/Tensor.hpp" #include "Options/Options.hpp" #include "PointwiseFunctions/AnalyticData/AnalyticData.hpp" @@ -18,7 +19,6 @@ #include "PointwiseFunctions/AnalyticData/GrMhd/MagnetizedFmDisk.hpp" #include "PointwiseFunctions/AnalyticData/GrMhd/SphericalTorus.hpp" #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/Solutions.hpp" -#include "PointwiseFunctions/GeneralRelativity/Transform.hpp" #include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp" #include "Utilities/Gsl.hpp" #include "Utilities/Serialization/CharmPupable.hpp" diff --git a/src/PointwiseFunctions/GeneralRelativity/CMakeLists.txt b/src/PointwiseFunctions/GeneralRelativity/CMakeLists.txt index 17541c4f2355..f889b878fd8b 100644 --- a/src/PointwiseFunctions/GeneralRelativity/CMakeLists.txt +++ b/src/PointwiseFunctions/GeneralRelativity/CMakeLists.txt @@ -27,7 +27,6 @@ spectre_target_sources( SpatialMetric.cpp TimeDerivativeOfSpacetimeMetric.cpp TimeDerivativeOfSpatialMetric.cpp - Transform.cpp WeylElectric.cpp WeylMagnetic.cpp WeylPropagating.cpp @@ -60,7 +59,6 @@ spectre_target_headers( TagsDeclarations.hpp TimeDerivativeOfSpacetimeMetric.hpp TimeDerivativeOfSpatialMetric.hpp - Transform.hpp WeylElectric.hpp WeylMagnetic.hpp WeylPropagating.hpp diff --git a/tests/Unit/DataStructures/Tensor/EagerMath/CMakeLists.txt b/tests/Unit/DataStructures/Tensor/EagerMath/CMakeLists.txt index 355082f8713f..7fb4c1ae5376 100644 --- a/tests/Unit/DataStructures/Tensor/EagerMath/CMakeLists.txt +++ b/tests/Unit/DataStructures/Tensor/EagerMath/CMakeLists.txt @@ -8,6 +8,7 @@ set(LIBRARY_SOURCES Test_Determinant.cpp Test_DeterminantAndInverse.cpp Test_DotProduct.cpp + Test_FrameTransform.cpp Test_Magnitude.cpp Test_Norms.cpp Test_OrthonormalOneform.cpp @@ -21,6 +22,7 @@ target_link_libraries( ${LIBRARY} PRIVATE DataStructures + DataStructuresHelpers DomainHelpers ErrorHandling GeneralRelativity diff --git a/tests/Unit/PointwiseFunctions/GeneralRelativity/Transform.py b/tests/Unit/DataStructures/Tensor/EagerMath/FrameTransform.py similarity index 90% rename from tests/Unit/PointwiseFunctions/GeneralRelativity/Transform.py rename to tests/Unit/DataStructures/Tensor/EagerMath/FrameTransform.py index 7414804279a8..ff048f9321f4 100644 --- a/tests/Unit/PointwiseFunctions/GeneralRelativity/Transform.py +++ b/tests/Unit/DataStructures/Tensor/EagerMath/FrameTransform.py @@ -45,8 +45,3 @@ def to_different_frame_II(src, jacobian): def to_different_frame_ijj(src, jacobian): # Jacobian here is d^x_src/d^x_dest return np.einsum("abe,ac,bd,ef", src, jacobian, jacobian, jacobian) - - -def first_index_to_different_frame(src, jacobian): - # Jacobian here is d^x_src/d^x_dest - return np.einsum("abc,ad->dbc", src, jacobian) diff --git a/tests/Unit/PointwiseFunctions/GeneralRelativity/Test_Transform.cpp b/tests/Unit/DataStructures/Tensor/EagerMath/Test_FrameTransform.cpp similarity index 54% rename from tests/Unit/PointwiseFunctions/GeneralRelativity/Test_Transform.cpp rename to tests/Unit/DataStructures/Tensor/EagerMath/Test_FrameTransform.cpp index dad00c49446e..429109aa4bf8 100644 --- a/tests/Unit/PointwiseFunctions/GeneralRelativity/Test_Transform.cpp +++ b/tests/Unit/DataStructures/Tensor/EagerMath/Test_FrameTransform.cpp @@ -7,22 +7,31 @@ #include "DataStructures/DataVector.hpp" #include "DataStructures/Tensor/EagerMath/DeterminantAndInverse.hpp" +#include "DataStructures/Tensor/EagerMath/FrameTransform.hpp" #include "DataStructures/Tensor/Tensor.hpp" +#include "DataStructures/Variables/FrameTransform.hpp" #include "Framework/CheckWithRandomValues.hpp" #include "Framework/SetupLocalPythonEnvironment.hpp" #include "Helpers/DataStructures/MakeWithRandomValues.hpp" -#include "PointwiseFunctions/GeneralRelativity/Transform.hpp" +namespace transform { namespace { +struct Var1 : db::SimpleTag { + using type = tnsr::I; +}; +struct Var2 : db::SimpleTag { + using type = tnsr::Ij; +}; + template DestTensorType tensor_transformed_by_python( const SrcTensorType& src_tensor, const DestTensorType& /*dest_tensor*/, const ::Jacobian& jacobian, const std::string& suffix) { - return pypp::call("Transform", "to_different_frame" + suffix, - src_tensor, jacobian); + return pypp::call( + "FrameTransform", "to_different_frame" + suffix, src_tensor, jacobian); } template @@ -92,26 +101,107 @@ void test_transform_to_different_frame(const DataType& used_for_size) { CHECK_ITERABLE_APPROX(dest_scalar, src_scalar); } -template -void test_transform_first_index_to_different_frame( - const DataType& used_for_size) { - tnsr::ijj (*f)( - const Tensor, - index_list, - SpatialIndex, - SpatialIndex>>&, - const ::Jacobian&) = - transform::first_index_to_different_frame; - pypp::check_with_random_values<1>(f, "Transform", - "first_index_to_different_frame", - {{{-10., 10.}}}, used_for_size); +void test_transform_first_index_to_different_frame() { + INFO("Transform first index"); + { + INFO("1D"); + InverseJacobian + inv_jacobian{}; + get<0, 0>(inv_jacobian) = 2.0; + { + INFO("Vector"); + const tnsr::I input{1.0}; + const auto result = first_index_to_different_frame(input, inv_jacobian); + static_assert(std::is_same_v, + tnsr::I>); + CHECK(get<0>(result) == 2.0); + } + { + INFO("Rank 2 tensor"); + tnsr::Ij input{}; + get<0, 0>(input) = 1.0; + const auto result = first_index_to_different_frame(input, inv_jacobian); + static_assert( + std::is_same_v< + std::decay_t, + Tensor< + double, Symmetry<1, 2>, + index_list, + SpatialIndex<1, UpLo::Lo, Frame::Inertial>>>>); + CHECK(get<0, 0>(result) == 2.0); + } + } + { + INFO("2D"); + InverseJacobian + inv_jacobian{}; + get<0, 0>(inv_jacobian) = 2.0; + get<1, 1>(inv_jacobian) = 3.0; + get<0, 1>(inv_jacobian) = 0.5; + get<1, 0>(inv_jacobian) = 1.5; + { + INFO("Vector"); + const tnsr::I input{{1.0, 2.0}}; + const auto result = first_index_to_different_frame(input, inv_jacobian); + static_assert(std::is_same_v, + tnsr::I>); + CHECK(get<0>(result) == 3.); + CHECK(get<1>(result) == 7.5); + } + { + INFO("Rank 2 tensor"); + tnsr::Ij input{}; + get<0, 0>(input) = 1.0; + get<1, 0>(input) = 2.0; + get<0, 1>(input) = 3.0; + get<1, 1>(input) = 4.0; + const auto result = first_index_to_different_frame(input, inv_jacobian); + static_assert( + std::is_same_v< + std::decay_t, + Tensor< + double, Symmetry<1, 2>, + index_list, + SpatialIndex<2, UpLo::Lo, Frame::Inertial>>>>); + CHECK(get<0, 0>(result) == 3.); + CHECK(get<1, 0>(result) == 7.5); + CHECK(get<0, 1>(result) == 8.); + CHECK(get<1, 1>(result) == 16.5); + } + } + { + INFO("Variables"); + const size_t num_points = 3; + InverseJacobian + inv_jacobian{num_points}; + get<0, 0>(inv_jacobian) = 2.0; + get<1, 1>(inv_jacobian) = 3.0; + get<0, 1>(inv_jacobian) = 0.5; + get<1, 0>(inv_jacobian) = 1.5; + Variables> input{num_points}; + std::iota(get(input).begin(), get(input).end(), 1.0); + std::iota(get(input).begin(), get(input).end(), 1.0); + CAPTURE(input); + const auto result = first_index_to_different_frame(input, inv_jacobian); + const auto& var1 = + get>(result); + const auto& var2 = + get>(result); + CHECK(get<0>(var1) == 3.); + CHECK(get<1>(var1) == 7.5); + CHECK(get<0, 0>(var2) == 3.); + CHECK(get<1, 0>(var2) == 7.5); + CHECK(get<0, 1>(var2) == 8.); + CHECK(get<1, 1>(var2) == 16.5); + } } + } // namespace -SPECTRE_TEST_CASE("Unit.PointwiseFunctions.GeneralRelativity.Transform", - "[PointwiseFunctions][Unit]") { +SPECTRE_TEST_CASE("Unit.Tensor.EagerMath.FrameTransform", + "[DataStructures][Unit]") { pypp::SetupLocalPythonEnvironment local_python_env( - "PointwiseFunctions/GeneralRelativity/"); + "DataStructures/Tensor/EagerMath/"); const DataVector dv(5); test_transform_to_different_frame<1, Frame::Grid, Frame::Inertial>(double{}); test_transform_to_different_frame<2, Frame::Grid, Frame::Inertial>(double{}); @@ -128,16 +218,7 @@ SPECTRE_TEST_CASE("Unit.PointwiseFunctions.GeneralRelativity.Transform", test_transform_to_different_frame<1, Frame::Inertial, Frame::Distorted>(dv); test_transform_to_different_frame<2, Frame::Inertial, Frame::Distorted>(dv); test_transform_to_different_frame<3, Frame::Inertial, Frame::Distorted>(dv); - test_transform_first_index_to_different_frame<1, Frame::ElementLogical, - Frame::Grid>(dv); - test_transform_first_index_to_different_frame<2, Frame::ElementLogical, - Frame::Grid>(dv); - test_transform_first_index_to_different_frame<3, Frame::ElementLogical, - Frame::Grid>(dv); - test_transform_first_index_to_different_frame<1, Frame::ElementLogical, - Frame::Distorted>(dv); - test_transform_first_index_to_different_frame<2, Frame::ElementLogical, - Frame::Distorted>(dv); - test_transform_first_index_to_different_frame<3, Frame::ElementLogical, - Frame::Distorted>(dv); + test_transform_first_index_to_different_frame(); } + +} // namespace transform diff --git a/tests/Unit/PointwiseFunctions/GeneralRelativity/CMakeLists.txt b/tests/Unit/PointwiseFunctions/GeneralRelativity/CMakeLists.txt index 481a41f318d2..496eed9bd4ad 100644 --- a/tests/Unit/PointwiseFunctions/GeneralRelativity/CMakeLists.txt +++ b/tests/Unit/PointwiseFunctions/GeneralRelativity/CMakeLists.txt @@ -13,7 +13,6 @@ set(LIBRARY_SOURCES Test_Psi4.cpp Test_Ricci.cpp Test_Tags.cpp - Test_Transform.cpp Test_WeylElectric.cpp Test_WeylMagnetic.cpp Test_WeylPropagating.cpp