Skip to content

Commit 1f17ca0

Browse files
committed
Fixes in Source/Particles/Pusher/GetAndSetPosition.H
1 parent cb9503c commit 1f17ca0

File tree

1 file changed

+19
-34
lines changed

1 file changed

+19
-34
lines changed

Source/Particles/Pusher/GetAndSetPosition.H

+19-34
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,16 @@ struct GetParticlePosition
6363
{
6464
using RType = amrex::ParticleReal;
6565

66-
#if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
67-
const RType* AMREX_RESTRICT m_x = nullptr;
68-
const RType* AMREX_RESTRICT m_z = nullptr;
69-
#elif defined(WARPX_DIM_3D)
7066
const RType* AMREX_RESTRICT m_x = nullptr;
7167
const RType* AMREX_RESTRICT m_y = nullptr;
7268
const RType* AMREX_RESTRICT m_z = nullptr;
73-
#elif defined(WARPX_DIM_1D_Z)
74-
const RType* AMREX_RESTRICT m_z = nullptr;
75-
#endif
7669

7770
#if defined(WARPX_DIM_RZ)
7871
const RType* m_theta = nullptr;
79-
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
80-
static constexpr RType m_y_default = RType(0.0);
81-
#elif defined(WARPX_DIM_1D_Z)
72+
#endif
73+
8274
static constexpr RType m_x_default = RType(0.0);
8375
static constexpr RType m_y_default = RType(0.0);
84-
#endif
8576

8677
GetParticlePosition () = default;
8778

@@ -118,20 +109,20 @@ struct GetParticlePosition
118109
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
119110
void operator() (const long i, RType& x, RType& y, RType& z) const noexcept
120111
{
121-
#ifdef WARPX_DIM_RZ
112+
#if defined(WARPX_DIM_RZ)
122113
RType const r = m_x[i];
123114
x = r*std::cos(m_theta[i]);
124115
y = r*std::sin(m_theta[i]);
125116
z = m_z[i];
126-
#elif WARPX_DIM_3D
117+
#elif defined(WARPX_DIM_3D)
127118
x = m_x[i];
128119
y = m_y[i];
129120
z = m_z[i];
130-
#elif WARPX_DIM_XZ
121+
#elif defined(WARPX_DIM_XZ)
131122
x = m_x[i];
132123
y = m_y_default;
133124
z = m_z[i];
134-
#else
125+
#elif defined(WARPX_DIM_1D_Z)
135126
x = m_x_default;
136127
y = m_y_default;
137128
z = m_z[i];
@@ -146,19 +137,19 @@ struct GetParticlePosition
146137
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
147138
void AsStored (const long i, RType& x, RType& y, RType& z) const noexcept
148139
{
149-
#ifdef WARPX_DIM_RZ
140+
#if defined(WARPX_DIM_RZ)
150141
x = m_x[i];
151142
y = m_theta[i];
152143
z = m_z[i];
153-
#elif WARPX_DIM_3D
144+
#elif defined(WARPX_DIM_3D)
154145
x = m_x[i];
155146
y = m_y[i];
156147
z = m_z[i];
157-
#elif WARPX_DIM_XZ
148+
#elif defined(WARPX_DIM_XZ)
158149
x = m_x[i];
159150
y = m_y_default;
160151
z = m_z[i];
161-
#else
152+
#elif defined(WARPX_DIM_1D_Z)
162153
x = m_x_default;
163154
y = m_y_default;
164155
z = m_z[i];
@@ -178,16 +169,10 @@ struct SetParticlePosition
178169
{
179170
using RType = amrex::ParticleReal;
180171

181-
#if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
182-
RType* AMREX_RESTRICT m_x;
183-
RType* AMREX_RESTRICT m_z;
184-
#elif defined(WARPX_DIM_3D)
185172
RType* AMREX_RESTRICT m_x;
186173
RType* AMREX_RESTRICT m_y;
187174
RType* AMREX_RESTRICT m_z;
188-
#elif defined(WARPX_DIM_1D_Z)
189-
RType* AMREX_RESTRICT m_z;
190-
#endif
175+
191176
#if defined(WARPX_DIM_RZ)
192177
RType* AMREX_RESTRICT m_theta;
193178
#endif
@@ -217,18 +202,18 @@ struct SetParticlePosition
217202
void operator() (const long i, RType x, RType y, RType z) const noexcept
218203
{
219204
amrex::ignore_unused(x,y,z);
220-
#ifdef WARPX_DIM_RZ
205+
#if defined(WARPX_DIM_RZ)
221206
m_theta[i] = std::atan2(y, x);
222207
m_x[i] = std::sqrt(x*x + y*y);
223208
m_z[i] = z;
224-
#elif WARPX_DIM_3D
209+
#elif defined(WARPX_DIM_3D)
225210
m_x[i] = x;
226211
m_y[i] = y;
227212
m_z[i] = z;
228-
#elif WARPX_DIM_XZ
213+
#elif defined(WARPX_DIM_XZ)
229214
m_x[i] = x;
230215
m_z[i] = z;
231-
#else
216+
#elif defined(WARPX_DIM_1D_Z)
232217
m_z[i] = z;
233218
#endif
234219
}
@@ -241,18 +226,18 @@ struct SetParticlePosition
241226
void AsStored (const long i, RType x, RType y, RType z) const noexcept
242227
{
243228
amrex::ignore_unused(x,y,z);
244-
#ifdef WARPX_DIM_RZ
229+
#if defined(WARPX_DIM_RZ)
245230
m_x[i] = x;
246231
m_theta[i] = y;
247232
m_z[i] = z;
248-
#elif WARPX_DIM_3D
233+
#elif defined(WARPX_DIM_3D)
249234
m_x[i] = x;
250235
m_y[i] = y;
251236
m_z[i] = z;
252-
#elif WARPX_DIM_XZ
237+
#elif defined(WARPX_DIM_XZ)
253238
m_x[i] = x;
254239
m_z[i] = z;
255-
#else
240+
#elif defined(WARPX_DIM_1D_Z)
256241
m_z[i] = z;
257242
#endif
258243
}

0 commit comments

Comments
 (0)