forked from openPMD/openPMD-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIteration.hpp
139 lines (119 loc) · 3.88 KB
/
Iteration.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* Copyright 2017-2020 Fabian Koller
*
* This file is part of openPMD-api.
*
* openPMD-api is free software: you can redistribute it and/or modify
* it under the terms of of either the GNU General Public License or
* the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* openPMD-api is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License and the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* and the GNU Lesser General Public License along with openPMD-api.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "openPMD/backend/Attributable.hpp"
#include "openPMD/backend/Container.hpp"
#include "openPMD/Mesh.hpp"
#include "openPMD/ParticleSpecies.hpp"
namespace openPMD
{
/** @brief Logical compilation of data from one snapshot (e.g. a single simulation cycle).
*
* @see https://github.com/openPMD/openPMD-standard/blob/latest/STANDARD.md#required-attributes-for-the-basepath
*/
class Iteration : public Attributable
{
template<
typename T,
typename T_key,
typename T_container
>
friend class Container;
friend class Series;
public:
Iteration(Iteration const&);
Iteration& operator=(Iteration const&);
/**
* @tparam T Floating point type of user-selected precision (e.g. float, double).
* @return Global reference time for this iteration.
*/
template< typename T >
T time() const;
/** Set the global reference time for this iteration.
*
* @tparam T Floating point type of user-selected precision (e.g. float, double).
* @param newTime Global reference time for this iteration.
* @return Reference to modified iteration.
*/
template< typename T >
Iteration& setTime(T newTime);
/**
* @tparam T Floating point type of user-selected precision (e.g. float, double).
* @return Time step used to reach this iteration.
*/
template< typename T >
T dt() const;
/** Set the time step used to reach this iteration.
*
* @tparam T Floating point type of user-selected precision (e.g. float, double).
* @param newDt Time step used to reach this iteration.
* @return Reference to modified iteration.
*/
template< typename T >
Iteration& setDt(T newDt);
/**
* @return Conversion factor to convert time and dt to seconds.
*/
double timeUnitSI() const;
/** Set the conversion factor to convert time and dt to seconds.
*
* @param newTimeUnitSI new value for timeUnitSI
* @return Reference to modified iteration.
*/
Iteration& setTimeUnitSI(double newTimeUnitSI);
Container< Mesh > meshes;
Container< ParticleSpecies > particles; //particleSpecies?
virtual ~Iteration() = default;
private:
Iteration();
void flushFileBased(std::string const&, uint64_t);
void flushGroupBased(uint64_t);
void flush();
void read();
virtual void linkHierarchy(std::shared_ptr< Writable > const& w);
}; //Iteration
extern template
float
Iteration::time< float >() const;
extern template
double
Iteration::time< double >() const;
extern template
long double
Iteration::time< long double >() const;
template< typename T >
inline T
Iteration::time() const
{ return Attributable::readFloatingpoint< T >("time"); }
extern template
float
Iteration::dt< float >() const;
extern template
double
Iteration::dt< double >() const;
extern template
long double
Iteration::dt< long double >() const;
template< typename T >
inline T
Iteration::dt() const
{ return Attributable::readFloatingpoint< T >("dt"); }
} // openPMD