Skip to content

Commit a8899d2

Browse files
authored
Gather: Rename Galerkin Varnames (#1297)
Rename the variables in `FieldGather` that control the lowered shape in Galerkin interpolation.
1 parent 05e4f43 commit a8899d2

File tree

1 file changed

+55
-52
lines changed

1 file changed

+55
-52
lines changed

Source/Particles/Gather/FieldGather.H

Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@
1818
/**
1919
* \brief Field gather for a single particle
2020
*
21-
* \param xp, yp, zp : Particle position coordinates
22-
* \param Exp, Eyp, Ezp : Electric field on particles.
23-
* \param Bxp, Byp, Bzp : Magnetic field on particles.
24-
* \param ex_arr ey_arr ez_arr : Array4 of the electric field, either full array or tile.
25-
* \param bx_arr by_arr bz_arr : Array4 of the magnetic field, either full array or tile.
26-
* \param ex_type, ey_type, ez_type : IndexType of the electric field
27-
* \param bx_type, by_type, bz_type : IndexType of the magnetic field
28-
* \param dx : 3D cell spacing
29-
* \param xyzmin : Physical lower bounds of domain in x, y, z.
30-
* \param lo : Index lower bounds of domain.
31-
* \param n_rz_azimuthal_modes : Number of azimuthal modes when using RZ geometry
21+
* \tparam depos_order Particle shape order
22+
* \tparam galerkin_interpolation Lower the order of the particle shape by
23+
* this value (0/1) for the parallel field component
24+
* \param xp, yp, zp Particle position coordinates
25+
* \param Exp, Eyp, Ezp Electric field on particles.
26+
* \param Bxp, Byp, Bzp Magnetic field on particles.
27+
* \param ex_arr ey_arr ez_arr Array4 of the electric field, either full array or tile.
28+
* \param bx_arr by_arr bz_arr Array4 of the magnetic field, either full array or tile.
29+
* \param ex_type, ey_type, ez_type IndexType of the electric field
30+
* \param bx_type, by_type, bz_type IndexType of the magnetic field
31+
* \param dx 3D cell spacing
32+
* \param xyzmin Physical lower bounds of domain in x, y, z.
33+
* \param lo Index lower bounds of domain.
34+
* \param n_rz_azimuthal_modes Number of azimuthal modes when using RZ geometry
3235
*/
33-
template <int depos_order, int lower_in_v>
36+
template <int depos_order, int galerkin_interpolation>
3437
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
3538
void doGatherShapeN (const amrex::ParticleReal xp,
3639
const amrex::ParticleReal yp,
@@ -100,32 +103,32 @@ void doGatherShapeN (const amrex::ParticleReal xp,
100103
// arrays will be needed.
101104
amrex::Real sx_node[depos_order + 1];
102105
amrex::Real sx_cell[depos_order + 1];
103-
amrex::Real sx_node_v[depos_order + 1 - lower_in_v];
104-
amrex::Real sx_cell_v[depos_order + 1 - lower_in_v];
106+
amrex::Real sx_node_galerkin[depos_order + 1 - galerkin_interpolation];
107+
amrex::Real sx_cell_galerkin[depos_order + 1 - galerkin_interpolation];
105108
int j_node = 0;
106109
int j_cell = 0;
107110
int j_node_v = 0;
108111
int j_cell_v = 0;
109112
Compute_shape_factor< depos_order > const compute_shape_factor;
110-
Compute_shape_factor< depos_order-lower_in_v > const compute_shape_factor_lower_in_v;
113+
Compute_shape_factor<depos_order - galerkin_interpolation > const compute_shape_factor_galerkin;
111114
if ((ey_type[0] == NODE) || (ez_type[0] == NODE) || (bx_type[0] == NODE)) {
112115
j_node = compute_shape_factor(sx_node, x);
113116
}
114117
if ((ey_type[0] == CELL) || (ez_type[0] == CELL) || (bx_type[0] == CELL)) {
115118
j_cell = compute_shape_factor(sx_cell, x - 0.5_rt);
116119
}
117120
if ((ex_type[0] == NODE) || (by_type[0] == NODE) || (bz_type[0] == NODE)) {
118-
j_node_v = compute_shape_factor_lower_in_v(sx_node_v, x);
121+
j_node_v = compute_shape_factor_galerkin(sx_node_galerkin, x);
119122
}
120123
if ((ex_type[0] == CELL) || (by_type[0] == CELL) || (bz_type[0] == CELL)) {
121-
j_cell_v = compute_shape_factor_lower_in_v(sx_cell_v, x - 0.5_rt);
124+
j_cell_v = compute_shape_factor_galerkin(sx_cell_galerkin, x - 0.5_rt);
122125
}
123-
const amrex::Real (&sx_ex)[depos_order + 1 - lower_in_v] = ((ex_type[0] == NODE) ? sx_node_v : sx_cell_v);
126+
const amrex::Real (&sx_ex)[depos_order + 1 - galerkin_interpolation] = ((ex_type[0] == NODE) ? sx_node_galerkin : sx_cell_galerkin);
124127
const amrex::Real (&sx_ey)[depos_order + 1 ] = ((ey_type[0] == NODE) ? sx_node : sx_cell );
125128
const amrex::Real (&sx_ez)[depos_order + 1 ] = ((ez_type[0] == NODE) ? sx_node : sx_cell );
126129
const amrex::Real (&sx_bx)[depos_order + 1 ] = ((bx_type[0] == NODE) ? sx_node : sx_cell );
127-
const amrex::Real (&sx_by)[depos_order + 1 - lower_in_v] = ((by_type[0] == NODE) ? sx_node_v : sx_cell_v);
128-
const amrex::Real (&sx_bz)[depos_order + 1 - lower_in_v] = ((bz_type[0] == NODE) ? sx_node_v : sx_cell_v);
130+
const amrex::Real (&sx_by)[depos_order + 1 - galerkin_interpolation] = ((by_type[0] == NODE) ? sx_node_galerkin : sx_cell_galerkin);
131+
const amrex::Real (&sx_bz)[depos_order + 1 - galerkin_interpolation] = ((bz_type[0] == NODE) ? sx_node_galerkin : sx_cell_galerkin);
129132
int const j_ex = ((ex_type[0] == NODE) ? j_node_v : j_cell_v);
130133
int const j_ey = ((ey_type[0] == NODE) ? j_node : j_cell );
131134
int const j_ez = ((ez_type[0] == NODE) ? j_node : j_cell );
@@ -138,8 +141,8 @@ void doGatherShapeN (const amrex::ParticleReal xp,
138141
const amrex::Real y = (yp-ymin)*dyi;
139142
amrex::Real sy_node[depos_order + 1];
140143
amrex::Real sy_cell[depos_order + 1];
141-
amrex::Real sy_node_v[depos_order + 1 - lower_in_v];
142-
amrex::Real sy_cell_v[depos_order + 1 - lower_in_v];
144+
amrex::Real sy_node_v[depos_order + 1 - galerkin_interpolation];
145+
amrex::Real sy_cell_v[depos_order + 1 - galerkin_interpolation];
143146
int k_node = 0;
144147
int k_cell = 0;
145148
int k_node_v = 0;
@@ -151,17 +154,17 @@ void doGatherShapeN (const amrex::ParticleReal xp,
151154
k_cell = compute_shape_factor(sy_cell, y - 0.5_rt);
152155
}
153156
if ((ey_type[1] == NODE) || (bx_type[1] == NODE) || (bz_type[1] == NODE)) {
154-
k_node_v = compute_shape_factor_lower_in_v(sy_node_v, y);
157+
k_node_v = compute_shape_factor_galerkin(sy_node_v, y);
155158
}
156159
if ((ey_type[1] == CELL) || (bx_type[1] == CELL) || (bz_type[1] == CELL)) {
157-
k_cell_v = compute_shape_factor_lower_in_v(sy_cell_v, y - 0.5_rt);
160+
k_cell_v = compute_shape_factor_galerkin(sy_cell_v, y - 0.5_rt);
158161
}
159162
const amrex::Real (&sy_ex)[depos_order + 1 ] = ((ex_type[1] == NODE) ? sy_node : sy_cell );
160-
const amrex::Real (&sy_ey)[depos_order + 1 - lower_in_v] = ((ey_type[1] == NODE) ? sy_node_v : sy_cell_v);
163+
const amrex::Real (&sy_ey)[depos_order + 1 - galerkin_interpolation] = ((ey_type[1] == NODE) ? sy_node_v : sy_cell_v);
161164
const amrex::Real (&sy_ez)[depos_order + 1 ] = ((ez_type[1] == NODE) ? sy_node : sy_cell );
162-
const amrex::Real (&sy_bx)[depos_order + 1 - lower_in_v] = ((bx_type[1] == NODE) ? sy_node_v : sy_cell_v);
165+
const amrex::Real (&sy_bx)[depos_order + 1 - galerkin_interpolation] = ((bx_type[1] == NODE) ? sy_node_v : sy_cell_v);
163166
const amrex::Real (&sy_by)[depos_order + 1 ] = ((by_type[1] == NODE) ? sy_node : sy_cell );
164-
const amrex::Real (&sy_bz)[depos_order + 1 - lower_in_v] = ((bz_type[1] == NODE) ? sy_node_v : sy_cell_v);
167+
const amrex::Real (&sy_bz)[depos_order + 1 - galerkin_interpolation] = ((bz_type[1] == NODE) ? sy_node_v : sy_cell_v);
165168
int const k_ex = ((ex_type[1] == NODE) ? k_node : k_cell );
166169
int const k_ey = ((ey_type[1] == NODE) ? k_node_v : k_cell_v);
167170
int const k_ez = ((ez_type[1] == NODE) ? k_node : k_cell );
@@ -174,8 +177,8 @@ void doGatherShapeN (const amrex::ParticleReal xp,
174177
const amrex::Real z = (zp-zmin)*dzi;
175178
amrex::Real sz_node[depos_order + 1];
176179
amrex::Real sz_cell[depos_order + 1];
177-
amrex::Real sz_node_v[depos_order + 1 - lower_in_v];
178-
amrex::Real sz_cell_v[depos_order + 1 - lower_in_v];
180+
amrex::Real sz_node_v[depos_order + 1 - galerkin_interpolation];
181+
amrex::Real sz_cell_v[depos_order + 1 - galerkin_interpolation];
179182
int l_node = 0;
180183
int l_cell = 0;
181184
int l_node_v = 0;
@@ -187,16 +190,16 @@ void doGatherShapeN (const amrex::ParticleReal xp,
187190
l_cell = compute_shape_factor(sz_cell, z - 0.5_rt);
188191
}
189192
if ((ez_type[zdir] == NODE) || (bx_type[zdir] == NODE) || (by_type[zdir] == NODE)) {
190-
l_node_v = compute_shape_factor_lower_in_v(sz_node_v, z);
193+
l_node_v = compute_shape_factor_galerkin(sz_node_v, z);
191194
}
192195
if ((ez_type[zdir] == CELL) || (bx_type[zdir] == CELL) || (by_type[zdir] == CELL)) {
193-
l_cell_v = compute_shape_factor_lower_in_v(sz_cell_v, z - 0.5_rt);
196+
l_cell_v = compute_shape_factor_galerkin(sz_cell_v, z - 0.5_rt);
194197
}
195198
const amrex::Real (&sz_ex)[depos_order + 1 ] = ((ex_type[zdir] == NODE) ? sz_node : sz_cell );
196199
const amrex::Real (&sz_ey)[depos_order + 1 ] = ((ey_type[zdir] == NODE) ? sz_node : sz_cell );
197-
const amrex::Real (&sz_ez)[depos_order + 1 - lower_in_v] = ((ez_type[zdir] == NODE) ? sz_node_v : sz_cell_v);
198-
const amrex::Real (&sz_bx)[depos_order + 1 - lower_in_v] = ((bx_type[zdir] == NODE) ? sz_node_v : sz_cell_v);
199-
const amrex::Real (&sz_by)[depos_order + 1 - lower_in_v] = ((by_type[zdir] == NODE) ? sz_node_v : sz_cell_v);
200+
const amrex::Real (&sz_ez)[depos_order + 1 - galerkin_interpolation] = ((ez_type[zdir] == NODE) ? sz_node_v : sz_cell_v);
201+
const amrex::Real (&sz_bx)[depos_order + 1 - galerkin_interpolation] = ((bx_type[zdir] == NODE) ? sz_node_v : sz_cell_v);
202+
const amrex::Real (&sz_by)[depos_order + 1 - galerkin_interpolation] = ((by_type[zdir] == NODE) ? sz_node_v : sz_cell_v);
200203
const amrex::Real (&sz_bz)[depos_order + 1 ] = ((bz_type[zdir] == NODE) ? sz_node : sz_cell );
201204
int const l_ex = ((ex_type[zdir] == NODE) ? l_node : l_cell );
202205
int const l_ey = ((ey_type[zdir] == NODE) ? l_node : l_cell );
@@ -209,7 +212,7 @@ void doGatherShapeN (const amrex::ParticleReal xp,
209212
// Each field is gathered in a separate block of
210213
// AMREX_SPACEDIM nested loops because the deposition
211214
// order can differ for each component of each field
212-
// when lower_in_v is set to 1
215+
// when galerkin_interpolation is set to 1
213216
#if (AMREX_SPACEDIM == 2)
214217
// Gather field on particle Eyp from field on grid ey_arr
215218
for (int iz=0; iz<=depos_order; iz++){
@@ -221,7 +224,7 @@ void doGatherShapeN (const amrex::ParticleReal xp,
221224
// Gather field on particle Exp from field on grid ex_arr
222225
// Gather field on particle Bzp from field on grid bz_arr
223226
for (int iz=0; iz<=depos_order; iz++){
224-
for (int ix=0; ix<=depos_order-lower_in_v; ix++){
227+
for (int ix=0; ix<=depos_order-galerkin_interpolation; ix++){
225228
Exp += sx_ex[ix]*sz_ex[iz]*
226229
ex_arr(lo.x+j_ex+ix, lo.y+l_ex+iz, 0, 0);
227230
Bzp += sx_bz[ix]*sz_bz[iz]*
@@ -230,7 +233,7 @@ void doGatherShapeN (const amrex::ParticleReal xp,
230233
}
231234
// Gather field on particle Ezp from field on grid ez_arr
232235
// Gather field on particle Bxp from field on grid bx_arr
233-
for (int iz=0; iz<=depos_order-lower_in_v; iz++){
236+
for (int iz=0; iz<=depos_order-galerkin_interpolation; iz++){
234237
for (int ix=0; ix<=depos_order; ix++){
235238
Ezp += sx_ez[ix]*sz_ez[iz]*
236239
ez_arr(lo.x+j_ez+ix, lo.y+l_ez+iz, 0, 0);
@@ -239,8 +242,8 @@ void doGatherShapeN (const amrex::ParticleReal xp,
239242
}
240243
}
241244
// Gather field on particle Byp from field on grid by_arr
242-
for (int iz=0; iz<=depos_order-lower_in_v; iz++){
243-
for (int ix=0; ix<=depos_order-lower_in_v; ix++){
245+
for (int iz=0; iz<=depos_order-galerkin_interpolation; iz++){
246+
for (int ix=0; ix<=depos_order-galerkin_interpolation; ix++){
244247
Byp += sx_by[ix]*sz_by[iz]*
245248
by_arr(lo.x+j_by+ix, lo.y+l_by+iz, 0, 0);
246249
}
@@ -273,7 +276,7 @@ void doGatherShapeN (const amrex::ParticleReal xp,
273276
// Gather field on particle Exp from field on grid ex_arr
274277
// Gather field on particle Bzp from field on grid bz_arr
275278
for (int iz=0; iz<=depos_order; iz++){
276-
for (int ix=0; ix<=depos_order-lower_in_v; ix++){
279+
for (int ix=0; ix<=depos_order-galerkin_interpolation; ix++){
277280
const amrex::Real dEx = (+ ex_arr(lo.x+j_ex+ix, lo.y+l_ex+iz, 0, 2*imode-1)*xy.real()
278281
- ex_arr(lo.x+j_ex+ix, lo.y+l_ex+iz, 0, 2*imode)*xy.imag());
279282
Exp += sx_ex[ix]*sz_ex[iz]*dEx;
@@ -284,7 +287,7 @@ void doGatherShapeN (const amrex::ParticleReal xp,
284287
}
285288
// Gather field on particle Ezp from field on grid ez_arr
286289
// Gather field on particle Bxp from field on grid bx_arr
287-
for (int iz=0; iz<=depos_order-lower_in_v; iz++){
290+
for (int iz=0; iz<=depos_order-galerkin_interpolation; iz++){
288291
for (int ix=0; ix<=depos_order; ix++){
289292
const amrex::Real dEz = (+ ez_arr(lo.x+j_ez+ix, lo.y+l_ez+iz, 0, 2*imode-1)*xy.real()
290293
- ez_arr(lo.x+j_ez+ix, lo.y+l_ez+iz, 0, 2*imode)*xy.imag());
@@ -295,8 +298,8 @@ void doGatherShapeN (const amrex::ParticleReal xp,
295298
}
296299
}
297300
// Gather field on particle Byp from field on grid by_arr
298-
for (int iz=0; iz<=depos_order-lower_in_v; iz++){
299-
for (int ix=0; ix<=depos_order-lower_in_v; ix++){
301+
for (int iz=0; iz<=depos_order-galerkin_interpolation; iz++){
302+
for (int ix=0; ix<=depos_order-galerkin_interpolation; ix++){
300303
const amrex::Real dBy = (+ by_arr(lo.x+j_by+ix, lo.y+l_by+iz, 0, 2*imode-1)*xy.real()
301304
- by_arr(lo.x+j_by+ix, lo.y+l_by+iz, 0, 2*imode)*xy.imag());
302305
Byp += sx_by[ix]*sz_by[iz]*dBy;
@@ -318,23 +321,23 @@ void doGatherShapeN (const amrex::ParticleReal xp,
318321
// Gather field on particle Exp from field on grid ex_arr
319322
for (int iz=0; iz<=depos_order; iz++){
320323
for (int iy=0; iy<=depos_order; iy++){
321-
for (int ix=0; ix<=depos_order-lower_in_v; ix++){
324+
for (int ix=0; ix<= depos_order - galerkin_interpolation; ix++){
322325
Exp += sx_ex[ix]*sy_ex[iy]*sz_ex[iz]*
323326
ex_arr(lo.x+j_ex+ix, lo.y+k_ex+iy, lo.z+l_ex+iz);
324327
}
325328
}
326329
}
327330
// Gather field on particle Eyp from field on grid ey_arr
328331
for (int iz=0; iz<=depos_order; iz++){
329-
for (int iy=0; iy<=depos_order-lower_in_v; iy++){
332+
for (int iy=0; iy<= depos_order - galerkin_interpolation; iy++){
330333
for (int ix=0; ix<=depos_order; ix++){
331334
Eyp += sx_ey[ix]*sy_ey[iy]*sz_ey[iz]*
332335
ey_arr(lo.x+j_ey+ix, lo.y+k_ey+iy, lo.z+l_ey+iz);
333336
}
334337
}
335338
}
336339
// Gather field on particle Ezp from field on grid ez_arr
337-
for (int iz=0; iz<=depos_order-lower_in_v; iz++){
340+
for (int iz=0; iz<= depos_order - galerkin_interpolation; iz++){
338341
for (int iy=0; iy<=depos_order; iy++){
339342
for (int ix=0; ix<=depos_order; ix++){
340343
Ezp += sx_ez[ix]*sy_ez[iy]*sz_ez[iz]*
@@ -344,25 +347,25 @@ void doGatherShapeN (const amrex::ParticleReal xp,
344347
}
345348
// Gather field on particle Bzp from field on grid bz_arr
346349
for (int iz=0; iz<=depos_order; iz++){
347-
for (int iy=0; iy<=depos_order-lower_in_v; iy++){
348-
for (int ix=0; ix<=depos_order-lower_in_v; ix++){
350+
for (int iy=0; iy<= depos_order - galerkin_interpolation; iy++){
351+
for (int ix=0; ix<= depos_order - galerkin_interpolation; ix++){
349352
Bzp += sx_bz[ix]*sy_bz[iy]*sz_bz[iz]*
350353
bz_arr(lo.x+j_bz+ix, lo.y+k_bz+iy, lo.z+l_bz+iz);
351354
}
352355
}
353356
}
354357
// Gather field on particle Byp from field on grid by_arr
355-
for (int iz=0; iz<=depos_order-lower_in_v; iz++){
358+
for (int iz=0; iz<= depos_order - galerkin_interpolation; iz++){
356359
for (int iy=0; iy<=depos_order; iy++){
357-
for (int ix=0; ix<=depos_order-lower_in_v; ix++){
360+
for (int ix=0; ix<= depos_order - galerkin_interpolation; ix++){
358361
Byp += sx_by[ix]*sy_by[iy]*sz_by[iz]*
359362
by_arr(lo.x+j_by+ix, lo.y+k_by+iy, lo.z+l_by+iz);
360363
}
361364
}
362365
}
363366
// Gather field on particle Bxp from field on grid bx_arr
364-
for (int iz=0; iz<=depos_order-lower_in_v; iz++){
365-
for (int iy=0; iy<=depos_order-lower_in_v; iy++){
367+
for (int iz=0; iz<= depos_order - galerkin_interpolation; iz++){
368+
for (int iy=0; iy<= depos_order - galerkin_interpolation; iy++){
366369
for (int ix=0; ix<=depos_order; ix++){
367370
Bxp += sx_bx[ix]*sy_bx[iy]*sz_bx[iz]*
368371
bx_arr(lo.x+j_bx+ix, lo.y+k_bx+iy, lo.z+l_bx+iz);

0 commit comments

Comments
 (0)