10#ifndef IMPACTX_ELEMENTS_MIXIN_BEAMOPTIC_H
11#define IMPACTX_ELEMENTS_MIXIN_BEAMOPTIC_H
35 template <
typename T_Element,
typename F>
65 template <
typename T,
typename IndexType>
69 if constexpr (std::is_integral_v<IndexType>) {
76 using DataType = std::conditional_t<
77 std::is_same_v<T, amrex::ParticleReal>,
87 val.copy_from(&ptr[i.index], stdx::element_aligned);
121 template <auto P_Method,
int N,
typename T,
typename IndexType,
typename ValType>
130 if constexpr (!std::is_integral_v<IndexType>) {
136 val.copy_to(&ptr[i.index], amrex::simd::stdx::element_aligned);
156 template <
typename T_Element>
210 template <
typename IndexType>
231 m_element.spin_and_phasespace_push(x, y,
t, px, py, pt, sx, sy, sz, idcpu,
m_ref_part);
237 using RealType = std::decay_t<
decltype(x)>;
238 using IdCpuType = std::decay_t<
decltype(idcpu)>;
239 constexpr auto P_Method = &T_Element::template spin_and_phasespace_push<RealType, IdCpuType>;
283 template <
typename T_Element>
330 template <
typename IndexType>
354 using RealType = std::decay_t<
decltype(x)>;
355 using IdCpuType = std::decay_t<
decltype(idcpu)>;
356 constexpr auto P_Method = &T_Element::template operator()<RealType, IdCpuType>;
383 template<
typename T_Element >
394 auto& soa_real = soa.GetRealData();
402 uint64_t*
const AMREX_RESTRICT part_idcpu = soa.GetIdCPUData().dataPtr();
405 if constexpr (std::is_base_of_v<mixin::SpinTransport, std::decay_t<T_Element>>) {
411 element, part_x, part_y, part_t, part_px, part_py, part_pt, part_sx, part_sy, part_sz, part_idcpu, ref_part);
416 throw std::runtime_error(
"Spin transport requested but element does not implement the `SpinTransport` interface class!");
421 element, part_x, part_y, part_t, part_px, part_py, part_pt, part_idcpu, ref_part);
434 template<
typename T_Element>
450 std::is_base_of_v<BeamOptic, T_Element>,
451 "BeamOptic can only be used as a mixin class!"
454 T_Element& element = *
static_cast<T_Element*
>(
this);
455 push_all(pc, element, step, period);
473 std::is_base_of_v<BeamOptic, T_Element>,
474 "BeamOptic can only be used as a mixin class!"
477 T_Element& element = *
static_cast<T_Element*
>(
this);
#define AMREX_FORCE_INLINE
auto numParticles() const
SoARef GetStructOfArrays() const
T_ParticleType ParticleType
Definition ImpactXParticleContainer.H:136
impactx::ParIterSoA iterator
amrex iterator for particle boxes
Definition ImpactXParticleContainer.H:139
amrex_particle_real ParticleReal
constexpr bool is_vectorized
constexpr bool is_nth_arg_non_const(R(*)(Args...), int n)
amrex::ParticleReal SIMDParticleReal
__host__ __device__ void ignore_unused(const Ts &...)
std::enable_if_t< std::is_integral_v< T > > ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
void ParallelForSIMD(N n, L const &f) noexcept
IndexTypeND< 3 > IndexType
void Abort(const std::string &msg)
AMREX_GPU_DEVICE AMREX_FORCE_INLINE decltype(auto) load_pdata(T *ptr, IndexType const i)
Definition beamoptic.H:67
void push_all_particles(ImpactXParticleContainer::iterator &pti, RefPart &AMREX_RESTRICT ref_part, T_Element &element, bool spin)
Definition beamoptic.H:384
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void store_pdata(ValType const &AMREX_RESTRICT val, T *const AMREX_RESTRICT ptr, IndexType const i)
Definition beamoptic.H:123
Definition alignment.H:23
Definition CovarianceMatrixMath.H:25
@ t
fixed t as the independent variable
Definition ImpactXParticleContainer.H:38
void ParallelFor(int n, F &&f)
Definition beamoptic.H:36
void push_all(ImpactXParticleContainer &pc, T_Element &element, int step, int period, bool omp_parallel=true)
Definition PushAll.H:33
@ nattribs
the number of attributes above (always last)
Definition ImpactXParticleContainer.H:83
@ pt
energy deviation, scaled by speed of light * the magnitude of the reference momentum [unitless] (at f...
Definition ImpactXParticleContainer.H:53
@ y
position in y [m] (at fixed s or t)
Definition ImpactXParticleContainer.H:49
@ t
time-of-flight ct [m] (at fixed s)
Definition ImpactXParticleContainer.H:50
@ sz
spin vector z-component [unitless] (at fixed s or t)
Definition ImpactXParticleContainer.H:56
@ sy
spin vector y-component [unitless] (at fixed s or t)
Definition ImpactXParticleContainer.H:55
@ px
momentum in x, scaled by the magnitude of the reference momentum [unitless] (at fixed s or t)
Definition ImpactXParticleContainer.H:51
@ sx
spin vector x-component [unitless] (at fixed s or t)
Definition ImpactXParticleContainer.H:54
@ nattribs
the number of attributes above (always last)
Definition ImpactXParticleContainer.H:59
@ py
momentum in y, scaled by the magnitude of the reference momentum [unitless] (at fixed s or t)
Definition ImpactXParticleContainer.H:52
@ x
position in x [m] (at fixed s or t)
Definition ImpactXParticleContainer.H:48
Definition ReferenceParticle.H:33
Definition beamoptic.H:436
void operator()(ImpactXParticleContainer &pc, int step, int period)
Definition beamoptic.H:443
Definition beamoptic.H:285
amrex::ParticleReal *const AMREX_RESTRICT m_part_px
Definition beamoptic.H:374
amrex::ParticleReal *const AMREX_RESTRICT m_part_t
Definition beamoptic.H:373
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void operator()(IndexType i) const
Definition beamoptic.H:333
T_Element m_element
Definition beamoptic.H:370
amrex::ParticleReal *const AMREX_RESTRICT m_part_pt
Definition beamoptic.H:376
PushSingleParticle(PushSingleParticle &&)=default
uint64_t *const AMREX_RESTRICT m_part_idcpu
Definition beamoptic.H:377
amrex::ParticleReal *const AMREX_RESTRICT m_part_x
Definition beamoptic.H:371
amrex::ParticleReal *const AMREX_RESTRICT m_part_y
Definition beamoptic.H:372
PushSingleParticle(T_Element element, amrex::ParticleReal *AMREX_RESTRICT part_x, amrex::ParticleReal *AMREX_RESTRICT part_y, amrex::ParticleReal *AMREX_RESTRICT part_t, amrex::ParticleReal *AMREX_RESTRICT part_px, amrex::ParticleReal *AMREX_RESTRICT part_py, amrex::ParticleReal *AMREX_RESTRICT part_pt, uint64_t *AMREX_RESTRICT part_idcpu, RefPart ref_part)
Definition beamoptic.H:301
amrex::ParticleTile< amrex::SoAParticle< RealSoA::nattribs, IntSoA::nattribs >, RealSoA::nattribs, IntSoA::nattribs > ParticleTileType
Definition beamoptic.H:287
amrex::ParticleReal *const AMREX_RESTRICT m_part_py
Definition beamoptic.H:375
ImpactXParticleContainer::ParticleType PType
Definition beamoptic.H:286
PushSingleParticle()=delete
~PushSingleParticle()=default
RefPart m_ref_part
Definition beamoptic.H:378
PushSingleParticle(PushSingleParticle const &)=default
Definition beamoptic.H:158
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void operator()(IndexType i) const
Definition beamoptic.H:213
PushSingleParticleSpin(T_Element element, amrex::ParticleReal *AMREX_RESTRICT part_x, amrex::ParticleReal *AMREX_RESTRICT part_y, amrex::ParticleReal *AMREX_RESTRICT part_t, amrex::ParticleReal *AMREX_RESTRICT part_px, amrex::ParticleReal *AMREX_RESTRICT part_py, amrex::ParticleReal *AMREX_RESTRICT part_pt, amrex::ParticleReal *AMREX_RESTRICT part_sx, amrex::ParticleReal *AMREX_RESTRICT part_sy, amrex::ParticleReal *AMREX_RESTRICT part_sz, uint64_t *AMREX_RESTRICT part_idcpu, RefPart ref_part)
Definition beamoptic.H:177
amrex::ParticleReal *const AMREX_RESTRICT m_part_x
Definition beamoptic.H:257
T_Element m_element
Definition beamoptic.H:256
amrex::ParticleReal *const AMREX_RESTRICT m_part_sz
Definition beamoptic.H:265
amrex::ParticleReal *const AMREX_RESTRICT m_part_t
Definition beamoptic.H:259
amrex::ParticleReal *const AMREX_RESTRICT m_part_px
Definition beamoptic.H:260
~PushSingleParticleSpin()=default
RefPart m_ref_part
Definition beamoptic.H:267
amrex::ParticleReal *const AMREX_RESTRICT m_part_sy
Definition beamoptic.H:264
amrex::ParticleReal *const AMREX_RESTRICT m_part_y
Definition beamoptic.H:258
PushSingleParticleSpin(PushSingleParticleSpin const &)=default
PushSingleParticleSpin(PushSingleParticleSpin &&)=default
PushSingleParticleSpin()=delete
amrex::ParticleTile< amrex::SoAParticle< RealSoA::nattribs, IntSoA::nattribs >, RealSoA::nattribs, IntSoA::nattribs > ParticleTileType
Definition beamoptic.H:160
ImpactXParticleContainer::ParticleType PType
Definition beamoptic.H:159
uint64_t *const AMREX_RESTRICT m_part_idcpu
Definition beamoptic.H:266
amrex::ParticleReal *const AMREX_RESTRICT m_part_py
Definition beamoptic.H:261
amrex::ParticleReal *const AMREX_RESTRICT m_part_sx
Definition beamoptic.H:263
amrex::ParticleReal *const AMREX_RESTRICT m_part_pt
Definition beamoptic.H:262