openPMD-api
Iteration.hpp
1 /* Copyright 2017-2020 Fabian Koller
2  *
3  * This file is part of openPMD-api.
4  *
5  * openPMD-api is free software: you can redistribute it and/or modify
6  * it under the terms of of either the GNU General Public License or
7  * the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * openPMD-api is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License and the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * and the GNU Lesser General Public License along with openPMD-api.
19  * If not, see <http://www.gnu.org/licenses/>.
20  */
21 #pragma once
22 
23 #include "openPMD/backend/Attributable.hpp"
24 #include "openPMD/backend/Container.hpp"
25 #include "openPMD/Mesh.hpp"
26 #include "openPMD/ParticleSpecies.hpp"
27 
28 
29 namespace openPMD
30 {
35 class Iteration : public Attributable
36 {
37  template<
38  typename T,
39  typename T_key,
40  typename T_container
41  >
42  friend class Container;
43  friend class Series;
44 
45 public:
46  Iteration(Iteration const&);
47  Iteration& operator=(Iteration const&);
48 
53  template< typename T >
54  T time() const;
61  template< typename T >
62  Iteration& setTime(T newTime);
63 
68  template< typename T >
69  T dt() const;
76  template< typename T >
77  Iteration& setDt(T newDt);
78 
82  double timeUnitSI() const;
88  Iteration& setTimeUnitSI(double newTimeUnitSI);
89 
90  Container< Mesh > meshes;
91  Container< ParticleSpecies > particles; //particleSpecies?
92 
93  virtual ~Iteration() = default;
94 private:
95  Iteration();
96 
97  void flushFileBased(std::string const&, uint64_t);
98  void flushGroupBased(uint64_t);
99  void flush();
100  void read();
101 
102  virtual void linkHierarchy(std::shared_ptr< Writable > const& w);
103 }; //Iteration
104 
105 extern template
106 float
107 Iteration::time< float >() const;
108 
109 extern template
110 double
111 Iteration::time< double >() const;
112 
113 extern template
114 long double
115 Iteration::time< long double >() const;
116 
117 template< typename T >
118 inline T
120 { return Attributable::readFloatingpoint< T >("time"); }
121 
122 
123 extern template
124 float
125 Iteration::dt< float >() const;
126 
127 extern template
128 double
129 Iteration::dt< double >() const;
130 
131 extern template
132 long double
133 Iteration::dt< long double >() const;
134 
135 template< typename T >
136 inline T
138 { return Attributable::readFloatingpoint< T >("dt"); }
139 } // openPMD
T time() const
Definition: Iteration.hpp:119
Iteration & setDt(T newDt)
Set the time step used to reach this iteration.
Definition: Iteration.cpp:79
double timeUnitSI() const
Definition: Iteration.cpp:88
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:35
T dt() const
Definition: Iteration.hpp:137
Root level of the openPMD hierarchy.
Definition: Series.hpp:55
Public definitions of openPMD-api.
Definition: Date.cpp:28
Iteration & setTime(T newTime)
Set the global reference time for this iteration.
Definition: Iteration.cpp:69
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:70
Iteration & setTimeUnitSI(double newTimeUnitSI)
Set the conversion factor to convert time and dt to seconds.
Definition: Iteration.cpp:94
Layer to manage storage of attributes associated with file objects.
Definition: Attributable.hpp:65