10#ifndef IMPACTX_POLYGONAPERTURE_H
11#define IMPACTX_POLYGONAPERTURE_H
61 static constexpr auto type =
"PolygonAperture";
97 std::vector< amrex::ParticleReal> vertices_x,
98 std::vector< amrex::ParticleReal> vertices_y,
118 throw std::runtime_error(
"PolygonAperture: shift_odd_x can only be used if repeat_y is set, too!");
122 if (
m_nvert != vertices_y.size()) {
123 throw std::runtime_error(
"PolygonAperture: horizontal and vertical vertices arrays must have same length!");
126 if ((vertices_x[0] != vertices_x[
m_nvert-1]) ||
127 (vertices_y[0] != vertices_y[
m_nvert-1])) {
128 throw std::runtime_error(
"PolygonAperture: first and last vertex must be exactly equal!");
133 std::move(vertices_x),
134 std::move(vertices_y)
144 using BeamOptic::operator();
155 Alignment::compute_constants(refpart);
175 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
197 using VBool =
decltype(x>0_prt);
210 sx += shift_x ?
dx : 0_prt;
218 VBool inside_aperture;
221 T_Real
const r2 = powi<2>(u) + powi<2>(
v);
224 inside_aperture = VBool(
true);
227#if AMREX_DEVICE_COMPILE
253 T_Real thetasum = 0.0;
256 for (
size_t i = 0; i <
m_nvert-1; ++i) {
257 v1conj =
Complex(u - vertices_x[i], -(
v-vertices_y[i]));
258 v2 =
Complex(u - vertices_x[i+1],
v-vertices_y[i+1]);
259 thetasum +=
arg(v2 * v1conj);
266 auto const invalid_mask =
m_action == Action::transmit ? !inside_aperture : inside_aperture;
271 using Thin::operator();
289 template<
typename T_Real=amrex::ParticleReal,
typename T_IdCpu=u
int64_t>
308 (*this)(x, y,
t, px, py, pt, idcpu, refpart);
312 using LinearTransport::operator();
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
#define IMPACTX_PUSH_EXTERN_TEMPLATE(ElementType)
Definition PushAll.H:78
amrex::GpuComplex< amrex::Real > Complex
T_ParticleType ParticleType
#define IMPACTX_GPUDATA_EXTERN(ElementType)
Definition dynamicdata.H:169
amrex_particle_real ParticleReal
constexpr T powi(T x) noexcept
__host__ __device__ detail::where_expression< T > where(bool const mask, T &value)
__host__ __device__ T arg(const GpuComplex< T > &a_z) noexcept
__host__ __device__ T abs(const GpuComplex< T > &a_z) 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:33
Definition PolygonAperture.H:60
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition PolygonAperture.H:325
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(T_Real const &AMREX_RESTRICT x, T_Real const &AMREX_RESTRICT y, T_Real const &AMREX_RESTRICT t, T_Real const &AMREX_RESTRICT px, T_Real const &AMREX_RESTRICT py, T_Real const &AMREX_RESTRICT pt, T_IdCpu &AMREX_RESTRICT idcpu, RefPart const &AMREX_RESTRICT refpart) const
Definition PolygonAperture.H:177
PolygonAperture(std::vector< amrex::ParticleReal > vertices_x, std::vector< amrex::ParticleReal > vertices_y, amrex::ParticleReal min_radius2=DEFAULT_min_radius2, amrex::ParticleReal repeat_x=DEFAULT_repeat_x, amrex::ParticleReal repeat_y=DEFAULT_repeat_y, bool shift_odd_x=DEFAULT_shift_odd_x, Action action=DEFAULT_action, amrex::ParticleReal dx=DEFAULT_dx, amrex::ParticleReal dy=DEFAULT_dy, amrex::ParticleReal rotation_degree=DEFAULT_rotation_degree, std::optional< std::string > name=DEFAULT_name)
Definition PolygonAperture.H:96
static constexpr Action DEFAULT_action
Definition PolygonAperture.H:78
AMREX_ENUM_IN_CLASS(Action, transmit, absorb,)
amrex::ParticleReal const * m_vertices_y_h_data
non-owning pointer to host x vertices
Definition PolygonAperture.H:342
amrex::ParticleReal const * m_vertices_y_d_data
non-owning pointer to device x vertices
Definition PolygonAperture.H:344
static constexpr amrex::ParticleReal DEFAULT_min_radius2
Definition PolygonAperture.H:74
amrex::ParticleReal m_repeat_y
horizontal period for repeated masking
Definition PolygonAperture.H:333
static constexpr amrex::ParticleReal DEFAULT_repeat_x
Definition PolygonAperture.H:75
amrex::ParticleReal const * m_vertices_x_d_data
non-owning pointer to host vertices
Definition PolygonAperture.H:343
std::vector< double >::size_type m_nvert
Definition PolygonAperture.H:340
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void spin_and_phasespace_push(T_Real const &AMREX_RESTRICT x, T_Real const &AMREX_RESTRICT y, T_Real const &AMREX_RESTRICT t, T_Real const &AMREX_RESTRICT px, T_Real const &AMREX_RESTRICT py, T_Real const &AMREX_RESTRICT pt, T_Real const &AMREX_RESTRICT sx, T_Real const &AMREX_RESTRICT sy, T_Real const &AMREX_RESTRICT sz, T_IdCpu &AMREX_RESTRICT idcpu, RefPart const &AMREX_RESTRICT refpart) const
Definition PolygonAperture.H:291
void compute_constants(RefPart const &refpart)
Definition PolygonAperture.H:153
void reverse()
Definition PolygonAperture.H:141
Action m_action
Definition PolygonAperture.H:331
int m_id
for hexagonal/triangular mask patterns: horizontal shift of every 2nd (odd) vertical period by m_repe...
Definition PolygonAperture.H:336
static constexpr bool DEFAULT_shift_odd_x
Definition PolygonAperture.H:77
static constexpr auto type
Definition PolygonAperture.H:61
bool m_shift_odd_x
vertical period for repeated masking
Definition PolygonAperture.H:334
amrex::ParticleReal m_min_radius2
unique PolygonAperture id used for data lookup map
Definition PolygonAperture.H:338
amrex::ParticleReal const * m_vertices_x_h_data
number of vertices
Definition PolygonAperture.H:341
static std::string action_name(Action const &action)
Definition PolygonAperture.cpp:18
ImpactXParticleContainer::ParticleType PType
Definition PolygonAperture.H:62
amrex::ParticleReal m_repeat_x
action type (transmit, absorb)
Definition PolygonAperture.H:332
mixin::GPUDataRegistry< PolygonVertices > DynamicData
Definition PolygonAperture.H:64
static constexpr amrex::ParticleReal DEFAULT_repeat_y
Definition PolygonAperture.H:76
Definition PolygonAperture.H:46
amrex::Gpu::TrackedVector< amrex::ParticleReal > y
Definition PolygonAperture.H:48
amrex::Gpu::TrackedVector< amrex::ParticleReal > x
Definition PolygonAperture.H:47
Definition alignment.H:29
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dy() const
Definition alignment.H:193
static constexpr amrex::ParticleReal DEFAULT_dy
Definition alignment.H:34
static constexpr amrex::ParticleReal DEFAULT_dx
Definition alignment.H:33
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dx() const
Definition alignment.H:183
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 rotate_aligned_map(Map6x6 const &R) const
Definition alignment.H:267
Alignment(amrex::ParticleReal dx, amrex::ParticleReal dy, amrex::ParticleReal rotation_degree)
Definition alignment.H:43
static constexpr amrex::ParticleReal DEFAULT_rotation_degree
Definition alignment.H:35
Definition beamoptic.H:567
Definition dynamicdata.H:54
static std::shared_ptr< PolygonVertices > const & get(int id)
Definition dynamicdata.H:98
static PolygonVertices & emplace(int id, Args &&... args)
Definition dynamicdata.H:125
Definition lineartransport.H:50
static constexpr std::nullopt_t DEFAULT_name
Definition named.H:30
AMREX_GPU_HOST Named(std::optional< std::string > name)
Definition named.H:59
AMREX_FORCE_INLINE std::string name() const
Definition named.H:124
Definition nofinalize.H:22
Definition spintransport.H:36