8 #ifndef WARPX_FILTER_CREATE_TRANSFORM_FROM_FAB_H_
9 #define WARPX_FILTER_CREATE_TRANSFORM_FROM_FAB_H_
46 template <
int N,
typename DstPC,
typename DstTile,
typename FAB,
typename Index,
47 typename CreateFunc1,
typename CreateFunc2,
typename TransFunc,
50 DstTile& dst1, DstTile& dst2,
const amrex::Box box,
51 const FAB *src_FAB,
const Index* mask,
52 const Index dst1_index,
const Index dst2_index,
53 CreateFunc1&& create1, CreateFunc2&& create2,
56 using namespace amrex;
58 const auto ncells = box.volume();
59 if (ncells == 0) {
return 0; }
61 constexpr
int spacedim = AMREX_SPACEDIM;
63 #if defined(WARPX_DIM_1D_Z)
64 const Real zlo_global = geom_lev_zero.ProbLo(0);
65 const Real
dz = geom_lev_zero.CellSize(0);
66 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
67 const Real xlo_global = geom_lev_zero.ProbLo(0);
68 const Real
dx = geom_lev_zero.CellSize(0);
69 const Real zlo_global = geom_lev_zero.ProbLo(1);
70 const Real
dz = geom_lev_zero.CellSize(1);
71 #elif defined(WARPX_DIM_3D)
72 const Real xlo_global = geom_lev_zero.ProbLo(0);
73 const Real
dx = geom_lev_zero.CellSize(0);
74 const Real ylo_global = geom_lev_zero.ProbLo(1);
75 const Real dy = geom_lev_zero.CellSize(1);
76 const Real zlo_global = geom_lev_zero.ProbLo(2);
77 const Real
dz = geom_lev_zero.CellSize(2);
80 const auto arrNumPartCreation = src_FAB->array();
83 const Index num_added = N*total;
84 auto old_np1 = dst1.size();
85 auto new_np1 = std::max(dst1_index + num_added, dst1.numParticles());
88 auto old_np2 = dst2.size();
89 auto new_np2 = std::max(dst2_index + num_added, dst2.numParticles());
92 auto *p_offsets = offsets.
dataPtr();
94 const auto dst1_data = dst1.getParticleTileData();
95 const auto dst2_data = dst2.getParticleTileData();
107 const int k = (spacedim >= 2) ? iv[1] : 0;
108 const int l = (spacedim == 3) ? iv[2] : 0;
112 #if defined(WARPX_DIM_1D_Z)
115 Real
const z = zlo_global + j*
dz;
116 #elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
117 Real
const x = xlo_global + j*
dx;
119 Real
const z = zlo_global + k*
dz;
120 #elif defined(WARPX_DIM_3D)
121 Real
const x = xlo_global + j*
dx;
122 Real
const y = ylo_global + k*dy;
123 Real
const z = zlo_global + l*
dz;
126 for (
int n = 0; n < N; ++n)
128 create1(dst1_data, N*p_offsets[
i] + dst1_index + n, engine,
x, y, z);
129 create2(dst2_data, N*p_offsets[
i] + dst2_index + n, engine,
x, y, z);
131 transform(dst1_data, dst2_data, N*p_offsets[
i] + dst1_index,
132 N*p_offsets[
i] + dst2_index, N, arrNumPartCreation(j,k,l));
138 pc1.getUserRealAttribs(), pc1.getUserIntAttribs(),
139 pc1.getParticleComps(), pc1.getParticleiComps(),
140 pc1.getUserRealAttribParser(),
141 pc1.getUserIntAttribParser(),
145 pc1.get_breit_wheeler_engine_ptr(),
146 pc1.get_quantum_sync_engine_ptr(),
148 pc1.getIonizationInitialLevel(),
152 pc2.getUserRealAttribs(), pc2.getUserIntAttribs(),
153 pc2.getParticleComps(), pc2.getParticleiComps(),
154 pc2.getUserRealAttribParser(),
155 pc2.getUserIntAttribParser(),
159 pc2.get_breit_wheeler_engine_ptr(),
160 pc2.get_quantum_sync_engine_ptr(),
162 pc2.getIonizationInitialLevel(),
202 template <
int N,
typename DstPC,
typename DstTile,
typename FABs,
typename Index,
203 typename FilterFunc,
typename CreateFunc1,
typename CreateFunc2,
206 const FABs& src_FABs,
const Index dst1_index,
207 const Index dst2_index, FilterFunc&& filter,
208 CreateFunc1&& create1, CreateFunc2&& create2,
211 using namespace amrex;
216 const Elixir tmp_eli = NumPartCreation.
elixir();
217 auto arrNumPartCreation = NumPartCreation.
array();
219 const auto ncells = box.volume();
220 if (ncells == 0) {
return 0; }
231 arrNumPartCreation(
i,j,k) = filter(src_FABs,
i,j,k,engine);
233 const auto mask_position = box.index(iv);
234 p_mask[mask_position] = (arrNumPartCreation(
i,j,k) > 0);
237 return filterCreateTransformFromFAB<N>(pc1, pc2, dst1, dst2, box, &NumPartCreation,
239 std::forward<CreateFunc1>(create1),
240 std::forward<CreateFunc2>(create2),
241 std::forward<TransFunc>(transform),
#define AMREX_D_DECL(a, b, c)
AMREX_FORCE_INLINE Array4< Real const > array() const noexcept
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
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
int dz
Definition: compute_domain.py:36
tuple dx
lab frame
Definition: stencil.py:429
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int const * dataPtr() const noexcept