10#ifndef IMPACTX_ELEMENTS_MIXIN_BEAMOPTIC_H
11#define IMPACTX_ELEMENTS_MIXIN_BEAMOPTIC_H
37 template <
typename T_Element,
typename F>
67 template <
typename T,
typename IndexType>
71 if constexpr (std::is_integral_v<IndexType>) {
78 using DataType = std::conditional_t<
79 std::is_same_v<T, amrex::ParticleReal>,
89 val.copy_from(&ptr[i.index], stdx::element_aligned);
130 template <
auto P_Method,
int N,
bool ForceWriteback =
false,
131 typename T,
typename IndexType,
typename ValType>
140 if constexpr (!std::is_integral_v<IndexType>) {
146 val.copy_to(&ptr[i.index], amrex::simd::stdx::element_aligned);
167 template <
typename T_Element,
bool T_DoAlignment>
221 template <
typename IndexType>
242 constexpr bool has_alignment = std::is_base_of_v<mixin::Alignment, T_Element> && T_DoAlignment;
243 constexpr bool has_aperture = std::is_base_of_v<mixin::PipeAperture, T_Element>;
246 if constexpr (has_alignment) {
252 m_element.spin_and_phasespace_push(x, y,
t, px, py, pt, sx, sy, sz, idcpu,
m_ref_part);
255 if constexpr (has_aperture) {
260 if constexpr (has_alignment) {
269 using RealType = std::decay_t<
decltype(x)>;
270 using IdCpuType = std::decay_t<
decltype(idcpu)>;
271 constexpr auto P_Method = &T_Element::template spin_and_phasespace_push<RealType, IdCpuType>;
277 constexpr bool wb_align = has_alignment;
278 constexpr bool wb_aperture = has_aperture;
323 template <
typename T_Element,
bool T_DoAlignment>
370 template <
typename IndexType>
388 constexpr bool has_alignment = std::is_base_of_v<mixin::Alignment, T_Element> && T_DoAlignment;
389 constexpr bool has_aperture = std::is_base_of_v<mixin::PipeAperture, T_Element>;
392 if constexpr (has_alignment) {
400 if constexpr (has_aperture) {
405 if constexpr (has_alignment) {
413 using RealType = std::decay_t<
decltype(x)>;
414 using IdCpuType = std::decay_t<
decltype(idcpu)>;
415 constexpr auto P_Method = &T_Element::template operator()<RealType, IdCpuType>;
420 constexpr bool wb_align = has_alignment;
421 constexpr bool wb_aperture = has_aperture;
456 template<
typename T_Element,
typename F >
459 if constexpr (std::is_base_of_v<mixin::Alignment, std::decay_t<T_Element>>) {
460#ifdef ImpactX_OPTIMIZE_ALIGNMENT
461 if (element.misaligned()) { f(std::true_type{}); }
462 else { f(std::false_type{}); }
468 f(std::false_type{});
474 template<
typename T_Element >
485 auto& soa_real = soa.GetRealData();
493 uint64_t*
const AMREX_RESTRICT part_idcpu = soa.GetIdCPUData().dataPtr();
496 if constexpr (std::is_base_of_v<mixin::SpinTransport, std::decay_t<T_Element>>) {
504 element, part_x, part_y, part_t, part_px, part_py, part_pt, part_sx, part_sy, part_sz, part_idcpu, ref_part);
508 throw std::runtime_error(
"Spin transport requested but element does not implement the `SpinTransport` interface class!");
515 element, part_x, part_y, part_t, part_px, part_py, part_pt, part_idcpu, ref_part);
527 template<
typename T_Element>
543 std::is_base_of_v<BeamOptic, T_Element>,
544 "BeamOptic can only be used as a mixin class!"
547 T_Element& element = *
static_cast<T_Element*
>(
this);
548 push_all(pc, element, step, period);
566 std::is_base_of_v<BeamOptic, T_Element>,
567 "BeamOptic can only be used as a mixin class!"
570 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 &...)
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
IndexTypeND< 3 > IndexType
void ParallelForSIMD(N n, L const &f) noexcept
void Abort(const std::string &msg)
AMREX_GPU_DEVICE AMREX_FORCE_INLINE decltype(auto) load_pdata(T *ptr, IndexType const i)
Definition beamoptic.H:69
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:133
void dispatch_misalignment(T_Element &element, F &&f)
Definition beamoptic.H:457
void push_all_particles(ImpactXParticleContainer::iterator &pti, RefPart &AMREX_RESTRICT ref_part, T_Element &element, bool spin)
Definition beamoptic.H:475
Definition alignment.H:25
Definition CovarianceMatrixMath.H:25
@ t
fixed t as the independent variable
Definition ImpactXParticleContainer.H:38
void ParallelFor(int n, F &&f)
Definition beamoptic.H:38
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:529
void operator()(ImpactXParticleContainer &pc, int step, int period)
Definition beamoptic.H:536
Definition beamoptic.H:325
PushSingleParticle()=delete
amrex::ParticleReal *const AMREX_RESTRICT m_part_py
Definition beamoptic.H:440
amrex::ParticleReal *const AMREX_RESTRICT m_part_pt
Definition beamoptic.H:441
uint64_t *const AMREX_RESTRICT m_part_idcpu
Definition beamoptic.H:442
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:341
RefPart m_ref_part
Definition beamoptic.H:443
T_Element m_element
Definition beamoptic.H:435
amrex::ParticleTile< amrex::SoAParticle< RealSoA::nattribs, IntSoA::nattribs >, RealSoA::nattribs, IntSoA::nattribs > ParticleTileType
Definition beamoptic.H:327
amrex::ParticleReal *const AMREX_RESTRICT m_part_t
Definition beamoptic.H:438
amrex::ParticleReal *const AMREX_RESTRICT m_part_px
Definition beamoptic.H:439
amrex::ParticleReal *const AMREX_RESTRICT m_part_y
Definition beamoptic.H:437
ImpactXParticleContainer::ParticleType PType
Definition beamoptic.H:326
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void operator()(IndexType i) const
Definition beamoptic.H:373
amrex::ParticleReal *const AMREX_RESTRICT m_part_x
Definition beamoptic.H:436
~PushSingleParticle()=default
PushSingleParticle(PushSingleParticle &&)=default
PushSingleParticle(PushSingleParticle const &)=default
Definition beamoptic.H:169
amrex::ParticleReal *const AMREX_RESTRICT m_part_py
Definition beamoptic.H:300
uint64_t *const AMREX_RESTRICT m_part_idcpu
Definition beamoptic.H:305
amrex::ParticleReal *const AMREX_RESTRICT m_part_sx
Definition beamoptic.H:302
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:188
amrex::ParticleReal *const AMREX_RESTRICT m_part_pt
Definition beamoptic.H:301
amrex::ParticleReal *const AMREX_RESTRICT m_part_t
Definition beamoptic.H:298
amrex::ParticleReal *const AMREX_RESTRICT m_part_px
Definition beamoptic.H:299
amrex::ParticleReal *const AMREX_RESTRICT m_part_sz
Definition beamoptic.H:304
amrex::ParticleReal *const AMREX_RESTRICT m_part_y
Definition beamoptic.H:297
amrex::ParticleTile< amrex::SoAParticle< RealSoA::nattribs, IntSoA::nattribs >, RealSoA::nattribs, IntSoA::nattribs > ParticleTileType
Definition beamoptic.H:171
amrex::ParticleReal *const AMREX_RESTRICT m_part_sy
Definition beamoptic.H:303
AMREX_GPU_DEVICE AMREX_FORCE_INLINE void operator()(IndexType i) const
Definition beamoptic.H:224
T_Element m_element
Definition beamoptic.H:295
RefPart m_ref_part
Definition beamoptic.H:306
PushSingleParticleSpin(PushSingleParticleSpin &&)=default
ImpactXParticleContainer::ParticleType PType
Definition beamoptic.H:170
amrex::ParticleReal *const AMREX_RESTRICT m_part_x
Definition beamoptic.H:296
PushSingleParticleSpin(PushSingleParticleSpin const &)=default
PushSingleParticleSpin()=delete
~PushSingleParticleSpin()=default