SENSEI
A frame work for generic in situ analytics
VTKAmrWriter.h
1 #ifndef sensei_VTKAmrWriter_h
2 #define sensei_VTKAmrWriter_h
3 
4 #include "AnalysisAdaptor.h"
5 #include "DataRequirements.h"
6 
7 #include <mpi.h>
8 #include <vector>
9 #include <string>
10 
11 
12 namespace sensei
13 {
14 /** Writes AMR data to disk in VTK format. This can be useful for generating
15  * preview datasets that allow configuration of Catalyst and/or Libsim scripts,
16  * or for staging data on resources such as burst buffers. This adaptor
17  * supports writing to a VTK(PXML), VisIt(.visit) or ParaView(.pvd) compatible
18  * format. One must provide a set of data requirments, consisting of a list of
19  * meshes and the arrays to write from each mesh. File names are derived using
20  * the output directory, the mesh name, and the mode.
21  */
22 class SENSEI_EXPORT VTKAmrWriter : public AnalysisAdaptor
23 {
24 public:
25  /// constructs a new VTKAmrWriter
26  static VTKAmrWriter* New();
27 
28  senseiTypeMacro(VTKAmrWriter, AnalysisAdaptor);
29 
30  /// @name Run time configuration
31  /// @{
32 
33  /// Sets the directory files will be written to.
34  int SetOutputDir(const std::string &outputDir);
35 
36  enum {MODE_PARAVIEW=0, MODE_VISIT=1};
37 
38  /// Sets the file creation mode. MODE_PARAVIEW=0, MODE_VISIT=1
39  int SetMode(int mode);
40 
41  /// Set the file creation mode by string Use either "paraview" or "visit".
42  int SetMode(std::string mode);
43 
44  /** Adds a set of sensei::DataRequirements, typically this will come from an XML
45  * configuratiopn file. Data requirements tell the adaptor what to fetch from
46  * the simulation and write to disk. If none are given then all available
47  * data is fetched and written.
48  */
49  int SetDataRequirements(const DataRequirements &reqs);
50 
51  /** Add an indivudal data requirement. Data requirements tell the adaptor
52  * what to fetch from the simulation and write to disk. If none are given
53  * then all available data is fetched and written.
54 
55  * @param[in] meshName the name of the mesh to fetch and write
56  * @param[in] association the type of data array to fetch and write
57  * vtkDataObject::POINT or vtkDataObject::CELL
58  * @param[in] arrays a list of arrays to fetch and write
59  * @returns zero if successful.
60  */
61  int AddDataRequirement(const std::string &meshName,
62  int association, const std::vector<std::string> &arrays);
63 
64  /// Must be called before Execute to configure for the run.
65  int Initialize();
66  /// @}
67 
68  /// Invokes the write.
69  bool Execute(DataAdaptor* data, DataAdaptor**) override;
70 
71  /** Finalizes output, flushes buffers, creates metadata files, and closes all
72  * streams.
73  */
74  int Finalize() override;
75 
76 protected:
77  VTKAmrWriter();
78  ~VTKAmrWriter();
79 
80  VTKAmrWriter(const VTKAmrWriter&) = delete;
81  void operator=(const VTKAmrWriter&) = delete;
82 
83 private:
84 #if !defined(SWIG)
85  std::string OutputDir;
86  DataRequirements Requirements;
87  int Mode;
88 
89  template<typename T>
90  using NameMap = std::map<std::string, T>;
91 
92  NameMap<std::vector<double>> Time;
93  NameMap<std::vector<long>> TimeStep;
94  NameMap<long> FileId;
95  NameMap<int> HaveBlockInfo;
96 #endif
97 };
98 
99 }
100 #endif
int Initialize(MPI_Comm comm, const std::string &fileName, InTransitDataAdaptor *&dataAdaptor)
Creates a sensei::ConfigurableAnalysis adaptor and sensei::InTransitDataAdaptor based on a SENSEI XML...
The base class for data consumers.
Definition: AnalysisAdaptor.h:24
Writes AMR data to disk in VTK format.
Definition: VTKAmrWriter.h:22
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