diff options
author | 2023-04-20 18:56:20 +0200 | |
---|---|---|
committer | 2023-04-20 09:56:20 -0700 | |
commit | 7771d25e8cb7ec8115c4e0cec24eee13a5bf9032 (patch) | |
tree | dc0fd88c71dc33645163f07df0138363e88d2ad7 /Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp | |
parent | 18e9ca3fd9e55651a39cc54d9fc31a8300756021 (diff) | |
download | WarpX-7771d25e8cb7ec8115c4e0cec24eee13a5bf9032.tar.gz WarpX-7771d25e8cb7ec8115c4e0cec24eee13a5bf9032.tar.zst WarpX-7771d25e8cb7ec8115c4e0cec24eee13a5bf9032.zip |
Use amrex::Math::powi<N>(x) in WarpX (#3846)
* use_powi
* fix bug
* fix bug
* fix bug
* fix bug
Diffstat (limited to 'Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp')
-rw-r--r-- | Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp index 8c28c42b2..ae1cf65eb 100644 --- a/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp +++ b/Source/FieldSolver/SpectralSolver/SpectralAlgorithms/PsatdAlgorithmJConstantInTime.cpp @@ -19,6 +19,7 @@ #include <AMReX_GpuLaunch.H> #include <AMReX_GpuQualifiers.H> #include <AMReX_IntVect.H> +#include <AMReX_Math.H> #include <AMReX_MFIter.H> #include <AMReX_PODVector.H> @@ -405,19 +406,19 @@ void PsatdAlgorithmJConstantInTime::InitializeSpectralCoefficients ( { // Calculate norm of k vector const amrex::Real knorm_s = std::sqrt( - std::pow(kx_s[i], 2) + + amrex::Math::powi<2>(kx_s[i]) + #if defined(WARPX_DIM_3D) - std::pow(ky_s[j], 2) + std::pow(kz_s[k], 2)); + amrex::Math::powi<2>(ky_s[j]) + amrex::Math::powi<2>(kz_s[k])); #else - std::pow(kz_s[j], 2)); + amrex::Math::powi<2>(kz_s[j])); #endif // Physical constants and imaginary unit constexpr amrex::Real c = PhysConst::c; constexpr amrex::Real ep0 = PhysConst::ep0; constexpr Complex I = Complex{0._rt, 1._rt}; - const amrex::Real c2 = std::pow(c, 2); - const amrex::Real dt2 = std::pow(dt, 2); + const amrex::Real c2 = amrex::Math::powi<2>(c); + const amrex::Real dt2 = amrex::Math::powi<2>(dt); // Calculate the dot product of the k vector with the Galilean velocity. // This has to be computed always with the centered (collocated) finite-order @@ -429,10 +430,10 @@ void PsatdAlgorithmJConstantInTime::InitializeSpectralCoefficients ( #else kz_c[j]*vg_z; #endif - const amrex::Real w2_c = std::pow(w_c, 2); + const amrex::Real w2_c = amrex::Math::powi<2>(w_c); const amrex::Real om_s = c * knorm_s; - const amrex::Real om2_s = std::pow(om_s, 2); + const amrex::Real om2_s = amrex::Math::powi<2>(om_s); const Complex theta_c = amrex::exp( I * w_c * dt * 0.5_rt); const Complex theta2_c = amrex::exp( I * w_c * dt); @@ -566,19 +567,19 @@ void PsatdAlgorithmJConstantInTime::InitializeSpectralCoefficientsAveraging ( { // Calculate norm of k vector const amrex::Real knorm_s = std::sqrt( - std::pow(kx_s[i], 2) + + amrex::Math::powi<2>(kx_s[i]) + #if defined(WARPX_DIM_3D) - std::pow(ky_s[j], 2) + std::pow(kz_s[k], 2)); + amrex::Math::powi<2>(ky_s[j]) + amrex::Math::powi<2>(kz_s[k])); #else - std::pow(kz_s[j], 2)); + amrex::Math::powi<2>(kz_s[j])); #endif // Physical constants and imaginary unit constexpr amrex::Real c = PhysConst::c; constexpr amrex::Real ep0 = PhysConst::ep0; constexpr Complex I = Complex{0._rt, 1._rt}; - const amrex::Real c2 = std::pow(c, 2); - const amrex::Real dt2 = std::pow(dt, 2); + const amrex::Real c2 = amrex::Math::powi<2>(c); + const amrex::Real dt2 = amrex::Math::powi<2>(dt); // Calculate the dot product of the k vector with the Galilean velocity. // This has to be computed always with the centered (collocated) finite-order @@ -590,12 +591,12 @@ void PsatdAlgorithmJConstantInTime::InitializeSpectralCoefficientsAveraging ( #else kz_c[j]*vg_z; #endif - const amrex::Real w2_c = std::pow(w_c, 2); - const amrex::Real w3_c = std::pow(w_c, 3); + const amrex::Real w2_c = amrex::Math::powi<2>(w_c); + const amrex::Real w3_c = amrex::Math::powi<3>(w_c); const amrex::Real om_s = c * knorm_s; - const amrex::Real om2_s = std::pow(om_s, 2); - const amrex::Real om4_s = std::pow(om_s, 4); + const amrex::Real om2_s = amrex::Math::powi<2>(om_s); + const amrex::Real om4_s = amrex::Math::powi<4>(om_s); const Complex theta_c = amrex::exp(I * w_c * dt * 0.5_rt); const Complex theta2_c = amrex::exp(I * w_c * dt); |