VTK: IO/ADIOS2/vtkADIOS2CoreImageReader.h Source File

| VTK 9.3.1

vtkADIOS2CoreImageReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
21 #ifndef vtkADIOS2CoreImageReader_h
22 #define vtkADIOS2CoreImageReader_h
23
24 #include <map> // For independently time stepped array indexing
25 #include <memory> // For std::unique_ptr
26 #include <string> // For variable name index mapping
27 #include <vector> // For independently time stepped array indexing
28
29 #include "vtkDataObjectAlgorithm.h"
30 #include "vtkSetGet.h" // For property get/set macros
31 #include "vtkSmartPointer.h" // For the object cache
32
33 #include "vtkIOADIOS2Module.h" // For export macro
34
35 VTK_ABI_NAMESPACE_BEGIN
36 class vtkCellArray;
37 class vtkDataArray;
38 class vtkDataObject;
39 class vtkDataSet;
40 class vtkDataSetAttributes;
41 class vtkFieldData;
42 class vtkImageData;
43 class vtkMultiBlockDataSet;
44 class vtkMultiProcessController;
45 class vtkStringArray;
46
47 //----------------------------------------------------------------------------
48
49 class VTKIOADIOS2_EXPORT vtkADIOS2CoreImageReader : public vtkDataObjectAlgorithm
50 {
51 public:
52 enum class VarType
53 {
54 PointData,
55 CellData
56 };
57 using Params = std::map<std::string, std::string>;
58 using StringToParams = std::map<std::string, Params>;
59 using InquireVariablesType = std::vector<std::pair<std::string, VarType>>;
60 static vtkADIOS2CoreImageReader* New();
61 vtkTypeMacro(vtkADIOS2CoreImageReader, vtkDataObjectAlgorithm);
62 void PrintSelf(ostream& os, vtkIndent indent) override;
63
68 int CanReadFile(VTK_FILEPATH const std::string& name);
69
70 virtual int CanReadFile(VTK_FILEPATH const char* filename);
71
73
76 vtkSetMacro(FileName, std::string);
77 vtkGetMacro(FileName, std::string);
79
80 void SetFileName(VTK_FILEPATH const char* filename);
81
83
87 vtkSetVector3Macro(Origin, double);
88 vtkGetVector3Macro(Origin, double);
90
92
96 vtkSetVector3Macro(Spacing, double);
97 vtkGetVector3Macro(Spacing, double);
99
101
106 vtkStringArray* GetAllDimensionArrays();
107 vtkSetMacro(DimensionArray, std::string);
108 vtkGetMacro(DimensionArray, std::string);
110
112
116 vtkSetMacro(DimensionArrayAsCell, bool);
117 vtkGetMacro(DimensionArrayAsCell, bool);
118 vtkBooleanMacro(DimensionArrayAsCell, bool);
120
121 vtkStringArray* GetAllTimeStepArrays();
123
127 vtkSetMacro(TimeStepArray, std::string);
128 vtkGetMacro(TimeStepArray, std::string);
130
132
141 int GetNumberOfArrays();
142 const char* GetArrayName(int index);
143
145
149 void SetArrayStatus(const char* name, int status);
150 int GetArrayStatus(const char* name);
152
154
161 vtkSetMacro(IsColumnMajor, bool);
162 vtkGetMacro(IsColumnMajor, bool);
163 vtkBooleanMacro(IsColumnMajor, bool);
165
167
170 void SetActiveScalar(const std::pair<std::string, VarType>& inqVars);
171 std::pair<std::string, VarType>& GetActiveScalar();
172 const std::pair<std::string, VarType>& GetActiveScalar() const;
173
175
178 StringToParams& GetAvilableVariables();
179 const StringToParams& GetAvilableVariables() const;
180
182
185 StringToParams& GetAvailableAttributes();
186 const StringToParams& GetAvailableAttributes() const;
187
189
192 void SetController(vtkMultiProcessController*);
194
198 int ProcessRequest(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
199
200 protected:
201 vtkADIOS2CoreImageReader();
202 ~vtkADIOS2CoreImageReader() override;
203
204 int RequestDataObjectInternal(vtkInformationVector*);
205
206 int RequestInformation(
207 vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
208 int RequestData(
209 vtkInformation* request, vtkInformationVector** input, vtkInformationVector* output) override;
210
211 std::string FetchTypeStringFromVarName(const std::string& name);
212
213 void UpdateDimensionFromDimensionArray();
214
215 // Read available variables and attributes in the file
216 bool OpenAndReadMetaData();
217
218 // Convert the array selection into inquire variables.
219 void ConvertArraySelectionToInqVar();
220
221 // Init the workDistribution based on the first inquired variable
222 bool InitWorkDistribution();
223
224 void ReadImageBlocks(vtkMultiBlockDataSet* mbds);
225
226 // Gather time steps info from the time step array
227 bool GatherTimeSteps();
228
229 // Helper function for InitWorkDistribution to calculate how many blocks each process shall read
230 template <typename T>
231 void CalculateWorkDistribution(const std::string& varName);
232
233 // Helper function for ReadImageBlocks to populate vtk data array from adios variable
234 template <typename T, template <typename...> class U>
235 vtkSmartPointer<vtkAbstractArray> PopulateDataArrayFromVar(
236 const std::string& varName, size_t blockIndex);
237
238 // Helper function to gather time steps from adios time array
239 template <typename T>
240 void GatherTimeStepsFromADIOSTimeArray();
241
242 std::string FileName;
243
244 bool DimensionArrayAsCell;
245 bool IsColumnMajor;
246
247 std::string DimensionArray;
248 std::string TimeStepArray;
249
250 double Origin[3];
251 double Spacing[3];
252 int Dimension[3];
253
254 double RequestTimeStep;
255
256 vtkSmartPointer<vtkMultiProcessController> Controller;
257
258 struct vtkADIOS2CoreImageReaderImpl;
259 std::unique_ptr<vtkADIOS2CoreImageReaderImpl> Impl;
260
261 private:
262 vtkADIOS2CoreImageReader(const vtkADIOS2CoreImageReader&) = delete;
263 void operator=(const vtkADIOS2CoreImageReader&) = delete;
264 };
265 VTK_ABI_NAMESPACE_END
266 #endif
vtkADIOS2CoreImageReader
Read ADIOS2 bp files.
Definition: vtkADIOS2CoreImageReader.h:50
vtkADIOS2CoreImageReader::CalculateWorkDistribution
void CalculateWorkDistribution(const std::string &varName)
vtkADIOS2CoreImageReader::InitWorkDistribution
bool InitWorkDistribution()
vtkADIOS2CoreImageReader::Impl
std::unique_ptr< vtkADIOS2CoreImageReaderImpl > Impl
Definition: vtkADIOS2CoreImageReader.h:258
vtkADIOS2CoreImageReader::OpenAndReadMetaData
bool OpenAndReadMetaData()
vtkADIOS2CoreImageReader::CanReadFile
virtual int CanReadFile(VTK_FILEPATH const char *filename)
vtkADIOS2CoreImageReader::ReadImageBlocks
void ReadImageBlocks(vtkMultiBlockDataSet *mbds)
vtkADIOS2CoreImageReader::GatherTimeStepsFromADIOSTimeArray
void GatherTimeStepsFromADIOSTimeArray()
vtkADIOS2CoreImageReader::GatherTimeSteps
bool GatherTimeSteps()
vtkADIOS2CoreImageReader::GetAllDimensionArrays
vtkStringArray * GetAllDimensionArrays()
Get/Set the name of the array to deduce the dimension of vtkImageData.
vtkADIOS2CoreImageReader::RequestDataObjectInternal
int RequestDataObjectInternal(vtkInformationVector *)
vtkADIOS2CoreImageReader::~vtkADIOS2CoreImageReader
~vtkADIOS2CoreImageReader() override
vtkADIOS2CoreImageReader::ProcessRequest
int ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
The main interface which triggers the reader to start.
vtkADIOS2CoreImageReader::GetArrayName
const char * GetArrayName(int index)
Get information about arrays.
vtkADIOS2CoreImageReader::IsColumnMajor
bool IsColumnMajor
Definition: vtkADIOS2CoreImageReader.h:245
vtkADIOS2CoreImageReader::UpdateDimensionFromDimensionArray
void UpdateDimensionFromDimensionArray()
vtkADIOS2CoreImageReader::SetController
void SetController(vtkMultiProcessController *)
Set the MPI controller.
vtkADIOS2CoreImageReader::InquireVariablesType
std::vector< std::pair< std::string, VarType > > InquireVariablesType
Definition: vtkADIOS2CoreImageReader.h:59
vtkADIOS2CoreImageReader::SetActiveScalar
void SetActiveScalar(const std::pair< std::string, VarType > &inqVars)
Get/Set the active scalar on each image block.
vtkADIOS2CoreImageReader::vtkADIOS2CoreImageReader
vtkADIOS2CoreImageReader()
vtkADIOS2CoreImageReader::New
static vtkADIOS2CoreImageReader * New()
vtkADIOS2CoreImageReader::Controller
vtkSmartPointer< vtkMultiProcessController > Controller
Definition: vtkADIOS2CoreImageReader.h:256
vtkADIOS2CoreImageReader::GetAvilableVariables
StringToParams & GetAvilableVariables()
Get the available variables.
vtkADIOS2CoreImageReader::CanReadFile
int CanReadFile(VTK_FILEPATH const std::string &name)
Test whether or not a given file should even be attempted for use with this reader.
vtkADIOS2CoreImageReader::RequestInformation
int RequestInformation(vtkInformation *request, vtkInformationVector **input, vtkInformationVector *output) override
vtkADIOS2CoreImageReader::Params
std::map< std::string, std::string > Params
Definition: vtkADIOS2CoreImageReader.h:57
vtkADIOS2CoreImageReader::SetArrayStatus
void SetArrayStatus(const char *name, int status)
Set the array that should be read in.
vtkADIOS2CoreImageReader::GetActiveScalar
const std::pair< std::string, VarType > & GetActiveScalar() const
Get/Set the active scalar on each image block.
vtkADIOS2CoreImageReader::SetFileName
void SetFileName(VTK_FILEPATH const char *filename)
vtkADIOS2CoreImageReader::DimensionArray
std::string DimensionArray
Definition: vtkADIOS2CoreImageReader.h:247
vtkADIOS2CoreImageReader::RequestData
int RequestData(vtkInformation *request, vtkInformationVector **input, vtkInformationVector *output) override
vtkADIOS2CoreImageReader::RequestTimeStep
double RequestTimeStep
Definition: vtkADIOS2CoreImageReader.h:254
vtkADIOS2CoreImageReader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkADIOS2CoreImageReader::GetAvailableAttributes
StringToParams & GetAvailableAttributes()
Get the available attributes.
vtkADIOS2CoreImageReader::GetNumberOfArrays
int GetNumberOfArrays()
Get information about arrays.
vtkADIOS2CoreImageReader::GetArrayStatus
int GetArrayStatus(const char *name)
Get information about arrays.
vtkADIOS2CoreImageReader::TimeStepArray
std::string TimeStepArray
Definition: vtkADIOS2CoreImageReader.h:248
vtkADIOS2CoreImageReader::GetAvilableVariables
const StringToParams & GetAvilableVariables() const
Get/Set the active scalar on each image block.
vtkADIOS2CoreImageReader::FileName
std::string FileName
Definition: vtkADIOS2CoreImageReader.h:242
vtkADIOS2CoreImageReader::PopulateDataArrayFromVar
vtkSmartPointer< vtkAbstractArray > PopulateDataArrayFromVar(const std::string &varName, size_t blockIndex)
vtkADIOS2CoreImageReader::FetchTypeStringFromVarName
std::string FetchTypeStringFromVarName(const std::string &name)
vtkADIOS2CoreImageReader::DimensionArrayAsCell
bool DimensionArrayAsCell
Definition: vtkADIOS2CoreImageReader.h:244
vtkADIOS2CoreImageReader::StringToParams
std::map< std::string, Params > StringToParams
Definition: vtkADIOS2CoreImageReader.h:58
vtkADIOS2CoreImageReader::GetAllTimeStepArrays
vtkStringArray * GetAllTimeStepArrays()
vtkADIOS2CoreImageReader::GetActiveScalar
std::pair< std::string, VarType > & GetActiveScalar()
Get/Set the active scalar on each image block.
vtkADIOS2CoreImageReader::GetAvailableAttributes
const StringToParams & GetAvailableAttributes() const
Get/Set the active scalar on each image block.
vtkADIOS2CoreImageReader::VarType
VarType
Definition: vtkADIOS2CoreImageReader.h:53
vtkADIOS2CoreImageReader::ConvertArraySelectionToInqVar
void ConvertArraySelectionToInqVar()
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:185
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkDataObjectAlgorithm
Superclass for algorithms that produce only data object as output.
Definition: vtkDataObjectAlgorithm.h:33
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:64
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:65
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:61
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkMultiBlockDataSet
Composite dataset that organizes datasets into blocks.
Definition: vtkMultiBlockDataSet.h:50
vtkMultiProcessController
Multiprocessing communication superclass.
Definition: vtkMultiProcessController.h:72
vtkSmartPointer< vtkAbstractArray >
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:41
vtkX3D::name
@ name
Definition: vtkX3D.h:219
vtkX3D::index
@ index
Definition: vtkX3D.h:246
vtkX3D::string
@ string
Definition: vtkX3D.h:490
vtkDataObjectAlgorithm.h
vtkSmartPointer.h
VTK_FILEPATH
#define VTK_FILEPATH
Definition: vtkWrappingHints.h:34