From 7450ff917d5589f397be59dc89d846427aa107fd Mon Sep 17 00:00:00 2001 From: BOURNE Emily EPFL Date: Tue, 12 May 2026 14:39:32 +0200 Subject: [PATCH 1/6] Add KOKKOS_FUNCTION annotations --- include/Definitions/geometry_helper.h | 3 +- .../poissonCoefficients.h | 7 +-- .../sonnendruckerCoefficients.h | 7 +-- .../sonnendruckerGyroCoefficients.h | 7 +-- .../zoniCoefficients.h | 7 +-- .../zoniGyroCoefficients.h | 7 +-- .../zoniShiftedCoefficients.h | 7 +-- .../zoniShiftedGyroCoefficients.h | 7 +-- .../DomainGeometry/circularGeometry.h | 13 +++--- .../DomainGeometry/circularGeometry.inl | 12 ++--- .../DomainGeometry/culhamGeometry.h | 45 ++++++++++--------- .../DomainGeometry/culhamGeometry.inl | 44 +++++++++--------- .../DomainGeometry/czarnyGeometry.h | 13 +++--- .../DomainGeometry/czarnyGeometry.inl | 12 ++--- .../DomainGeometry/shafranovGeometry.h | 13 +++--- .../DomainGeometry/shafranovGeometry.inl | 12 ++--- include/Level/level.h | 6 ++- include/Residual/ResidualGive/applyAGive.inl | 4 +- .../DensityProfileCoefficients/CMakeLists.txt | 3 +- .../poissonCoefficients.cpp | 6 +-- .../sonnendruckerCoefficients.cpp | 6 +-- .../sonnendruckerGyroCoefficients.cpp | 6 +-- .../zoniCoefficients.cpp | 6 +-- .../zoniGyroCoefficients.cpp | 6 +-- .../zoniShiftedCoefficients.cpp | 6 +-- .../zoniShiftedGyroCoefficients.cpp | 6 +-- .../DomainGeometry/CMakeLists.txt | 3 +- 27 files changed, 145 insertions(+), 129 deletions(-) diff --git a/include/Definitions/geometry_helper.h b/include/Definitions/geometry_helper.h index 29821c9e..61f961ad 100644 --- a/include/Definitions/geometry_helper.h +++ b/include/Definitions/geometry_helper.h @@ -4,9 +4,10 @@ #include "../InputFunctions/domainGeometry.h" #include +#include template -inline void compute_jacobian_elements(const DomainGeometry& domain_geometry, double r, double theta, double coeff_alpha, +KOKKOS_INLINE_FUNCTION void compute_jacobian_elements(const DomainGeometry& domain_geometry, double r, double theta, double coeff_alpha, double& arr, double& att, double& art, double& detDF) { /* Calculate the elements of the Jacobian matrix for the transformation mapping */ diff --git a/include/InputFunctions/DensityProfileCoefficients/poissonCoefficients.h b/include/InputFunctions/DensityProfileCoefficients/poissonCoefficients.h index 4cbf3d60..6f5d2e97 100644 --- a/include/InputFunctions/DensityProfileCoefficients/poissonCoefficients.h +++ b/include/InputFunctions/DensityProfileCoefficients/poissonCoefficients.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "../densityProfileCoefficients.h" @@ -13,10 +14,10 @@ class PoissonCoefficients PoissonCoefficients() = default; explicit PoissonCoefficients(double Rmax, double alpha); - double alpha(double r, double theta) const; - double beta(double r, double theta) const; + KOKKOS_FUNCTION double alpha(double r, double theta) const; + KOKKOS_FUNCTION double beta(double r, double theta) const; - double getAlphaJump() const; + KOKKOS_FUNCTION double getAlphaJump() const; private: const double Rmax = 1.3; diff --git a/include/InputFunctions/DensityProfileCoefficients/sonnendruckerCoefficients.h b/include/InputFunctions/DensityProfileCoefficients/sonnendruckerCoefficients.h index 62bc1a42..2b8953b8 100644 --- a/include/InputFunctions/DensityProfileCoefficients/sonnendruckerCoefficients.h +++ b/include/InputFunctions/DensityProfileCoefficients/sonnendruckerCoefficients.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "../densityProfileCoefficients.h" @@ -13,10 +14,10 @@ class SonnendruckerCoefficients SonnendruckerCoefficients() = default; explicit SonnendruckerCoefficients(double Rmax, double alpha); - double alpha(double r, double theta) const; - double beta(double r, double theta) const; + KOKKOS_FUNCTION double alpha(double r, double theta) const; + KOKKOS_FUNCTION double beta(double r, double theta) const; - double getAlphaJump() const; + KOKKOS_FUNCTION double getAlphaJump() const; private: const double Rmax = 1.3; diff --git a/include/InputFunctions/DensityProfileCoefficients/sonnendruckerGyroCoefficients.h b/include/InputFunctions/DensityProfileCoefficients/sonnendruckerGyroCoefficients.h index 083d8361..6207372e 100644 --- a/include/InputFunctions/DensityProfileCoefficients/sonnendruckerGyroCoefficients.h +++ b/include/InputFunctions/DensityProfileCoefficients/sonnendruckerGyroCoefficients.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "../densityProfileCoefficients.h" @@ -13,10 +14,10 @@ class SonnendruckerGyroCoefficients SonnendruckerGyroCoefficients() = default; explicit SonnendruckerGyroCoefficients(double Rmax, double alpha); - double alpha(double r, double theta) const; - double beta(double r, double theta) const; + KOKKOS_FUNCTION double alpha(double r, double theta) const; + KOKKOS_FUNCTION double beta(double r, double theta) const; - double getAlphaJump() const; + KOKKOS_FUNCTION double getAlphaJump() const; private: const double Rmax = 1.3; diff --git a/include/InputFunctions/DensityProfileCoefficients/zoniCoefficients.h b/include/InputFunctions/DensityProfileCoefficients/zoniCoefficients.h index db14a255..d4845af1 100644 --- a/include/InputFunctions/DensityProfileCoefficients/zoniCoefficients.h +++ b/include/InputFunctions/DensityProfileCoefficients/zoniCoefficients.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "../densityProfileCoefficients.h" @@ -13,10 +14,10 @@ class ZoniCoefficients ZoniCoefficients() = default; explicit ZoniCoefficients(double Rmax, double alpha); - double alpha(double r, double theta) const; - double beta(double r, double theta) const; + KOKKOS_FUNCTION double alpha(double r, double theta) const; + KOKKOS_FUNCTION double beta(double r, double theta) const; - double getAlphaJump() const; + KOKKOS_FUNCTION double getAlphaJump() const; private: const double Rmax = 1.3; diff --git a/include/InputFunctions/DensityProfileCoefficients/zoniGyroCoefficients.h b/include/InputFunctions/DensityProfileCoefficients/zoniGyroCoefficients.h index d06a5cd0..9f48a6ee 100644 --- a/include/InputFunctions/DensityProfileCoefficients/zoniGyroCoefficients.h +++ b/include/InputFunctions/DensityProfileCoefficients/zoniGyroCoefficients.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "../densityProfileCoefficients.h" @@ -13,10 +14,10 @@ class ZoniGyroCoefficients ZoniGyroCoefficients() = default; explicit ZoniGyroCoefficients(double Rmax, double alpha); - double alpha(double r, double theta) const; - double beta(double r, double theta) const; + KOKKOS_FUNCTION double alpha(double r, double theta) const; + KOKKOS_FUNCTION double beta(double r, double theta) const; - double getAlphaJump() const; + KOKKOS_FUNCTION double getAlphaJump() const; private: const double Rmax = 1.3; diff --git a/include/InputFunctions/DensityProfileCoefficients/zoniShiftedCoefficients.h b/include/InputFunctions/DensityProfileCoefficients/zoniShiftedCoefficients.h index 802dee8f..3a590a23 100644 --- a/include/InputFunctions/DensityProfileCoefficients/zoniShiftedCoefficients.h +++ b/include/InputFunctions/DensityProfileCoefficients/zoniShiftedCoefficients.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "../densityProfileCoefficients.h" @@ -13,10 +14,10 @@ class ZoniShiftedCoefficients ZoniShiftedCoefficients() = default; explicit ZoniShiftedCoefficients(double Rmax, double alpha); - double alpha(double r, double theta) const; - double beta(double r, double theta) const; + KOKKOS_FUNCTION double alpha(double r, double theta) const; + KOKKOS_FUNCTION double beta(double r, double theta) const; - double getAlphaJump() const; + KOKKOS_FUNCTION double getAlphaJump() const; private: const double Rmax = 1.3; diff --git a/include/InputFunctions/DensityProfileCoefficients/zoniShiftedGyroCoefficients.h b/include/InputFunctions/DensityProfileCoefficients/zoniShiftedGyroCoefficients.h index 80c25373..9f18ea0d 100644 --- a/include/InputFunctions/DensityProfileCoefficients/zoniShiftedGyroCoefficients.h +++ b/include/InputFunctions/DensityProfileCoefficients/zoniShiftedGyroCoefficients.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "../densityProfileCoefficients.h" @@ -13,10 +14,10 @@ class ZoniShiftedGyroCoefficients ZoniShiftedGyroCoefficients() = default; explicit ZoniShiftedGyroCoefficients(double Rmax, double alpha); - double alpha(double r, double theta) const; - double beta(double r, double theta) const; + KOKKOS_FUNCTION double alpha(double r, double theta) const; + KOKKOS_FUNCTION double beta(double r, double theta) const; - double getAlphaJump() const; + KOKKOS_FUNCTION double getAlphaJump() const; private: const double Rmax = 1.3; diff --git a/include/InputFunctions/DomainGeometry/circularGeometry.h b/include/InputFunctions/DomainGeometry/circularGeometry.h index 37815cde..081d86c4 100644 --- a/include/InputFunctions/DomainGeometry/circularGeometry.h +++ b/include/InputFunctions/DomainGeometry/circularGeometry.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "../domainGeometry.h" @@ -13,12 +14,12 @@ class CircularGeometry CircularGeometry() = default; explicit CircularGeometry(double Rmax); - double Fx(double r, double theta) const; - double Fy(double r, double theta) const; - double dFx_dr(double r, double theta) const; - double dFy_dr(double r, double theta) const; - double dFx_dt(double r, double theta) const; - double dFy_dt(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double Fx(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double Fy(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFx_dr(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFy_dr(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFx_dt(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFy_dt(double r, double theta) const; private: const double Rmax = 1.3; diff --git a/include/InputFunctions/DomainGeometry/circularGeometry.inl b/include/InputFunctions/DomainGeometry/circularGeometry.inl index d80c482d..129cf91d 100644 --- a/include/InputFunctions/DomainGeometry/circularGeometry.inl +++ b/include/InputFunctions/DomainGeometry/circularGeometry.inl @@ -3,37 +3,37 @@ #include "circularGeometry.h" // In earlier versions denoted by 'x' -inline double CircularGeometry::Fx(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CircularGeometry::Fx(double r, double theta) const { return (r / Rmax) * std::cos(theta); } // In earlier versions denoted by 'y' -inline double CircularGeometry::Fy(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CircularGeometry::Fy(double r, double theta) const { return (r / Rmax) * std::sin(theta); } // In earlier versions denoted by 'Jrr' -inline double CircularGeometry::dFx_dr(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CircularGeometry::dFx_dr(double r, double theta) const { return (std::cos(theta)) / Rmax; } // In earlier versions denoted by 'Jtr' -inline double CircularGeometry::dFy_dr(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CircularGeometry::dFy_dr(double r, double theta) const { return (std::sin(theta)) / Rmax; } // In earlier versions denoted by 'Jrt' -inline double CircularGeometry::dFx_dt(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CircularGeometry::dFx_dt(double r, double theta) const { return (-(r / Rmax)) * std::sin(theta); } // In earlier versions denoted by 'Jtt' -inline double CircularGeometry::dFy_dt(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CircularGeometry::dFy_dt(double r, double theta) const { return (r / Rmax) * std::cos(theta); } diff --git a/include/InputFunctions/DomainGeometry/culhamGeometry.h b/include/InputFunctions/DomainGeometry/culhamGeometry.h index c4e9543e..575eb06e 100644 --- a/include/InputFunctions/DomainGeometry/culhamGeometry.h +++ b/include/InputFunctions/DomainGeometry/culhamGeometry.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "../domainGeometry.h" @@ -16,34 +17,34 @@ class CulhamGeometry CulhamGeometry(); explicit CulhamGeometry(double Rmax); - double Fx(double r, double theta) const; - double Fy(double r, double theta) const; - double dFx_dr(double r, double theta) const; - double dFy_dr(double r, double theta) const; - double dFx_dt(double r, double theta) const; - double dFy_dt(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double Fx(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double Fy(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFx_dr(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFy_dr(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFx_dt(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFy_dt(double r, double theta) const; private: const double Rmax = 1.3; void initializeGeometry(); - double my_sum(std::array& f, int64_t start_idx, int64_t end_idx) const; - double q(double rr) const; - double dq(double rr) const; - double p(double rr) const; - double dp(double rr) const; - double dg(double rr, double g) const; - double double_deriv(double rr, double c, double g, double dg, double val, double d_val) const; - double g(double rr) const; - double Delta(double rr) const; - double Delta_prime(double rr) const; - double E(double rr) const; - double T(double rr) const; - double E_prime(double rr) const; - double T_prime(double rr) const; - double P(double rr) const; - double dP(double rr) const; + KOKKOS_INLINE_FUNCTION double my_sum(std::array& f, int64_t start_idx, int64_t end_idx) const; + KOKKOS_INLINE_FUNCTION double q(double rr) const; + KOKKOS_INLINE_FUNCTION double dq(double rr) const; + KOKKOS_INLINE_FUNCTION double p(double rr) const; + KOKKOS_INLINE_FUNCTION double dp(double rr) const; + KOKKOS_INLINE_FUNCTION double dg(double rr, double g) const; + KOKKOS_INLINE_FUNCTION double double_deriv(double rr, double c, double g, double dg, double val, double d_val) const; + KOKKOS_INLINE_FUNCTION double g(double rr) const; + KOKKOS_INLINE_FUNCTION double Delta(double rr) const; + KOKKOS_INLINE_FUNCTION double Delta_prime(double rr) const; + KOKKOS_INLINE_FUNCTION double E(double rr) const; + KOKKOS_INLINE_FUNCTION double T(double rr) const; + KOKKOS_INLINE_FUNCTION double E_prime(double rr) const; + KOKKOS_INLINE_FUNCTION double T_prime(double rr) const; + KOKKOS_INLINE_FUNCTION double P(double rr) const; + KOKKOS_INLINE_FUNCTION double dP(double rr) const; double rr; double dr; diff --git a/include/InputFunctions/DomainGeometry/culhamGeometry.inl b/include/InputFunctions/DomainGeometry/culhamGeometry.inl index 1def1f72..313cadca 100644 --- a/include/InputFunctions/DomainGeometry/culhamGeometry.inl +++ b/include/InputFunctions/DomainGeometry/culhamGeometry.inl @@ -3,7 +3,7 @@ #include "culhamGeometry.h" // In earlier versions denoted by 'x' -inline double CulhamGeometry::Fx(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::Fx(double r, double theta) const { double sin_theta = std::sin(theta); double cos_theta = std::cos(theta); @@ -13,7 +13,7 @@ inline double CulhamGeometry::Fx(double r, double theta) const } // In earlier versions denoted by 'y' -inline double CulhamGeometry::Fy(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::Fy(double r, double theta) const { double sin_theta = std::sin(theta); double cos_theta = std::cos(theta); @@ -23,7 +23,7 @@ inline double CulhamGeometry::Fy(double r, double theta) const } // In earlier versions denoted by 'Jrr' -inline double CulhamGeometry::dFx_dr(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::dFx_dr(double r, double theta) const { double sin_theta = std::sin(theta); double cos_theta = std::cos(theta); @@ -34,7 +34,7 @@ inline double CulhamGeometry::dFx_dr(double r, double theta) const } // In earlier versions denoted by 'Jtr' -inline double CulhamGeometry::dFy_dr(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::dFy_dr(double r, double theta) const { double sin_theta = std::sin(theta); double cos_theta = std::cos(theta); @@ -45,7 +45,7 @@ inline double CulhamGeometry::dFy_dr(double r, double theta) const } // In earlier versions denoted by 'Jrt' -inline double CulhamGeometry::dFx_dt(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::dFx_dt(double r, double theta) const { double sin_theta = std::sin(theta); double cos_theta = std::cos(theta); @@ -55,7 +55,7 @@ inline double CulhamGeometry::dFx_dt(double r, double theta) const } // In earlier versions denoted by 'Jtt' -inline double CulhamGeometry::dFy_dt(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::dFy_dt(double r, double theta) const { double sin_theta = std::sin(theta); double cos_theta = std::cos(theta); @@ -64,7 +64,7 @@ inline double CulhamGeometry::dFy_dt(double r, double theta) const 2.0 * T((r / Rmax)) * cos_two_theta; } -inline double CulhamGeometry::my_sum(std::array& f, int64_t start_idx, int64_t end_idx) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::my_sum(std::array& f, int64_t start_idx, int64_t end_idx) const { int64_t i; double result; @@ -75,27 +75,27 @@ inline double CulhamGeometry::my_sum(std::array& f, int64_t start_ return result; } -inline double CulhamGeometry::q(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::q(double rr) const { return 0.8 - 0.1 * (rr * rr); } -inline double CulhamGeometry::dq(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::dq(double rr) const { return (-0.2) * rr; } -inline double CulhamGeometry::p(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::p(double rr) const { return 100000.0 - 90000.0 * (rr * rr); } -inline double CulhamGeometry::dp(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::dp(double rr) const { return (-180000.0) * rr; } -inline double CulhamGeometry::dg(double rr, double g) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::dg(double rr, double g) const { return ((-g) * (0.0625000000000001 * (rr * rr) / pow((1.0 - 0.125 * (rr * rr)), 2.0) + 2.0 / (4.0 - 0.5 * (rr * rr))) + @@ -103,7 +103,7 @@ inline double CulhamGeometry::dg(double rr, double g) const (rr / (4.0 - 0.5 * (rr * rr)) + (4.0 - 0.5 * (rr * rr)) / (g * rr)); } -inline double CulhamGeometry::double_deriv(double rr, double c, double g, double dg, double val, double d_val) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::double_deriv(double rr, double c, double g, double dg, double val, double d_val) const { return c * val / (rr * rr) - d_val * (pow(rr, (double)((-1))) + (4.0 - 0.5 * (rr * rr)) * @@ -113,7 +113,7 @@ inline double CulhamGeometry::double_deriv(double rr, double c, double g, double (g * rr)); } -inline double CulhamGeometry::g(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::g(double rr) const { int64_t ri; double dr; @@ -131,7 +131,7 @@ inline double CulhamGeometry::g(double rr) const } } -inline double CulhamGeometry::Delta(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::Delta(double rr) const { int64_t ri; double dr; @@ -149,7 +149,7 @@ inline double CulhamGeometry::Delta(double rr) const } } -inline double CulhamGeometry::Delta_prime(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::Delta_prime(double rr) const { int64_t ri; double dr; @@ -167,7 +167,7 @@ inline double CulhamGeometry::Delta_prime(double rr) const } } -inline double CulhamGeometry::E(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::E(double rr) const { int64_t ri; double dr; @@ -185,7 +185,7 @@ inline double CulhamGeometry::E(double rr) const } } -inline double CulhamGeometry::T(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::T(double rr) const { int64_t ri; double dr; @@ -203,7 +203,7 @@ inline double CulhamGeometry::T(double rr) const } } -inline double CulhamGeometry::E_prime(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::E_prime(double rr) const { int64_t ri; double dr; @@ -221,7 +221,7 @@ inline double CulhamGeometry::E_prime(double rr) const } } -inline double CulhamGeometry::T_prime(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::T_prime(double rr) const { int64_t ri; double dr; @@ -239,7 +239,7 @@ inline double CulhamGeometry::T_prime(double rr) const } } -inline double CulhamGeometry::P(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::P(double rr) const { if (rr == 0) { return 0.0; @@ -249,7 +249,7 @@ inline double CulhamGeometry::P(double rr) const } } -inline double CulhamGeometry::dP(double rr) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::dP(double rr) const { if (rr == 0) { return 0.0; diff --git a/include/InputFunctions/DomainGeometry/czarnyGeometry.h b/include/InputFunctions/DomainGeometry/czarnyGeometry.h index 9cd3fd4f..e0e50003 100644 --- a/include/InputFunctions/DomainGeometry/czarnyGeometry.h +++ b/include/InputFunctions/DomainGeometry/czarnyGeometry.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "../domainGeometry.h" @@ -15,12 +16,12 @@ class CzarnyGeometry explicit CzarnyGeometry(); explicit CzarnyGeometry(double Rmax, double inverse_aspect_ratio_epsilon, double ellipticity_e); - double Fx(double r, double theta) const; - double Fy(double r, double theta) const; - double dFx_dr(double r, double theta) const; - double dFy_dr(double r, double theta) const; - double dFx_dt(double r, double theta) const; - double dFy_dt(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double Fx(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double Fy(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFx_dr(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFy_dr(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFx_dt(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFy_dt(double r, double theta) const; private: const double Rmax = 1.3; diff --git a/include/InputFunctions/DomainGeometry/czarnyGeometry.inl b/include/InputFunctions/DomainGeometry/czarnyGeometry.inl index 5556fcc8..3e71b6b3 100644 --- a/include/InputFunctions/DomainGeometry/czarnyGeometry.inl +++ b/include/InputFunctions/DomainGeometry/czarnyGeometry.inl @@ -3,7 +3,7 @@ #include "czarnyGeometry.h" // In earlier versions denoted by 'x' -inline double CzarnyGeometry::Fx(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CzarnyGeometry::Fx(double r, double theta) const { double cos_theta = std::cos(theta); return (1.0 - @@ -12,7 +12,7 @@ inline double CzarnyGeometry::Fx(double r, double theta) const } // In earlier versions denoted by 'y' -inline double CzarnyGeometry::Fy(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CzarnyGeometry::Fy(double r, double theta) const { double sin_theta = std::sin(theta); double cos_theta = std::cos(theta); @@ -22,7 +22,7 @@ inline double CzarnyGeometry::Fy(double r, double theta) const } // In earlier versions denoted by 'Jrr' -inline double CzarnyGeometry::dFx_dr(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CzarnyGeometry::dFx_dr(double r, double theta) const { double cos_theta = std::cos(theta); return -(cos_theta) / @@ -31,7 +31,7 @@ inline double CzarnyGeometry::dFx_dr(double r, double theta) const } // In earlier versions denoted by 'Jtr' -inline double CzarnyGeometry::dFy_dr(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CzarnyGeometry::dFy_dr(double r, double theta) const { double sin_theta = std::sin(theta); double cos_theta = std::cos(theta); @@ -43,7 +43,7 @@ inline double CzarnyGeometry::dFy_dr(double r, double theta) const } // In earlier versions denoted by 'Jrt' -inline double CzarnyGeometry::dFx_dt(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CzarnyGeometry::dFx_dt(double r, double theta) const { double sin_theta = std::sin(theta); double cos_theta = std::cos(theta); @@ -52,7 +52,7 @@ inline double CzarnyGeometry::dFx_dt(double r, double theta) const } // In earlier versions denoted by 'Jtt' -inline double CzarnyGeometry::dFy_dt(double r, double theta) const +KOKKOS_INLINE_FUNCTION double CzarnyGeometry::dFy_dt(double r, double theta) const { double sin_theta = std::sin(theta); double cos_theta = std::cos(theta); diff --git a/include/InputFunctions/DomainGeometry/shafranovGeometry.h b/include/InputFunctions/DomainGeometry/shafranovGeometry.h index cf87a15c..cd2a594d 100644 --- a/include/InputFunctions/DomainGeometry/shafranovGeometry.h +++ b/include/InputFunctions/DomainGeometry/shafranovGeometry.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "../domainGeometry.h" @@ -15,12 +16,12 @@ class ShafranovGeometry ShafranovGeometry() = default; explicit ShafranovGeometry(double Rmax, double elongation_kappa, double shift_delta); - double Fx(double r, double theta) const; - double Fy(double r, double theta) const; - double dFx_dr(double r, double theta) const; - double dFy_dr(double r, double theta) const; - double dFx_dt(double r, double theta) const; - double dFy_dt(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double Fx(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double Fy(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFx_dr(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFy_dr(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFx_dt(double r, double theta) const; + KOKKOS_INLINE_FUNCTION double dFy_dt(double r, double theta) const; private: const double Rmax = 1.3; diff --git a/include/InputFunctions/DomainGeometry/shafranovGeometry.inl b/include/InputFunctions/DomainGeometry/shafranovGeometry.inl index 690c4dca..e388ccfa 100644 --- a/include/InputFunctions/DomainGeometry/shafranovGeometry.inl +++ b/include/InputFunctions/DomainGeometry/shafranovGeometry.inl @@ -3,42 +3,42 @@ #include "shafranovGeometry.h" // In earlier versions denoted by 'x' -inline double ShafranovGeometry::Fx(double r, double theta) const +KOKKOS_INLINE_FUNCTION double ShafranovGeometry::Fx(double r, double theta) const { double cos_theta = std::cos(theta); return (1.0 - elongation_kappa) * (r / Rmax) * cos_theta - shift_delta * (r / Rmax) * (r / Rmax); } // In earlier versions denoted by 'y' -inline double ShafranovGeometry::Fy(double r, double theta) const +KOKKOS_INLINE_FUNCTION double ShafranovGeometry::Fy(double r, double theta) const { double sin_theta = std::sin(theta); return (1.0 + elongation_kappa) * (r / Rmax) * sin_theta; } // In earlier versions denoted by 'Jrr' -inline double ShafranovGeometry::dFx_dr(double r, double theta) const +KOKKOS_INLINE_FUNCTION double ShafranovGeometry::dFx_dr(double r, double theta) const { double cos_theta = std::cos(theta); return ((Rmax - elongation_kappa * Rmax) * cos_theta - 2.0 * shift_delta * r) / (Rmax * Rmax); } // In earlier versions denoted by 'Jtr' -inline double ShafranovGeometry::dFy_dr(double r, double theta) const +KOKKOS_INLINE_FUNCTION double ShafranovGeometry::dFy_dr(double r, double theta) const { double sin_theta = std::sin(theta); return (elongation_kappa + 1.0) * sin_theta / Rmax; } // In earlier versions denoted by 'Jrt' -inline double ShafranovGeometry::dFx_dt(double r, double theta) const +KOKKOS_INLINE_FUNCTION double ShafranovGeometry::dFx_dt(double r, double theta) const { double sin_theta = std::sin(theta); return ((elongation_kappa - 1.0) * r * sin_theta) / Rmax; } // In earlier versions denoted by 'Jtt' -inline double ShafranovGeometry::dFy_dt(double r, double theta) const +KOKKOS_INLINE_FUNCTION double ShafranovGeometry::dFy_dt(double r, double theta) const { double cos_theta = std::cos(theta); return ((elongation_kappa + 1.0) * r * cos_theta) / Rmax; diff --git a/include/Level/level.h b/include/Level/level.h index a791a7f1..105b6e2a 100644 --- a/include/Level/level.h +++ b/include/Level/level.h @@ -19,6 +19,8 @@ class ExtrapolatedSmoother; #include #include +#include + #include "../PolarGrid/polargrid.h" #include "../InputFunctions/boundaryConditions.h" @@ -153,7 +155,7 @@ class LevelCache ConstVector art() const; ConstVector detDF() const; - inline void obtainValues(const int i_r, const int i_theta, const int global_index, double r, double theta, + KOKKOS_INLINE_FUNCTION void obtainValues(const int i_r, const int i_theta, const int global_index, double r, double theta, double& coeff_beta, double& arr, double& att, double& art, double& detDF) const { coeff_beta = cache_density_profile_coefficients_ ? coeff_beta_[global_index] @@ -191,4 +193,4 @@ class LevelCache #include "levelCache.inl" #include "level.inl" -} // namespace gmgpolar \ No newline at end of file +} // namespace gmgpolar diff --git a/include/Residual/ResidualGive/applyAGive.inl b/include/Residual/ResidualGive/applyAGive.inl index 565f7288..c58c28b2 100644 --- a/include/Residual/ResidualGive/applyAGive.inl +++ b/include/Residual/ResidualGive/applyAGive.inl @@ -4,7 +4,7 @@ namespace residual_give { template -static inline void node_apply_a_give(int i_r, int i_theta, const PolarGrid& grid, const LevelCacheType& level_cache, +static KOKKOS_INLINE_FUNCTION void node_apply_a_give(int i_r, int i_theta, const PolarGrid& grid, const LevelCacheType& level_cache, bool DirBC_Interior, Vector& result, ConstVector& x) { /* ---------------------------------------- */ @@ -260,4 +260,4 @@ void ResidualGive::applySystemOperator(Vector result, Co Kokkos::fence(); } } -// clang-format on \ No newline at end of file +// clang-format on diff --git a/src/InputFunctions/DensityProfileCoefficients/CMakeLists.txt b/src/InputFunctions/DensityProfileCoefficients/CMakeLists.txt index 505bb9f8..0eef7d69 100644 --- a/src/InputFunctions/DensityProfileCoefficients/CMakeLists.txt +++ b/src/InputFunctions/DensityProfileCoefficients/CMakeLists.txt @@ -12,4 +12,5 @@ add_library(InputFunctions_DensityProfileCoefficients STATIC ${DENSITY_PROFILE_C target_include_directories(InputFunctions_DensityProfileCoefficients PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include/InputFunctions/DensityProfileCoefficients -) \ No newline at end of file +) +target_link_libraries(InputFunctions_DensityProfileCoefficients PUBLIC Kokkos::kokkos) diff --git a/src/InputFunctions/DensityProfileCoefficients/poissonCoefficients.cpp b/src/InputFunctions/DensityProfileCoefficients/poissonCoefficients.cpp index 94affce1..ab66832c 100644 --- a/src/InputFunctions/DensityProfileCoefficients/poissonCoefficients.cpp +++ b/src/InputFunctions/DensityProfileCoefficients/poissonCoefficients.cpp @@ -7,17 +7,17 @@ PoissonCoefficients::PoissonCoefficients(double Rmax, double alpha_jump) { } -double PoissonCoefficients::alpha(double r, double theta) const +KOKKOS_FUNCTION double PoissonCoefficients::alpha(double r, double theta) const { return 1.0; } -double PoissonCoefficients::beta(double r, double theta) const +KOKKOS_FUNCTION double PoissonCoefficients::beta(double r, double theta) const { return 0.0; } -double PoissonCoefficients::getAlphaJump() const +KOKKOS_FUNCTION double PoissonCoefficients::getAlphaJump() const { return alpha_jump; } diff --git a/src/InputFunctions/DensityProfileCoefficients/sonnendruckerCoefficients.cpp b/src/InputFunctions/DensityProfileCoefficients/sonnendruckerCoefficients.cpp index 2cc66f2d..a1b74f77 100644 --- a/src/InputFunctions/DensityProfileCoefficients/sonnendruckerCoefficients.cpp +++ b/src/InputFunctions/DensityProfileCoefficients/sonnendruckerCoefficients.cpp @@ -7,17 +7,17 @@ SonnendruckerCoefficients::SonnendruckerCoefficients(double Rmax, double alpha_j { } -double SonnendruckerCoefficients::alpha(double r, double theta) const +KOKKOS_FUNCTION double SonnendruckerCoefficients::alpha(double r, double theta) const { return 0.452961672473868 - 0.348432055749129 * atan(14.4444444444444 * (r / Rmax) - 11.1111111111111); } -double SonnendruckerCoefficients::beta(double r, double theta) const +KOKKOS_FUNCTION double SonnendruckerCoefficients::beta(double r, double theta) const { return 0.0; } -double SonnendruckerCoefficients::getAlphaJump() const +KOKKOS_FUNCTION double SonnendruckerCoefficients::getAlphaJump() const { return alpha_jump; } diff --git a/src/InputFunctions/DensityProfileCoefficients/sonnendruckerGyroCoefficients.cpp b/src/InputFunctions/DensityProfileCoefficients/sonnendruckerGyroCoefficients.cpp index 768bdac5..6b701c1f 100644 --- a/src/InputFunctions/DensityProfileCoefficients/sonnendruckerGyroCoefficients.cpp +++ b/src/InputFunctions/DensityProfileCoefficients/sonnendruckerGyroCoefficients.cpp @@ -7,18 +7,18 @@ SonnendruckerGyroCoefficients::SonnendruckerGyroCoefficients(double _Rmax, doubl { } -double SonnendruckerGyroCoefficients::alpha(double r, double theta) const +KOKKOS_FUNCTION double SonnendruckerGyroCoefficients::alpha(double r, double theta) const { return 0.452961672473868 - 0.348432055749129 * atan(14.4444444444444 * (r / Rmax) - 11.1111111111111); } -double SonnendruckerGyroCoefficients::beta(double r, double theta) const +KOKKOS_FUNCTION double SonnendruckerGyroCoefficients::beta(double r, double theta) const { return pow((0.452961672473868 - 0.348432055749129 * atan(14.4444444444444 * (r / Rmax) - 11.1111111111111)), (double)((-1))); } -double SonnendruckerGyroCoefficients::getAlphaJump() const +KOKKOS_FUNCTION double SonnendruckerGyroCoefficients::getAlphaJump() const { return alpha_jump; } diff --git a/src/InputFunctions/DensityProfileCoefficients/zoniCoefficients.cpp b/src/InputFunctions/DensityProfileCoefficients/zoniCoefficients.cpp index 3065415f..83b795ff 100644 --- a/src/InputFunctions/DensityProfileCoefficients/zoniCoefficients.cpp +++ b/src/InputFunctions/DensityProfileCoefficients/zoniCoefficients.cpp @@ -7,17 +7,17 @@ ZoniCoefficients::ZoniCoefficients(double Rmax, double alpha_jump) { } -double ZoniCoefficients::alpha(double r, double theta) const +KOKKOS_FUNCTION double ZoniCoefficients::alpha(double r, double theta) const { return exp(-tanh(10.0 * (r / Rmax) - 5.0)); } -double ZoniCoefficients::beta(double r, double theta) const +KOKKOS_FUNCTION double ZoniCoefficients::beta(double r, double theta) const { return 0.0; } -double ZoniCoefficients::getAlphaJump() const +KOKKOS_FUNCTION double ZoniCoefficients::getAlphaJump() const { return alpha_jump; } diff --git a/src/InputFunctions/DensityProfileCoefficients/zoniGyroCoefficients.cpp b/src/InputFunctions/DensityProfileCoefficients/zoniGyroCoefficients.cpp index aba20f60..52e12213 100644 --- a/src/InputFunctions/DensityProfileCoefficients/zoniGyroCoefficients.cpp +++ b/src/InputFunctions/DensityProfileCoefficients/zoniGyroCoefficients.cpp @@ -7,17 +7,17 @@ ZoniGyroCoefficients::ZoniGyroCoefficients(double Rmax, double alpha_jump) { } -double ZoniGyroCoefficients::alpha(double r, double theta) const +KOKKOS_FUNCTION double ZoniGyroCoefficients::alpha(double r, double theta) const { return exp(-tanh(10.0 * (r / Rmax) - 5.0)); } -double ZoniGyroCoefficients::beta(double r, double theta) const +KOKKOS_FUNCTION double ZoniGyroCoefficients::beta(double r, double theta) const { return exp(tanh(10.0 * (r / Rmax) - 5.0)); } -double ZoniGyroCoefficients::getAlphaJump() const +KOKKOS_FUNCTION double ZoniGyroCoefficients::getAlphaJump() const { return alpha_jump; } diff --git a/src/InputFunctions/DensityProfileCoefficients/zoniShiftedCoefficients.cpp b/src/InputFunctions/DensityProfileCoefficients/zoniShiftedCoefficients.cpp index 7d7a0607..1e63e4b7 100644 --- a/src/InputFunctions/DensityProfileCoefficients/zoniShiftedCoefficients.cpp +++ b/src/InputFunctions/DensityProfileCoefficients/zoniShiftedCoefficients.cpp @@ -7,17 +7,17 @@ ZoniShiftedCoefficients::ZoniShiftedCoefficients(double Rmax, double alpha_jump) { } -double ZoniShiftedCoefficients::alpha(double r, double theta) const +KOKKOS_FUNCTION double ZoniShiftedCoefficients::alpha(double r, double theta) const { return exp(-tanh(20.0 * (r / Rmax) - 14.0)); } -double ZoniShiftedCoefficients::beta(double r, double theta) const +KOKKOS_FUNCTION double ZoniShiftedCoefficients::beta(double r, double theta) const { return 0.0; } -double ZoniShiftedCoefficients::getAlphaJump() const +KOKKOS_FUNCTION double ZoniShiftedCoefficients::getAlphaJump() const { return alpha_jump; } diff --git a/src/InputFunctions/DensityProfileCoefficients/zoniShiftedGyroCoefficients.cpp b/src/InputFunctions/DensityProfileCoefficients/zoniShiftedGyroCoefficients.cpp index 1f3555a5..8fdb1388 100644 --- a/src/InputFunctions/DensityProfileCoefficients/zoniShiftedGyroCoefficients.cpp +++ b/src/InputFunctions/DensityProfileCoefficients/zoniShiftedGyroCoefficients.cpp @@ -7,17 +7,17 @@ ZoniShiftedGyroCoefficients::ZoniShiftedGyroCoefficients(double Rmax, double alp { } -double ZoniShiftedGyroCoefficients::alpha(double r, double theta) const +KOKKOS_FUNCTION double ZoniShiftedGyroCoefficients::alpha(double r, double theta) const { return exp(-tanh(20.0 * (r / Rmax) - 14.0)); } -double ZoniShiftedGyroCoefficients::beta(double r, double theta) const +KOKKOS_FUNCTION double ZoniShiftedGyroCoefficients::beta(double r, double theta) const { return exp(tanh(20.0 * (r / Rmax) - 14.0)); } -double ZoniShiftedGyroCoefficients::getAlphaJump() const +KOKKOS_FUNCTION double ZoniShiftedGyroCoefficients::getAlphaJump() const { return alpha_jump; } diff --git a/src/InputFunctions/DomainGeometry/CMakeLists.txt b/src/InputFunctions/DomainGeometry/CMakeLists.txt index 65b2c8b3..d83d211b 100644 --- a/src/InputFunctions/DomainGeometry/CMakeLists.txt +++ b/src/InputFunctions/DomainGeometry/CMakeLists.txt @@ -9,4 +9,5 @@ add_library(InputFunctions_DomainGeometry STATIC ${DOMAIN_GEOMETRY_SOURCES}) target_include_directories(InputFunctions_DomainGeometry PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include/InputFunctions/DomainGeometry -) \ No newline at end of file +) +target_link_libraries(InputFunctions_DomainGeometry PUBLIC Kokkos::kokkos) From 995020c4d2e5bc6d7f9bee0e3024e54a664bc262 Mon Sep 17 00:00:00 2001 From: BOURNE Emily EPFL Date: Tue, 12 May 2026 14:56:17 +0200 Subject: [PATCH 2/6] Run on host and add missing fences --- include/Residual/ResidualGive/applyAGive.inl | 7 +++---- include/Residual/ResidualGive/residualGive.inl | 5 +++-- include/Residual/ResidualTake/residualTake.inl | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/Residual/ResidualGive/applyAGive.inl b/include/Residual/ResidualGive/applyAGive.inl index c58c28b2..391584a1 100644 --- a/include/Residual/ResidualGive/applyAGive.inl +++ b/include/Residual/ResidualGive/applyAGive.inl @@ -1,5 +1,4 @@ #pragma once - namespace residual_give { @@ -217,7 +216,7 @@ void ResidualGive::applySystemOperator(Vector result, Co for (int start_circle = 0; start_circle < 3; ++start_circle) { const int num_circular_tasks = (num_circle_tasks - start_circle + 2) / 3; Kokkos::parallel_for( - "ResidualGive: ApplyA (Circular)", Kokkos::RangePolicy<>(0, num_circular_tasks), + "ResidualGive: ApplyA (Circular)", Kokkos::RangePolicy(0, num_circular_tasks), KOKKOS_LAMBDA(const int circle_task) { const int i_r = start_circle + circle_task * 3; for (int i_theta = 0; i_theta < grid.ntheta(); i_theta++) { @@ -239,7 +238,7 @@ void ResidualGive::applySystemOperator(Vector result, Co for (int i_theta = 0; i_theta < additional_radial_tasks; i_theta++) { Kokkos::parallel_for( - "ResidualGive: ApplyA (Radial, additional)", Kokkos::RangePolicy<>(0, 1), KOKKOS_LAMBDA(const int) { + "ResidualGive: ApplyA (Radial, additional)", Kokkos::RangePolicy(0, 1), KOKKOS_LAMBDA(const int) { for (int i_r = grid.numberSmootherCircles(); i_r < grid.nr(); i_r++) { node_apply_a_give(i_r, i_theta, grid, level_cache, DirBC_Interior, result, x); } @@ -250,7 +249,7 @@ void ResidualGive::applySystemOperator(Vector result, Co for (int start_radial = 0; start_radial < 3; ++start_radial) { const int num_radial_batches = (num_radial_tasks - start_radial + 2) / 3; Kokkos::parallel_for( - "ResidualGive: ApplyA (Radial)", Kokkos::RangePolicy<>(0, num_radial_batches), + "ResidualGive: ApplyA (Radial)", Kokkos::RangePolicy(0, num_radial_batches), KOKKOS_LAMBDA(const int radial_task) { const int i_theta = start_radial + radial_task * 3; for (int i_r = grid.numberSmootherCircles(); i_r < grid.nr(); i_r++) { diff --git a/include/Residual/ResidualGive/residualGive.inl b/include/Residual/ResidualGive/residualGive.inl index 122efdf1..4f769340 100644 --- a/include/Residual/ResidualGive/residualGive.inl +++ b/include/Residual/ResidualGive/residualGive.inl @@ -21,6 +21,7 @@ void ResidualGive::computeResidual(Vector result, ConstV const int n = result.size(); Kokkos::parallel_for( - "Residual Give: Subtract A*x from rhs", Kokkos::RangePolicy<>(0, n), + "Residual Give: Subtract A*x from rhs", Kokkos::RangePolicy(0, n), KOKKOS_LAMBDA(const int i) { result[i] = rhs[i] - result[i]; }); -} \ No newline at end of file + Kokkos::fence(); +} diff --git a/include/Residual/ResidualTake/residualTake.inl b/include/Residual/ResidualTake/residualTake.inl index 40e6dfa9..b9e98396 100644 --- a/include/Residual/ResidualTake/residualTake.inl +++ b/include/Residual/ResidualTake/residualTake.inl @@ -21,6 +21,7 @@ void ResidualTake::computeResidual(Vector result, ConstV const int n = result.size(); Kokkos::parallel_for( - "Residual Take: Subtract A*x from rhs", Kokkos::RangePolicy<>(0, n), + "Residual Take: Subtract A*x from rhs", Kokkos::RangePolicy(0, n), KOKKOS_LAMBDA(const int i) { result[i] = rhs[i] - result[i]; }); + Kokkos::fence(); } From ccfc1021e6aefa5b05b957c73bf6deb1a6763916 Mon Sep 17 00:00:00 2001 From: Emily Bourne Date: Tue, 12 May 2026 15:10:39 +0200 Subject: [PATCH 3/6] Clang formatting --- include/Definitions/geometry_helper.h | 5 +++-- .../InputFunctions/DomainGeometry/culhamGeometry.h | 3 ++- .../DomainGeometry/culhamGeometry.inl | 6 ++++-- include/Level/level.h | 5 +++-- include/Residual/ResidualGive/applyAGive.inl | 14 +++++++++----- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/Definitions/geometry_helper.h b/include/Definitions/geometry_helper.h index 61f961ad..b3c645a7 100644 --- a/include/Definitions/geometry_helper.h +++ b/include/Definitions/geometry_helper.h @@ -7,8 +7,9 @@ #include template -KOKKOS_INLINE_FUNCTION void compute_jacobian_elements(const DomainGeometry& domain_geometry, double r, double theta, double coeff_alpha, - double& arr, double& att, double& art, double& detDF) +KOKKOS_INLINE_FUNCTION void compute_jacobian_elements(const DomainGeometry& domain_geometry, double r, double theta, + double coeff_alpha, double& arr, double& att, double& art, + double& detDF) { /* Calculate the elements of the Jacobian matrix for the transformation mapping */ /* The Jacobian matrix is: */ diff --git a/include/InputFunctions/DomainGeometry/culhamGeometry.h b/include/InputFunctions/DomainGeometry/culhamGeometry.h index 575eb06e..48005f18 100644 --- a/include/InputFunctions/DomainGeometry/culhamGeometry.h +++ b/include/InputFunctions/DomainGeometry/culhamGeometry.h @@ -35,7 +35,8 @@ class CulhamGeometry KOKKOS_INLINE_FUNCTION double p(double rr) const; KOKKOS_INLINE_FUNCTION double dp(double rr) const; KOKKOS_INLINE_FUNCTION double dg(double rr, double g) const; - KOKKOS_INLINE_FUNCTION double double_deriv(double rr, double c, double g, double dg, double val, double d_val) const; + KOKKOS_INLINE_FUNCTION double double_deriv(double rr, double c, double g, double dg, double val, + double d_val) const; KOKKOS_INLINE_FUNCTION double g(double rr) const; KOKKOS_INLINE_FUNCTION double Delta(double rr) const; KOKKOS_INLINE_FUNCTION double Delta_prime(double rr) const; diff --git a/include/InputFunctions/DomainGeometry/culhamGeometry.inl b/include/InputFunctions/DomainGeometry/culhamGeometry.inl index 313cadca..6f629573 100644 --- a/include/InputFunctions/DomainGeometry/culhamGeometry.inl +++ b/include/InputFunctions/DomainGeometry/culhamGeometry.inl @@ -64,7 +64,8 @@ KOKKOS_INLINE_FUNCTION double CulhamGeometry::dFy_dt(double r, double theta) con 2.0 * T((r / Rmax)) * cos_two_theta; } -KOKKOS_INLINE_FUNCTION double CulhamGeometry::my_sum(std::array& f, int64_t start_idx, int64_t end_idx) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::my_sum(std::array& f, int64_t start_idx, + int64_t end_idx) const { int64_t i; double result; @@ -103,7 +104,8 @@ KOKKOS_INLINE_FUNCTION double CulhamGeometry::dg(double rr, double g) const (rr / (4.0 - 0.5 * (rr * rr)) + (4.0 - 0.5 * (rr * rr)) / (g * rr)); } -KOKKOS_INLINE_FUNCTION double CulhamGeometry::double_deriv(double rr, double c, double g, double dg, double val, double d_val) const +KOKKOS_INLINE_FUNCTION double CulhamGeometry::double_deriv(double rr, double c, double g, double dg, double val, + double d_val) const { return c * val / (rr * rr) - d_val * (pow(rr, (double)((-1))) + (4.0 - 0.5 * (rr * rr)) * diff --git a/include/Level/level.h b/include/Level/level.h index 105b6e2a..9c1dd32f 100644 --- a/include/Level/level.h +++ b/include/Level/level.h @@ -155,8 +155,9 @@ class LevelCache ConstVector art() const; ConstVector detDF() const; - KOKKOS_INLINE_FUNCTION void obtainValues(const int i_r, const int i_theta, const int global_index, double r, double theta, - double& coeff_beta, double& arr, double& att, double& art, double& detDF) const + KOKKOS_INLINE_FUNCTION void obtainValues(const int i_r, const int i_theta, const int global_index, double r, + double theta, double& coeff_beta, double& arr, double& att, double& art, + double& detDF) const { coeff_beta = cache_density_profile_coefficients_ ? coeff_beta_[global_index] : density_profile_coefficients_.beta(r, theta); diff --git a/include/Residual/ResidualGive/applyAGive.inl b/include/Residual/ResidualGive/applyAGive.inl index 391584a1..72a1d09e 100644 --- a/include/Residual/ResidualGive/applyAGive.inl +++ b/include/Residual/ResidualGive/applyAGive.inl @@ -3,8 +3,9 @@ namespace residual_give { template -static KOKKOS_INLINE_FUNCTION void node_apply_a_give(int i_r, int i_theta, const PolarGrid& grid, const LevelCacheType& level_cache, - bool DirBC_Interior, Vector& result, ConstVector& x) +static KOKKOS_INLINE_FUNCTION void node_apply_a_give(int i_r, int i_theta, const PolarGrid& grid, + const LevelCacheType& level_cache, bool DirBC_Interior, + Vector& result, ConstVector& x) { /* ---------------------------------------- */ /* Compute or retrieve stencil coefficients */ @@ -216,7 +217,8 @@ void ResidualGive::applySystemOperator(Vector result, Co for (int start_circle = 0; start_circle < 3; ++start_circle) { const int num_circular_tasks = (num_circle_tasks - start_circle + 2) / 3; Kokkos::parallel_for( - "ResidualGive: ApplyA (Circular)", Kokkos::RangePolicy(0, num_circular_tasks), + "ResidualGive: ApplyA (Circular)", + Kokkos::RangePolicy(0, num_circular_tasks), KOKKOS_LAMBDA(const int circle_task) { const int i_r = start_circle + circle_task * 3; for (int i_theta = 0; i_theta < grid.ntheta(); i_theta++) { @@ -238,7 +240,8 @@ void ResidualGive::applySystemOperator(Vector result, Co for (int i_theta = 0; i_theta < additional_radial_tasks; i_theta++) { Kokkos::parallel_for( - "ResidualGive: ApplyA (Radial, additional)", Kokkos::RangePolicy(0, 1), KOKKOS_LAMBDA(const int) { + "ResidualGive: ApplyA (Radial, additional)", Kokkos::RangePolicy(0, 1), + KOKKOS_LAMBDA(const int) { for (int i_r = grid.numberSmootherCircles(); i_r < grid.nr(); i_r++) { node_apply_a_give(i_r, i_theta, grid, level_cache, DirBC_Interior, result, x); } @@ -249,7 +252,8 @@ void ResidualGive::applySystemOperator(Vector result, Co for (int start_radial = 0; start_radial < 3; ++start_radial) { const int num_radial_batches = (num_radial_tasks - start_radial + 2) / 3; Kokkos::parallel_for( - "ResidualGive: ApplyA (Radial)", Kokkos::RangePolicy(0, num_radial_batches), + "ResidualGive: ApplyA (Radial)", + Kokkos::RangePolicy(0, num_radial_batches), KOKKOS_LAMBDA(const int radial_task) { const int i_theta = start_radial + radial_task * 3; for (int i_r = grid.numberSmootherCircles(); i_r < grid.nr(); i_r++) { From 89d7971e1744dd97d91b34e571ccd1259583fb38 Mon Sep 17 00:00:00 2001 From: Julian Litz <91479202+julianlitz@users.noreply.github.com> Date: Tue, 12 May 2026 17:56:28 +0200 Subject: [PATCH 4/6] Update residualGive.inl --- include/Residual/ResidualGive/residualGive.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Residual/ResidualGive/residualGive.inl b/include/Residual/ResidualGive/residualGive.inl index 4f769340..00313f26 100644 --- a/include/Residual/ResidualGive/residualGive.inl +++ b/include/Residual/ResidualGive/residualGive.inl @@ -23,5 +23,6 @@ void ResidualGive::computeResidual(Vector result, ConstV Kokkos::parallel_for( "Residual Give: Subtract A*x from rhs", Kokkos::RangePolicy(0, n), KOKKOS_LAMBDA(const int i) { result[i] = rhs[i] - result[i]; }); + Kokkos::fence(); } From 95a89ed97081143ffe0884bb2b7b57b3547f3a30 Mon Sep 17 00:00:00 2001 From: Julian Litz <91479202+julianlitz@users.noreply.github.com> Date: Tue, 12 May 2026 17:56:45 +0200 Subject: [PATCH 5/6] Update residualTake.inl --- include/Residual/ResidualTake/residualTake.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Residual/ResidualTake/residualTake.inl b/include/Residual/ResidualTake/residualTake.inl index b9e98396..df6bc7d3 100644 --- a/include/Residual/ResidualTake/residualTake.inl +++ b/include/Residual/ResidualTake/residualTake.inl @@ -23,5 +23,6 @@ void ResidualTake::computeResidual(Vector result, ConstV Kokkos::parallel_for( "Residual Take: Subtract A*x from rhs", Kokkos::RangePolicy(0, n), KOKKOS_LAMBDA(const int i) { result[i] = rhs[i] - result[i]; }); + Kokkos::fence(); } From 761863a0a39b74c9d5feef922ee713e0dbcf711b Mon Sep 17 00:00:00 2001 From: Julian Litz <91479202+julianlitz@users.noreply.github.com> Date: Tue, 12 May 2026 21:13:11 +0200 Subject: [PATCH 6/6] Adjust i_theta calculation for radial tasks --- include/Residual/ResidualGive/applyAGive.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Residual/ResidualGive/applyAGive.inl b/include/Residual/ResidualGive/applyAGive.inl index 72a1d09e..08c26658 100644 --- a/include/Residual/ResidualGive/applyAGive.inl +++ b/include/Residual/ResidualGive/applyAGive.inl @@ -255,7 +255,7 @@ void ResidualGive::applySystemOperator(Vector result, Co "ResidualGive: ApplyA (Radial)", Kokkos::RangePolicy(0, num_radial_batches), KOKKOS_LAMBDA(const int radial_task) { - const int i_theta = start_radial + radial_task * 3; + const int i_theta = additional_radial_tasks + start_radial + radial_task * 3; for (int i_r = grid.numberSmootherCircles(); i_r < grid.nr(); i_r++) { node_apply_a_give(i_r, i_theta, grid, level_cache, DirBC_Interior, result, x); }