ImpactX
Loading...
Searching...
No Matches
src
elements
mixin
pipeaperture.H
Go to the documentation of this file.
1
/* Copyright 2022-2025 The Regents of the University of California, through Lawrence
2
* Berkeley National Laboratory (subject to receipt of any required
3
* approvals from the U.S. Dept. of Energy). All rights reserved.
4
*
5
* This file is part of ImpactX.
6
*
7
* Authors: Axel Huebl, Chad Mitchell, Alexander Sinn
8
* License: BSD-3-Clause-LBNL
9
*/
10
#ifndef IMPACTX_ELEMENTS_MIXIN_PIPE_APERTURE_H
11
#define IMPACTX_ELEMENTS_MIXIN_PIPE_APERTURE_H
12
13
#include <
AMReX_Extension.H
>
14
#include <
AMReX_GpuQualifiers.H
>
15
#include <
AMReX_Math.H
>
16
#include <
AMReX_Particle.H
>
17
#include <
AMReX_REAL.H
>
18
#include <
AMReX_SIMD.H
>
19
20
21
namespace
impactx::elements::mixin
22
{
25
struct
PipeAperture
26
{
32
PipeAperture
(
33
amrex::ParticleReal
aperture_x
,
34
amrex::ParticleReal
aperture_y
35
)
36
{
37
using namespace
amrex::literals;
// for _prt
38
39
m_inv_aperture_x
=
aperture_x
> 0_prt ? 1_prt /
aperture_x
: 0_prt;
40
m_inv_aperture_y
=
aperture_y
> 0_prt ? 1_prt /
aperture_y
: 0_prt;
41
}
42
43
PipeAperture
() =
default
;
44
PipeAperture
(
PipeAperture
const
&) =
default
;
45
PipeAperture
&
operator=
(
PipeAperture
const
&) =
default
;
46
PipeAperture
(
PipeAperture
&&) =
default
;
47
PipeAperture
&
operator=
(
PipeAperture
&& rhs) =
default
;
48
49
~PipeAperture
() =
default
;
50
57
template
<
typename
T_Real=amrex::ParticleReal,
typename
T_IdCpu=u
int
64_t>
58
AMREX_GPU_HOST_DEVICE
AMREX_FORCE_INLINE
59
void
apply_aperture
(
60
T_Real &
AMREX_RESTRICT
x,
61
T_Real &
AMREX_RESTRICT
y,
62
T_IdCpu &
AMREX_RESTRICT
idcpu
63
)
const
64
{
65
using namespace
amrex::literals;
// for _rt and _prt
66
using
amrex::Math::powi
;
67
namespace
stdx =
amrex::simd::stdx
;
68
69
// skip aperture application if aperture_x <= 0 or aperture_y <= 0
70
if
(
m_inv_aperture_x
> 0_prt &&
m_inv_aperture_y
> 0_prt) {
71
72
// scale horizontal and vertical coordinates
73
// performance optimization: we intentionally store the inverse of
74
// the aperture, so we can do a quick multiplication (instead of a
75
// costly division) here.
76
T_Real
const
u = x *
m_inv_aperture_x
;
77
T_Real
const
v
= y *
m_inv_aperture_y
;
78
79
// compare against the aperture boundary
80
auto
const
mask
= u*u +
v
*
v
> 1_prt;
81
amrex::ParticleIDWrapper<T_IdCpu>
{idcpu}.
make_invalid
(
mask
);
82
}
83
}
84
89
AMREX_GPU_HOST_DEVICE
AMREX_FORCE_INLINE
90
amrex::ParticleReal
aperture_x
()
const
91
{
92
using namespace
amrex::literals;
// for _prt
93
return
m_inv_aperture_x
> 0_prt ? 1_prt /
m_inv_aperture_x
: 0_prt;
94
}
95
100
AMREX_GPU_HOST_DEVICE
AMREX_FORCE_INLINE
101
amrex::ParticleReal
aperture_y
()
const
102
{
103
using namespace
amrex::literals;
// for _prt
104
return
m_inv_aperture_y
> 0_prt ? 1_prt /
m_inv_aperture_y
: 0_prt;
105
}
106
107
// performance optimization: we intentionally store the inverse of
108
// the aperture, so we can do a quick multiplication instead of a costly
109
// division in the comparison operation per particle
110
amrex::ParticleReal
m_inv_aperture_x
= 0;
111
amrex::ParticleReal
m_inv_aperture_y
= 0;
112
};
113
114
}
// namespace impactx::elements::mixin
115
116
#endif
// IMPACTX_ELEMENTS_MIXIN_PIPE_APERTURE_H
AMReX_Extension.H
AMREX_FORCE_INLINE
#define AMREX_FORCE_INLINE
AMREX_RESTRICT
#define AMREX_RESTRICT
AMReX_GpuQualifiers.H
AMREX_GPU_HOST_DEVICE
#define AMREX_GPU_HOST_DEVICE
mask
Array4< int const > mask
AMReX_Math.H
AMReX_Particle.H
AMReX_REAL.H
AMReX_SIMD.H
RigidAdvanceMode::v
@ v
amrex::Math::powi
constexpr T powi(T x) noexcept
amrex::simd::stdx
impactx::elements::mixin
Definition
alignment.H:23
amrex::ParticleIDWrapper
amrex::ParticleIDWrapper::make_invalid
__host__ __device__ void make_invalid() const noexcept
impactx::elements::mixin::PipeAperture::PipeAperture
PipeAperture(PipeAperture &&)=default
impactx::elements::mixin::PipeAperture::apply_aperture
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void apply_aperture(T_Real &AMREX_RESTRICT x, T_Real &AMREX_RESTRICT y, T_IdCpu &AMREX_RESTRICT idcpu) const
Definition
pipeaperture.H:59
impactx::elements::mixin::PipeAperture::PipeAperture
PipeAperture(PipeAperture const &)=default
impactx::elements::mixin::PipeAperture::m_inv_aperture_x
amrex::ParticleReal m_inv_aperture_x
Definition
pipeaperture.H:110
impactx::elements::mixin::PipeAperture::~PipeAperture
~PipeAperture()=default
impactx::elements::mixin::PipeAperture::operator=
PipeAperture & operator=(PipeAperture const &)=default
impactx::elements::mixin::PipeAperture::PipeAperture
PipeAperture()=default
impactx::elements::mixin::PipeAperture::aperture_x
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal aperture_x() const
Definition
pipeaperture.H:90
impactx::elements::mixin::PipeAperture::aperture_y
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal aperture_y() const
Definition
pipeaperture.H:101
impactx::elements::mixin::PipeAperture::PipeAperture
PipeAperture(amrex::ParticleReal aperture_x, amrex::ParticleReal aperture_y)
Definition
pipeaperture.H:32
impactx::elements::mixin::PipeAperture::m_inv_aperture_y
amrex::ParticleReal m_inv_aperture_y
inverse of the horizontal aperture size [1/m]
Definition
pipeaperture.H:111
Generated by
1.13.2