23 #include "openPMD/Error.hpp"
24 #include "openPMD/IO/AbstractIOHandler.hpp"
25 #include "openPMD/IO/Access.hpp"
26 #include "openPMD/IO/Format.hpp"
27 #include "openPMD/Iteration.hpp"
28 #include "openPMD/IterationEncoding.hpp"
29 #include "openPMD/Streaming.hpp"
30 #include "openPMD/auxiliary/TypeTraits.hpp"
31 #include "openPMD/auxiliary/Variant.hpp"
32 #include "openPMD/backend/Attributable.hpp"
33 #include "openPMD/backend/Container.hpp"
34 #include "openPMD/backend/ParsePreference.hpp"
35 #include "openPMD/config.hpp"
36 #include "openPMD/snapshots/Snapshots.hpp"
37 #include "openPMD/version.hpp"
53 #include <unordered_map>
58 #ifndef OPENPMD_private
59 #define OPENPMD_private private:
65 class StatefulIterator;
73 enum class default_or_explicit : bool
102 using IterationIndex_t = Iteration::IterationIndex_t;
202 default_or_explicit m_iterationEncodingSetExplicitly =
203 default_or_explicit::default_;
220 uint64_t m_hintLazyParsingAfterTimeout = 20;
240 m_deferred_initialization = std::nullopt;
248 std::optional<MPI_Comm> m_communicator;
270 std::optional<chunk_assignment::RankMeta> m_bufferedRead;
275 class SeriesInternal;
315 std::string
const &filepath,
318 std::string
const &options =
"{}");
368 std::string
const &filepath,
370 std::string
const &options =
"{}");
378 ~
Series()
override =
default;
396 operator bool()
const;
485 chunk_assignment::RankMeta
rankTable(
bool collective);
487 chunk_assignment::RankMeta
rankTable(
bool collective =
false);
521 std::string
author()
const;
545 std::string
const &newName,
546 std::string
const &newVersion = std::string(
"unspecified"));
564 "Set the version with the second argument of setSoftware()")]]
Series &
571 std::string
date()
const;
653 std::string
name()
const;
679 void flush(std::string backendConfig =
"{}");
784 template <
typename X = void,
typename... Args>
788 auxiliary::dependent_false_v<X>,
789 "Cannot call this on an instance of Series.");
796 static constexpr
char const *
const BASEPATH =
"/data/%T/";
799 using iterations_t = decltype(internal::SeriesData::iterations);
800 using iterations_iterator = iterations_t::iterator;
803 std::shared_ptr<Data_t> m_series =
nullptr;
813 throw std::runtime_error(
814 "[Series] Cannot use default-constructed Series.");
818 inline Data_t
const &get()
const
826 throw std::runtime_error(
827 "[Series] Cannot use default-constructed Series.");
831 inline void setData(std::shared_ptr<internal::SeriesData> series)
833 m_series = std::move(series);
834 iterations = m_series->iterations;
835 Attributable::setData(m_series);
838 std::unique_ptr<ParsedInput> parseInput(std::string);
848 template <
typename TracingJSON>
850 bool hasExpansionPattern(std::string filenameWithExtension);
851 bool reparseExpansionPattern(std::string filenameWithExtension);
852 template <
typename... MPI_Communicator>
854 std::string
const &filepath,
856 std::string
const &options,
857 MPI_Communicator &&...);
858 template <
typename TracingJSON,
typename... MPI_Communicator>
859 std::tuple<std::unique_ptr<ParsedInput>, TracingJSON> initIOHandler(
860 std::string
const &filepath,
861 std::string
const &options,
863 bool resolve_generic_extension,
864 MPI_Communicator &&...);
866 std::unique_ptr<AbstractIOHandler>, std::unique_ptr<ParsedInput>);
880 iterations_iterator begin,
881 iterations_iterator end,
882 internal::FlushParams
const &flushParams,
883 bool flushIOHandler =
true);
885 iterations_iterator begin,
886 iterations_iterator end,
887 internal::FlushParams
const &flushParams,
888 bool flushIOHandler =
true);
897 iterations_iterator begin,
898 iterations_iterator end,
899 internal::FlushParams
const &flushParams,
900 bool flushIOHandler =
true);
901 void flushMeshesPath();
902 void flushParticlesPath();
903 void flushRankTable();
908 std::optional<IterationIndex_t> read_only_this_single_iteration);
909 void readOneIterationFileBased(std::string
const &filePath);
926 bool do_always_throw_errors,
928 std::optional<IterationIndex_t> read_only_this_single_iteration);
932 enum class IterationOpened : bool
957 iterations_iterator
indexOf(Iteration
const &);
975 internal::AttributableData &file,
976 iterations_iterator it);
995 Series &setIterationEncoding_internal(
1002 std::optional<std::vector<IterationIndex_t>> currentSnapshot();
1004 AbstractIOHandler *runDeferredInitialization();
1006 AbstractIOHandler *IOHandler();
1007 AbstractIOHandler
const *IOHandler()
const;
1015 std::optional<std::vector<std::vector<IterationIndex_t>>>
1016 preparseSnapshots();
1018 Snapshots makeRandomAccessSnapshots();
1019 Snapshots makeSynchronousSnapshots();
1023 [[nodiscard]]
bool randomAccessSteps()
const;
1025 std::vector<std::string> availableDatasets();
1030 void printDirty(Series
const &);
1036 #include "openPMD/ReadIterations.hpp"
Interface for communicating between logical and physically persistent data.
Definition: AbstractIOHandler.hpp:206
Layer to manage storage of attributes associated with file objects.
Definition: Attributable.hpp:222
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:146
Legacy class as return type for Series::readIterations().
Definition: ReadIterations.hpp:75
Implementation for the root level of the openPMD hierarchy.
Definition: Series.hpp:288
Series & setName(std::string const &name)
Set the pattern for file names.
Definition: Series.cpp:731
std::string softwareVersion() const
Definition: Series.cpp:639
Series & setMeshesPath(std::string const &meshesPath)
Set the path to mesh records, relative(!) to basePath.
Definition: Series.cpp:275
std::string iterationFormat() const
Definition: Series.cpp:695
void flush(std::string backendConfig="{}")
Execute all required remaining IO operations to write or read data.
Definition: Series.cpp:780
auto iterationFlush(Args &&...)
This overrides Attributable::iterationFlush() which will fail on Series.
Definition: Series.hpp:785
void parseBase()
Parse the Series.
Definition: Series.cpp:3510
std::string basePath() const
Definition: Series.cpp:249
Series & setSoftwareDependencies(std::string const &newSoftwareDependencies)
Indicate dependencies of software that were used to create the file.
Definition: Series.cpp:667
iterations_iterator indexOf(Iteration const &)
Find the given iteration in Series::iterations and return an iterator into Series::iterations at that...
Definition: Series.cpp:2598
Iteration::IterationIndex_t IterationIndex_t
An unsigned integer type, used to identify Iterations in a Series.
Definition: Series.hpp:383
Series & setParticlesPath(std::string const &particlesPath)
Set the path to groups for each particle species, relative(!) to basePath.
Definition: Series.cpp:594
std::future< void > flush_impl(iterations_iterator begin, iterations_iterator end, internal::FlushParams const &flushParams, bool flushIOHandler=true)
Internal call for flushing a Series.
Definition: Series.cpp:1364
std::string machine() const
Definition: Series.cpp:673
std::string date() const
Definition: Series.cpp:650
WriteIterations writeIterations()
Entry point to the writing end of the streaming API.
Definition: Series.cpp:3515
std::string backend() const
The currently used backend.
Definition: Series.cpp:769
void close()
Close the Series and release the data storage/transport backends.
Definition: Series.cpp:3531
Series & setOpenPMD(std::string const &openPMD)
Set the version of the enforced openPMD standard.
Definition: Series.cpp:226
void flushStep(bool doFlush)
Called at the end of an IO step to store the iterations defined in the IO step to the snapshot attrib...
Definition: Series.cpp:2812
std::string openPMD() const
Definition: Series.cpp:221
Series & setAuthor(std::string const &author)
Indicate the author and contact for the information in the file.
Definition: Series.cpp:620
Snapshots snapshots()
Preferred way to access Iterations/Snapshots.
Definition: Series.cpp:3400
Series & setSoftwareVersion(std::string const &softwareVersion)
Indicate the version of the software/code/simulation that created the file.
Definition: Series.cpp:644
AdvanceStatus advance(AdvanceMode mode, internal::AttributableData &file, iterations_iterator it)
In step-based IO mode, begin or end an IO step for the given iteration.
Definition: Series.cpp:2613
std::string author() const
Definition: Series.cpp:615
std::string meshesPath() const
Definition: Series.cpp:270
Series & setMachine(std::string const &newMachine)
Indicate the machine or relevant hardware that created the file.
Definition: Series.cpp:678
std::string software() const
Definition: Series.cpp:626
std::vector< IterationIndex_t > readGorVBased(bool do_always_throw_errors, bool init, std::optional< IterationIndex_t > read_only_this_single_iteration)
Note on re-parsing of a Series: If init == false, the parsing process will seek for new Iterations/Re...
Definition: Series.cpp:2068
uint32_t openPMDextension() const
Definition: Series.cpp:238
chunk_assignment::RankMeta rankTable(bool collective)
Definition: Series.cpp:329
Series & setBasePath(std::string const &basePath)
Set the common prefix for all data sets and sub-groups of a specific iteration.
Definition: Series.cpp:254
bool hasRankTableRead()
Definition: Series.cpp:312
Series & setRankTable(std::string const &myRankInfo)
Set the Mpi Ranks Meta Info attribute, i.e.
Definition: Series.cpp:460
void parseJsonOptions(TracingJSON &options, ParsedInput &)
Parse non-backend-specific configuration in JSON config.
Definition: Series.cpp:3149
std::string particlesPath() const
Definition: Series.cpp:589
Series & setDate(std::string const &date)
Indicate the date of creation.
Definition: Series.cpp:655
std::string name() const
Definition: Series.cpp:726
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:632
std::string softwareDependencies() const
Definition: Series.cpp:661
ReadIterations readIterations()
Entry point to the reading end of the streaming API.
Definition: Series.cpp:3352
Series & setOpenPMDextension(uint32_t openPMDextension)
Set a 32-bit mask of applied extensions to the openPMD standard.
Definition: Series.cpp:243
Series & setIterationEncoding(IterationEncoding iterationEncoding)
Set the encoding style for multiple iterations in this series.
Definition: Series.cpp:689
IterationEncoding iterationEncoding() const
Definition: Series.cpp:684
Series & setIterationFormat(std::string const &iterationFormat)
Set a pattern describing how to access single iterations in the raw file.
Definition: Series.cpp:700
Entry point for accessing Snapshots/Iterations.
Definition: Snapshots.hpp:50
Based on the logic of the former class ReadIterations, integrating into itself the logic of former Wr...
Definition: StatefulIterator.hpp:204
Definition: ContainerImpls.hpp:36
Layer to mirror structure of logical data and persistent data in file.
Definition: Writable.hpp:76
Definition: Attributable.hpp:107
Data members for Series.
Definition: Series.hpp:90
std::unordered_map< IterationIndex_t, size_t > m_snapshotToStep
For reading: In which IO step do I need to look for an Iteration?
Definition: Series.hpp:131
std::unique_ptr< StatefulIterator > m_sharedStatefulIterator
Series::readIterations() returns an iterator type that modifies the state of the Series (by proceedin...
Definition: Series.hpp:121
std::string m_filenamePrefix
Filename leading up to the expansion pattern.
Definition: Series.hpp:173
std::set< IterationIndex_t > m_currentlyActiveIterations
For writing: Remember which iterations have been written in the currently active output step.
Definition: Series.hpp:127
std::unordered_map< IterationIndex_t, std::string > m_iterationFilenames
This map contains the filenames of those Iterations which were found on the file system upon opening ...
Definition: Series.hpp:151
std::optional< std::string > m_overrideFilebasedFilename
Needed if reading a single iteration of a file-based series.
Definition: Series.hpp:161
StepStatus m_stepStatus
Whether a step is currently active for this iteration.
Definition: Series.hpp:215
std::string m_name
Name of the iteration without filename suffix.
Definition: Series.hpp:168
std::optional< ParsePreference > m_parsePreference
Remember the preference that the backend specified for parsing.
Definition: Series.hpp:237
std::string m_filenamePostfix
Filename after the expansion pattern without filename extension.
Definition: Series.hpp:177
int m_filenamePadding
The padding in file-based iteration encoding.
Definition: Series.hpp:188
bool m_parseLazily
True if a user opts into lazy parsing.
Definition: Series.hpp:219
bool m_wroteAtLeastOneIOStep
In variable-based encoding, all backends except ADIOS2 can only write one single iteration.
Definition: Series.hpp:229
std::string m_filenameExtension
Filename extension as specified by the user.
Definition: Series.hpp:182
IterationEncoding m_iterationEncoding
The iteration encoding used in this series.
Definition: Series.hpp:192
Format m_format
Detected IO format (backend).
Definition: Series.hpp:207
Public definitions of openPMD-api.
Definition: Date.cpp:29
Access
File access mode to use during IO.
Definition: Access.hpp:58
AdvanceMode
In step-based mode (i.e.
Definition: Streaming.hpp:46
StepStatus
Used in step-based mode (i.e.
Definition: Streaming.hpp:57
AdvanceStatus
In step-based mode (i.e.
Definition: Streaming.hpp:32
Format
File format to use during IO.
Definition: Format.hpp:30
IterationEncoding
Encoding scheme of an Iterations Series'.
Definition: IterationEncoding.hpp:33
Definition: Series.hpp:252
Definition: Series.hpp:263
Definition: Series.hpp:258
Definition: Series.hpp:254