VTK  9.0.1
vtkADIOS2CoreImageReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkADIOS2CoreImageReader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
30 #ifndef vtkADIOS2CoreImageReader_h
31 #define vtkADIOS2CoreImageReader_h
32 
33 #include <map> // For independently time stepped array indexing
34 #include <memory> // For std::unique_ptr
35 #include <string> // For variable name index mapping
36 #include <vector> // For independently time stepped array indexing
37 
38 #include "vtkDataObjectAlgorithm.h"
39 #include "vtkMultiProcessController.h" // For the process controller
40 #include "vtkSetGet.h" // For property get/set macros
41 #include "vtkSmartPointer.h" // For the object cache
42 
43 #include "vtkIOADIOS2Module.h" // For export macro
44 
45 class vtkCellArray;
46 class vtkDataArray;
47 class vtkDataObject;
48 class vtkDataSet;
50 class vtkFieldData;
51 class vtkImageData;
53 class vtkStringArray;
54 
55 //----------------------------------------------------------------------------
56 
57 class VTKIOADIOS2_EXPORT vtkADIOS2CoreImageReader : public vtkDataObjectAlgorithm
58 {
59 public:
60  enum class VarType
61  {
62  PointData,
63  CellData
64  };
65  using Params = std::map<std::string, std::string>;
66  using StringToParams = std::map<std::string, Params>;
67  using InquireVariablesType = std::vector<std::pair<std::string, VarType> >;
68  static vtkADIOS2CoreImageReader* New(void);
70  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
76  int CanReadFile(const std::string& name);
77 
78  virtual int CanReadFile(const char* filename);
79 
81 
84  vtkSetMacro(FileName, std::string);
85  vtkGetMacro(FileName, std::string);
87 
88  void SetFileName(const char* filename);
89 
91 
95  vtkSetVector3Macro(Origin, double);
96  vtkGetVector3Macro(Origin, double);
98 
100 
104  vtkSetVector3Macro(Spacing, double);
105  vtkGetVector3Macro(Spacing, double);
107 
109 
114  vtkStringArray* GetAllDimensionArrays();
115  vtkSetMacro(DimensionArray, std::string);
116  vtkGetMacro(DimensionArray, std::string);
118 
120 
124  vtkSetMacro(DimensionArrayAsCell, bool);
125  vtkGetMacro(DimensionArrayAsCell, bool);
126  vtkBooleanMacro(DimensionArrayAsCell, bool);
128 
129  vtkStringArray* GetAllTimeStepArrays();
131 
135  vtkSetMacro(TimeStepArray, std::string);
136  vtkGetMacro(TimeStepArray, std::string);
138 
140 
149  int GetNumberOfArrays();
150  const char* GetArrayName(int index);
151 
153 
157  void SetArrayStatus(const char* name, int status);
158  int GetArrayStatus(const char* name);
160 
162 
169  vtkSetMacro(IsColumnMajor, bool);
170  vtkGetMacro(IsColumnMajor, bool);
171  vtkBooleanMacro(IsColumnMajor, bool);
173 
175 
178  void SetActiveScalar(const std::pair<std::string, VarType>& inqVars);
179  std::pair<std::string, VarType>& GetActiveScalar();
180  const std::pair<std::string, VarType>& GetActiveScalar() const;
181 
183 
186  StringToParams& GetAvilableVariables();
187  const StringToParams& GetAvilableVariables() const;
188 
190 
193  StringToParams& GetAvailableAttributes();
194  const StringToParams& GetAvailableAttributes() const;
195 
197 
200  void SetController(vtkMultiProcessController*);
202 
206  virtual int ProcessRequest(
208 
209 protected:
211  ~vtkADIOS2CoreImageReader() override;
212 
213  int RequestDataObjectInternal(vtkInformationVector*);
214 
215  virtual int RequestInformation(
216  vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
217  virtual int RequestData(
218  vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
219 
220  std::string FetchTypeStringFromVarName(const std::string& name);
221 
222  void UpdateDimensionFromDimensionArray();
223 
224  // Read available variables and attributes in the file
225  bool OpenAndReadMetaData();
226 
227  // Convert the array selection into inquire variables.
228  void ConvertArraySelectionToInqVar();
229 
230  // Init the workDistribution based on the first inquired variable
231  bool InitWorkDistribution();
232 
233  void ReadImageBlocks(vtkMultiBlockDataSet* mbds);
234 
235  // Gather time steps info from the time step array
236  bool GatherTimeSteps();
237 
238  // Helper function for InitWorkDistribution to calculate how many blocks each process shall read
239  template <typename T>
240  void CalculateWorkDistribution(const std::string& varName);
241 
242  // Helper function for ReadImageBlocks to populate vtk data array from adios variable
243  template <typename T, template <typename...> class U>
244  vtkSmartPointer<vtkAbstractArray> PopulateDataArrayFromVar(
245  const std::string& varName, size_t blockIndex);
246 
247  // Helper function to gather time steps from adios time array
248  template <typename T>
249  void GatherTimeStepsFromADIOSTimeArray();
250 
252 
255 
258 
259  double Origin[3];
260  double Spacing[3];
261  int Dimension[3];
262 
264 
266 
267  struct vtkADIOS2CoreImageReaderImpl;
268  std::unique_ptr<vtkADIOS2CoreImageReaderImpl> Impl;
269 
270 private:
272  void operator=(const vtkADIOS2CoreImageReader&) = delete;
273 };
274 #endif
Store vtkAlgorithm input/output information.
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
static vtkDataObjectAlgorithm * New()
vtkTypeBool ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
see vtkAlgorithm for details
a vtkAbstractArray subclass for strings
a simple class to control print indentation
Definition: vtkIndent.h:33
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
std::vector< std::pair< std::string, VarType > > InquireVariablesType
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
std::map< std::string, Params > StringToParams
represent and manipulate attribute data in a dataset
Superclass for algorithms that produce only data object as output.
object to represent cell connectivity
Definition: vtkCellArray.h:179
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Composite dataset that organizes datasets into blocks.
std::unique_ptr< vtkADIOS2CoreImageReaderImpl > Impl
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
vtkSmartPointer< vtkMultiProcessController > Controller
Store zero or more vtkInformation instances.
std::map< std::string, std::string > Params
general representation of visualization data
Definition: vtkDataObject.h:59
represent and manipulate fields of data
Definition: vtkFieldData.h:53
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Multiprocessing communication superclass.