15 #ifndef FIELDGATHER_H_
16 #define FIELDGATHER_H_
45 template <
int depos_order_xy>
61 const amrex::Real dx_inv,
62 const amrex::Real dy_inv,
63 const amrex::Real x_pos_offset,
64 const amrex::Real y_pos_offset)
67 const amrex::Real
x = (xp-x_pos_offset)*dx_inv;
68 const amrex::Real y = (yp-y_pos_offset)*dy_inv;
70 constexpr
int derivative_type = 1;
76 for (
int iy=0; iy<=depos_order_xy+derivative_type; iy++){
80 for (
int ix=0; ix<=depos_order_xy+derivative_type; ix++){
83 auto [shape_y, shape_dy,
j] =
84 single_derivative_shape_factor<derivative_type, depos_order_xy>(y, iy);
85 auto [shape_x, shape_dx,
i] =
86 single_derivative_shape_factor<derivative_type, depos_order_xy>(
x, ix);
88 ExmByp += (shape_dx* shape_y) * slice_arr(
i,
j, psi_comp) * dx_inv;
89 EypBxp += (shape_x * shape_dy)* slice_arr(
i,
j, psi_comp) * dy_inv;
90 Ezp += (shape_x * shape_y) * slice_arr(
i,
j, ez_comp);
91 Bxp += (shape_x * shape_y) * slice_arr(
i,
j, bx_comp);
92 Byp += (shape_x * shape_y) * slice_arr(
i,
j, by_comp);
93 Bzp += (shape_x * shape_y) * slice_arr(
i,
j, bz_comp);
125 const amrex::ParticleReal yp,
126 amrex::ParticleReal& ExmByp,
127 amrex::ParticleReal& EypBxp,
128 amrex::ParticleReal& Ezp,
129 amrex::ParticleReal& Bxp,
130 amrex::ParticleReal& Byp,
131 amrex::ParticleReal& Bzp,
138 const amrex::Real dx_inv,
139 const amrex::Real dy_inv,
140 const amrex::Real x_pos_offset,
141 const amrex::Real y_pos_offset,
142 const int depos_order_xy)
144 if (depos_order_xy == 0) {
145 doGatherShapeN<0>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr,
146 psi_comp, ez_comp, bx_comp, by_comp, bz_comp,
147 dx_inv, dy_inv, x_pos_offset, y_pos_offset);
148 }
else if (depos_order_xy == 1) {
149 doGatherShapeN<1>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr,
150 psi_comp, ez_comp, bx_comp, by_comp, bz_comp,
151 dx_inv, dy_inv, x_pos_offset, y_pos_offset);
152 }
else if (depos_order_xy == 2) {
153 doGatherShapeN<2>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr,
154 psi_comp, ez_comp, bx_comp, by_comp, bz_comp,
155 dx_inv, dy_inv, x_pos_offset, y_pos_offset);
156 }
else if (depos_order_xy == 3) {
157 doGatherShapeN<3>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr,
158 psi_comp, ez_comp, bx_comp, by_comp, bz_comp,
159 dx_inv, dy_inv, x_pos_offset, y_pos_offset);
181 template <
int depos_order_xy>
184 const amrex::Real yp,
190 const amrex::Real dx_inv,
191 const amrex::Real dy_inv,
192 const amrex::Real x_pos_offset,
193 const amrex::Real y_pos_offset)
196 const amrex::Real
x = (xp-x_pos_offset)*dx_inv;
197 const amrex::Real y = (yp-y_pos_offset)*dy_inv;
202 amrex::Real sx_cell[depos_order_xy + 1];
203 const int i_cell = compute_shape_factor<depos_order_xy>(sx_cell,
x);
206 amrex::Real sy_cell[depos_order_xy + 1];
207 const int j_cell = compute_shape_factor<depos_order_xy>(sy_cell, y);
210 for (
int iy=0; iy<=depos_order_xy; iy++){
211 for (
int ix=0; ix<=depos_order_xy; ix++){
212 Bxp += sx_cell[ix]*sy_cell[iy] * slice_arr(i_cell+ix, j_cell+iy, bx_comp);
213 Byp += sx_cell[ix]*sy_cell[iy] * slice_arr(i_cell+ix, j_cell+iy, by_comp);
235 template <
int depos_order_xy>
238 const amrex::Real yp,
239 amrex::Real& Aabssqp,
240 amrex::Real& AabssqDxp,
241 amrex::Real& AabssqDyp,
243 const amrex::Real dx_inv,
244 const amrex::Real dy_inv,
245 const amrex::Real x_pos_offset,
246 const amrex::Real y_pos_offset)
248 using namespace amrex::literals;
251 const amrex::Real
x = (xp-x_pos_offset)*dx_inv;
252 const amrex::Real y = (yp-y_pos_offset)*dy_inv;
257 amrex::Real sx_cell[depos_order_xy + 1];
258 const int i_cell = compute_shape_factor<depos_order_xy>(sx_cell,
x);
261 amrex::Real sy_cell[depos_order_xy + 1];
262 const int j_cell = compute_shape_factor<depos_order_xy>(sy_cell, y);
266 for (
int iy=0; iy<=depos_order_xy; iy++){
267 for (
int ix=0; ix<=depos_order_xy; ix++){
268 const amrex::Real x00y00 =
abssq(
269 a_arr(i_cell+ix , j_cell+iy , 0),
270 a_arr(i_cell+ix , j_cell+iy , 1) );
271 const amrex::Real xp1y00 =
abssq(
272 a_arr(i_cell+ix+1, j_cell+iy , 0),
273 a_arr(i_cell+ix+1, j_cell+iy , 1) );
274 const amrex::Real xm1y00 =
abssq(
275 a_arr(i_cell+ix-1, j_cell+iy , 0),
276 a_arr(i_cell+ix-1, j_cell+iy , 1) );
277 const amrex::Real x00yp1 =
abssq(
278 a_arr(i_cell+ix , j_cell+iy+1, 0),
279 a_arr(i_cell+ix , j_cell+iy+1, 1) );
280 const amrex::Real x00ym1 =
abssq(
281 a_arr(i_cell+ix , j_cell+iy-1, 0),
282 a_arr(i_cell+ix , j_cell+iy-1, 1) );
283 Aabssqp += sx_cell[ix]*sy_cell[iy]*x00y00;
284 AabssqDxp += sx_cell[ix]*sy_cell[iy]*0.5_rt*dx_inv*(xp1y00-xm1y00);
285 AabssqDyp += sx_cell[ix]*sy_cell[iy]*0.5_rt*dy_inv*(x00yp1-x00ym1);
305 template <
int depos_order_xy>
308 const amrex::Real yp,
309 amrex::Real& Aabssqp,
311 const amrex::Real dx_inv,
312 const amrex::Real dy_inv,
313 const amrex::Real x_pos_offset,
314 const amrex::Real y_pos_offset)
317 const amrex::Real
x = (xp-x_pos_offset)*dx_inv;
318 const amrex::Real y = (yp-y_pos_offset)*dy_inv;
323 amrex::Real sx_cell[depos_order_xy + 1];
324 const int i_cell = compute_shape_factor<depos_order_xy>(sx_cell,
x);
327 amrex::Real sy_cell[depos_order_xy + 1];
328 const int j_cell = compute_shape_factor<depos_order_xy>(sy_cell, y);
331 for (
int iy=0; iy<=depos_order_xy; iy++){
332 for (
int ix=0; ix<=depos_order_xy; ix++){
333 const amrex::Real x00y00 =
abssq(
334 a_arr(i_cell+ix , j_cell+iy , 0),
335 a_arr(i_cell+ix , j_cell+iy , 1) );
336 Aabssqp += sx_cell[ix]*sy_cell[iy]*x00y00;
343 const amrex::Real yp,
347 const amrex::Real dx_inv,
348 const amrex::Real dy_inv,
349 const amrex::Real x_pos_offset,
350 const amrex::Real y_pos_offset)
353 const amrex::Real
x = (xp - x_pos_offset) * dx_inv;
354 const amrex::Real y = (yp - y_pos_offset) * dy_inv;
357 auto [shape_y,
j] = compute_single_shape_factor<false, 0>(y, 0);
358 auto [shape_x,
i] = compute_single_shape_factor<false, 0>(
x, 0);
361 Ezp += (shape_x * shape_y) * slice_arr(
i,
j, ez_comp);
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void doLaserGatherShapeN(const amrex::Real xp, const amrex::Real yp, amrex::Real &Aabssqp, amrex::Real &AabssqDxp, amrex::Real &AabssqDyp, Array3< amrex::Real const > const &a_arr, const amrex::Real dx_inv, const amrex::Real dy_inv, const amrex::Real x_pos_offset, const amrex::Real y_pos_offset)
Laser field gather for a single particle.
Definition: FieldGather.H:237
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void doBxByGatherShapeN(const amrex::Real xp, const amrex::Real yp, amrex::Real &Bxp, amrex::Real &Byp, Array3< amrex::Real const > const &slice_arr, const int bx_comp, const int by_comp, const amrex::Real dx_inv, const amrex::Real dy_inv, const amrex::Real x_pos_offset, const amrex::Real y_pos_offset)
Field gather for a single particle of just Bx and By.
Definition: FieldGather.H:183
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void doGatherEz(const amrex::Real xp, const amrex::Real yp, amrex::Real &Ezp, Array3< amrex::Real const > const &slice_arr, const int ez_comp, const amrex::Real dx_inv, const amrex::Real dy_inv, const amrex::Real x_pos_offset, const amrex::Real y_pos_offset)
Definition: FieldGather.H:342
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void doGatherShapeN(const amrex::Real xp, const amrex::Real yp, amrex::Real &ExmByp, amrex::Real &EypBxp, amrex::Real &Ezp, amrex::Real &Bxp, amrex::Real &Byp, amrex::Real &Bzp, Array3< amrex::Real const > const &slice_arr, const int psi_comp, const int ez_comp, const int bx_comp, const int by_comp, const int bz_comp, const amrex::Real dx_inv, const amrex::Real dy_inv, const amrex::Real x_pos_offset, const amrex::Real y_pos_offset)
Field gather for a single particle.
Definition: FieldGather.H:47
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real abssq(amrex::Real r, amrex::Real i)
Definition: GPUUtil.H:187
int i
Definition: MakeOpenBoundary.py:152
j
Definition: MakeOpenBoundary.py:128