10#ifndef IMPACTX_APERTURE_H
11#define IMPACTX_APERTURE_H
42 static constexpr auto type =
"Aperture";
79 amrex::ParticleReal aperture_x,
80 amrex::ParticleReal aperture_y,
81 amrex::ParticleReal repeat_x,
82 amrex::ParticleReal repeat_y,
86 amrex::ParticleReal
dx = 0,
87 amrex::ParticleReal
dy = 0,
88 amrex::ParticleReal rotation_degree = 0,
89 std::optional<std::string>
name = std::nullopt
95 using namespace amrex::literals;
97 if (aperture_x > 0_prt) {
100 throw std::runtime_error(
"Aperture: aperture_x must be > 0!");
103 if (aperture_y > 0_prt) {
106 throw std::runtime_error(
"Aperture: aperture_y must be > 0!");
110 throw std::runtime_error(
"Aperture: shift_odd_x can only be used if repeat_y is set, too!");
115 using BeamOptic::operator();
126 Alignment::compute_constants(refpart);
141 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
154 using namespace amrex::literals;
159 using VBool =
decltype(x>0_prt);
173 amrex::simd::stdx::where(shift_x, sx) +=
dx;
175 sx += shift_x ?
dx : 0_prt;
190 VBool inside_aperture;
195 inside_aperture = (powi<2>(u) <= 1_prt && powi<2>(
v) <= 1_prt);
199 inside_aperture = (powi<2>(u) + powi<2>(
v) <= 1_prt);
203 inside_aperture = VBool{
true};
217 using Thin::operator();
220 using LinearTransport::operator();
231 throw std::runtime_error(std::string(
type) +
": Envelope tracking is not yet implemented!");
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
T_ParticleType ParticleType
constexpr T powi(T x) noexcept
@ t
fixed t as the independent variable
Definition ImpactXParticleContainer.H:38
amrex::SmallMatrix< amrex::ParticleReal, 6, 6, amrex::Order::F, 1 > Map6x6
Definition CovarianceMatrix.H:20
__host__ __device__ void make_invalid() const noexcept
static constexpr __host__ __device__ SmallMatrix< T, NRows, NCols, ORDER, StartIndex > Identity() noexcept
Definition ReferenceParticle.H:31
Aperture(amrex::ParticleReal aperture_x, amrex::ParticleReal aperture_y, amrex::ParticleReal repeat_x, amrex::ParticleReal repeat_y, bool shift_odd_x, Shape shape, Action action, amrex::ParticleReal dx=0, amrex::ParticleReal dy=0, amrex::ParticleReal rotation_degree=0, std::optional< std::string > name=std::nullopt)
Definition Aperture.H:78
ImpactXParticleContainer::ParticleType PType
Definition Aperture.H:43
static std::string shape_name(Shape const &shape)
Definition Aperture.cpp:17
static constexpr auto type
Definition Aperture.H:42
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(T_Real &AMREX_RESTRICT x, T_Real &AMREX_RESTRICT y, T_Real &AMREX_RESTRICT t, T_Real &AMREX_RESTRICT px, T_Real &AMREX_RESTRICT py, T_Real &AMREX_RESTRICT pt, T_IdCpu &AMREX_RESTRICT idcpu, RefPart const &AMREX_RESTRICT refpart) const
Definition Aperture.H:143
void compute_constants(RefPart const &refpart)
Definition Aperture.H:124
amrex::ParticleReal m_repeat_x
maximum vertical coordinate
Definition Aperture.H:242
amrex::ParticleReal m_inv_aperture_y
maximum horizontal coordinate
Definition Aperture.H:241
Action
Definition Aperture.H:52
@ absorb
Definition Aperture.H:54
@ transmit
Definition Aperture.H:53
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition Aperture.H:229
Shape m_shape
Definition Aperture.H:235
amrex::ParticleReal m_inv_aperture_x
action type (transmit, absorb)
Definition Aperture.H:240
bool m_shift_odd_x
vertical period for repeated masking
Definition Aperture.H:244
Action m_action
aperture type (rectangular, elliptical)
Definition Aperture.H:236
amrex::ParticleReal m_repeat_y
horizontal period for repeated masking
Definition Aperture.H:243
static std::string action_name(Action const &action)
Definition Aperture.cpp:31
Shape
Definition Aperture.H:47
@ rectangular
Definition Aperture.H:48
@ elliptical
Definition Aperture.H:49
Definition alignment.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void shift_out(T_Real &AMREX_RESTRICT x, T_Real &AMREX_RESTRICT y, T_Real &AMREX_RESTRICT px, T_Real &AMREX_RESTRICT py) const
Definition alignment.H:109
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dy() const
Definition alignment.H:146
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dx() const
Definition alignment.H:136
Alignment(amrex::ParticleReal dx, amrex::ParticleReal dy, amrex::ParticleReal rotation_degree)
Definition alignment.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void shift_in(T_Real &AMREX_RESTRICT x, T_Real &AMREX_RESTRICT y, T_Real &AMREX_RESTRICT px, T_Real &AMREX_RESTRICT py) const
Definition alignment.H:78
Definition beamoptic.H:219
Definition lineartransport.H:29
AMREX_GPU_HOST Named(std::optional< std::string > name)
Definition named.H:57
AMREX_FORCE_INLINE std::string name() const
Definition named.H:122
Definition nofinalize.H:22