SENSEI
A frame work for generic in situ analytics
SliceExtract.h
1 #ifndef sensei_SliceExtract_h
2 #define sensei_SliceExtract_h
3 
4 #include "AnalysisAdaptor.h"
5 
6 #include <vector>
7 #include <array>
8 #include <string>
9 
10 /// @cond
11 class svtkCompositeDataSet;
12 namespace pugi { class xml_node; }
13 namespace sensei { class DataRequirements; }
14 /// @endcond
15 
16 namespace sensei
17 {
18 
19 /// Extract a slice defined by a point and a normal and writes it to disk
20 class SENSEI_EXPORT SliceExtract : public AnalysisAdaptor
21 {
22 public:
23  /// Create an instance of SliceExtract
24  static SliceExtract *New();
25 
26  senseiTypeMacro(SliceExtract, AnalysisAdaptor);
27  //void PrintSelf(ostream& os, svtkIndent indent) override;
28 
29  /// @name Run time configuration
30  /// @{
31 
32  /// Enable writing the results to disk
33  void EnableWriter(int val);
34 
35  /// Enable the use of an optimized partitioner
36  void EnablePartitioner(int val);
37 
38  enum {OP_ISO_SURFACE=0, OP_PLANAR_SLICE=1};
39 
40  /** Set which operation will be used. Valid values are OP_ISO_SURFACE=0,
41  * OP_PLANAR_SLICE=1
42  */
43  int SetOperation(int op);
44 
45  /** set which operation will be used. Valid values are "planar_slice",
46  * "iso_surface"
47  */
48  int SetOperation(std::string op);
49 
50  /** set the values to compute iso-surfaces for. if these aren't set the
51  * NumberOfIsoSurfaces field is used to generate equally spaced values on the
52  * fly. This applies in OP_ISO_SURFACE
53  */
54  void SetIsoValues(const std::string &mesh, const std::string &arrayName,
55  int arrayCentering, const std::vector<double> &vals);
56 
57  /** set the number of iso-surfaces to extract. Equally spaced iso-values are
58  * determined at each update. This applies in OP_ISO_SURFACE when explicit
59  * values have not been provided
60  */
61  void SetNumberOfIsoValues(const std::string &mesh,
62  const std::string &array, int centering, int numIsos);
63 
64  /** set the point and nornal defining the slice plane this applies when
65  * running in OP_PLANAR_SLICE
66  */
67  int SetPoint(const std::array<double,3> &point);
68 
69  /** set the point and nornal defining the slice plane this applies when
70  * running in OP_PLANAR_SLICE
71  */
72  int SetNormal(const std::array<double,3> &normal);
73 
74  /// Sets the directory files will be written to.
75  int SetWriterOutputDir(const std::string &outputDir);
76 
77  /// Set the file creation mode by string Use either "paraview" or "visit".
78  int SetWriterMode(const std::string &mode);
79 
80  /** Sets the writer type to a VTK legacy writer("legacy") or the VTK XML
81  * writer ("xml").
82  */
83  int SetWriterWriter(const std::string &writer);
84 
85  /** Adds a set of sensei::DataRequirements, typically this will come from an XML
86  * configuratiopn file. Data requirements tell the adaptor what to fetch from
87  * the simulation and write to disk. If none are given then all available
88  * data is fetched and written.
89  */
90  int SetDataRequirements(const DataRequirements &reqs);
91 
92  /** Add an indivudal data requirement. Data requirements tell the adaptor
93  * what to fetch from the simulation and write to disk. If none are given
94  * then all available data is fetched and written.
95 
96  * @param[in] meshName the name of the mesh to fetch and write
97  * @param[in] association the type of data array to fetch and write
98  * vtkDataObject::POINT or vtkDataObject::CELL
99  * @param[in] arrays a list of arrays to fetch and write
100  * @returns zero if successful.
101  */
102  int AddDataRequirement(const std::string &meshName,
103  int association, const std::vector<std::string> &arrays);
104 
105  /// Sets the verbosity level of the internally used adaptors.
106  void SetVerbose(int val) override;
107 
108  /// @}
109 
110  /// Compute a slice and write it to disk.
111  bool Execute(DataAdaptor* data, DataAdaptor**) override;
112 
113  /// Flush and close all open files.
114  int Finalize() override;
115 
116 private:
117 
118  bool ExecuteSlice(DataAdaptor *daIn, DataAdaptor **daOut);
119  bool ExecuteIsoSurface(DataAdaptor *daIn, DataAdaptor **daOut);
120 
121  int Slice(svtkCompositeDataSet *input, const std::array<double,3> &point,
122  const std::array<double,3> &normal, svtkCompositeDataSet *&output);
123 
124  int IsoSurface(svtkCompositeDataSet *input,
125  const std::string &arrayName, int arrayCen,
126  const std::vector<double> &vals, svtkCompositeDataSet *&output);
127 
128  int WriteExtract(long timeStep, double time, const std::string &mesh,
129  svtkCompositeDataSet *input);
130 
131 protected:
132  SliceExtract();
133  ~SliceExtract();
134 
135  SliceExtract(const SliceExtract&) = delete;
136  void operator=(const SliceExtract&) = delete;
137 
138  struct InternalsType;
139  InternalsType *Internals;
140 };
141 
142 }
143 #endif
The base class for data consumers.
Definition: AnalysisAdaptor.h:24
Extract a slice defined by a point and a normal and writes it to disk.
Definition: SliceExtract.h:20
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
Definition: ADIOS2DataAdaptor.h:10
Base class that defines the interface for fetching data from a simulation.
Definition: DataAdaptor.h:25