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 #include <string>
21 #include <vector>
22 
23 
24 namespace impactx::diagnostics
25 {
26 namespace detail
27 {
29  public:
31  using ParticleIter = typename ParticleContainer::ParIterType;
32 
34 
35  unsigned long GetTotalNumParticles () { return m_Total; }
36 
37  std::vector<unsigned long long> m_ParticleOffsetAtRank;
38  std::vector<unsigned long long> m_ParticleSizeAtRank;
39  private:
46  void GetParticleOffsetOfProcessor (const long &numParticles,
47  unsigned long long &offset,
48  unsigned long long &sum) const;
49 
50  int m_MPIRank = 0;
51  int m_MPISize = 1;
52 
53  unsigned long long m_Total = 0;
54 
55  std::vector<unsigned long long> m_ParticleCounterByLevel;
56  };
57 } // namespace detail
58 
64  struct BeamMonitor
65  : public elements::Thin
66  {
67  static constexpr auto name = "BeamMonitor";
70 
79  BeamMonitor (std::string series_name, std::string backend="default", std::string encoding="g");
80 
81  BeamMonitor (BeamMonitor const & other) = default;
82  BeamMonitor (BeamMonitor && other) = default;
83  BeamMonitor& operator= (BeamMonitor const & other) = default;
84  BeamMonitor& operator= (BeamMonitor && other) = default;
85 
96  void prepare (
97  PinnedContainer & pc,
98  std::vector<std::string> const & real_soa_names,
99  std::vector<std::string> const & int_soa_names,
100  RefPart const & ref_part,
101  int step
102  );
103 
111  void operator() (
113  int step
114  );
115 
123  void operator() (
124  PinnedContainer::ParIterType & pti,
125  std::vector<std::string> const & real_soa_names,
126  std::vector<std::string> const & int_soa_names,
127  RefPart const & ref_part
128  );
129 
131  using Thin::operator();
132 
137  std::string series_name () const { return m_series_name; }
138 
143  static inline std::map<std::string, std::any> m_unique_series = {};
144 
147  void
148  finalize ();
149 
150  private:
151  std::string m_series_name;
152  std::string m_OpenPMDFileType;
153  std::any m_series;
154  int m_step = 0;
155 
157 
162  std::vector<uint64_t> m_offset;
163 
164  };
165 
166 } // namespace impactx::diagnostics
167 
168 #endif // IMPACTX_ELEMENTS_DIAGS_OPENPMD_H
Definition: ImpactXParticleContainer.H:131
void GetParticleOffsetOfProcessor(const long &numParticles, unsigned long long &offset, unsigned long long &sum) const
Definition: openPMD.cpp:81
std::vector< unsigned long long > m_ParticleSizeAtRank
Definition: openPMD.H:38
unsigned long long m_Total
Definition: openPMD.H:53
ImpactXParticleCounter(ParticleContainer &pc)
Definition: openPMD.cpp:34
unsigned long GetTotalNumParticles()
Definition: openPMD.H:35
typename ImpactXParticleContainer::ContainerLike< amrex::PinnedArenaAllocator > ParticleContainer
Definition: openPMD.H:30
typename ParticleContainer::ParIterType ParticleIter
Definition: openPMD.H:31
std::vector< unsigned long long > m_ParticleCounterByLevel
Definition: openPMD.H:55
std::vector< unsigned long long > m_ParticleOffsetAtRank
Definition: openPMD.H:37
Definition: DiagnosticOutput.cpp:26
Definition: ReferenceParticle.H:30
Definition: openPMD.H:66
std::vector< uint64_t > m_offset
minimum number of digits to iteration number in file name
Definition: openPMD.H:162
typename ImpactXParticleContainer::ParticleType PType
Definition: openPMD.H:68
std::string m_series_name
Definition: openPMD.H:151
int m_step
openPMD::Series; ...
Definition: openPMD.H:154
BeamMonitor(BeamMonitor const &other)=default
void prepare(PinnedContainer &pc, std::vector< std::string > const &real_soa_names, std::vector< std::string > const &int_soa_names, RefPart const &ref_part, int step)
Definition: openPMD.cpp:219
typename ImpactXParticleContainer::ContainerLike< amrex::PinnedArenaAllocator > PinnedContainer
Definition: openPMD.H:69
BeamMonitor(BeamMonitor &&other)=default
std::any m_series
...
Definition: openPMD.H:153
BeamMonitor & operator=(BeamMonitor const &other)=default
int m_file_min_digits
...
Definition: openPMD.H:156
std::string series_name() const
Definition: openPMD.H:137
static std::map< std::string, std::any > m_unique_series
Definition: openPMD.H:143
void finalize()
Definition: openPMD.cpp:139
void operator()(ImpactXParticleContainer &pc, int step)
Definition: openPMD.cpp:302
static constexpr auto name
Definition: openPMD.H:67
BeamMonitor(std::string series_name, std::string backend="default", std::string encoding="g")
Definition: openPMD.cpp:154
std::string m_OpenPMDFileType
...
Definition: openPMD.H:152
Definition: thin.H:24