Skip to content

Commit 2c49d00

Browse files
cemitch99ax3l
andauthored
Apply suggestions from code review
Co-authored-by: Axel Huebl <[email protected]>
1 parent 5b8689a commit 2c49d00

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/elements/Quad.H

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,7 @@ namespace impactx::elements
340340
amrex::ParticleReal const omega = std::sqrt(std::abs(m_k));
341341

342342
// compute trigonometric quantities
343-
amrex::ParticleReal const sin_omega_ds = std::sin(omega*slice_ds);
344-
amrex::ParticleReal const cos_omega_ds = std::cos(omega*slice_ds);
343+
auto const [sin_omega_ds, cos_omega_ds] = amrex::Math::sincos(omega*slice_ds);
345344
amrex::ParticleReal const sinh_omega_ds = std::sinh(omega*slice_ds);
346345
amrex::ParticleReal const cosh_omega_ds = std::cosh(omega*slice_ds);
347346

src/elements/mixin/spintransport.H

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#include <AMReX_Extension.H>
1919
#include <AMReX_REAL.H>
2020

21+
#include <cmath>
22+
23+
2124
namespace impactx::elements::mixin
2225
{
2326
/** This is a helper class for applying a spin map generated by a three-component vector
@@ -35,22 +38,22 @@ namespace impactx::elements::mixin
3538
* @param[inout] sy spin vector y-component
3639
* @param[inout] sz spin vector z-component
3740
*/
38-
template<typename T_Real>
41+
template<typename T_Real=amrex::ParticleReal>
3942
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
4043
void rotate_spin (
41-
amrex::ParticleReal lambdax,
42-
amrex::ParticleReal lambday,
43-
amrex::ParticleReal lambdaz,
44-
amrex::ParticleReal sx,
45-
amrex::ParticleReal sy,
46-
amrex::ParticleReal sz
44+
T_Real lambdax,
45+
T_Real lambday,
46+
T_Real lambdaz,
47+
T_Real & AMREX_RESTRICT sx,
48+
T_Real & AMREX_RESTRICT sy,
49+
T_Real & AMREX_RESTRICT sz
4750
) const
4851
{
4952
using namespace amrex::literals; // for _prt
5053

5154
// Compute quaternion coefficients
5255
amrex::ParticleReal angle = std::sqrt(lambdax*lambdax+lambday*lambday+lambdaz*lambdaz);
53-
auto const [sin_half_angle, cos_half_angle] = amrex::Math::sincos(angle/2_prt);
56+
auto const [sin_half_angle, cos_half_angle] = amrex::Math::sincos(angle*0.5_prt);
5457
amrex::ParticleReal w0 = cos_half_angle;
5558
amrex::ParticleReal w1 = (angle==0_prt) ? 0_prt : -(lambdax/angle)*sin_half_angle;
5659
amrex::ParticleReal w2 = (angle==0_prt) ? 0_prt : -(lambday/angle)*sin_half_angle;

0 commit comments

Comments
 (0)