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 
92  void prepare (
93  PinnedContainer & pc,
94  RefPart const & ref_part,
95  int step
96  );
97 
105  void operator() (
107  int step
108  );
109 
115  void operator() (
116  PinnedContainer::ParIterType & pti,
117  RefPart const & ref_part
118  );
119 
121  using Thin::operator();
122 
127  std::string series_name () const { return m_series_name; }
128 
133  static inline std::map<std::string, std::any> m_unique_series = {};
134 
137  void
138  finalize ();
139 
140  private:
141  std::string m_series_name;
142  std::string m_OpenPMDFileType;
143  std::any m_series;
144  int m_step = 0;
145 
147 
152  std::vector<uint64_t> m_offset;
153 
154  };
155 
156 } // namespace impactx::diagnostics
157 
158 #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:80
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:33
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:27
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:152
typename ImpactXParticleContainer::ParticleType PType
Definition: openPMD.H:66
std::string m_series_name
Definition: openPMD.H:141
int m_step
openPMD::Series; ...
Definition: openPMD.H:144
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:143
BeamMonitor & operator=(BeamMonitor const &other)=default
int m_file_min_digits
...
Definition: openPMD.H:146
std::string series_name() const
Definition: openPMD.H:127
static std::map< std::string, std::any > m_unique_series
Definition: openPMD.H:133
void finalize()
Definition: openPMD.cpp:138
void operator()(ImpactXParticleContainer &pc, int step)
Definition: openPMD.cpp:308
static constexpr auto name
Definition: openPMD.H:65
BeamMonitor(std::string series_name, std::string backend="default", std::string encoding="g")
Definition: openPMD.cpp:153
std::string m_OpenPMDFileType
...
Definition: openPMD.H:142
void prepare(PinnedContainer &pc, RefPart const &ref_part, int step)
Definition: openPMD.cpp:218
Definition: thin.H:24