ImpactX
ImpactXParticleContainer.H
Go to the documentation of this file.
1 /* Copyright 2022-2023 The Regents of the University of California, through Lawrence
2  * Berkeley National Laboratory (subject to receipt of any required
3  * approvals from the U.S. Dept. of Energy). All rights reserved.
4  *
5  * This file is part of ImpactX.
6  *
7  * Authors: Axel Huebl
8  * License: BSD-3-Clause-LBNL
9  */
10 #ifndef IMPACTX_PARTICLE_CONTAINER_H
11 #define IMPACTX_PARTICLE_CONTAINER_H
12 
13 #include "ReferenceParticle.H"
14 
15 #include <AMReX_AmrCoreFwd.H>
16 #include <AMReX_BaseFwd.H>
17 #include <AMReX_MultiFab.H>
18 #include <AMReX_ParIter.H>
19 #include <AMReX_Particles.H>
20 
21 #include <AMReX_IntVect.H>
22 #include <AMReX_Vector.H>
23 
24 #include <optional>
25 #include <tuple>
26 #include <unordered_map>
27 
28 
29 namespace impactx
30 {
38  struct RealAoS
39  {
40  enum
41  {
42  x,
43  y,
44  z,
46  };
47 
49  static constexpr auto names_t = { "position_x", "position_y", "position_z" };
51  static constexpr auto names_s = { "position_x", "position_y", "position_ct" };
52  static_assert(names_t.size() == nattribs);
53  static_assert(names_s.size() == nattribs);
54  };
55 
59  struct RealSoA
60  {
61  enum
62  {
63  ux,
64  uy,
65  pt,
66  m_qm,
67  w,
69  };
70 
72  static constexpr auto names_t = { "momentum_x", "momentum_y", "momentum_z", "qmm", "weighting" };
74  static constexpr auto names_s = { "momentum_x", "momentum_y", "momentum_t", "qmm", "weighting" };
75  static_assert(names_t.size() == nattribs);
76  static_assert(names_s.size() == nattribs);
77  };
78 
82  struct IntSoA
83  {
84  enum
85  {
87  };
88  };
89 
95  class ParIter
96  : public amrex::ParIter<0, 0, RealSoA::nattribs, IntSoA::nattribs>
97  {
98  public:
100 
101  ParIter (ContainerType& pc, int level);
102 
103  ParIter (ContainerType& pc, int level, amrex::MFItInfo& info);
104  };
105 
112  : public amrex::ParConstIter<0, 0, RealSoA::nattribs, IntSoA::nattribs>
113  {
114  public:
116 
117  ParConstIter (ContainerType& pc, int level);
118 
119  ParConstIter (ContainerType& pc, int level, amrex::MFItInfo& info);
120  };
121 
127  : public amrex::ParticleContainer<0, 0, RealSoA::nattribs, IntSoA::nattribs>
128  {
129  public:
132 
135 
138 
140  virtual ~ImpactXParticleContainer() = default;
141 
159  void
160  AddNParticles (int lev,
167  amrex::ParticleReal const & qm,
168  amrex::ParticleReal const & bchchg);
169 
174  void
175  SetRefParticle (RefPart const refpart);
176 
181  RefPart &
182  GetRefParticle ();
183 
188  RefPart const
189  GetRefParticle () const;
190 
194  void SetRefParticleEdge ();
195 
198  int
199  GetParticleShape () const { return m_particle_shape.value(); }
200 
207  void SetParticleShape ();
208 
217  void SetParticleShape (int const order);
218 
223  std::tuple<
224  amrex::ParticleReal, amrex::ParticleReal,
225  amrex::ParticleReal, amrex::ParticleReal,
226  amrex::ParticleReal, amrex::ParticleReal>
227  MinAndMaxPositions ();
228 
233  std::tuple<
234  amrex::ParticleReal, amrex::ParticleReal,
235  amrex::ParticleReal, amrex::ParticleReal,
236  amrex::ParticleReal, amrex::ParticleReal>
237  MeanAndStdPositions ();
238 
248  void
249  DepositCharge (std::unordered_map<int, amrex::MultiFab> & rho,
250  amrex::Vector<amrex::IntVect> const & ref_ratio);
251 
252  private:
253 
256 
258  std::optional<int> m_particle_shape;
259 
260  }; // ImpactXParticleContainer
261 
262 } // namespace impactx
263 
264 #endif // IMPACTX_PARTICLE_CONTAINER_H
charge to mass ratio, in q_e/m_e (q_e/eV) TODO: rename to qm_m
Definition: ImpactXParticleContainer.H:66
momentum in z, scaled by the magnitude of the reference momentum [unitless] (at fixed t) OR energy de...
Definition: ImpactXParticleContainer.H:65
Definition: ImpactXParticleContainer.H:95
particle weight, unitless
Definition: ImpactXParticleContainer.H:67
momentum in y, scaled by the magnitude of the reference momentum [unitless] (at fixed t or s) ...
Definition: ImpactXParticleContainer.H:64
Definition: ImpactX.cpp:31
the number of attributes above (always last)
Definition: ImpactXParticleContainer.H:45
momentum in x, scaled by the magnitude of the reference momentum [unitless] (at fixed t or s) ...
Definition: ImpactXParticleContainer.H:63
Definition: ImpactXParticleContainer.H:38
position in y [m] (at fixed t OR fixed s)
Definition: ImpactXParticleContainer.H:43
int GetParticleShape() const
Definition: ImpactXParticleContainer.H:199
static constexpr auto names_t
named labels for fixed t
Definition: ImpactXParticleContainer.H:49
static constexpr auto names_s
named labels for fixed s
Definition: ImpactXParticleContainer.H:51
Definition: ImpactXParticleContainer.H:111
std::optional< int > m_particle_shape
the particle shape
Definition: ImpactXParticleContainer.H:258
Definition: ReferenceParticle.H:29
position in x [m] (at fixed t OR fixed s)
Definition: ImpactXParticleContainer.H:42
Definition: ImpactXParticleContainer.H:126
RefPart m_refpart
the reference particle for the beam in the particle container
Definition: ImpactXParticleContainer.H:255
Definition: ImpactXParticleContainer.H:82
position in z [m] (at fixed t) OR time-of-flight ct [m] (at fixed s)
Definition: ImpactXParticleContainer.H:44
Definition: ImpactXParticleContainer.H:59