Skip to content

Commit 0655ce3

Browse files
committed
RZ: Rename 1st Component to r
Update ``PIdx`` - RZ: first component is "r" Follow-ups could: - RZ: move "theta" after "r", "z" - all: move "w" (weight) after momenta
1 parent b0ae812 commit 0655ce3

File tree

8 files changed

+54
-27
lines changed

8 files changed

+54
-27
lines changed

Docs/source/developers/dimensionality.rst

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Dimensions CMake Option
1515
**2D3V** ``WarpX_DIMS=2``
1616
**1D3V** ``WarpX_DIMS=1``
1717
**RZ** ``WarpX_DIMS=RZ``
18+
**all** ``WarpX_DIMS="1;2;RZ;3"``
1819
========== ==========================
1920

2021
Note that one can :ref:`build multiple WarpX dimensions at once <building-cmake-options>` via ``-DWarpX_DIMS="1;2;RZ;3"``.

Source/Diagnostics/ComputeDiagFunctors/BackTransformParticleFunctor.H

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct LorentzTransformParticles
147147
dst.m_rdata[PIdx::y][i_dst] = yp;
148148
dst.m_rdata[PIdx::z][i_dst] = zp;
149149
#elif defined (WARPX_DIM_RZ)
150-
dst.m_rdata[PIdx::x][i_dst] = std::sqrt(xp*xp + yp*yp);
150+
dst.m_rdata[PIdx::r][i_dst] = std::sqrt(xp * xp + yp * yp);
151151
dst.m_rdata[PIdx::z][i_dst] = zp;
152152
dst.m_rdata[PIdx::theta][i_dst] = std::atan2(yp, xp);
153153
#elif defined (WARPX_DIM_XZ)

Source/Diagnostics/WarpXOpenPMD.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ WarpXOpenPMDPlot::SaveRealProperty (ParticleIter& pti,
913913
// reconstruct Cartesian positions for RZ simulations
914914
// r,z,theta -> x,y,z
915915
#if defined(WARPX_DIM_RZ)
916-
auto const * const r = soa.GetRealData(PIdx::x).data();
916+
auto const * const r = soa.GetRealData(PIdx::r).data();
917917
auto const * const theta = soa.GetRealData(PIdx::theta).data();
918918

919919
if (write_real_comp[0]) {

Source/Particles/NamedComponentParticleContainer.H

+16-9
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,23 @@
2323
struct PIdx
2424
{
2525
enum {
26-
#if !defined (WARPX_DIM_1D_Z)
27-
x,
26+
#ifdef WARPX_DIM_RZ
27+
r, ///< position in r
28+
#elif !defined (WARPX_DIM_1D_Z)
29+
x, ///< position in x
2830
#endif
2931
#if defined (WARPX_DIM_3D)
30-
y,
32+
y, ///< position in y
3133
#endif
32-
z,
33-
w, ///< weight
34-
ux, uy, uz,
34+
z, ///< position in z
35+
w, ///< weight
36+
ux, ///< momentum in x
37+
uy, ///< momentum in y
38+
uz, ///< momentum in z
3539
#ifdef WARPX_DIM_RZ
36-
theta, ///< RZ needs all three position components
40+
theta, ///< azimuthal position angle
3741
#endif
38-
nattribs ///< number of compile-time attributes
42+
nattribs ///< number of compile-time attributes
3943
};
4044
};
4145

@@ -78,7 +82,9 @@ public:
7882
NamedComponentParticleContainer (amrex::AmrParGDB* amr_pgdb)
7983
: amrex::ParticleContainerPureSoA<PIdx::nattribs, 0, T_Allocator>(amr_pgdb) {
8084
// build up the map of string names to particle component numbers
81-
#if !defined (WARPX_DIM_1D_Z)
85+
#ifdef WARPX_DIM_RZ
86+
particle_comps["r"] = PIdx::r;
87+
#elif !defined (WARPX_DIM_1D_Z)
8288
particle_comps["x"] = PIdx::x;
8389
#endif
8490
#if defined (WARPX_DIM_3D)
@@ -89,6 +95,7 @@ public:
8995
particle_comps["ux"] = PIdx::ux;
9096
particle_comps["uy"] = PIdx::uy;
9197
particle_comps["uz"] = PIdx::uz;
98+
9299
#ifdef WARPX_DIM_RZ
93100
particle_comps["theta"] = PIdx::theta;
94101
#endif

Source/Particles/ParticleCreation/SmartCreate.H

+5-1
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@ struct SmartCreate
5252
prt.m_rdata[PIdx::x][i_prt] = x;
5353
prt.m_rdata[PIdx::y][i_prt] = y;
5454
prt.m_rdata[PIdx::z][i_prt] = z;
55-
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
55+
#elif defined(WARPX_DIM_XZ)
5656
prt.m_rdata[PIdx::x][i_prt] = x;
5757
prt.m_rdata[PIdx::z][i_prt] = z;
5858
amrex::ignore_unused(y);
59+
#elif defined(WARPX_DIM_RZ)
60+
prt.m_rdata[PIdx::r][i_prt] = x;
61+
prt.m_rdata[PIdx::z][i_prt] = z;
62+
amrex::ignore_unused(y);
5963
#else
6064
prt.m_rdata[PIdx::z][i_prt] = z;
6165
amrex::ignore_unused(x,y);

Source/Particles/PhysicalParticleContainer.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ namespace
219219
) noexcept
220220
{
221221
pa[PIdx::z][ip] = 0._rt;
222-
#if (AMREX_SPACEDIM >= 2)
222+
#ifdef WARPX_DIM_RZ
223+
pa[PIdx::r][ip] = 0._rt;
224+
#elif !defined(WARPX_DIM_1D_Z)
223225
pa[PIdx::x][ip] = 0._rt;
224226
#endif
225227
#if defined(WARPX_DIM_3D)
@@ -1448,10 +1450,11 @@ PhysicalParticleContainer::AddPlasma (PlasmaInjector const& plasma_injector, int
14481450
pa[PIdx::x][ip] = pos.x;
14491451
pa[PIdx::y][ip] = pos.y;
14501452
pa[PIdx::z][ip] = pos.z;
1451-
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
1452-
#ifdef WARPX_DIM_RZ
1453+
#elif defined(WARPX_DIM_RZ)
1454+
pa[PIdx::r][ip] = xb;
1455+
pa[PIdx::z][ip] = pos.z;
14531456
pa[PIdx::theta][ip] = theta;
1454-
#endif
1457+
#elif defined(WARPX_DIM_XZ)
14551458
pa[PIdx::x][ip] = xb;
14561459
pa[PIdx::z][ip] = pos.z;
14571460
#else
@@ -1946,7 +1949,7 @@ PhysicalParticleContainer::AddPlasmaFlux (PlasmaInjector const& plasma_injector,
19461949
pa[PIdx::z][ip] = ppos.z;
19471950
#elif defined(WARPX_DIM_RZ)
19481951
pa[PIdx::theta][ip] = std::atan2(ppos.y, ppos.x);
1949-
pa[PIdx::x][ip] = std::sqrt(ppos.x*ppos.x + ppos.y*ppos.y);
1952+
pa[PIdx::r][ip] = std::sqrt(ppos.x*ppos.x + ppos.y*ppos.y);
19501953
pa[PIdx::z][ip] = ppos.z;
19511954
#elif defined(WARPX_DIM_XZ)
19521955
pa[PIdx::x][ip] = ppos.x;

Source/Particles/Pusher/GetAndSetPosition.H

+21-9
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void get_particle_position (const WarpXParticleContainer::SuperParticleType& p,
3434

3535
#if defined(WARPX_DIM_RZ)
3636
amrex::ParticleReal const theta = p.rdata(T_PIdx::theta);
37-
amrex::ParticleReal const r = p.pos(T_PIdx::x);
37+
amrex::ParticleReal const r = p.pos(T_PIdx::r);
3838
x = r*std::cos(theta);
3939
y = r*std::sin(theta);
4040
z = p.pos(PIdx::z);
@@ -63,9 +63,12 @@ struct GetParticlePosition
6363
{
6464
using RType = amrex::ParticleReal;
6565

66-
#if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
66+
#if defined(WARPX_DIM_XZ)
6767
const RType* AMREX_RESTRICT m_x = nullptr;
6868
const RType* AMREX_RESTRICT m_z = nullptr;
69+
#elif defined(WARPX_DIM_RZ)
70+
const RType* AMREX_RESTRICT m_r = nullptr;
71+
const RType* AMREX_RESTRICT m_z = nullptr;
6972
#elif defined(WARPX_DIM_3D)
7073
const RType* AMREX_RESTRICT m_x = nullptr;
7174
const RType* AMREX_RESTRICT m_y = nullptr;
@@ -97,9 +100,12 @@ struct GetParticlePosition
97100
{
98101
const auto& soa = a_pti.GetStructOfArrays();
99102

100-
#if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
103+
#if defined(WARPX_DIM_XZ)
101104
m_x = soa.GetRealData(PIdx::x).dataPtr() + a_offset;
102105
m_z = soa.GetRealData(PIdx::z).dataPtr() + a_offset;
106+
#elif defined(WARPX_DIM_RZ)
107+
m_r = soa.GetRealData(PIdx::r).dataPtr() + a_offset;
108+
m_z = soa.GetRealData(PIdx::z).dataPtr() + a_offset;
103109
#elif defined(WARPX_DIM_3D)
104110
m_x = soa.GetRealData(PIdx::x).dataPtr() + a_offset;
105111
m_y = soa.GetRealData(PIdx::y).dataPtr() + a_offset;
@@ -119,7 +125,7 @@ struct GetParticlePosition
119125
void operator() (const long i, RType& x, RType& y, RType& z) const noexcept
120126
{
121127
#ifdef WARPX_DIM_RZ
122-
RType const r = m_x[i];
128+
RType const r = m_r[i];
123129
x = r*std::cos(m_theta[i]);
124130
y = r*std::sin(m_theta[i]);
125131
z = m_z[i];
@@ -147,7 +153,7 @@ struct GetParticlePosition
147153
void AsStored (const long i, RType& x, RType& y, RType& z) const noexcept
148154
{
149155
#ifdef WARPX_DIM_RZ
150-
x = m_x[i];
156+
x = m_r[i];
151157
y = m_theta[i];
152158
z = m_z[i];
153159
#elif WARPX_DIM_3D
@@ -178,9 +184,12 @@ struct SetParticlePosition
178184
{
179185
using RType = amrex::ParticleReal;
180186

181-
#if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
187+
#if defined(WARPX_DIM_XZ)
182188
RType* AMREX_RESTRICT m_x;
183189
RType* AMREX_RESTRICT m_z;
190+
#elif defined(WARPX_DIM_RZ)
191+
RType* AMREX_RESTRICT m_r;
192+
RType* AMREX_RESTRICT m_z;
184193
#elif defined(WARPX_DIM_3D)
185194
RType* AMREX_RESTRICT m_x;
186195
RType* AMREX_RESTRICT m_y;
@@ -196,9 +205,12 @@ struct SetParticlePosition
196205
SetParticlePosition (const ptiType& a_pti, long a_offset = 0) noexcept
197206
{
198207
auto& soa = a_pti.GetStructOfArrays();
199-
#if defined(WARPX_DIM_RZ) || defined(WARPX_DIM_XZ)
208+
#if defined(WARPX_DIM_XZ)
200209
m_x = soa.GetRealData(PIdx::x).dataPtr() + a_offset;
201210
m_z = soa.GetRealData(PIdx::z).dataPtr() + a_offset;
211+
#elif defined(WARPX_DIM_RZ)
212+
m_r = soa.GetRealData(PIdx::r).dataPtr() + a_offset;
213+
m_z = soa.GetRealData(PIdx::z).dataPtr() + a_offset;
202214
#elif defined(WARPX_DIM_3D)
203215
m_x = soa.GetRealData(PIdx::x).dataPtr() + a_offset;
204216
m_y = soa.GetRealData(PIdx::y).dataPtr() + a_offset;
@@ -224,7 +236,7 @@ struct SetParticlePosition
224236
#endif
225237
#ifdef WARPX_DIM_RZ
226238
m_theta[i] = std::atan2(y, x);
227-
m_x[i] = std::sqrt(x*x + y*y);
239+
m_r[i] = std::sqrt(x*x + y*y);
228240
m_z[i] = z;
229241
#elif WARPX_DIM_3D
230242
m_x[i] = x;
@@ -252,7 +264,7 @@ struct SetParticlePosition
252264
amrex::ignore_unused(x,y);
253265
#endif
254266
#ifdef WARPX_DIM_RZ
255-
m_x[i] = x;
267+
m_r[i] = x;
256268
m_theta[i] = y;
257269
m_z[i] = z;
258270
#elif WARPX_DIM_3D

Source/Particles/WarpXParticleContainer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ WarpXParticleContainer::AddNParticles (int /*lev*/, long n,
234234
#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
235235
amrex::ignore_unused(y);
236236
#ifdef WARPX_DIM_RZ
237-
pinned_tile.push_back_real(PIdx::x, r.data(), r.data() + np);
237+
pinned_tile.push_back_real(PIdx::r, r.data(), r.data() + np);
238238
#else
239239
pinned_tile.push_back_real(PIdx::x, x.data() + ibegin, x.data() + iend);
240240
#endif

0 commit comments

Comments
 (0)