SENSEI
A frame work for generic in situ analytics
HDF5AnalysisAdaptor.h
1 #ifndef HDF5AnalysisAdaptor_h
2 #define HDF5AnalysisAdaptor_h
3 
4 #include "AnalysisAdaptor.h"
5 #include "DataRequirements.h"
6 #include "MeshMetadata.h"
7 
8 #include "hdf5.h"
9 #include <mpi.h>
10 #include <string>
11 #include <vector>
12 
13 #include "HDF5Schema.h"
14 
15 class svtkDataObject;
16 class svtkCompositeDataSet;
17 
18 namespace sensei {
19 
20 /// The write side of the HDF5 transport
21 class SENSEI_EXPORT HDF5AnalysisAdaptor : public AnalysisAdaptor {
22 public:
23  /// creates a new instance.
24  static HDF5AnalysisAdaptor *New();
25 
26  senseiTypeMacro(HDF5AnalysisAdaptor, AnalysisAdaptor);
27 
28  /// prints the current object state.
29  void PrintSelf(ostream &os, svtkIndent indent) override;
30 
31  /// @name Run time configuration
32  /// @{
33 
34  /** Sets the maximum buffer allocated by HDF5 in MB takes affect on first
35  * Execute.
36  */
37  void SetMaxBufferSize(unsigned int size) { this->MaxBufferSize = size; }
38 
39  /// Set the filename. The default value is "no.file"
40  void SetStreamName(const std::string &filename)
41  { this->m_FileName = filename; }
42 
43  /// Enables HDF5 streaming
44  void SetStreaming(bool streamOption) { this->m_DoStreaming = streamOption; }
45 
46  /// Enables MPI collective I/O
47  void SetCollective(bool s) { m_Collective = s; }
48 
49  std::string GetFileName() const { return this->m_FileName; }
50 
51  /// data requirements tell the adaptor what to push
52  /// if none are given then all data is pushed.
53  int SetDataRequirements(const DataRequirements &reqs);
54 
55  int AddDataRequirement(const std::string &meshName, int association,
56  const std::vector<std::string> &arrays);
57 
58  ///@}
59 
60  /// Triggers I/O and processing on the receiving side.
61  bool Execute(DataAdaptor *data, DataAdaptor**) override;
62 
63  /// Flushes and closes all open streams and files.
64  int Finalize() override;
65 
66 protected:
69 
70  // intializes HDF5 in no-xml mode, allocate buffers, and declares a group
71  // bool InitializeHDF5(const std::vector<MeshMetadataPtr> &metadata);
72  bool InitializeHDF5();
73 
74  // writes the data collection
75  /*
76  bool WriteTimestep(unsigned long timeStep, double time,
77  const std::vector<MeshMetadataPtr> &metadata,
78  const std::vector<svtkCompositeDataSet*> &dobjects);
79  */
80  unsigned int MaxBufferSize;
81  sensei::DataRequirements Requirements;
82  std::string m_FileName;
83  bool m_DoStreaming = false;
84  bool m_Collective = false;
85 
86 private:
87  senseiHDF5::WriteStream *m_HDF5Writer;
88 
89  HDF5AnalysisAdaptor(const HDF5AnalysisAdaptor &) = delete;
90  void operator=(const HDF5AnalysisAdaptor &) = delete;
91 };
92 
93 }
94 
95 #endif
The base class for data consumers.
Definition: AnalysisAdaptor.h:24
The write side of the HDF5 transport.
Definition: HDF5AnalysisAdaptor.h:21
void SetStreamName(const std::string &filename)
Set the filename. The default value is "no.file".
Definition: HDF5AnalysisAdaptor.h:40
This is a helper class that handles the common task of specifying the set of meshes and arrays rqeuir...
Definition: DataRequirements.h:25
void SetCollective(bool s)
Enables MPI collective I/O.
Definition: HDF5AnalysisAdaptor.h:47
SENSEI.
Definition: ADIOS2AnalysisAdaptor.h:27
void SetMaxBufferSize(unsigned int size)
Sets the maximum buffer allocated by HDF5 in MB takes affect on first Execute.
Definition: HDF5AnalysisAdaptor.h:37
Base class that defines the interface for fetching data from a simulation.
Definition: DataAdaptor.h:25
void SetStreaming(bool streamOption)
Enables HDF5 streaming.
Definition: HDF5AnalysisAdaptor.h:44