VTK  9.3.20240423
vtkAMRBaseReader.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
8#ifndef vtkAMRBaseReader_h
9#define vtkAMRBaseReader_h
10
11#include "vtkIOAMRModule.h" // For export macro
13#include <map> // STL map header
14#include <utility> // for STL pair
15#include <vector> // STL vector header
16
17// Forward Declarations
18VTK_ABI_NAMESPACE_BEGIN
23class vtkIndent;
25class vtkUniformGrid;
26class vtkDataArray;
27
28class VTKIOAMR_EXPORT vtkAMRBaseReader : public vtkOverlappingAMRAlgorithm
29{
30public:
32 void PrintSelf(ostream& os, vtkIndent indent) override;
33
38 void Initialize();
39
41
44 vtkSetMacro(EnableCaching, vtkTypeBool);
45 vtkGetMacro(EnableCaching, vtkTypeBool);
46 vtkBooleanMacro(EnableCaching, vtkTypeBool);
47 bool IsCachingEnabled() const { return ((this->EnableCaching) ? true : false); }
49
51
56 vtkGetObjectMacro(Controller, vtkMultiProcessController);
58
60
63 vtkSetMacro(MaxLevel, int);
65
67
71 vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
72 vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
74
76
82
84
88 const char* GetPointArrayName(int index);
89 const char* GetCellArrayName(int index);
91
93
97 int GetPointArrayStatus(const char* name);
98 int GetCellArrayStatus(const char* name);
99 void SetPointArrayStatus(const char* name, int status);
100 void SetCellArrayStatus(const char* name, int status);
102
104
109 virtual void SetFileName(VTK_FILEPATH const char* fileName) = 0;
111
115 virtual int GetNumberOfBlocks() = 0;
116
120 virtual int GetNumberOfLevels() = 0;
121
122protected:
125
126 // Description:
127 // Checks if this reader instance is attached to a communicator
128 // with more than one MPI processes.
130
135 bool IsBlockMine(int blockIdx);
136
143
149
157
162 void GetAMRData(int blockIdx, vtkUniformGrid* block, const char* fieldName);
163
167 void GetAMRPointData(int blockIdx, vtkUniformGrid* block, const char* fieldName);
168
174 void LoadPointData(int blockIdx, vtkUniformGrid* block);
175
182 void LoadCellData(int blockIdx, vtkUniformGrid* block);
183
192 int GetBlockProcessId(int blockIdx);
193
202
206 virtual void ReadMetaData() = 0;
207
211 virtual int GetBlockLevel(int blockIdx) = 0;
212
218 virtual int FillMetaData() = 0;
219
223 virtual vtkUniformGrid* GetAMRGrid(int blockIdx) = 0;
224
228 virtual void GetAMRGridData(int blockIdx, vtkUniformGrid* block, const char* field) = 0;
229
233 virtual void GetAMRGridPointData(int blockIdx, vtkUniformGrid* block, const char* field) = 0;
234
236
239 int RequestData(vtkInformation* vtkNotUsed(request),
240 vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector) override;
242 vtkInformationVector* outputVector) override;
243 int FillOutputPortInformation(int port, vtkInformation* info) override;
245
246 // Array selection member variables and methods
250
257
261 virtual void SetUpDataArraySelections() = 0;
262
267 vtkObject* caller, unsigned long eid, void* clientdata, void* calldata);
268
271 char* FileName;
273
278
281
282 std::vector<int> BlockMap;
283
284private:
285 vtkAMRBaseReader(const vtkAMRBaseReader&) = delete;
286 void operator=(const vtkAMRBaseReader&) = delete;
287};
288
289VTK_ABI_NAMESPACE_END
290#endif /* vtkAMRBaseReader_h */
An abstract class that encapsulates common functionality for all AMR readers.
std::vector< int > BlockMap
void SetupBlockRequest(vtkInformation *outputInfo)
Initializes the request of blocks to be loaded.
int GetNumberOfCellArrays()
Get the number of point or cell arrays available in the input.
virtual void SetController(vtkMultiProcessController *)
Set/Get a multiprocess-controller for reading in parallel.
int RequestData(vtkInformation *vtkNotUsed(request), vtkInformationVector **vtkNotUsed(inputVector), vtkInformationVector *outputVector) override
Standard Pipeline methods, subclasses may override this method if needed.
vtkDataArraySelection * PointDataArraySelection
void LoadCellData(int blockIdx, vtkUniformGrid *block)
A wrapper that loops over all cell arrays and loads the cell arrays that are enabled,...
vtkCallbackCommand * SelectionObserver
const char * GetPointArrayName(int index)
Get the name of the point or cell array with the given index in the input.
vtkDataArraySelection * CellDataArraySelection
virtual int GetNumberOfBlocks()=0
Returns the total number of blocks.
vtkTypeBool EnableCaching
virtual void ReadMetaData()=0
Reads all the metadata from the file.
void LoadRequestedBlocks(vtkOverlappingAMR *amrds)
This method loads all the blocks in the BlockMap for the given process.
const char * GetCellArrayName(int index)
Get the name of the point or cell array with the given index in the input.
static void SelectionModifiedCallback(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)
Call-back registered with the SelectionObserver.
int GetCellArrayStatus(const char *name)
Get/Set whether the point or cell array with the given name is to be read.
virtual void GetAMRGridData(int blockIdx, vtkUniformGrid *block, const char *field)=0
Loads the block data.
bool IsCachingEnabled() const
Set/Get Reader caching property.
void AssignAndLoadBlocks(vtkOverlappingAMR *amrds)
This method assigns blocks to processes using block-cyclic distribution.
void SetPointArrayStatus(const char *name, int status)
Get/Set whether the point or cell array with the given name is to be read.
virtual int FillMetaData()=0
Loads all the AMR metadata & constructs the LevelIdxPair12InternalIdx datastructure which maps (level...
vtkUniformGrid * GetAMRBlock(int blockIdx)
Loads the AMR block corresponding to the given index.
~vtkAMRBaseReader() override
int GetPointArrayStatus(const char *name)
Get/Set whether the point or cell array with the given name is to be read.
virtual void GetAMRGridPointData(int blockIdx, vtkUniformGrid *block, const char *field)=0
Loads the block Point data.
void InitializeArraySelections()
Initializes the array selections.
bool IsBlockMine(int blockIdx)
Determines if the block is owned by this process based on the the block index and total number of pro...
virtual vtkUniformGrid * GetAMRGrid(int blockIdx)=0
Loads the block according to the index w.r.t.
int GetBlockProcessId(int blockIdx)
Returns the block process ID for the block corresponding to the given block index.
int RequestInformation(vtkInformation *rqst, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Standard Pipeline methods, subclasses may override this method if needed.
virtual int GetBlockLevel(int blockIdx)=0
Returns the block level for the given block.
vtkOverlappingAMR * Metadata
void GetAMRPointData(int blockIdx, vtkUniformGrid *block, const char *fieldName)
Loads the AMR point data corresponding to the given field name.
void Initialize()
Initializes the AMR reader.
vtkAMRDataSetCache * Cache
void GetAMRData(int blockIdx, vtkUniformGrid *block, const char *fieldName)
Loads the AMR data corresponding to the given field name.
void LoadPointData(int blockIdx, vtkUniformGrid *block)
A wrapper that loops over point arrays and load the point arrays that are enabled,...
void SetCellArrayStatus(const char *name, int status)
Get/Set whether the point or cell array with the given name is to be read.
vtkGetFilePathMacro(FileName)
Set/Get the filename.
vtkMultiProcessController * Controller
virtual int GetNumberOfLevels()=0
Returns the total number of levels.
virtual void SetFileName(VTK_FILEPATH const char *fileName)=0
Set/Get the filename.
int FillOutputPortInformation(int port, vtkInformation *info) override
Standard Pipeline methods, subclasses may override this method if needed.
int GetNumberOfPointArrays()
Get the number of point or cell arrays available in the input.
virtual void SetUpDataArraySelections()=0
Initializes the PointDataArraySelection & CellDataArraySelection.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
A concrete implementation of vtkObject that provides functionality for caching AMR blocks.
supports function callbacks
Store on/off settings for data arrays, etc.
abstract superclass for arrays of numeric data
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Multiprocessing communication superclass.
abstract base class for most VTK objects
Definition vtkObject.h:162
A base class for all algorithms that take as input vtkOverlappingAMR and produce vtkOverlappingAMR.
hierarchical dataset of vtkUniformGrids
image data with blanking
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_FILEPATH