|
17 | 17 | #include <AMReX_MultiFab.H>
|
18 | 18 | #include <AMReX_ParIter.H>
|
19 | 19 | #include <AMReX_Particles.H>
|
| 20 | +#include <AMReX_ParticleTile.H> |
20 | 21 |
|
21 | 22 | #include <AMReX_IntVect.H>
|
22 | 23 | #include <AMReX_Vector.H>
|
|
28 | 29 |
|
29 | 30 | namespace impactx
|
30 | 31 | {
|
31 |
| - /** AMReX pre-defined Real attributes |
32 |
| - * |
33 |
| - * These are the AMReX pre-defined struct indexes for the Real attributes |
34 |
| - * stored in an AoS in ImpactXParticleContainer. We document this here, |
35 |
| - * because we change the meaning of these "positions" depending on the |
36 |
| - * coordinate system we are currently in. |
37 |
| - */ |
38 |
| - struct RealAoS |
39 |
| - { |
40 |
| - enum |
41 |
| - { |
42 |
| - x, ///< position in x [m] (at fixed s OR fixed t) |
43 |
| - y, ///< position in y [m] (at fixed s OR fixed t) |
44 |
| - t, ///< time-of-flight c*t [m] (at fixed s) |
45 |
| - nattribs ///< the number of attributes above (always last) |
46 |
| - }; |
47 |
| - |
48 |
| - // at fixed t, the third component represents the position z |
49 |
| - enum { |
50 |
| - z = t ///< position in z [m] (at fixed t) |
51 |
| - }; |
52 |
| - |
53 |
| - //! named labels for fixed s |
54 |
| - static constexpr auto names_s = { "position_x", "position_y", "position_t" }; |
55 |
| - //! named labels for fixed t |
56 |
| - static constexpr auto names_t = { "position_x", "position_y", "position_z" }; |
57 |
| - static_assert(names_s.size() == nattribs); |
58 |
| - static_assert(names_t.size() == nattribs); |
59 |
| - }; |
60 |
| - |
61 |
| - /** This struct indexes the additional Real attributes |
| 32 | + /** This struct indexes the Real attributes |
62 | 33 | * stored in an SoA in ImpactXParticleContainer
|
63 | 34 | */
|
64 | 35 | struct RealSoA
|
65 | 36 | {
|
66 | 37 | enum
|
67 | 38 | {
|
| 39 | + x, ///< position in x [m] (at fixed s or t) |
| 40 | + y, ///< position in y [m] (at fixed s or t) |
| 41 | + t, ///< time-of-flight ct [m] (at fixed s) |
68 | 42 | ux, ///< momentum in x, scaled by the magnitude of the reference momentum [unitless] (at fixed s or t)
|
69 | 43 | uy, ///< momentum in y, scaled by the magnitude of the reference momentum [unitless] (at fixed s or t)
|
70 | 44 | pt, ///< energy deviation, scaled by speed of light * the magnitude of the reference momentum [unitless] (at fixed s)
|
71 | 45 | qm, ///< charge to mass ratio, in q_e/m_e [q_e/eV]
|
72 |
| - w, ///< particle weight, number of real particles represented by this macroparticle [unitless] |
| 46 | + w, ///< particle weight, unitless |
73 | 47 | nattribs ///< the number of attributes above (always last)
|
74 | 48 | };
|
75 | 49 |
|
76 |
| - // at fixed t, the third component represents the momentum in z |
| 50 | + // at fixed t, the third component represents the position z, the 6th component represents the momentum in z |
77 | 51 | enum {
|
| 52 | + z = t, ///< position in z [m] (at fixed t) |
78 | 53 | pz = pt ///< momentum in z, scaled by the magnitude of the reference momentum [unitless] (at fixed t)
|
79 | 54 | };
|
80 | 55 |
|
81 | 56 | //! named labels for fixed s
|
82 |
| - static constexpr auto names_s = { "momentum_x", "momentum_y", "momentum_t", "qm", "weighting" }; |
| 57 | + static constexpr auto names_s = { "position_x", "position_y", "position_t", "momentum_x", "momentum_y", "momentum_t", "qm", "weighting" }; |
83 | 58 | //! named labels for fixed t
|
84 |
| - static constexpr auto names_t = { "momentum_x", "momentum_y", "momentum_z", "qm", "weighting" }; |
| 59 | + static constexpr auto names_t = { "position_x", "position_y", "position_z", "momentum_x", "momentum_y", "momentum_z", "qm", "weighting" }; |
85 | 60 | static_assert(names_s.size() == nattribs);
|
86 | 61 | static_assert(names_t.size() == nattribs);
|
87 | 62 | };
|
88 | 63 |
|
89 |
| - /** This struct indexes the additional Integer attributes |
| 64 | + /** This struct indexes the Integer attributes |
90 | 65 | * stored in an SoA in ImpactXParticleContainer
|
91 | 66 | */
|
92 | 67 | struct IntSoA
|
93 | 68 | {
|
94 | 69 | enum
|
95 | 70 | {
|
96 |
| - nattribs ///< the number of particles above (always last) |
| 71 | + id, |
| 72 | + cpu, |
| 73 | + nattribs ///< the number of attributes above (always last) |
97 | 74 | };
|
| 75 | + |
| 76 | + //! named labels for fixed s |
| 77 | + static constexpr auto names_s = { "id", "cpu" }; |
| 78 | + //! named labels for fixed t |
| 79 | + static constexpr auto names_t = { "id", "cpu" }; |
| 80 | + static_assert(names_s.size() == nattribs); |
| 81 | + static_assert(names_t.size() == nattribs); |
98 | 82 | };
|
99 | 83 |
|
100 | 84 | /** AMReX iterator for particle boxes
|
101 | 85 | *
|
102 | 86 | * We subclass here to change the default threading strategy, which is
|
103 | 87 | * `static` in AMReX, to `dynamic` in ImpactX.
|
104 | 88 | */
|
105 |
| - class ParIter |
106 |
| - : public amrex::ParIter<0, 0, RealSoA::nattribs, IntSoA::nattribs> |
| 89 | + class ParIterSoA |
| 90 | + : public amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs> |
107 | 91 | {
|
108 | 92 | public:
|
109 |
| - using amrex::ParIter<0, 0, RealSoA::nattribs, IntSoA::nattribs>::ParIter; |
| 93 | + using amrex::ParIterSoA<RealSoA::nattribs, IntSoA::nattribs>::ParIterSoA; |
110 | 94 |
|
111 |
| - ParIter (ContainerType& pc, int level); |
| 95 | + ParIterSoA (ContainerType& pc, int level); |
112 | 96 |
|
113 |
| - ParIter (ContainerType& pc, int level, amrex::MFItInfo& info); |
| 97 | + ParIterSoA (ContainerType& pc, int level, amrex::MFItInfo& info); |
114 | 98 | };
|
115 | 99 |
|
116 | 100 | /** Const AMReX iterator for particle boxes - data is read only.
|
117 | 101 | *
|
118 | 102 | * We subclass here to change the default threading strategy, which is
|
119 | 103 | * `static` in AMReX, to `dynamic` in ImpactX.
|
120 | 104 | */
|
121 |
| - class ParConstIter |
122 |
| - : public amrex::ParConstIter<0, 0, RealSoA::nattribs, IntSoA::nattribs> |
| 105 | + class ParConstIterSoA |
| 106 | + : public amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs> |
123 | 107 | {
|
124 | 108 | public:
|
125 |
| - using amrex::ParConstIter<0, 0, RealSoA::nattribs, IntSoA::nattribs>::ParConstIter; |
| 109 | + using amrex::ParConstIterSoA<RealSoA::nattribs, IntSoA::nattribs>::ParConstIterSoA; |
126 | 110 |
|
127 |
| - ParConstIter (ContainerType& pc, int level); |
| 111 | + ParConstIterSoA (ContainerType& pc, int level); |
128 | 112 |
|
129 |
| - ParConstIter (ContainerType& pc, int level, amrex::MFItInfo& info); |
| 113 | + ParConstIterSoA (ContainerType& pc, int level, amrex::MFItInfo& info); |
130 | 114 | };
|
131 | 115 |
|
132 | 116 | /** Beam Particles in ImpactX
|
133 | 117 | *
|
134 | 118 | * This class stores particles, distributed over MPI ranks.
|
135 | 119 | */
|
136 | 120 | class ImpactXParticleContainer
|
137 |
| - : public amrex::ParticleContainer<0, 0, RealSoA::nattribs, IntSoA::nattribs> |
| 121 | + : public amrex::ParticleContainerPureSoA<RealSoA::nattribs, IntSoA::nattribs> |
138 | 122 | {
|
139 | 123 | public:
|
140 | 124 | //! amrex iterator for particle boxes
|
141 |
| - using iterator = impactx::ParIter; |
| 125 | + using iterator = impactx::ParIterSoA; |
142 | 126 |
|
143 | 127 | //! amrex constant iterator for particle boxes (read-only)
|
144 |
| - using const_iterator = impactx::ParConstIter; |
| 128 | + using const_iterator = impactx::ParConstIterSoA; |
145 | 129 |
|
146 | 130 | //! Construct a new particle container
|
147 | 131 | ImpactXParticleContainer (amrex::AmrCore* amr_core);
|
|
0 commit comments