Skip to content

Commit 479e12b

Browse files
committed
Fix 1D: filterCreateTransformFromFAB
1 parent f601feb commit 479e12b

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

Source/Particles/ParticleCreation/FilterCreateTransformFromFAB.H

+28-8
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,22 @@ Index filterCreateTransformFromFAB (DstTile& dst1, DstTile& dst2, const amrex::B
6262

6363
constexpr int spacedim = AMREX_SPACEDIM;
6464

65+
#if defined(WARPX_DIM_1D_Z)
66+
const Real zlo_global = geom.ProbLo(0);
67+
const Real dz = geom.CellSize(0);
68+
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
6569
const Real xlo_global = geom.ProbLo(0);
6670
const Real dx = geom.CellSize(0);
67-
const Real ylo_global = (spacedim == 3) ? geom.ProbLo(1) : amrex::Real(0.);
68-
const Real dy = (spacedim == 3) ? geom.CellSize(1) : amrex::Real(0.);
69-
const Real zlo_global = (spacedim == 3) ? geom.ProbLo(2) : geom.ProbLo(1);
70-
const Real dz = (spacedim == 3) ? geom.CellSize(2) : geom.CellSize(1);
71+
const Real zlo_global = geom.ProbLo(1);
72+
const Real dz = geom.CellSize(1);
73+
#elif defined(WARPX_DIM_3D)
74+
const Real xlo_global = geom.ProbLo(0);
75+
const Real dx = geom.CellSize(0);
76+
const Real ylo_global = geom.ProbLo(1);
77+
const Real dy = geom.CellSize(1);
78+
const Real zlo_global = geom.ProbLo(2);
79+
const Real dz = geom.CellSize(2);
80+
#endif
7181

7282
const auto arrNumPartCreation = src_FAB->array();
7383
Gpu::DeviceVector<Index> offsets(ncells);
@@ -91,14 +101,24 @@ Index filterCreateTransformFromFAB (DstTile& dst1, DstTile& dst2, const amrex::B
91101
{
92102
const IntVect iv = box.atOffset(i);
93103
const int j = iv[0];
94-
const int k = iv[1];
104+
const int k = (spacedim >= 2) ? iv[1] : 0;
95105
const int l = (spacedim == 3) ? iv[2] : 0;
96106

97107
// Currently all particles are created on nodes. This makes it useless
98108
// to use N>1 (for now).
99-
const Real x = xlo_global + j*dx;
100-
const Real y = ylo_global + k*dy;
101-
const Real z = (spacedim == 3) ? zlo_global + l*dz : zlo_global + k*dz;
109+
#if defined(WARPX_DIM_1D_Z)
110+
Real const x = 0.0;
111+
Real const y = 0.0;
112+
Real const z = zlo_global + j*dz;
113+
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
114+
Real const x = xlo_global + j*dx;
115+
Real const y = 0.0;
116+
Real const z = zlo_global + k*dz;
117+
#elif defined(WARPX_DIM_3D)
118+
Real const x = xlo_global + j*dx;
119+
Real const y = ylo_global + k*dy;
120+
Real const z = zlo_global + l*dz;
121+
#endif
102122

103123
for (int n = 0; n < N; ++n)
104124
{

0 commit comments

Comments
 (0)