8#ifndef WARPX_ADDPLASMAUTILITIES_H_
9#define WARPX_ADDPLASMAUTILITIES_H_
26 amrex::ParticleReal
x,
y,
z;
30 x{static_cast<
amrex::ParticleReal>(a.
x)},
31 y{static_cast<
amrex::ParticleReal>(a.
y)},
32 z{static_cast<
amrex::ParticleReal>(a.
z)}
74 const amrex::Long pcount) {
75 using namespace amrex::literals;
76 return (pcount != 0) ?
AMREX_D_TERM(dx[0],*dx[1],*dx[2])/pcount : 0.0_rt;
86#if defined(WARPX_DIM_3D)
88#elif defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
89 if (normal_axis == 0) { r /= iv[0]; }
90 else if (normal_axis == 2) { r /= iv[1]; }
91#elif defined(WARPX_DIM_1D_Z)
92 if (normal_axis == 2) { r /= iv[0]; }
93#elif defined(WARPX_DIM_RCYLINDER) || defined(WARPX_DIM_RSPHERE)
94 if (normal_axis == 0) { r /= iv[0]; }
113amrex::Real compute_scale_fac_area_eb (
115 const amrex::Real num_ppc_real,
117 const amrex::Real n1,
118 const amrex::Real n2)) {
119 using namespace amrex::literals;
124#if defined(WARPX_DIM_3D)
129#elif defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
134 amrex::Real scale_fac = 0.0_rt;
139 scale_fac /= num_ppc_real;
158void rotate_momentum_eb (
161 const amrex::Real n1,
162 const amrex::Real n2))
164 using namespace amrex::literals;
166#if defined(WARPX_DIM_3D)
170 amrex::Real
const nx = -n0;
171 amrex::Real
const ny = -n1;
172 amrex::Real
const nz = -n2;
175 amrex::Real
const cos_theta = nz;
176 amrex::Real
const sin_theta = std::sqrt(1._rt-nz*nz);
177 amrex::Real
const nperp = std::sqrt(nx*nx + ny*ny);
178 amrex::Real cos_phi = 1;
179 amrex::Real sin_phi = 0;
185 amrex::Real
const ux = pu.
x*cos_theta*cos_phi - pu.
y*sin_phi + pu.
z*sin_theta*cos_phi;
186 amrex::Real
const uy = pu.
x*cos_theta*sin_phi + pu.
y*cos_phi + pu.
z*sin_theta*sin_phi;
187 amrex::Real
const uz = -pu.
x*sin_theta + pu.
z*cos_theta;
192#elif defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
196 amrex::Real
const sin_theta = -n0;
197 amrex::Real
const cos_theta = -n1;
198 amrex::Real
const uz = pu.
z*cos_theta - pu.
x*sin_theta;
199 amrex::Real
const ux = pu.
x*cos_theta + pu.
z*sin_theta;
214 const amrex::Real num_ppc_real,
const int flux_normal_axis) {
215 using namespace amrex::literals;
216 amrex::Real scale_fac =
AMREX_D_TERM(dx[0],*dx[1],*dx[2])/num_ppc_real;
218#if defined(WARPX_DIM_3D)
219 scale_fac /= dx[flux_normal_axis];
220#elif defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
223 if (flux_normal_axis == 0) { scale_fac /= dx[0]; }
226 if (flux_normal_axis == 2) { scale_fac /= dx[1]; }
229#elif defined(WARPX_DIM_1D_Z)
230 if (flux_normal_axis == 2) { scale_fac /= dx[0]; }
231#elif defined(WARPX_DIM_RCYLINDER) || defined(WARPX_DIM_RSPHERE)
232 if (flux_normal_axis == 0) { scale_fac /= dx[0]; }
244 std::size_t a_num_user_real_attribs,
245 const amrex::Vector< std::unique_ptr<amrex::Parser> >& a_user_int_attrib_parser,
246 const amrex::Vector< std::unique_ptr<amrex::Parser> >& a_user_real_attrib_parser);
254 template <
typename SoAType>
256 const std::vector<std::string>& a_user_int_attribs,
257 const std::vector<std::string>& a_user_real_attribs,
264 m_d_pa_user_int.resize(a_user_int_attribs.size());
265 m_d_pa_user_real.resize(a_user_real_attribs.size());
266 m_d_user_int_attrib_parserexec.resize(a_user_int_attribs.size());
267 m_d_user_real_attrib_parserexec.resize(a_user_real_attribs.size());
270 for (std::size_t ia = 0; ia < a_user_int_attribs.size(); ++ia) {
273 for (std::size_t ia = 0; ia < a_user_real_attribs.size(); ++ia) {
311 template <
typename SoAType>
313 bool a_has_quantum_sync,
bool a_has_breit_wheeler,
314 const std::shared_ptr<QuantumSynchrotronEngine>& a_shr_p_qs_engine,
315 const std::shared_ptr<BreitWheelerEngine>& a_shr_p_bw_engine)
320 a_shr_p_qs_engine->build_optical_depth_functor();
325 a_shr_p_bw_engine->build_optical_depth_functor();
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
#define AMREX_D_TERM(a, b, c)
#define AMREX_D_DECL(a, b, c)
bool find_overlap_flux(const amrex::RealBox &tile_realbox, const amrex::RealBox &part_realbox, const amrex::GpuArray< amrex::Real, 3 > &dx, const amrex::GpuArray< amrex::Real, 3 > &prob_lo, const PlasmaInjector &plasma_injector, amrex::RealBox &overlap_realbox, amrex::Box &overlap_box, amrex::IntVect &shifted)
Definition AddPlasmaUtilities.cpp:45
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real compute_scale_fac_area_plane(const amrex::GpuArray< amrex::Real, 3 > &dx, const amrex::Real num_ppc_real, const int flux_normal_axis)
Definition AddPlasmaUtilities.H:213
bool find_overlap(const amrex::RealBox &tile_realbox, const amrex::RealBox &part_realbox, const amrex::GpuArray< amrex::Real, 3 > &dx, const amrex::GpuArray< amrex::Real, 3 > &prob_lo, amrex::RealBox &overlap_realbox, amrex::Box &overlap_box, amrex::IntVect &shifted)
Definition AddPlasmaUtilities.cpp:12
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int compute_area_weights(const amrex::IntVect &iv, const int normal_axis)
Definition AddPlasmaUtilities.H:84
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real compute_scale_fac_volume(const amrex::GpuArray< amrex::Real, 3 > &dx, const amrex::Long pcount)
Definition AddPlasmaUtilities.H:73
Definition BreitWheelerEngineWrapper.H:78
Definition PlasmaInjector.H:39
Definition QuantumSyncEngineWrapper.H:76
void copyAsync(HostToDevice, InIter begin, InIter end, OutIter result) noexcept
static constexpr HostToDevice hostToDevice
PODVector< T, PinnedArenaAllocator< T > > PinnedVector
PODVector< T, ArenaAllocator< T > > DeviceVector
constexpr T powi(T x) noexcept
__host__ __device__ void ignore_unused(const Ts &...)
Definition AddPlasmaUtilities.H:25
amrex::ParticleReal z
Definition AddPlasmaUtilities.H:26
AMREX_GPU_HOST_DEVICE PDim3(PDim3 const &)=default
amrex::ParticleReal x
Definition AddPlasmaUtilities.H:26
AMREX_GPU_HOST_DEVICE PDim3(PDim3 &&)=default
AMREX_GPU_HOST_DEVICE ~PDim3()=default
AMREX_GPU_HOST_DEVICE PDim3 & operator=(PDim3 &&)=default
amrex::ParticleReal y
Definition AddPlasmaUtilities.H:26
AMREX_GPU_HOST_DEVICE PDim3 & operator=(PDim3 const &)=default
AMREX_GPU_HOST_DEVICE PDim3(const amrex::XDim3 &a)
Definition AddPlasmaUtilities.H:29
amrex::ParserExecutor< 7 > const * getUserRealParserExecData() const
Definition AddPlasmaUtilities.cpp:154
amrex::ParticleReal ** getUserRealDataPtrs()
Definition AddPlasmaUtilities.cpp:138
PlasmaParserHelper(SoAType &a_soa, std::size_t old_size, const std::vector< std::string > &a_user_int_attribs, const std::vector< std::string > &a_user_real_attribs, const PlasmaParserWrapper &wrapper)
Definition AddPlasmaUtilities.H:255
const PlasmaParserWrapper * m_wrapper_ptr
Definition AddPlasmaUtilities.H:305
amrex::ParserExecutor< 7 > const * getUserIntParserExecData() const
Definition AddPlasmaUtilities.cpp:146
amrex::Gpu::PinnedVector< amrex::ParticleReal * > m_pa_user_real_pinned
Definition AddPlasmaUtilities.H:295
amrex::Gpu::PinnedVector< int * > m_pa_user_int_pinned
Definition AddPlasmaUtilities.H:294
int ** getUserIntDataPtrs()
Definition AddPlasmaUtilities.cpp:130
Definition AddPlasmaUtilities.H:242
amrex::Gpu::PinnedVector< amrex::ParserExecutor< 7 > > m_user_int_attrib_parserexec_pinned
Definition AddPlasmaUtilities.H:248
PlasmaParserWrapper(std::size_t a_num_user_int_attribs, std::size_t a_num_user_real_attribs, const amrex::Vector< std::unique_ptr< amrex::Parser > > &a_user_int_attrib_parser, const amrex::Vector< std::unique_ptr< amrex::Parser > > &a_user_real_attrib_parser)
Definition AddPlasmaUtilities.cpp:113
amrex::Gpu::PinnedVector< amrex::ParserExecutor< 7 > > m_user_real_attrib_parserexec_pinned
Definition AddPlasmaUtilities.H:249
QuantumSynchrotronGetOpticalDepth quantum_sync_get_opt
Definition AddPlasmaUtilities.H:336
QEDHelper(SoAType &a_soa, std::size_t old_size, bool a_has_quantum_sync, bool a_has_breit_wheeler, const std::shared_ptr< QuantumSynchrotronEngine > &a_shr_p_qs_engine, const std::shared_ptr< BreitWheelerEngine > &a_shr_p_bw_engine)
Definition AddPlasmaUtilities.H:312
amrex::ParticleReal * p_optical_depth_BW
Definition AddPlasmaUtilities.H:331
bool has_breit_wheeler
Definition AddPlasmaUtilities.H:334
bool has_quantum_sync
Definition AddPlasmaUtilities.H:333
amrex::ParticleReal * p_optical_depth_QSR
Definition AddPlasmaUtilities.H:330
BreitWheelerGetOpticalDepth breit_wheeler_get_opt
Definition AddPlasmaUtilities.H:337