vtkSpyPlotReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
3 // SPDX-License-Identifier: BSD-3-Clause
41 #ifndef vtkSpyPlotReader_h
42 #define vtkSpyPlotReader_h
43 
45 #include "vtkPVVTKExtensionsIOSPCTHModule.h" //needed for exports
46 #include "vtkParaViewDeprecation.h" // for deprecation
47 
48 class vtkBoundingBox;
49 class vtkCallbackCommand;
50 class vtkCellData;
51 class vtkDataArray;
54 // class vtkHierarchicalBoxDataSet;
58 class vtkRectilinearGrid;
59 class vtkSpyPlotBlock;
63 
65 {
66 public:
67  static vtkSpyPlotReader* New();
69  void PrintSelf(ostream& os, vtkIndent indent) override;
70 
74  PARAVIEW_DEPRECATED_IN_6_1_0("Noop, do not use.")
75  void PrintBlockList(vtkNonOverlappingAMR* hbds, int myProcId);
76 
78 
82  virtual void SetFileName(const char* filename);
83  vtkGetStringMacro(FileName);
85 
87 
91  vtkSetMacro(TimeStep, int);
92  vtkGetMacro(TimeStep, int);
94 
96 
103  vtkSetMacro(DistributeFiles, int);
104  vtkGetMacro(DistributeFiles, int);
105  vtkBooleanMacro(DistributeFiles, int);
107 
109 
114  vtkSetMacro(GenerateLevelArray, int);
115  vtkGetMacro(GenerateLevelArray, int);
116  vtkBooleanMacro(GenerateLevelArray, int);
118 
120 
125  vtkSetMacro(GenerateBlockIdArray, int);
126  vtkGetMacro(GenerateBlockIdArray, int);
127  vtkBooleanMacro(GenerateBlockIdArray, int);
129 
131 
136  vtkSetMacro(GenerateActiveBlockArray, int);
137  vtkGetMacro(GenerateActiveBlockArray, int);
138  vtkBooleanMacro(GenerateActiveBlockArray, int);
140 
142 
147  vtkSetMacro(GenerateTracerArray, int);
148  vtkGetMacro(GenerateTracerArray, int);
149  vtkBooleanMacro(GenerateTracerArray, int);
151 
153 
158  void SetGenerateMarkers(int gm);
159  vtkGetMacro(GenerateMarkers, int);
160  vtkBooleanMacro(GenerateMarkers, int);
162 
164 
168  void SetDownConvertVolumeFraction(int vf);
169  vtkGetMacro(DownConvertVolumeFraction, int);
170  vtkBooleanMacro(DownConvertVolumeFraction, int);
172 
174 
179  vtkSetMacro(ComputeDerivedVariables, int);
180  vtkGetMacro(ComputeDerivedVariables, int);
181  vtkBooleanMacro(ComputeDerivedVariables, int);
183 
185 
192  void SetMergeXYZComponents(int merge);
193  vtkGetMacro(MergeXYZComponents, int);
194  vtkBooleanMacro(MergeXYZComponents, int);
196 
198 
201  vtkGetVector2Macro(TimeStepRange, int);
203 
205 
208  int GetNumberOfCellArrays();
209  const char* GetCellArrayName(int idx);
210  int GetCellArrayStatus(const char* name);
211  void SetCellArrayStatus(const char* name, int status);
213 
219  void SetGlobalController(vtkMultiProcessController* controller);
220 
224  virtual int CanReadFile(const char* fname);
225 
226 protected:
228  ~vtkSpyPlotReader() override;
229 
230  // Determine the bounds of just this reader
231  void GetLocalBounds(vtkSpyPlotBlockIterator* biter, int nBlocks, int progressInterval);
232 
233  // Set the global bounds of all readers
234  void SetGlobalBounds(vtkSpyPlotBlockIterator* biter, int total_num_of_block, int progressInterval,
235  int* rightHasBounds, int* leftHasBounds);
236 
237  // Determine the box size on just this reader
238  // returns true if box size is a constant on this reader
239  // false if not.
240  bool GetLocalBoxSize(vtkSpyPlotBlockIterator* biter, int* localBoxSize) const;
241 
242  // Determine box size if it is a constant across the data set
243  // If not then this is set to -1,-1,-1.
244  void SetGlobalBoxSize(vtkSpyPlotBlockIterator* biter);
245 
246  // Determine the minimum level that is used on just this level
247  // and get the spacing there
248  void GetLocalMinLevelAndSpacing(
249  vtkSpyPlotBlockIterator* biter, int* localMinLevel, double spacing[3]) const;
250 
251  // Set the minimum level that is used
252  // and get the spacing there
253  void SetGlobalMinLevelAndSpacing(vtkSpyPlotBlockIterator* biter);
254 
255  // Set things up to process an AMR Block
256  int PrepareAMRData(vtkNonOverlappingAMR* hb, vtkSpyPlotBlock* block, int* level, int* blockId,
257  int extents[6], int realExtents[6], int realDims[3], vtkCellData** cd);
258 
259  // Set things up to process a non-AMR Block
260  int PrepareData(vtkMultiBlockDataSet* hb, vtkSpyPlotBlock* block, vtkRectilinearGrid** rg,
261  int extents[6], int realExtents[6], int realDims[3], vtkCellData** cd);
262 
263  // Update the field data (interms of ghost cells) that
264  // contain whose block did not contain any bad ghost cells
265  void UpdateFieldData(int numFields, int dims[3], int level, int blockID,
266  vtkSpyPlotUniReader* uniReader, vtkCellData* cd);
267 
268  // Update the field data (interms of ghost cells) that
269  // contain whose block did contain bad ghost cells
270  void UpdateBadGhostFieldData(int numFields, int dims[3], int realDims[3], int realExtents[6],
271  int level, int blockID, vtkSpyPlotUniReader* uniReader, vtkCellData* cd);
272 
273  // Sets up the blocks for the markers data
274  void PrepareBlocks(vtkMultiBlockDataSet* poly, int numMat);
275 
276  // Sets up the markers data on the second output port
277  int PrepareMarkers(vtkMultiBlockDataSet* poly, vtkSpyPlotUniReader* reader);
278 
279  // The array selections.
280  vtkDataArraySelection* CellDataArraySelection;
281 
282  int FillOutputPortInformation(int port, vtkInformation* info) override;
283 
284  // Create either vtkNonOverlappingAMR or vtkMultiBlockDataSet based on
285  // whether the dataset is AMR.
286  int RequestDataObject(
287  vtkInformation* req, vtkInformationVector** inV, vtkInformationVector* outV) override;
288 
289  // Read the case file and the first binary file do get meta
290  // information (number of files, number of fields, number of timestep).
291  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
292  vtkInformationVector* outputVector) override;
293 
294  // Read the data: get the number of pieces (=processors) and get
295  // my piece id (=my processor id).
296  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
297  vtkInformationVector* outputVector) override;
298 
306  int UpdateMetaData(vtkInformation* request, vtkInformationVector* outputVector);
307 
308  int UpdateFile(vtkInformation* request, vtkInformationVector* outputVector);
309 
310  void AddGhostLevelArray(int numLevels);
311  int AddBlockIdArray(vtkCompositeDataSet* cds);
312  int AddAttributes(vtkNonOverlappingAMR* hbds);
313  int AddActiveBlockArray(vtkCellData* cd, vtkIdType nCells, unsigned char status);
314 
315  // Have all the readers have the same global level structure
316  void SetGlobalLevels(vtkCompositeDataSet* cds);
317 
318  // The observer to modify this object when the array selections are
319  // modified.
320  char* FileName;
321 
322  int TimeStep; // set by the user
323  int TimeStepRange[2];
324  int CurrentTimeStep; // computed
325 
326  int IsAMR; // AMR (hierarchy of uniform grids)
327  // or flat mesh (set of rectilinear grids)?
328 
329  // access to all processes
330  vtkMultiProcessController* GlobalController;
331 
335  int UpdateTimeStep(
336  vtkInformation* requestInfo, vtkInformationVector* outputInfo, vtkCompositeDataSet* hb);
337 
341  int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
342  const int extents[6] = nullptr) override
343  {
344  return this->Superclass::UpdateTimeStep(time, piece, numPieces, ghostLevels, extents);
345  }
346 
347  // The file format stores a vector field as separated scalar component
348  // fields. This method rebuilds the vector field from those scalar
349  // component fields.
350  void MergeVectors(vtkDataSetAttributes* da);
351  int MergeVectors(vtkDataSetAttributes* da, vtkDataArray* a1, vtkDataArray* a2);
352  int MergeVectors(vtkDataSetAttributes* da, vtkDataArray* a1, vtkDataArray* a2, vtkDataArray* a3);
353 
355  int ComputeDerivedVars(
356  vtkCellData* data, vtkSpyPlotBlock* block, vtkSpyPlotUniReader* reader, const int& blockID);
357 
359 
363  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
365 
366  // vtkSpyPlotReaderMap needs access to GetCellDataArraySelection().
367  friend class vtkSpyPlotReaderMap;
369 
371 
372  vtkBoundingBox* Bounds; // bounds of the hierarchy without the bad ghostcells.
373  int BoxSize[3]; // size of boxes if they are all the same, else -1,-1,-1
374  int MinLevel; // first used level
375  double MinLevelSpacing[3]; // grid spacing on first used level
376 
377  int GenerateLevelArray; // user flag
378  int GenerateBlockIdArray; // user flag
379  int GenerateActiveBlockArray; // user flag
380  int GenerateTracerArray; // user flag
381  int GenerateMarkers; // user flag
382 
384 
386 
388 
389  // This flag is used to determine if core meta-data needs to be re-read.
391 
392 private:
393  vtkSpyPlotReader(const vtkSpyPlotReader&) = delete;
394  void operator=(const vtkSpyPlotReader&) = delete;
395 
396  class VectorOfDoubles;
397 
398  VectorOfDoubles* TimeSteps;
399  void SetTimeStepsInternal(const VectorOfDoubles&);
400 };
401 
402 #endif
Maps strings to vtkSpyPlotUniReaders.
vtkBoundingBox * Bounds
int vtkIdType
vtkSpyPlotReaderMap * Map
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual int UpdateTimeStep(double time, int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=0)
#define PARAVIEW_DEPRECATED_IN_6_1_0(reason)
Read SPCTH Spy Plot file format.
static vtkCompositeDataSetAlgorithm * New()
#define VTKPVVTKEXTENSIONSIOSPCTH_EXPORT
#define const
Definition: zconf.h:238
Represents a SpyPlot Block Grid.
void operator=(const vtkObjectBase &)
Read SPCTH Spy Plot file format.