ImpactX
openPMD.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_ELEMENTS_DIAGS_OPENPMD_H
11 #define IMPACTX_ELEMENTS_DIAGS_OPENPMD_H
12 
15 
16 #include <AMReX_Extension.H>
17 #include <AMReX_REAL.H>
18 
19 #include <any>
20 
21 
22 namespace impactx::diagnostics
23 {
24 namespace detail
25 {
27  public:
29  using ParticleIter = typename ParticleContainer::ParIterType;
30 
32 
33  unsigned long GetTotalNumParticles () { return m_Total; }
34 
35  std::vector<unsigned long long> m_ParticleOffsetAtRank;
36  std::vector<unsigned long long> m_ParticleSizeAtRank;
37  private:
44  void GetParticleOffsetOfProcessor (const long &numParticles,
45  unsigned long long &offset,
46  unsigned long long &sum) const;
47 
48  int m_MPIRank = 0;
49  int m_MPISize = 1;
50 
51  unsigned long long m_Total = 0;
52 
53  std::vector<unsigned long long> m_ParticleCounterByLevel;
54  };
55 } // namespace detail
56 
62  struct BeamMonitor
63  : public elements::Thin
64  {
65  static constexpr auto name = "BeamMonitor";
68 
77  BeamMonitor (std::string series_name, std::string backend="default", std::string encoding="g");
78 
79  BeamMonitor (BeamMonitor const & other) = default;
80  BeamMonitor (BeamMonitor && other) = default;
81  BeamMonitor& operator= (BeamMonitor const & other) = default;
82  BeamMonitor& operator= (BeamMonitor && other) = default;
83 
90  void prepare (
91  PinnedContainer & pc,
92  RefPart const & ref_part,
93  int step
94  );
95 
103  void operator() (
105  int step
106  );
107 
108  // TODO: move to private function
109  void operator() (
110  PinnedContainer::ParIterType & pti,
111  RefPart const & ref_part
112  );
113 
115  using Thin::operator();
116 
121  std::string series_name () const { return m_series_name; }
122 
127  static inline std::map<std::string, std::any> m_unique_series = {};
128 
131  void
132  finalize ();
133 
134  private:
135  std::string m_series_name;
136  std::string m_OpenPMDFileType;
137  std::any m_series;
138  int m_step = 0;
139 
141 
146  std::vector<uint64_t> m_offset;
147 
148  };
149 
150 } // namespace impactx::diagnostics
151 
152 #endif // IMPACTX_ELEMENTS_DIAGS_OPENPMD_H
Definition: ImpactXParticleContainer.H:138
void GetParticleOffsetOfProcessor(const long &numParticles, unsigned long long &offset, unsigned long long &sum) const
Definition: openPMD.cpp:76
std::vector< unsigned long long > m_ParticleSizeAtRank
Definition: openPMD.H:36
unsigned long long m_Total
Definition: openPMD.H:51
ImpactXParticleCounter(ParticleContainer &pc)
Definition: openPMD.cpp:29
unsigned long GetTotalNumParticles()
Definition: openPMD.H:33
typename ImpactXParticleContainer::ContainerLike< amrex::PinnedArenaAllocator > ParticleContainer
Definition: openPMD.H:28
typename ParticleContainer::ParIterType ParticleIter
Definition: openPMD.H:29
std::vector< unsigned long long > m_ParticleCounterByLevel
Definition: openPMD.H:53
std::vector< unsigned long long > m_ParticleOffsetAtRank
Definition: openPMD.H:35
Definition: DiagnosticOutput.cpp:24
Definition: ReferenceParticle.H:30
Definition: openPMD.H:64
std::vector< uint64_t > m_offset
minimum number of digits to iteration number in file name
Definition: openPMD.H:146
typename ImpactXParticleContainer::ParticleType PType
Definition: openPMD.H:66
std::string m_series_name
Definition: openPMD.H:135
int m_step
openPMD::Series; ...
Definition: openPMD.H:138
BeamMonitor(BeamMonitor const &other)=default
typename ImpactXParticleContainer::ContainerLike< amrex::PinnedArenaAllocator > PinnedContainer
Definition: openPMD.H:67
BeamMonitor(BeamMonitor &&other)=default
std::any m_series
...
Definition: openPMD.H:137
BeamMonitor & operator=(BeamMonitor const &other)=default
int m_file_min_digits
...
Definition: openPMD.H:140
std::string series_name() const
Definition: openPMD.H:121
static std::map< std::string, std::any > m_unique_series
Definition: openPMD.H:127
void finalize()
Definition: openPMD.cpp:134
void operator()(ImpactXParticleContainer &pc, int step)
Definition: openPMD.cpp:288
static constexpr auto name
Definition: openPMD.H:65
BeamMonitor(std::string series_name, std::string backend="default", std::string encoding="g")
Definition: openPMD.cpp:149
std::string m_OpenPMDFileType
...
Definition: openPMD.H:136
void prepare(PinnedContainer &pc, RefPart const &ref_part, int step)
Definition: openPMD.cpp:213
Definition: thin.H:24