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 
89  void prepare (
90  PinnedContainer & pc,
91  int step
92  );
93 
101  void operator() (
103  int step
104  );
105 
106  // TODO: move to private function
107  void operator() (
108  PinnedContainer::ParIterType & pti,
109  RefPart const & ref_part
110  );
111 
113  using Thin::operator();
114 
119  std::string series_name () const { return m_series_name; }
120 
125  static inline std::map<std::string, std::any> m_unique_series = {};
126 
129  void
130  finalize ();
131 
132  private:
133  std::string m_series_name;
134  std::string m_OpenPMDFileType;
135  std::any m_series;
136  int m_step = 0;
137 
138  int m_file_min_digits = 6;
139 
144  std::vector<uint64_t> m_offset;
145 
146  };
147 
148 } // namespace impactx::diagnostics
149 
150 #endif // IMPACTX_ELEMENTS_DIAGS_OPENPMD_H
typename ImpactXParticleContainer::ParticleType PType
Definition: openPMD.H:66
ImpactXParticleCounter(ParticleContainer &pc)
Definition: openPMD.cpp:29
Definition: DiagnosticOutput.cpp:22
std::string m_OpenPMDFileType
...
Definition: openPMD.H:134
unsigned long long m_Total
Definition: openPMD.H:51
unsigned long GetTotalNumParticles()
Definition: openPMD.H:33
typename ParticleContainer::ParIterType ParticleIter
Definition: openPMD.H:29
typename ImpactXParticleContainer::ContainerLike< amrex::PinnedArenaAllocator > ParticleContainer
Definition: openPMD.H:28
void GetParticleOffsetOfProcessor(const long &numParticles, unsigned long long &offset, unsigned long long &sum) const
Definition: openPMD.cpp:76
Definition: thin.H:23
std::vector< uint64_t > m_offset
minimum number of digits to iteration number in file name
Definition: openPMD.H:144
std::vector< unsigned long long > m_ParticleSizeAtRank
Definition: openPMD.H:36
std::string m_series_name
Definition: openPMD.H:133
std::vector< unsigned long long > m_ParticleOffsetAtRank
Definition: openPMD.H:35
Definition: ReferenceParticle.H:29
std::any m_series
...
Definition: openPMD.H:135
string name
Definition: ImpactXParticleContainer.H:126
typename ImpactXParticleContainer::ContainerLike< amrex::PinnedArenaAllocator > PinnedContainer
Definition: openPMD.H:67
Definition: openPMD.H:62
std::vector< unsigned long long > m_ParticleCounterByLevel
Definition: openPMD.H:53
std::string series_name() const
Definition: openPMD.H:119