diff --git a/src/Utilities/System/CMakeLists.txt b/src/Utilities/System/CMakeLists.txt index 6d441dbcdd1b..3fb50e6cfc44 100644 --- a/src/Utilities/System/CMakeLists.txt +++ b/src/Utilities/System/CMakeLists.txt @@ -9,6 +9,7 @@ spectre_target_sources( ${LIBRARY} PRIVATE Abort.cpp + Exit.cpp ParallelInfo.cpp Prefetch.cpp ) diff --git a/src/Utilities/System/Exit.cpp b/src/Utilities/System/Exit.cpp new file mode 100644 index 000000000000..6834edbf1042 --- /dev/null +++ b/src/Utilities/System/Exit.cpp @@ -0,0 +1,18 @@ +// Distributed under the MIT License. +// See LICENSE.txt for details. + +#include "Utilities/System/Exit.hpp" + +#include +#include + +namespace sys { + +[[noreturn]] void exit(const int exit_code) { + CkExit(exit_code); + // the following call is never reached, but suppresses the warning that + // a 'noreturn' function does return + std::terminate(); // LCOV_EXCL_LINE +} + +} // namespace sys diff --git a/src/Utilities/System/Exit.hpp b/src/Utilities/System/Exit.hpp index a83d858556f2..fc28a5632934 100644 --- a/src/Utilities/System/Exit.hpp +++ b/src/Utilities/System/Exit.hpp @@ -3,19 +3,11 @@ #pragma once -#include -#include - namespace sys { /// \ingroup UtilitiesGroup /// \brief Exit the program normally. /// This should only be called once over all processors. -[[noreturn]] inline void exit(const int exit_code = 0) { - CkExit(exit_code); - // the following call is never reached, but suppresses the warning that - // a 'noreturn' function does return - std::terminate(); // LCOV_EXCL_LINE -} +[[noreturn]] void exit(int exit_code = 0); } // namespace sys diff --git a/src/Utilities/System/ParallelInfo.cpp b/src/Utilities/System/ParallelInfo.cpp index 0fb7445e41e2..8ec0d391ba18 100644 --- a/src/Utilities/System/ParallelInfo.cpp +++ b/src/Utilities/System/ParallelInfo.cpp @@ -1,12 +1,40 @@ // Distributed under the MIT License. // See LICENSE.txt for details. +#include #include #include #include "Utilities/System/ParallelInfo.hpp" namespace sys { +int number_of_procs() { return CkNumPes(); } + +int my_proc() { return CkMyPe(); } + +int number_of_nodes() { return CkNumNodes(); } + +int my_node() { return CkMyNode(); } + +int procs_on_node([[maybe_unused]] const int node_index) { + return CkNodeSize(node_index); +} + +int my_local_rank() { return CkMyRank(); } + +int first_proc_on_node([[maybe_unused]] const int node_index) { + return CkNodeFirst(node_index); +} + +int node_of([[maybe_unused]] const int proc_index) { + return CkNodeOf(proc_index); +} + +int local_rank_of([[maybe_unused]] const int proc_index) { + return CkRankOf(proc_index); +} + +double wall_time() { return CkWallTimer(); } std::string pretty_wall_time(const double total_seconds) { // Subseconds don't really matter so just ignore them. This gives nice round diff --git a/src/Utilities/System/ParallelInfo.hpp b/src/Utilities/System/ParallelInfo.hpp index eb3be6a837af..9fdc4bb4269b 100644 --- a/src/Utilities/System/ParallelInfo.hpp +++ b/src/Utilities/System/ParallelInfo.hpp @@ -9,7 +9,6 @@ #pragma once -#include #include namespace sys { @@ -17,82 +16,62 @@ namespace sys { * \ingroup UtilitiesGroup * \brief Number of processing elements. */ -inline int number_of_procs() { return CkNumPes(); } +int number_of_procs(); /*! * \ingroup UtilitiesGroup * \brief %Index of my processing element. */ -inline int my_proc() { return CkMyPe(); } +int my_proc(); /*! * \ingroup UtilitiesGroup * \brief Number of nodes. */ -inline int number_of_nodes() { return CkNumNodes(); } +int number_of_nodes(); /*! * \ingroup UtilitiesGroup * \brief %Index of my node. */ -inline int my_node() { return CkMyNode(); } +int my_node(); /*! * \ingroup UtilitiesGroup * \brief Number of processing elements on the given node. */ -inline int procs_on_node(const int node_index) { - // When using the verbs-linux-x86_64 non-SMP build of Charm++ these - // functions have unused-parameter warnings. This is remedied by - // casting the integer to a void which results in no extra assembly - // code being generated. We use this instead of pragmas because we - // would require one pragma for GCC and one for clang, which would - // result in code duplication. Commenting out the variable - // nodeIndex gives compilation failures on most Charm++ builds since - // they actually use the variable. Charm++ plz... - static_cast(node_index); - return CkNodeSize(node_index); -} +int procs_on_node(int node_index); /*! * \ingroup UtilitiesGroup * \brief The local index of my processing element on my node. * This is in the interval 0, ..., procs_on_node(my_node()) - 1. */ -inline int my_local_rank() { return CkMyRank(); } +int my_local_rank(); /*! * \ingroup UtilitiesGroup * \brief %Index of first processing element on the given node. */ -inline int first_proc_on_node(const int node_index) { - static_cast(node_index); - return CkNodeFirst(node_index); -} +int first_proc_on_node(int node_index); /*! * \ingroup UtilitiesGroup * \brief %Index of the node for the given processing element. */ -inline int node_of(const int proc_index) { - static_cast(proc_index); - return CkNodeOf(proc_index); -} +int node_of(int proc_index); /*! * \ingroup UtilitiesGroup * \brief The local index for the given processing element on its node. */ -inline int local_rank_of(const int proc_index) { - static_cast(proc_index); - return CkRankOf(proc_index); -} +int local_rank_of(int proc_index); /*! * \ingroup UtilitiesGroup * \brief The elapsed wall time in seconds. */ -inline double wall_time() { return CkWallTimer(); } +double wall_time(); /// @{ /// \ingroup UtilitiesGroup diff --git a/tests/Unit/DataStructures/Test_ApplyMatrices.cpp b/tests/Unit/DataStructures/Test_ApplyMatrices.cpp index 7c607722a8ee..2dac940c6979 100644 --- a/tests/Unit/DataStructures/Test_ApplyMatrices.cpp +++ b/tests/Unit/DataStructures/Test_ApplyMatrices.cpp @@ -117,7 +117,7 @@ struct CheckApply { // factor of 6 or so. Approx custom_approx = Approx::custom().epsilon(1.e-13).scale(1.0); for (const auto p : result - expected) { - CHECK_COMPLEX_CUSTOM_APPROX(p, 0.0, custom_approx); + CHECK_ITERABLE_CUSTOM_APPROX(p, 0.0, custom_approx); } const auto ref_matrices = make_array, Dim>(matrices); @@ -126,7 +126,7 @@ struct CheckApply { const auto vector_result = apply_matrices( matrices, get(get(source_data)), source_mesh.extents()); for (const auto p : vector_result - get(get(expected))) { - CHECK_COMPLEX_APPROX(p, 0.0); + CHECK_ITERABLE_APPROX(p, 0.0); } CHECK(apply_matrices(ref_matrices, get(get(source_data)), source_mesh.extents()) == vector_result); diff --git a/tests/Unit/Domain/CoordinateMaps/TimeDependent/Test_RotationMatrixHelpers.cpp b/tests/Unit/Domain/CoordinateMaps/TimeDependent/Test_RotationMatrixHelpers.cpp index d120807b5847..a52f783e948d 100644 --- a/tests/Unit/Domain/CoordinateMaps/TimeDependent/Test_RotationMatrixHelpers.cpp +++ b/tests/Unit/Domain/CoordinateMaps/TimeDependent/Test_RotationMatrixHelpers.cpp @@ -31,12 +31,13 @@ void check_rotation_matrix_helpers_3d( Approx custom_approx = Approx::custom().epsilon(5e-12).scale(1.0); { INFO("Check rotation matrix"); - CHECK_MATRIX_CUSTOM_APPROX(rot_matrix, expected_rot_matrix, custom_approx); + CHECK_ITERABLE_CUSTOM_APPROX(rot_matrix, expected_rot_matrix, + custom_approx); } { INFO("Check rotation matrix deriv"); - CHECK_MATRIX_CUSTOM_APPROX(rot_matrix_deriv, expected_rot_matrix_deriv, - custom_approx); + CHECK_ITERABLE_CUSTOM_APPROX(rot_matrix_deriv, expected_rot_matrix_deriv, + custom_approx); } } @@ -57,11 +58,11 @@ void check_rotation_matrix_helpers_2d(const double init_omega, { INFO("Check rotation matrix"); - CHECK_MATRIX_APPROX(rot_matrix, expected_rot_matrix); + CHECK_ITERABLE_APPROX(rot_matrix, expected_rot_matrix); } { INFO("Check rotation matrix deriv"); - CHECK_MATRIX_APPROX(rot_matrix_deriv, expected_rot_matrix_deriv); + CHECK_ITERABLE_APPROX(rot_matrix_deriv, expected_rot_matrix_deriv); } } diff --git a/tests/Unit/Domain/Creators/Test_ExpandOverBlocks.cpp b/tests/Unit/Domain/Creators/Test_ExpandOverBlocks.cpp index 323b335f64f5..5e1866fcd51e 100644 --- a/tests/Unit/Domain/Creators/Test_ExpandOverBlocks.cpp +++ b/tests/Unit/Domain/Creators/Test_ExpandOverBlocks.cpp @@ -40,7 +40,7 @@ SPECTRE_TEST_CASE("Unit.Domain.ExpandOverBlocks", "[Domain][Unit]") { std::vector>{{2, 3, 4}, {3, 4, 5}, {4, 5, 6}}, 3, {{2, 3, 4}, {3, 4, 5}, {4, 5, 6}}); CHECK_THROWS_WITH( - SINGLE_ARG(ExpandOverBlocks{3}( + (ExpandOverBlocks{3}( std::vector>{{2}, {3}})), Catch::Matchers::ContainsSubstring( "You supplied 2 values, but the domain creator has 3 blocks.")); diff --git a/tests/Unit/Evolution/DgSubcell/Test_SliceData.cpp b/tests/Unit/Evolution/DgSubcell/Test_SliceData.cpp index f510fe4a9498..ffb904235d26 100644 --- a/tests/Unit/Evolution/DgSubcell/Test_SliceData.cpp +++ b/tests/Unit/Evolution/DgSubcell/Test_SliceData.cpp @@ -4,6 +4,7 @@ #include "Framework/TestingFramework.hpp" #include +#include #include #include #include @@ -115,7 +116,7 @@ void test_slice_data( disable_floating_point_exceptions(); for (const auto& [_, data_in_direction] : sliced_data) { for (const double& at_point : data_in_direction) { - CHECK(isnan(at_point)); + CHECK(std::isnan(at_point)); } } enable_floating_point_exceptions(); diff --git a/tests/Unit/Evolution/DgSubcell/Test_SliceTensor.cpp b/tests/Unit/Evolution/DgSubcell/Test_SliceTensor.cpp index e4943ee8f744..6aeeb0db6a7d 100644 --- a/tests/Unit/Evolution/DgSubcell/Test_SliceTensor.cpp +++ b/tests/Unit/Evolution/DgSubcell/Test_SliceTensor.cpp @@ -3,6 +3,7 @@ #include "Framework/TestingFramework.hpp" +#include #include #include @@ -77,7 +78,7 @@ void test() { CHECK(get(sliced_scalar).size() == get(expected_sliced_scalar).size()); for (const double value_at_point : get(sliced_scalar)) { - CHECK(isnan(value_at_point)); + CHECK(std::isnan(value_at_point)); } enable_floating_point_exceptions(); #endif diff --git a/tests/Unit/Evolution/DgSubcell/Test_SliceVariable.cpp b/tests/Unit/Evolution/DgSubcell/Test_SliceVariable.cpp index b1d2f53dbc9b..d63ffbc9495f 100644 --- a/tests/Unit/Evolution/DgSubcell/Test_SliceVariable.cpp +++ b/tests/Unit/Evolution/DgSubcell/Test_SliceVariable.cpp @@ -3,6 +3,7 @@ #include "Framework/TestingFramework.hpp" +#include #include #include @@ -56,7 +57,7 @@ void test_slice( disable_floating_point_exceptions(); CHECK(sliced_vars.size() == expected_sliced_vars.size()); for (size_t i = 0; i < sliced_vars.size(); ++i) { - CHECK(isnan( + CHECK(std::isnan( *std::next(sliced_vars.data(), static_cast(i)))); } CHECK(sliced_vars != expected_sliced_vars); diff --git a/tests/Unit/Evolution/Systems/Cce/AnalyticSolutions/Test_LinearizedBondiSachs.cpp b/tests/Unit/Evolution/Systems/Cce/AnalyticSolutions/Test_LinearizedBondiSachs.cpp index ab2b45a8c56f..b53b1b16f193 100644 --- a/tests/Unit/Evolution/Systems/Cce/AnalyticSolutions/Test_LinearizedBondiSachs.cpp +++ b/tests/Unit/Evolution/Systems/Cce/AnalyticSolutions/Test_LinearizedBondiSachs.cpp @@ -35,16 +35,16 @@ void check_22_and_33_modes( const std::complex& expected_22_mode, const std::complex& expected_33_mode, const size_t l_max, Approx bondi_approx) { - CHECK_COMPLEX_CUSTOM_APPROX( + CHECK_ITERABLE_CUSTOM_APPROX( goldberg_modes.data()[Spectral::Swsh::goldberg_mode_index(l_max, 2, 2)], expected_22_mode, bondi_approx); - CHECK_COMPLEX_CUSTOM_APPROX( + CHECK_ITERABLE_CUSTOM_APPROX( goldberg_modes.data()[Spectral::Swsh::goldberg_mode_index(l_max, 2, -2)], expected_22_mode, bondi_approx); - CHECK_COMPLEX_CUSTOM_APPROX( + CHECK_ITERABLE_CUSTOM_APPROX( goldberg_modes.data()[Spectral::Swsh::goldberg_mode_index(l_max, 3, 3)], expected_33_mode, bondi_approx); - CHECK_COMPLEX_CUSTOM_APPROX( + CHECK_ITERABLE_CUSTOM_APPROX( goldberg_modes.data()[Spectral::Swsh::goldberg_mode_index(l_max, 3, -3)], -expected_33_mode, bondi_approx); } diff --git a/tests/Unit/Framework/TestingFramework.hpp b/tests/Unit/Framework/TestingFramework.hpp index e1b19343ce90..ff33ad4396cd 100644 --- a/tests/Unit/Framework/TestingFramework.hpp +++ b/tests/Unit/Framework/TestingFramework.hpp @@ -11,20 +11,17 @@ #include #include #include -#include +#include #include -#include #include -#include #include #include +#include #include #include "Utilities/ErrorHandling/Error.hpp" #include "Utilities/Requires.hpp" #include "Utilities/StlStreamDeclarations.hpp" -#include "Utilities/System/Abort.hpp" -#include "Utilities/System/Exit.hpp" #include "Utilities/TypeTraits/IsA.hpp" #include "Utilities/TypeTraits/IsIterable.hpp" #include "Utilities/TypeTraits/IsMaplike.hpp" @@ -84,31 +81,6 @@ static Approx approx = // NOLINT .epsilon(std::numeric_limits::epsilon() * 100) // NOLINT .scale(1.0); // NOLINT -/*! - * \ingroup TestingFrameworkGroup - * \brief A wrapper around Catch's CHECK macro that checks approximate - * equality of the two entries in a std::complex. For efficiency, no function - * forwarding is performed, just a pair of `CHECK`s inline - */ -#define CHECK_COMPLEX_APPROX(a, b) \ - do { \ - INFO(__FILE__ ":" + std::to_string(__LINE__) + ": " #a " == " #b); \ - CHECK(approx(real(a)) == real(b)); \ - CHECK(approx(imag(a)) == imag(b)); \ - } while (false) - -/*! - * \ingroup TestingFrameworkGroup - * \brief Same as `CHECK_COMPLEX_APPROX` with user-defined Approx. - * The third argument should be of type `Approx`. - */ -#define CHECK_COMPLEX_CUSTOM_APPROX(a, b, appx) \ - do { \ - INFO(__FILE__ ":" + std::to_string(__LINE__) + ": " #a " == " #b); \ - CHECK(appx(real(a)) == real(b)); \ - CHECK(appx(imag(a)) == imag(b)); \ - } while (false) - /*! * \ingroup TestingFrameworkGroup * \brief A wrapper around Catch's CHECK macro that checks approximate @@ -228,32 +200,16 @@ struct check_iterable_approx< } }; -#define CHECK_MATRIX_APPROX(a, b) \ - do { \ - INFO(__FILE__ ":" + std::to_string(__LINE__) + ": " #a " == " #b); \ - check_matrix_approx, std::decay_t>>::apply(a, b); \ - } while (false) - -#define CHECK_MATRIX_CUSTOM_APPROX(a, b, appx) \ - do { \ - INFO(__FILE__ ":" + std::to_string(__LINE__) + ": " #a " == " #b); \ - check_matrix_approx, std::decay_t>>::apply(a, b, \ - appx); \ - } while (false) - +// This implementation is for a column-major matrix. It does not trivially +// generalize to a row-major matrix because the iterator +// `blaze::DynamicMatrix::cbegin(i)` traverses either a row or a +// column, and takes its index as argument. template -struct check_matrix_approx { +struct check_iterable_approx and + blaze::IsDenseMatrix_v>> { // clang-tidy: non-const reference static void apply(const M& a, const M& b, Approx& appx = approx) { // NOLINT - // This implementation is for a column-major matrix. It does not trivially - // generalize to a row-major matrix because the iterator - // `blaze::DynamicMatrix::cbegin(i)` traverses either a row or a - // column, and takes its index as argument. - static_assert(blaze::IsColumnMajorMatrix_v and - blaze::IsDenseMatrix_v); CHECK(a.columns() == b.columns()); for (size_t j = 0; j < a.columns(); j++) { CAPTURE(a); @@ -285,12 +241,6 @@ struct check_matrix_approx { }; /// \endcond -/// \cond HIDDEN_SYMBOLS -[[noreturn]] inline void spectre_testing_signal_handler(int /*signal*/) { - sys::exit(); -} -/// \endcond - /*! * \ingroup TestingFrameworkGroup * \brief Mark a test as checking the output with a regular expression diff --git a/tests/Unit/Framework/Tests/Test_TestingFramework.cpp b/tests/Unit/Framework/Tests/Test_TestingFramework.cpp index 8eccbba1b88d..5798c0f5fe74 100644 --- a/tests/Unit/Framework/Tests/Test_TestingFramework.cpp +++ b/tests/Unit/Framework/Tests/Test_TestingFramework.cpp @@ -5,6 +5,7 @@ #include +#include "DataStructures/DataVector.hpp" #include "Utilities/System/Abort.hpp" SPECTRE_TEST_CASE("Unit.TestingFramework.Approx", "[Unit]") { @@ -32,6 +33,23 @@ SPECTRE_TEST_CASE("Unit.TestingFramework.Approx", "[Unit]") { CHECK(1.0 == my_approx(1.0 + 5e-13)); CHECK(1.0 != my_approx(1.0 + 5e-12)); // [approx_new_custom] + + Approx custom_approx = Approx::custom().epsilon(5.e-12).scale(1.0); + + CHECK_ITERABLE_APPROX(1.0, 1.0 + 1.e-15); + CHECK_ITERABLE_CUSTOM_APPROX(1.0, 1.0 + 1.e-13, custom_approx); + + const std::complex c0{1.0, -1.0}; + const std::complex c1{1.0 + 1.e-15, -1.0 + 1.e-15}; + const std::complex c2{1.0 + 1.e-13, -1.0 + 1.e-13}; + CHECK_ITERABLE_APPROX(c0, c1); + CHECK_ITERABLE_CUSTOM_APPROX(c0, c2, custom_approx); + + DataVector dv0{1.0, 1.0, 1.0}; + DataVector dv1{1.0 + 1.e-15, 1.0 - 1.e-15, 1.0}; + DataVector dv2{1.0 + 1.e-15, 1.0 - 1.e-15, 1.0 - 1.e-13}; + CHECK_ITERABLE_APPROX(dv0, dv1); + CHECK_ITERABLE_CUSTOM_APPROX(dv0, dv2, custom_approx); } // [[OutputRegex, I failed]] diff --git a/tests/Unit/NumericalAlgorithms/Interpolation/Test_SpanInterpolators.cpp b/tests/Unit/NumericalAlgorithms/Interpolation/Test_SpanInterpolators.cpp index dec0b1454633..891691e26dfd 100644 --- a/tests/Unit/NumericalAlgorithms/Interpolation/Test_SpanInterpolators.cpp +++ b/tests/Unit/NumericalAlgorithms/Interpolation/Test_SpanInterpolators.cpp @@ -46,7 +46,7 @@ void test_linear_interpolator(const gsl::not_null gen) { linear_interpolator_complex_values.data(), linear_interpolator_complex_values.size()}, target_point); - CHECK_COMPLEX_APPROX( + CHECK_ITERABLE_APPROX( complex_linear_interpolation, target_point * linear_interpolator_complex_values[1] + (1.0 - target_point) * linear_interpolator_complex_values[0]); @@ -77,9 +77,9 @@ void test_interpolator_approximate_fidelity( interpolator_values.data(), interpolator_points.size()}, target_time); - CHECK_COMPLEX_CUSTOM_APPROX(interpolator_result, - amplitude * cos(frequency * target_time), - interpolator_approx); + CHECK_ITERABLE_CUSTOM_APPROX(interpolator_result, + amplitude * cos(frequency * target_time), + interpolator_approx); } SPECTRE_TEST_CASE("Unit.NumericalAlgorithms.Interpolation.SpanInterpolators", diff --git a/tests/Unit/NumericalAlgorithms/LinearOperators/Test_CoefficientTransforms.cpp b/tests/Unit/NumericalAlgorithms/LinearOperators/Test_CoefficientTransforms.cpp index f02ce121eeda..21be1935cb64 100644 --- a/tests/Unit/NumericalAlgorithms/LinearOperators/Test_CoefficientTransforms.cpp +++ b/tests/Unit/NumericalAlgorithms/LinearOperators/Test_CoefficientTransforms.cpp @@ -80,10 +80,10 @@ void check_transforms( for (IndexIterator index_it(mesh.extents()); index_it; ++index_it) { CAPTURE(*index_it); if (alg::found(coeffs_to_include, index_it->indices())) { - CHECK_COMPLEX_APPROX(u_modal[index_it.collapsed_index()], basis_factor); + CHECK_ITERABLE_APPROX(u_modal[index_it.collapsed_index()], basis_factor); } else { - CHECK_COMPLEX_APPROX(u_modal[index_it.collapsed_index()], - typename ModalVectorType::ElementType{0.0}); + CHECK_ITERABLE_APPROX(u_modal[index_it.collapsed_index()], + typename ModalVectorType::ElementType{0.0}); } } diff --git a/tests/Unit/NumericalAlgorithms/LinearSolver/Test_BuildMatrix.cpp b/tests/Unit/NumericalAlgorithms/LinearSolver/Test_BuildMatrix.cpp index 15ddbcf6b78f..a4c5a9050fef 100644 --- a/tests/Unit/NumericalAlgorithms/LinearSolver/Test_BuildMatrix.cpp +++ b/tests/Unit/NumericalAlgorithms/LinearSolver/Test_BuildMatrix.cpp @@ -49,7 +49,7 @@ SPECTRE_TEST_CASE("Unit.LinearSolver.Serial.BuildMatrix", build_matrix(make_not_null(&matrix_representation), make_not_null(&operand_buffer), make_not_null(&result_buffer), linear_operator); - CHECK_MATRIX_APPROX(matrix_representation, matrix); + CHECK_ITERABLE_APPROX(matrix_representation, matrix); CHECK(linear_operator.invocations == 2); } { @@ -112,7 +112,7 @@ SPECTRE_TEST_CASE("Unit.LinearSolver.Serial.BuildMatrix", build_matrix(make_not_null(&matrix_representation), make_not_null(&operand_buffer), make_not_null(&result_buffer), linear_operator); - CHECK_MATRIX_APPROX(matrix_representation, expected_matrix); + CHECK_ITERABLE_APPROX(matrix_representation, expected_matrix); } } diff --git a/tests/Unit/NumericalAlgorithms/LinearSolver/Test_ExplicitInverse.cpp b/tests/Unit/NumericalAlgorithms/LinearSolver/Test_ExplicitInverse.cpp index f85a18ec19eb..84300a22d2c3 100644 --- a/tests/Unit/NumericalAlgorithms/LinearSolver/Test_ExplicitInverse.cpp +++ b/tests/Unit/NumericalAlgorithms/LinearSolver/Test_ExplicitInverse.cpp @@ -46,7 +46,7 @@ SPECTRE_TEST_CASE("Unit.LinearSolver.Serial.ExplicitInverse", const auto has_converged = solver.solve(make_not_null(&solution), linear_operator, source); REQUIRE(has_converged); - CHECK_MATRIX_APPROX(solver.matrix_representation(), blaze::inv(matrix)); + CHECK_ITERABLE_APPROX(solver.matrix_representation(), blaze::inv(matrix)); CHECK_ITERABLE_APPROX(solution, expected_solution); std::ifstream matrix_file("Matrix.txt"); std::string matrix_csv((std::istreambuf_iterator(matrix_file)), @@ -64,14 +64,14 @@ SPECTRE_TEST_CASE("Unit.LinearSolver.Serial.ExplicitInverse", 0.6363636363636364}; resetting_solver.solve(make_not_null(&solution), linear_operator2, source); - CHECK_MATRIX_APPROX(resetting_solver.matrix_representation(), - blaze::inv(matrix2)); + CHECK_ITERABLE_APPROX(resetting_solver.matrix_representation(), + blaze::inv(matrix2)); CHECK_ITERABLE_APPROX(solution, expected_solution2); // Without resetting, the solver should keep applying the cached // inverse even when solving a different operator solver.solve(make_not_null(&solution), linear_operator2, source); // Still the inverse of the operator we solved first - CHECK_MATRIX_APPROX(solver.matrix_representation(), blaze::inv(matrix)); + CHECK_ITERABLE_APPROX(solver.matrix_representation(), blaze::inv(matrix)); CHECK_ITERABLE_APPROX(solution, expected_solution); } } @@ -119,7 +119,7 @@ SPECTRE_TEST_CASE("Unit.LinearSolver.Serial.ExplicitInverse", blaze::submatrix(expected_matrix, 0, 0, 3, 3) = matrix_element; blaze::submatrix(expected_matrix, 3, 3, 2, 2) = matrix_overlap; blaze::invert(expected_matrix); - CHECK_MATRIX_APPROX(solver.matrix_representation(), expected_matrix); + CHECK_ITERABLE_APPROX(solver.matrix_representation(), expected_matrix); CHECK_VARIABLES_APPROX(solution.element_data, expected_solution.element_data); CHECK_VARIABLES_APPROX(solution.overlap_data.at(overlap_id), diff --git a/tests/Unit/NumericalAlgorithms/Spectral/Test_LegendreGauss.cpp b/tests/Unit/NumericalAlgorithms/Spectral/Test_LegendreGauss.cpp index 133a4f1ce4ac..1614c41934c2 100644 --- a/tests/Unit/NumericalAlgorithms/Spectral/Test_LegendreGauss.cpp +++ b/tests/Unit/NumericalAlgorithms/Spectral/Test_LegendreGauss.cpp @@ -74,7 +74,7 @@ void test_diff_matrix(const size_t num_points, const Matrix& expected_matrix) { const auto& diff_matrix = Spectral::differentiation_matrix(num_points); - CHECK_MATRIX_APPROX(expected_matrix, diff_matrix); + CHECK_ITERABLE_APPROX(expected_matrix, diff_matrix); } } // namespace @@ -135,7 +135,7 @@ void test_modal_to_nodal_matrix(const size_t num_points, const auto& matrix = Spectral::modal_to_nodal_matrix(num_points); - CHECK_MATRIX_APPROX(expected_matrix, matrix); + CHECK_ITERABLE_APPROX(expected_matrix, matrix); } } // namespace @@ -183,7 +183,7 @@ void test_nodal_to_modal_matrix(const size_t num_points, const auto& matrix = Spectral::nodal_to_modal_matrix(num_points); - CHECK_MATRIX_APPROX(expected_matrix, matrix); + CHECK_ITERABLE_APPROX(expected_matrix, matrix); } } // namespace diff --git a/tests/Unit/NumericalAlgorithms/Spectral/Test_LegendreGaussLobatto.cpp b/tests/Unit/NumericalAlgorithms/Spectral/Test_LegendreGaussLobatto.cpp index 5a01e8b6fbc3..7299750faf7e 100644 --- a/tests/Unit/NumericalAlgorithms/Spectral/Test_LegendreGaussLobatto.cpp +++ b/tests/Unit/NumericalAlgorithms/Spectral/Test_LegendreGaussLobatto.cpp @@ -150,7 +150,7 @@ void test_diff_matrix(const size_t num_points, const Matrix& expected_matrix) { num_points); Approx diff_approx = approx; diff_approx.margin(1.0e-13); - CHECK_MATRIX_CUSTOM_APPROX(expected_matrix, diff_matrix, diff_approx); + CHECK_ITERABLE_CUSTOM_APPROX(expected_matrix, diff_matrix, diff_approx); } } // namespace @@ -259,7 +259,7 @@ void test_modal_to_nodal_matrix(const size_t num_points, Spectral::modal_to_nodal_matrix( num_points); - CHECK_MATRIX_APPROX(expected_matrix, matrix); + CHECK_ITERABLE_APPROX(expected_matrix, matrix); } } // namespace @@ -346,7 +346,7 @@ void test_nodal_to_modal_matrix(const size_t num_points, Spectral::nodal_to_modal_matrix( num_points); - CHECK_MATRIX_APPROX(expected_matrix, matrix); + CHECK_ITERABLE_APPROX(expected_matrix, matrix); } } // namespace diff --git a/tests/Unit/NumericalAlgorithms/Spectral/Test_Spectral.cpp b/tests/Unit/NumericalAlgorithms/Spectral/Test_Spectral.cpp index 658aad24897c..126eb213c701 100644 --- a/tests/Unit/NumericalAlgorithms/Spectral/Test_Spectral.cpp +++ b/tests/Unit/NumericalAlgorithms/Spectral/Test_Spectral.cpp @@ -529,7 +529,7 @@ void test_double_instantiation() { Spectral::interpolation_matrix(mesh1d, interpolation_target); const auto vector_matrix = Spectral::interpolation_matrix( mesh1d, std::vector{interpolation_target}); - CHECK_MATRIX_APPROX(double_matrix, vector_matrix); + CHECK_ITERABLE_APPROX(double_matrix, vector_matrix); } } // namespace diff --git a/tests/Unit/NumericalAlgorithms/Spectral/Test_SwshCoefficients.cpp b/tests/Unit/NumericalAlgorithms/Spectral/Test_SwshCoefficients.cpp index fbf14b7b27f5..dc3f28478bb1 100644 --- a/tests/Unit/NumericalAlgorithms/Spectral/Test_SwshCoefficients.cpp +++ b/tests/Unit/NumericalAlgorithms/Spectral/Test_SwshCoefficients.cpp @@ -207,23 +207,24 @@ void check_goldberg_mode_conversion() { l_max, coefficient_info.l, -static_cast(coefficient_info.m), i)]; - CHECK_COMPLEX_CUSTOM_APPROX(goldberg_mode_plus_m, alternative_mode_plus_m, - swsh_approx); - CHECK_COMPLEX_CUSTOM_APPROX(goldberg_mode_plus_m, - goldberg_mode_plus_m_from_full_set, - swsh_approx); - CHECK_COMPLEX_CUSTOM_APPROX(goldberg_mode_plus_m, - expected_goldberg_modes[goldberg_mode_index( - l_max, coefficient_info.l, - static_cast(coefficient_info.m), i)], - swsh_approx); - - CHECK_COMPLEX_CUSTOM_APPROX(goldberg_mode_minus_m, - alternative_mode_minus_m, swsh_approx); - CHECK_COMPLEX_CUSTOM_APPROX(goldberg_mode_minus_m, - goldberg_mode_minus_m_from_full_set, - swsh_approx); - CHECK_COMPLEX_CUSTOM_APPROX( + CHECK_ITERABLE_CUSTOM_APPROX(goldberg_mode_plus_m, + alternative_mode_plus_m, swsh_approx); + CHECK_ITERABLE_CUSTOM_APPROX(goldberg_mode_plus_m, + goldberg_mode_plus_m_from_full_set, + swsh_approx); + CHECK_ITERABLE_CUSTOM_APPROX( + goldberg_mode_plus_m, + expected_goldberg_modes[goldberg_mode_index( + l_max, coefficient_info.l, static_cast(coefficient_info.m), + i)], + swsh_approx); + + CHECK_ITERABLE_CUSTOM_APPROX(goldberg_mode_minus_m, + alternative_mode_minus_m, swsh_approx); + CHECK_ITERABLE_CUSTOM_APPROX(goldberg_mode_minus_m, + goldberg_mode_minus_m_from_full_set, + swsh_approx); + CHECK_ITERABLE_CUSTOM_APPROX( goldberg_mode_minus_m, expected_goldberg_modes[goldberg_mode_index( l_max, coefficient_info.l, -static_cast(coefficient_info.m), diff --git a/tests/Unit/NumericalAlgorithms/Spectral/Test_SwshTransform.cpp b/tests/Unit/NumericalAlgorithms/Spectral/Test_SwshTransform.cpp index 1e04ff2af84d..5480be03ba1d 100644 --- a/tests/Unit/NumericalAlgorithms/Spectral/Test_SwshTransform.cpp +++ b/tests/Unit/NumericalAlgorithms/Spectral/Test_SwshTransform.cpp @@ -269,7 +269,7 @@ void test_interpolate_to_collocation() { for (size_t j = 0; j < square(std::min(l_max, target_l_max) + 1); ++j) { CAPTURE(i); CAPTURE(j); - CHECK_COMPLEX_APPROX( + CHECK_ITERABLE_APPROX( expected_goldberg_modes.data()[i * square(l_max + 1) + j], resampled_goldberg_modes.data()[i * square(target_l_max + 1) + j]); } diff --git a/tests/Unit/ParallelAlgorithms/LinearSolver/AsynchronousSolvers/Test_ElementActions.cpp b/tests/Unit/ParallelAlgorithms/LinearSolver/AsynchronousSolvers/Test_ElementActions.cpp index a48459abf42c..51636f6509ce 100644 --- a/tests/Unit/ParallelAlgorithms/LinearSolver/AsynchronousSolvers/Test_ElementActions.cpp +++ b/tests/Unit/ParallelAlgorithms/LinearSolver/AsynchronousSolvers/Test_ElementActions.cpp @@ -205,7 +205,7 @@ SPECTRE_TEST_CASE("Unit.ParallelLinearSolver.Asynchronous.ElementActions", CHECK(written_legend == std::vector{"Iteration", "Residual"}); const Matrix expected_reductions{{0., sqrt(27.)}, {1., sqrt(243.)}}; - CHECK_MATRIX_APPROX(written_reductions, expected_reductions); + CHECK_ITERABLE_APPROX(written_reductions, expected_reductions); } file_system::rm(reduction_file_name + ".h5", true); } diff --git a/tests/Unit/Time/Tags/Test_StepChoosers.cpp b/tests/Unit/Time/Tags/Test_StepChoosers.cpp index 859ded4dffb0..aa25ff5e48c2 100644 --- a/tests/Unit/Time/Tags/Test_StepChoosers.cpp +++ b/tests/Unit/Time/Tags/Test_StepChoosers.cpp @@ -3,6 +3,7 @@ #include "Framework/TestingFramework.hpp" +#include #include #include "Helpers/DataStructures/DataBox/TestHelpers.hpp" diff --git a/tests/Unit/Utilities/Test_Functional.cpp b/tests/Unit/Utilities/Test_Functional.cpp index 085d1b763972..764c41f036a4 100644 --- a/tests/Unit/Utilities/Test_Functional.cpp +++ b/tests/Unit/Utilities/Test_Functional.cpp @@ -174,7 +174,7 @@ MAKE_BINARY_INPLACE_TEST(MinusAssign, -=, -); MAKE_BINARY_INPLACE_TEST(MultAssign, *=, *); MAKE_BINARY_INPLACE_TEST(PlusAssign, +=, +); -using RealTypeList = tmpl::list; +using RealTypeList = tmpl::list; using AllTypeList = tmpl::list>; using DoubleSet = tmpl::list>;