SENSEI
A frame work for generic in situ analytics
VTKPosthocIO.h
1 #ifndef sensei_VTKPosthocIO_h
2 #define sensei_VTKPosthocIO_h
3 
4 #include "AnalysisAdaptor.h"
5 #include "DataRequirements.h"
6 #include "MeshMetadata.h"
7 
8 #include <svtkSmartPointer.h>
9 
10 #include <mpi.h>
11 #include <vector>
12 #include <string>
13 
14 
15 namespace sensei
16 {
17 class VTKPosthocIO;
18 using VTKPosthocIOPtr = svtkSmartPointer<VTKPosthocIO>;
19 
20 /** Writes simulation data to disk in a VTK based format. This can be useful
21  * for generating preview datasets that allow configuration of Catalyst and/or
22  * Libsim scripts, or for staging data on resources such as burst buffers. This
23  * adaptor supports writing to VisIt(.visit) or ParaView(.pvd) compatible
24  * format. One must provide a set of data requirments, consisting of a list of
25  * meshes and the arrays to write from each mesh. File names are derived using
26  * the output directory, the mesh name, and the mode.
27  */
28 class SENSEI_EXPORT VTKPosthocIO : public AnalysisAdaptor
29 {
30 public:
31  /// Constructs a VTKPosthocIO instance.
32  static VTKPosthocIO* New();
33 
34  senseiTypeMacro(VTKPosthocIO, AnalysisAdaptor);
35 
36  /// @name Run time configuration
37  /// @{
38 
39  /// Sets the directory files will be written to.
40  int SetOutputDir(const std::string &outputDir);
41 
42  /// File creation modes.
43  enum {MODE_PARAVIEW=0, MODE_VISIT=1};
44 
45  /// Sets the file creation mode. MODE_PARAVIEW=0, MODE_VISIT=1
46  int SetMode(int mode);
47 
48  /// Set the file creation mode by string Use either "paraview" or "visit".
49  int SetMode(std::string mode);
50 
51  enum {WRITER_VTK_LEGACY=0, WRITER_VTK_XML=1};
52 
53  /** Sets the writer type to a VTK legacy writer(WRITER_VTK_LEGACY=0) or the
54  * VTK XML writer (WRITER_VTK_XML=1).
55  */
56  int SetWriter(int writer);
57 
58  /** Sets the writer type to a VTK legacy writer("legacy") or the VTK XML
59  * writer ("xml").
60  */
61  int SetWriter(std::string writer);
62 
63  /** if set this overrides the default of vtkGhostType for ParaView and
64  * avtGhostZones for VisIt
65  */
66  void SetGhostArrayName(const std::string &name);
67 
68  /// Get the name of the ghost cells array.
69  std::string GetGhostArrayName();
70 
71  /** Adds a set of sensei::DataRequirements, typically this will come from an XML
72  * configuratiopn file. Data requirements tell the adaptor what to fetch from
73  * the simulation and write to disk. If none are given then all available
74  * data is fetched and written.
75  */
76  int SetDataRequirements(const DataRequirements &reqs);
77 
78  /** Add an indivudal data requirement. Data requirements tell the adaptor
79  * what to fetch from the simulation and write to disk. If none are given
80  * then all available data is fetched and written.
81 
82  * @param[in] meshName the name of the mesh to fetch and write
83  * @param[in] association the type of data array to fetch and write
84  * vtkDataObject::POINT or vtkDataObject::CELL
85  * @param[in] arrays a list of arrays to fetch and write
86  * @returns zero if successful.
87  */
88  int AddDataRequirement(const std::string &meshName,
89  int association, const std::vector<std::string> &arrays);
90 
91  /// Controls how many calls to Execute do nothing between actual I/O
92  int SetFrequency(unsigned int frequency);
93 
94  /// @}
95 
96  bool Execute(DataAdaptor* data, DataAdaptor**) override;
97 
98  int Finalize() override;
99 
100 protected:
101  VTKPosthocIO();
102  ~VTKPosthocIO();
103 
104  VTKPosthocIO(const VTKPosthocIO&) = delete;
105  void operator=(const VTKPosthocIO&) = delete;
106 
107 private:
108 #if !defined(SWIG)
109  unsigned int Frequency;
110  std::string OutputDir;
111  DataRequirements Requirements;
112  int Mode;
113  int Writer;
114  std::string GhostArrayName;
115 
116  template<typename T>
117  using NameMap = std::map<std::string, T>;
118 
119  NameMap<std::vector<double>> Time;
120  NameMap<std::vector<long>> TimeStep;
121  NameMap<std::vector<MeshMetadataPtr>> Metadata;
122  NameMap<std::string> BlockExt;
123  NameMap<long> FileId;
124  NameMap<int> HaveBlockInfo;
125 #endif
126 };
127 
128 }
129 #endif
The base class for data consumers.
Definition: AnalysisAdaptor.h:24
This is a helper class that handles the common task of specifying the set of meshes and arrays rqeuir...
Definition: DataRequirements.h:25
SENSEI.
Definition: ADIOS2AnalysisAdaptor.h:27
Base class that defines the interface for fetching data from a simulation.
Definition: DataAdaptor.h:25
Writes simulation data to disk in a VTK based format.
Definition: VTKPosthocIO.h:28