8 #ifndef WARPX_FILTER_COPY_TRANSFORM_H_
9 #define WARPX_FILTER_COPY_TRANSFORM_H_
52 template <
int N,
typename DstPC,
typename DstTile,
typename SrcTile,
typename Index,
53 typename TransFunc,
typename CopyFunc,
56 Index* mask, Index dst_index,
57 CopyFunc&& copy, TransFunc&& transform) noexcept
59 using namespace amrex;
61 const auto np = src.numParticles();
62 if (np == 0) {
return 0; }
66 const Index num_added = N * total;
67 auto old_np = dst.size();
68 auto new_np = std::max(dst_index + num_added, dst.numParticles());
71 auto *
const p_offsets = offsets.
dataPtr();
73 const auto src_data = src.getParticleTileData();
74 const auto dst_data = dst.getParticleTileData();
81 for (
int j = 0; j < N; ++j) {
82 copy(dst_data, src_data,
i, N*p_offsets[
i] + dst_index + j, engine);
84 transform(dst_data, src_data,
i, N*p_offsets[
i] + dst_index, engine);
90 pc.getUserRealAttribs(), pc.getUserIntAttribs(),
91 pc.getParticleComps(), pc.getParticleiComps(),
92 pc.getUserRealAttribParser(),
93 pc.getUserIntAttribParser(),
97 pc.get_breit_wheeler_engine_ptr(),
98 pc.get_quantum_sync_engine_ptr(),
100 pc.getIonizationInitialLevel(),
144 template <
int N,
typename DstPC,
typename DstTile,
typename SrcTile,
typename Index,
145 typename PredFunc,
typename TransFunc,
typename CopyFunc>
147 PredFunc&& filter, CopyFunc&& copy, TransFunc&& transform) noexcept
149 using namespace amrex;
151 const auto np = src.numParticles();
152 if (np == 0) {
return 0; }
157 const auto src_data = src.getParticleTileData();
162 p_mask[
i] = filter(src_data,
i, engine);
165 return filterCopyTransformParticles<N>(pc, dst, src,
mask.
dataPtr(), dst_index,
166 std::forward<CopyFunc>(
copy),
167 std::forward<TransFunc>(transform));
211 template <
int N,
typename DstPC,
typename DstTile,
typename SrcTile,
typename Index,
212 typename TransFunc,
typename CopyFunc1,
typename CopyFunc2,
215 Index dst1_index, Index dst2_index,
216 CopyFunc1&& copy1, CopyFunc2&& copy2,
217 TransFunc&& transform) noexcept
219 using namespace amrex;
221 auto np = src.numParticles();
222 if (np == 0) {
return 0; }
226 const Index num_added = N * total;
227 auto old_np1 = dst1.size();
228 auto new_np1 = std::max(dst1_index + num_added, dst1.numParticles());
229 dst1.resize(new_np1);
231 auto old_np2 = dst2.size();
232 auto new_np2 = std::max(dst2_index + num_added, dst2.numParticles());
233 dst2.resize(new_np2);
235 auto *p_offsets = offsets.
dataPtr();
237 const auto src_data = src.getParticleTileData();
238 const auto dst1_data = dst1.getParticleTileData();
239 const auto dst2_data = dst2.getParticleTileData();
246 for (
int j = 0; j < N; ++j)
248 copy1(dst1_data, src_data,
i, N*p_offsets[
i] + dst1_index + j, engine);
249 copy2(dst2_data, src_data,
i, N*p_offsets[
i] + dst2_index + j, engine);
251 transform(dst1_data, dst2_data, src_data,
i,
252 N*p_offsets[
i] + dst1_index,
253 N*p_offsets[
i] + dst2_index,
260 pc1.getUserRealAttribs(), pc1.getUserIntAttribs(),
261 pc1.getParticleComps(), pc1.getParticleiComps(),
262 pc1.getUserRealAttribParser(),
263 pc1.getUserIntAttribParser(),
267 pc1.get_breit_wheeler_engine_ptr(),
268 pc1.get_quantum_sync_engine_ptr(),
270 pc1.getIonizationInitialLevel(),
274 pc2.getUserRealAttribs(), pc2.getUserIntAttribs(),
275 pc2.getParticleComps(), pc2.getParticleiComps(),
276 pc2.getUserRealAttribParser(),
277 pc2.getUserIntAttribParser(),
281 pc2.get_breit_wheeler_engine_ptr(),
282 pc2.get_quantum_sync_engine_ptr(),
284 pc2.getIonizationInitialLevel(),
333 template <
int N,
typename DstPC,
typename DstTile,
typename SrcTile,
typename Index,
334 typename PredFunc,
typename TransFunc,
typename CopyFunc1,
typename CopyFunc2>
336 Index dst1_index, Index dst2_index,
337 PredFunc&& filter, CopyFunc1&& copy1, CopyFunc2&& copy2,
338 TransFunc&& transform) noexcept
340 using namespace amrex;
342 auto np = src.numParticles();
343 if (np == 0) {
return 0; }
348 const auto src_data = src.getParticleTileData();
353 p_mask[
i] = filter(src_data,
i, engine);
356 return filterCopyTransformParticles<N>(pc1, pc2, dst1, dst2, src,
mask.
dataPtr(),
357 dst1_index, dst2_index,
358 std::forward<CopyFunc1>(copy1),
359 std::forward<CopyFunc2>(copy2),
360 std::forward<TransFunc>(transform));
void DefaultInitializeRuntimeAttributes(PTile &ptile, const int n_external_attr_real, const int n_external_attr_int, const std::vector< std::string > &user_real_attribs, const std::vector< std::string > &user_int_attribs, const std::map< std::string, int > &particle_comps, const std::map< std::string, int > &particle_icomps, const std::vector< amrex::Parser * > &user_real_attrib_parser, const std::vector< amrex::Parser * > &user_int_attrib_parser, const bool do_qed_comps, BreitWheelerEngine *p_bw_engine, QuantumSynchrotronEngine *p_qs_engine, const int ionization_initial_level, int start, int stop)
Default initialize runtime attributes in a tile. This routine does not initialize the first n_externa...
Definition: DefaultInitialization.H:118
void synchronize() noexcept
void copy(HostToDevice, InIter begin, InIter end, OutIter result) noexcept
T ExclusiveSum(N n, T const *in, T *out, RetSum a_ret_sum=retSum)
AMREX_ATTRIBUTE_FLATTEN_FOR void ParallelForRNG(T n, L const &f) noexcept
std::enable_if_t< B, T > EnableIf_t
i
Definition: check_interp_points_and_weights.py:174
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int const * dataPtr() const noexcept