From 7f1f50018d740c2b47ae2a0585b381bd5b3d9618 Mon Sep 17 00:00:00 2001 From: BOURNE Emily EPFL Date: Thu, 28 May 2026 17:49:45 +0200 Subject: [PATCH 1/7] Put applyExtrapolatedRestriction and applyExtrapolatedProlongation on GPU --- include/GMGPolar/utils.h | 27 +++++++++++++------ include/Interpolation/interpolation.h | 12 ++++----- .../extrapolated_prolongation.cpp | 20 +++++++------- .../extrapolated_restriction.cpp | 20 +++++++------- .../extrapolated_prolongation.cpp | 13 +++++---- .../extrapolated_restriction.cpp | 13 +++++---- 6 files changed, 61 insertions(+), 44 deletions(-) diff --git a/include/GMGPolar/utils.h b/include/GMGPolar/utils.h index af7f123c..42d09bed 100644 --- a/include/GMGPolar/utils.h +++ b/include/GMGPolar/utils.h @@ -44,30 +44,41 @@ void GMGPolar::injection(int current template void GMGPolar::extrapolatedProlongation(int current_level, - HostVector result, - HostConstVector x) const + HostVector result_host, + HostConstVector x_host) const { + auto result = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), result_host); + auto x = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), x_host); + assert(current_level < number_of_levels_ && 1 <= current_level); if (!interpolation_) throw std::runtime_error("Interpolation not initialized."); - PolarGrid current_grid(levels_[current_level].grid()); - PolarGrid previous_grid(levels_[current_level - 1].grid()); + PolarGrid current_grid = levels_[current_level].grid(); + PolarGrid previous_grid = levels_[current_level - 1].grid(); interpolation_->applyExtrapolatedProlongation(current_grid, previous_grid, result, x); + + Kokkos::deep_copy(result_host, result); + Kokkos::deep_copy(x_host, x); } template void GMGPolar::extrapolatedRestriction(int current_level, - HostVector result, - HostConstVector x) const + HostVector result_host, + HostConstVector x_host) const { + auto result = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), result_host); + auto x = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), x_host); assert(current_level < number_of_levels_ - 1 && 0 <= current_level); if (!interpolation_) throw std::runtime_error("Interpolation not initialized."); - PolarGrid current_grid(levels_[current_level].grid()); - PolarGrid next_grid(levels_[current_level + 1].grid()); + PolarGrid current_grid = levels_[current_level].grid(); + PolarGrid next_grid = levels_[current_level + 1].grid(); interpolation_->applyExtrapolatedRestriction(current_grid, next_grid, result, x); + + Kokkos::deep_copy(result_host, result); + Kokkos::deep_copy(x_host, x); } template diff --git a/include/Interpolation/interpolation.h b/include/Interpolation/interpolation.h index 00810375..7198458f 100644 --- a/include/Interpolation/interpolation.h +++ b/include/Interpolation/interpolation.h @@ -27,18 +27,18 @@ class Interpolation const PolarGrid& fine_grid, HostVector fine_result, HostConstVector coarse_values) const; - void applyExtrapolatedProlongation(const PolarGrid& coarse_grid, - const PolarGrid& fine_grid, HostVector fine_result, - HostConstVector coarse_values) const; + void applyExtrapolatedProlongation(const PolarGrid& coarse_grid, + const PolarGrid& fine_grid, Vector fine_result, + ConstVector coarse_values) const; /* Scaled full weighting (FW) restriction operator. */ void applyRestriction(const PolarGrid& fine_grid, const PolarGrid& coarse_grid, HostVector coarse_result, HostConstVector fine_values) const; - void applyExtrapolatedRestriction(const PolarGrid& fine_grid, - const PolarGrid& coarse_grid, HostVector coarse_result, - HostConstVector fine_values) const; + void applyExtrapolatedRestriction(const PolarGrid& fine_grid, + const PolarGrid& coarse_grid, Vector coarse_result, + ConstVector fine_values) const; /* Bicubic FMG interpolator 1/16 * [-1, 9, 9, -1] */ void applyFMGInterpolation(const PolarGrid& coarse_grid, diff --git a/src/Interpolation/extrapolated_prolongation.cpp b/src/Interpolation/extrapolated_prolongation.cpp index 9b001dee..9fa4b712 100644 --- a/src/Interpolation/extrapolated_prolongation.cpp +++ b/src/Interpolation/extrapolated_prolongation.cpp @@ -48,10 +48,10 @@ using namespace gmgpolar; */ static KOKKOS_INLINE_FUNCTION void fineNodeExtrapolatedProlongation(const int i_r, const int i_theta, - const PolarGrid& coarse_grid, - const PolarGrid& fine_grid, - HostVector& fine_result, - HostConstVector& coarse_values) + const PolarGrid& coarse_grid, + const PolarGrid& fine_grid, + Vector& fine_result, + ConstVector& coarse_values) { const int i_r_coarse = i_r / 2; const int i_theta_coarse = i_theta / 2; @@ -85,10 +85,10 @@ static KOKKOS_INLINE_FUNCTION void fineNodeExtrapolatedProlongation(const int i_ } } -void Interpolation::applyExtrapolatedProlongation(const PolarGrid& coarse_grid, - const PolarGrid& fine_grid, - HostVector fine_result, - HostConstVector coarse_values) const +void Interpolation::applyExtrapolatedProlongation(const PolarGrid& coarse_grid, + const PolarGrid& fine_grid, + Vector fine_result, + ConstVector coarse_values) const { assert(std::ssize(coarse_values) == coarse_grid.numberOfNodes()); assert(std::ssize(fine_result) == fine_grid.numberOfNodes()); @@ -99,7 +99,7 @@ void Interpolation::applyExtrapolatedProlongation(const PolarGrid>( // Rank of the index space + Kokkos::MDRangePolicy>( // Rank of the index space {0, 0}, // Starting point of the index space {fine_grid.numberSmootherCircles(), fine_grid.ntheta()} // Ending point of the index space ), @@ -111,7 +111,7 @@ void Interpolation::applyExtrapolatedProlongation(const PolarGrid>( // Rank of the index space + Kokkos::MDRangePolicy>( // Rank of the index space {0, fine_grid.numberSmootherCircles()}, // Starting point of the index space {fine_grid.ntheta(), fine_grid.nr()} // Ending point of the index space ), diff --git a/src/Interpolation/extrapolated_restriction.cpp b/src/Interpolation/extrapolated_restriction.cpp index 47e59b4f..b38e93bf 100644 --- a/src/Interpolation/extrapolated_restriction.cpp +++ b/src/Interpolation/extrapolated_restriction.cpp @@ -23,10 +23,10 @@ using namespace gmgpolar; */ static KOKKOS_INLINE_FUNCTION void coarseNodeExtrapolatedRestriction(const int i_r_coarse, const int i_theta_coarse, - const PolarGrid& fine_grid, - const PolarGrid& coarse_grid, - HostVector& coarse_result, - HostConstVector& fine_values) + const PolarGrid& fine_grid, + const PolarGrid& coarse_grid, + Vector& coarse_result, + ConstVector& fine_values) { const int i_r = i_r_coarse * 2; const int i_theta = i_theta_coarse * 2; @@ -50,10 +50,10 @@ static KOKKOS_INLINE_FUNCTION void coarseNodeExtrapolatedRestriction(const int i coarse_result[coarse_grid.index(i_r_coarse, i_theta_coarse)] = value; } -void Interpolation::applyExtrapolatedRestriction(const PolarGrid& fine_grid, - const PolarGrid& coarse_grid, - HostVector coarse_result, - HostConstVector fine_values) const +void Interpolation::applyExtrapolatedRestriction(const PolarGrid& fine_grid, + const PolarGrid& coarse_grid, + Vector coarse_result, + ConstVector fine_values) const { assert(std::ssize(fine_values) == fine_grid.numberOfNodes()); assert(std::ssize(coarse_result) == coarse_grid.numberOfNodes()); @@ -64,7 +64,7 @@ void Interpolation::applyExtrapolatedRestriction(const PolarGrid>( // Rank of the index space + Kokkos::MDRangePolicy>( // Rank of the index space {0, 0}, // Starting point of the index space {coarse_grid.numberSmootherCircles(), coarse_grid.ntheta()} // Ending point of the index space ), @@ -77,7 +77,7 @@ void Interpolation::applyExtrapolatedRestriction(const PolarGrid>( // Rank of the index space + Kokkos::MDRangePolicy>( // Rank of the index space {0, coarse_grid.numberSmootherCircles()}, // Starting point of the index space {coarse_grid.ntheta(), coarse_grid.nr()} // Ending point of the index space ), diff --git a/tests/Interpolation/extrapolated_prolongation.cpp b/tests/Interpolation/extrapolated_prolongation.cpp index 47195d9a..c9ac9764 100644 --- a/tests/Interpolation/extrapolated_prolongation.cpp +++ b/tests/Interpolation/extrapolated_prolongation.cpp @@ -47,20 +47,23 @@ TEST(ExtrapolatedProlongationTest, ExtrapolatedProlongationMatchesStencil) std::vector fine_angles = { 0, M_PI / 16, M_PI / 8, M_PI / 2, M_PI, M_PI + M_PI / 16, M_PI + M_PI / 8, M_PI + M_PI / 2, 2 * M_PI}; - PolarGrid fine_grid(fine_radii, fine_angles); - PolarGrid coarse_grid = coarseningGrid(fine_grid); + PolarGrid fine_grid(fine_radii, fine_angles); + PolarGrid coarse_grid = coarseningGrid(fine_grid); + + PolarGrid h_fine_grid(fine_grid); + PolarGrid h_coarse_grid(coarse_grid); Interpolation I(/*DirBC*/ true); - HostVector coarse_values = generate_random_sample_data(coarse_grid, 1234, 0.0, 1.0); + HostVector coarse_values = generate_random_sample_data(h_coarse_grid, 1234, 0.0, 1.0); HostVector fine_result("fine_result", fine_grid.numberOfNodes()); I.applyExtrapolatedProlongation(coarse_grid, fine_grid, fine_result, coarse_values); for (int i_r = 0; i_r < fine_grid.nr(); ++i_r) { for (int i_theta = 0; i_theta < fine_grid.ntheta(); ++i_theta) { - double expected = expected_extrapolated_value(coarse_grid, fine_grid, coarse_values, i_r, i_theta); - double got = fine_result[fine_grid.index(i_r, i_theta)]; + double expected = expected_extrapolated_value(h_coarse_grid, h_fine_grid, coarse_values, i_r, i_theta); + double got = fine_result[h_fine_grid.index(i_r, i_theta)]; ASSERT_NEAR(expected, got, 1e-10) << "Mismatch at (" << i_r << ", " << i_theta << ")"; } } diff --git a/tests/Interpolation/extrapolated_restriction.cpp b/tests/Interpolation/extrapolated_restriction.cpp index 403b4b3b..5bff7628 100644 --- a/tests/Interpolation/extrapolated_restriction.cpp +++ b/tests/Interpolation/extrapolated_restriction.cpp @@ -46,21 +46,24 @@ TEST(ExtrapolatedRestrictionTest, ExtrapolatedRestrictionMatchesStencil) std::vector fine_angles = { 0, M_PI / 16, M_PI / 8, M_PI / 2, M_PI, M_PI + M_PI / 16, M_PI + M_PI / 8, M_PI + M_PI / 2, 2 * M_PI}; - PolarGrid fine_grid(fine_radii, fine_angles); - PolarGrid coarse_grid = coarseningGrid(fine_grid); + PolarGrid fine_grid(fine_radii, fine_angles); + PolarGrid coarse_grid = coarseningGrid(fine_grid); + + PolarGrid h_fine_grid(fine_grid); + PolarGrid h_coarse_grid(coarse_grid); Interpolation I(/*DirBC*/ true); - HostVector fine_values = generate_random_sample_data(fine_grid, 9012, 0.0, 1.0); + HostVector fine_values = generate_random_sample_data(h_fine_grid, 9012, 0.0, 1.0); HostVector coarse_result("coarse_result", coarse_grid.numberOfNodes()); I.applyExtrapolatedRestriction(fine_grid, coarse_grid, coarse_result, fine_values); for (int i_r_coarse = 0; i_r_coarse < coarse_grid.nr(); ++i_r_coarse) { for (int i_theta_coarse = 0; i_theta_coarse < coarse_grid.ntheta(); ++i_theta_coarse) { - double expected = expected_extrapolated_restriction_value(fine_grid, coarse_grid, fine_values, i_r_coarse, + double expected = expected_extrapolated_restriction_value(h_fine_grid, h_coarse_grid, fine_values, i_r_coarse, i_theta_coarse); - double got = coarse_result[coarse_grid.index(i_r_coarse, i_theta_coarse)]; + double got = coarse_result[h_coarse_grid.index(i_r_coarse, i_theta_coarse)]; ASSERT_NEAR(expected, got, 1e-10) << "Mismatch at (" << i_r_coarse << ", " << i_theta_coarse << ")"; } } From dc04e5aa97673f1bac21fc577f9485ca6fc7a43f Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Fri, 29 May 2026 16:55:04 +0200 Subject: [PATCH 2/7] Clang format --- include/GMGPolar/utils.h | 13 ++++++------- src/Interpolation/extrapolated_prolongation.cpp | 3 +-- src/Interpolation/extrapolated_restriction.cpp | 3 +-- tests/Interpolation/extrapolated_restriction.cpp | 4 ++-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/include/GMGPolar/utils.h b/include/GMGPolar/utils.h index 42d09bed..f07ee616 100644 --- a/include/GMGPolar/utils.h +++ b/include/GMGPolar/utils.h @@ -43,18 +43,17 @@ void GMGPolar::injection(int current } template -void GMGPolar::extrapolatedProlongation(int current_level, - HostVector result_host, - HostConstVector x_host) const +void GMGPolar::extrapolatedProlongation( + int current_level, HostVector result_host, HostConstVector x_host) const { auto result = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), result_host); - auto x = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), x_host); + auto x = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), x_host); assert(current_level < number_of_levels_ && 1 <= current_level); if (!interpolation_) throw std::runtime_error("Interpolation not initialized."); - PolarGrid current_grid = levels_[current_level].grid(); + PolarGrid current_grid = levels_[current_level].grid(); PolarGrid previous_grid = levels_[current_level - 1].grid(); interpolation_->applyExtrapolatedProlongation(current_grid, previous_grid, result, x); @@ -68,13 +67,13 @@ void GMGPolar::extrapolatedRestricti HostConstVector x_host) const { auto result = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), result_host); - auto x = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), x_host); + auto x = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), x_host); assert(current_level < number_of_levels_ - 1 && 0 <= current_level); if (!interpolation_) throw std::runtime_error("Interpolation not initialized."); PolarGrid current_grid = levels_[current_level].grid(); - PolarGrid next_grid = levels_[current_level + 1].grid(); + PolarGrid next_grid = levels_[current_level + 1].grid(); interpolation_->applyExtrapolatedRestriction(current_grid, next_grid, result, x); Kokkos::deep_copy(result_host, result); diff --git a/src/Interpolation/extrapolated_prolongation.cpp b/src/Interpolation/extrapolated_prolongation.cpp index 9fa4b712..22c75ee6 100644 --- a/src/Interpolation/extrapolated_prolongation.cpp +++ b/src/Interpolation/extrapolated_prolongation.cpp @@ -87,8 +87,7 @@ static KOKKOS_INLINE_FUNCTION void fineNodeExtrapolatedProlongation(const int i_ void Interpolation::applyExtrapolatedProlongation(const PolarGrid& coarse_grid, const PolarGrid& fine_grid, - Vector fine_result, - ConstVector coarse_values) const + Vector fine_result, ConstVector coarse_values) const { assert(std::ssize(coarse_values) == coarse_grid.numberOfNodes()); assert(std::ssize(fine_result) == fine_grid.numberOfNodes()); diff --git a/src/Interpolation/extrapolated_restriction.cpp b/src/Interpolation/extrapolated_restriction.cpp index b38e93bf..b3f8b2de 100644 --- a/src/Interpolation/extrapolated_restriction.cpp +++ b/src/Interpolation/extrapolated_restriction.cpp @@ -52,8 +52,7 @@ static KOKKOS_INLINE_FUNCTION void coarseNodeExtrapolatedRestriction(const int i void Interpolation::applyExtrapolatedRestriction(const PolarGrid& fine_grid, const PolarGrid& coarse_grid, - Vector coarse_result, - ConstVector fine_values) const + Vector coarse_result, ConstVector fine_values) const { assert(std::ssize(fine_values) == fine_grid.numberOfNodes()); assert(std::ssize(coarse_result) == coarse_grid.numberOfNodes()); diff --git a/tests/Interpolation/extrapolated_restriction.cpp b/tests/Interpolation/extrapolated_restriction.cpp index 5bff7628..6264a9c6 100644 --- a/tests/Interpolation/extrapolated_restriction.cpp +++ b/tests/Interpolation/extrapolated_restriction.cpp @@ -61,8 +61,8 @@ TEST(ExtrapolatedRestrictionTest, ExtrapolatedRestrictionMatchesStencil) for (int i_r_coarse = 0; i_r_coarse < coarse_grid.nr(); ++i_r_coarse) { for (int i_theta_coarse = 0; i_theta_coarse < coarse_grid.ntheta(); ++i_theta_coarse) { - double expected = expected_extrapolated_restriction_value(h_fine_grid, h_coarse_grid, fine_values, i_r_coarse, - i_theta_coarse); + double expected = expected_extrapolated_restriction_value(h_fine_grid, h_coarse_grid, fine_values, + i_r_coarse, i_theta_coarse); double got = coarse_result[h_coarse_grid.index(i_r_coarse, i_theta_coarse)]; ASSERT_NEAR(expected, got, 1e-10) << "Mismatch at (" << i_r_coarse << ", " << i_theta_coarse << ")"; } From d4ebff81ce3c57392623b33b655ed0da4f3c2240 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Fri, 29 May 2026 16:55:36 +0200 Subject: [PATCH 3/7] Const doesn't need to be copied --- include/GMGPolar/utils.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/GMGPolar/utils.h b/include/GMGPolar/utils.h index f07ee616..484e7479 100644 --- a/include/GMGPolar/utils.h +++ b/include/GMGPolar/utils.h @@ -77,7 +77,6 @@ void GMGPolar::extrapolatedRestricti interpolation_->applyExtrapolatedRestriction(current_grid, next_grid, result, x); Kokkos::deep_copy(result_host, result); - Kokkos::deep_copy(x_host, x); } template From 42e054b15709612f032c8d98c4b5661302872d63 Mon Sep 17 00:00:00 2001 From: BOURNE Emily EPFL Date: Fri, 29 May 2026 16:57:48 +0200 Subject: [PATCH 4/7] Don't copy const --- include/GMGPolar/utils.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/GMGPolar/utils.h b/include/GMGPolar/utils.h index 484e7479..2804e51a 100644 --- a/include/GMGPolar/utils.h +++ b/include/GMGPolar/utils.h @@ -58,7 +58,6 @@ void GMGPolar::extrapolatedProlongat interpolation_->applyExtrapolatedProlongation(current_grid, previous_grid, result, x); Kokkos::deep_copy(result_host, result); - Kokkos::deep_copy(x_host, x); } template From 5aea55d0d188dccdfc0493d118b6048c2111f29e Mon Sep 17 00:00:00 2001 From: BOURNE Emily EPFL Date: Fri, 29 May 2026 17:02:49 +0200 Subject: [PATCH 5/7] Correct MemorySpace --- tests/Interpolation/extrapolated_prolongation.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Interpolation/extrapolated_prolongation.cpp b/tests/Interpolation/extrapolated_prolongation.cpp index c9ac9764..7ef5a06f 100644 --- a/tests/Interpolation/extrapolated_prolongation.cpp +++ b/tests/Interpolation/extrapolated_prolongation.cpp @@ -50,8 +50,8 @@ TEST(ExtrapolatedProlongationTest, ExtrapolatedProlongationMatchesStencil) PolarGrid fine_grid(fine_radii, fine_angles); PolarGrid coarse_grid = coarseningGrid(fine_grid); - PolarGrid h_fine_grid(fine_grid); - PolarGrid h_coarse_grid(coarse_grid); + PolarGrid h_fine_grid(fine_grid); + PolarGrid h_coarse_grid(coarse_grid); Interpolation I(/*DirBC*/ true); From 4031e7d7c049b5fd2ba336792fa5a9aca6a2b45e Mon Sep 17 00:00:00 2001 From: BOURNE Emily EPFL Date: Fri, 29 May 2026 17:08:50 +0200 Subject: [PATCH 6/7] Fix memory spaces --- tests/Interpolation/extrapolated_prolongation.cpp | 12 ++++++++---- tests/Interpolation/extrapolated_restriction.cpp | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/Interpolation/extrapolated_prolongation.cpp b/tests/Interpolation/extrapolated_prolongation.cpp index 7ef5a06f..fb54349d 100644 --- a/tests/Interpolation/extrapolated_prolongation.cpp +++ b/tests/Interpolation/extrapolated_prolongation.cpp @@ -55,15 +55,19 @@ TEST(ExtrapolatedProlongationTest, ExtrapolatedProlongationMatchesStencil) Interpolation I(/*DirBC*/ true); - HostVector coarse_values = generate_random_sample_data(h_coarse_grid, 1234, 0.0, 1.0); - HostVector fine_result("fine_result", fine_grid.numberOfNodes()); + HostVector h_coarse_values = generate_random_sample_data(h_coarse_grid, 1234, 0.0, 1.0); + Vector fine_result("fine_result", fine_grid.numberOfNodes()); + + auto coarse_values = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), h_coarse_values); I.applyExtrapolatedProlongation(coarse_grid, fine_grid, fine_result, coarse_values); + auto h_fine_result = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), fine_result); + for (int i_r = 0; i_r < fine_grid.nr(); ++i_r) { for (int i_theta = 0; i_theta < fine_grid.ntheta(); ++i_theta) { - double expected = expected_extrapolated_value(h_coarse_grid, h_fine_grid, coarse_values, i_r, i_theta); - double got = fine_result[h_fine_grid.index(i_r, i_theta)]; + double expected = expected_extrapolated_value(h_coarse_grid, h_fine_grid, h_coarse_values, i_r, i_theta); + double got = h_fine_result[h_fine_grid.index(i_r, i_theta)]; ASSERT_NEAR(expected, got, 1e-10) << "Mismatch at (" << i_r << ", " << i_theta << ")"; } } diff --git a/tests/Interpolation/extrapolated_restriction.cpp b/tests/Interpolation/extrapolated_restriction.cpp index 6264a9c6..3b3f94e2 100644 --- a/tests/Interpolation/extrapolated_restriction.cpp +++ b/tests/Interpolation/extrapolated_restriction.cpp @@ -54,16 +54,20 @@ TEST(ExtrapolatedRestrictionTest, ExtrapolatedRestrictionMatchesStencil) Interpolation I(/*DirBC*/ true); - HostVector fine_values = generate_random_sample_data(h_fine_grid, 9012, 0.0, 1.0); - HostVector coarse_result("coarse_result", coarse_grid.numberOfNodes()); + HostVector h_fine_values = generate_random_sample_data(h_fine_grid, 9012, 0.0, 1.0); + Vector coarse_result("coarse_result", coarse_grid.numberOfNodes()); + + auto fine_values = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), h_fine_values); I.applyExtrapolatedRestriction(fine_grid, coarse_grid, coarse_result, fine_values); + auto h_coarse_result = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), coarse_result); + for (int i_r_coarse = 0; i_r_coarse < coarse_grid.nr(); ++i_r_coarse) { for (int i_theta_coarse = 0; i_theta_coarse < coarse_grid.ntheta(); ++i_theta_coarse) { - double expected = expected_extrapolated_restriction_value(h_fine_grid, h_coarse_grid, fine_values, + double expected = expected_extrapolated_restriction_value(h_fine_grid, h_coarse_grid, h_fine_values, i_r_coarse, i_theta_coarse); - double got = coarse_result[h_coarse_grid.index(i_r_coarse, i_theta_coarse)]; + double got = h_coarse_result[h_coarse_grid.index(i_r_coarse, i_theta_coarse)]; ASSERT_NEAR(expected, got, 1e-10) << "Mismatch at (" << i_r_coarse << ", " << i_theta_coarse << ")"; } } From 8e8dc2703974f55c4e470f16e48f69f4b3739761 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Fri, 29 May 2026 17:25:20 +0200 Subject: [PATCH 7/7] Clang format --- tests/Interpolation/extrapolated_prolongation.cpp | 4 ++-- tests/Interpolation/extrapolated_restriction.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Interpolation/extrapolated_prolongation.cpp b/tests/Interpolation/extrapolated_prolongation.cpp index fb54349d..137c8ab5 100644 --- a/tests/Interpolation/extrapolated_prolongation.cpp +++ b/tests/Interpolation/extrapolated_prolongation.cpp @@ -58,11 +58,11 @@ TEST(ExtrapolatedProlongationTest, ExtrapolatedProlongationMatchesStencil) HostVector h_coarse_values = generate_random_sample_data(h_coarse_grid, 1234, 0.0, 1.0); Vector fine_result("fine_result", fine_grid.numberOfNodes()); - auto coarse_values = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), h_coarse_values); + auto coarse_values = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), h_coarse_values); I.applyExtrapolatedProlongation(coarse_grid, fine_grid, fine_result, coarse_values); - auto h_fine_result = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), fine_result); + auto h_fine_result = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), fine_result); for (int i_r = 0; i_r < fine_grid.nr(); ++i_r) { for (int i_theta = 0; i_theta < fine_grid.ntheta(); ++i_theta) { diff --git a/tests/Interpolation/extrapolated_restriction.cpp b/tests/Interpolation/extrapolated_restriction.cpp index 3b3f94e2..d6b7273d 100644 --- a/tests/Interpolation/extrapolated_restriction.cpp +++ b/tests/Interpolation/extrapolated_restriction.cpp @@ -57,11 +57,11 @@ TEST(ExtrapolatedRestrictionTest, ExtrapolatedRestrictionMatchesStencil) HostVector h_fine_values = generate_random_sample_data(h_fine_grid, 9012, 0.0, 1.0); Vector coarse_result("coarse_result", coarse_grid.numberOfNodes()); - auto fine_values = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), h_fine_values); + auto fine_values = Kokkos::create_mirror_view_and_copy(DefaultMemorySpace(), h_fine_values); I.applyExtrapolatedRestriction(fine_grid, coarse_grid, coarse_result, fine_values); - auto h_coarse_result = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), coarse_result); + auto h_coarse_result = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), coarse_result); for (int i_r_coarse = 0; i_r_coarse < coarse_grid.nr(); ++i_r_coarse) { for (int i_theta_coarse = 0; i_theta_coarse < coarse_grid.ntheta(); ++i_theta_coarse) {