openPMD-api
Series.hpp
1 /* Copyright 2017-2020 Fabian Koller, Axel Huebl
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/config.hpp"
24 #include "openPMD/auxiliary/Deprecated.hpp"
25 #include "openPMD/backend/Attributable.hpp"
26 #include "openPMD/backend/Container.hpp"
27 #include "openPMD/IO/AbstractIOHandler.hpp"
28 #include "openPMD/IO/AccessType.hpp"
29 #include "openPMD/IO/Format.hpp"
30 #include "openPMD/Iteration.hpp"
31 #include "openPMD/IterationEncoding.hpp"
32 #include "openPMD/version.hpp"
33 
34 #if openPMD_HAVE_MPI
35 # include <mpi.h>
36 #endif
37 
38 #include <string>
39 
40 // expose private and protected members for invasive testing
41 #ifndef OPENPMD_private
42 # define OPENPMD_private private
43 #endif
44 
45 
46 namespace openPMD
47 {
55 class Series : public Attributable
56 {
57  friend class Iteration;
58 
59 public:
60 #if openPMD_HAVE_MPI
61  Series(std::string const& filepath,
62  AccessType at,
63  MPI_Comm comm);
64 #endif
65  Series(std::string const& filepath,
66  AccessType at);
67  ~Series();
68 
72  std::string openPMD() const;
78  Series& setOpenPMD(std::string const& openPMD);
79 
83  uint32_t openPMDextension() const;
89  Series& setOpenPMDextension(uint32_t openPMDextension);
90 
94  std::string basePath() const;
100  Series& setBasePath(std::string const& basePath);
101 
106  std::string meshesPath() const;
112  Series& setMeshesPath(std::string const& meshesPath);
113 
118  std::string particlesPath() const;
124  Series& setParticlesPath(std::string const& particlesPath);
125 
130  std::string author() const;
136  Series& setAuthor(std::string const& author);
137 
142  std::string software() const;
149  Series& setSoftware(std::string const& newName, std::string const& newVersion = std::string("unspecified"));
150 
155  std::string softwareVersion() const;
163  OPENPMDAPI_DEPRECATED("Set the version with the second argument of setSoftware()")
164  Series& setSoftwareVersion(std::string const& softwareVersion);
165 
170  std::string date() const;
176  Series& setDate(std::string const& date);
177 
182  std::string softwareDependencies() const;
188  Series& setSoftwareDependencies(std::string const& newSoftwareDependencies);
189 
194  std::string machine() const;
200  Series& setMachine(std::string const& newMachine);
201 
211  Series& setIterationEncoding(IterationEncoding iterationEncoding);
212 
216  std::string iterationFormat() const;
227  Series& setIterationFormat(std::string const& iterationFormat);
228 
232  std::string name() const;
233 
239  Series& setName(std::string const& name);
240 
247  std::string backend() const;
248 
251  void flush();
252 
254 
255 OPENPMD_private:
256  struct ParsedInput;
257  std::unique_ptr< ParsedInput > parseInput(std::string);
258  void init(std::shared_ptr< AbstractIOHandler >, std::unique_ptr< ParsedInput >);
259  void initDefaults();
260  void flushFileBased();
261  void flushGroupBased();
262  void flushMeshesPath();
263  void flushParticlesPath();
264  void readFileBased();
265  void readGroupBased();
266  void readBase();
267  void read();
268 
269  static constexpr char const * const BASEPATH = "/data/%T/";
270 
271  std::shared_ptr< IterationEncoding > m_iterationEncoding;
272  std::shared_ptr< std::string > m_name;
273  std::shared_ptr< Format > m_format;
274 
275  std::shared_ptr< std::string > m_filenamePrefix;
276  std::shared_ptr< std::string > m_filenamePostfix;
277  std::shared_ptr< int > m_filenamePadding;
278 }; // Series
279 } // namespace openPMD
Series & setOpenPMD(std::string const &openPMD)
Set the version of the enforced openPMD standard.
Definition: Series.cpp:117
AccessType
File access mode to use during IO.
Definition: AccessType.hpp:28
std::string basePath() const
Definition: Series.cpp:137
Series & setSoftwareDependencies(std::string const &newSoftwareDependencies)
Indicate dependencies of software that were used to create the file.
Definition: Series.cpp:255
std::string softwareDependencies() const
Definition: Series.cpp:249
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:35
Definition: Series.cpp:71
Series & setMachine(std::string const &newMachine)
Indicate the machine or relevant hardware that created the file.
Definition: Series.cpp:268
std::string meshesPath() const
Definition: Series.cpp:154
Series & setDate(std::string const &date)
Indicate the date of creation.
Definition: Series.cpp:242
Series & setName(std::string const &name)
Set the pattern for file names.
Definition: Series.cpp:328
Series & setBasePath(std::string const &basePath)
Set the common prefix for all data sets and sub-groups of a specific iteration.
Definition: Series.cpp:143
std::string machine() const
Definition: Series.cpp:262
std::string name() const
Definition: Series.cpp:322
std::string author() const
Definition: Series.cpp:196
std::string iterationFormat() const
Definition: Series.cpp:302
Root level of the openPMD hierarchy.
Definition: Series.hpp:55
void flush()
Execute all required remaining IO operations to write or read data.
Definition: Series.cpp:348
uint32_t openPMDextension() const
Definition: Series.cpp:124
std::string backend() const
The currently used backend.
Definition: Series.cpp:342
Series & setMeshesPath(std::string const &meshesPath)
Set the path to mesh records, relative(!) to basePath.
Definition: Series.cpp:160
Public definitions of openPMD-api.
Definition: Date.cpp:28
IterationEncoding iterationEncoding() const
Definition: Series.cpp:275
Series & setIterationFormat(std::string const &iterationFormat)
Set a pattern describing how to access single iterations in the raw file.
Definition: Series.cpp:308
Series & setSoftwareVersion(std::string const &softwareVersion)
Indicate the version of the software/code/simulation that created the file.
Definition: Series.cpp:229
Series & setIterationEncoding(IterationEncoding iterationEncoding)
Set the encoding style for multiple iterations in this series.
Definition: Series.cpp:281
IterationEncoding
Encoding scheme of an Iterations Series&#39;.
Definition: IterationEncoding.hpp:32
Series & setParticlesPath(std::string const &particlesPath)
Set the path to groups for each particle species, relative(!) to basePath.
Definition: Series.cpp:181
Series & setAuthor(std::string const &author)
Indicate the author and contact for the information in the file.
Definition: Series.cpp:202
std::string softwareVersion() const
Definition: Series.cpp:223
Series & setOpenPMDextension(uint32_t openPMDextension)
Set a 32-bit mask of applied extensions to the openPMD standard.
Definition: Series.cpp:130
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:70
std::string particlesPath() const
Definition: Series.cpp:175
std::string date() const
Definition: Series.cpp:236
Series & setSoftware(std::string const &newName, std::string const &newVersion=std::string("unspecified"))
Indicate the software/code/simulation that created the file.
Definition: Series.cpp:215
std::string openPMD() const
Definition: Series.cpp:111
std::string software() const
Definition: Series.cpp:209
Layer to manage storage of attributes associated with file objects.
Definition: Attributable.hpp:65