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 
47 class vtkBoundingBox;
48 class vtkCallbackCommand;
49 class vtkCellData;
50 class vtkDataArray;
53 // class vtkHierarchicalBoxDataSet;
57 class vtkRectilinearGrid;
58 class vtkSpyPlotBlock;
62 
64 {
65 public:
66  static vtkSpyPlotReader* New();
68  void PrintSelf(ostream& os, vtkIndent indent) override;
69 
71 
75  virtual void SetFileName(const char* filename);
76  vtkGetStringMacro(FileName);
78 
80 
84  vtkSetMacro(TimeStep, int);
85  vtkGetMacro(TimeStep, int);
87 
89 
96  vtkSetMacro(DistributeFiles, int);
97  vtkGetMacro(DistributeFiles, int);
98  vtkBooleanMacro(DistributeFiles, int);
100 
102 
107  vtkSetMacro(GenerateLevelArray, int);
108  vtkGetMacro(GenerateLevelArray, int);
109  vtkBooleanMacro(GenerateLevelArray, int);
111 
113 
118  vtkSetMacro(GenerateBlockIdArray, int);
119  vtkGetMacro(GenerateBlockIdArray, int);
120  vtkBooleanMacro(GenerateBlockIdArray, int);
122 
124 
129  vtkSetMacro(GenerateActiveBlockArray, int);
130  vtkGetMacro(GenerateActiveBlockArray, int);
131  vtkBooleanMacro(GenerateActiveBlockArray, int);
133 
135 
140  vtkSetMacro(GenerateTracerArray, int);
141  vtkGetMacro(GenerateTracerArray, int);
142  vtkBooleanMacro(GenerateTracerArray, int);
144 
146 
151  void SetGenerateMarkers(int gm);
152  vtkGetMacro(GenerateMarkers, int);
153  vtkBooleanMacro(GenerateMarkers, int);
155 
157 
161  void SetDownConvertVolumeFraction(int vf);
162  vtkGetMacro(DownConvertVolumeFraction, int);
163  vtkBooleanMacro(DownConvertVolumeFraction, int);
165 
167 
172  vtkSetMacro(ComputeDerivedVariables, int);
173  vtkGetMacro(ComputeDerivedVariables, int);
174  vtkBooleanMacro(ComputeDerivedVariables, int);
176 
178 
185  void SetMergeXYZComponents(int merge);
186  vtkGetMacro(MergeXYZComponents, int);
187  vtkBooleanMacro(MergeXYZComponents, int);
189 
191 
194  vtkGetVector2Macro(TimeStepRange, int);
196 
198 
201  int GetNumberOfCellArrays();
202  const char* GetCellArrayName(int idx);
203  int GetCellArrayStatus(const char* name);
204  void SetCellArrayStatus(const char* name, int status);
206 
212  void SetGlobalController(vtkMultiProcessController* controller);
213 
217  virtual int CanReadFile(const char* fname);
218 
219 protected:
221  ~vtkSpyPlotReader() override;
222 
223  // Determine the bounds of just this reader
224  void GetLocalBounds(vtkSpyPlotBlockIterator* biter, int nBlocks, int progressInterval);
225 
226  // Set the global bounds of all readers
227  void SetGlobalBounds(vtkSpyPlotBlockIterator* biter, int total_num_of_block, int progressInterval,
228  int* rightHasBounds, int* leftHasBounds);
229 
230  // Determine the box size on just this reader
231  // returns true if box size is a constant on this reader
232  // false if not.
233  bool GetLocalBoxSize(vtkSpyPlotBlockIterator* biter, int* localBoxSize) const;
234 
235  // Determine box size if it is a constant across the data set
236  // If not then this is set to -1,-1,-1.
237  void SetGlobalBoxSize(vtkSpyPlotBlockIterator* biter);
238 
239  // Determine the minimum level that is used on just this level
240  // and get the spacing there
241  void GetLocalMinLevelAndSpacing(
242  vtkSpyPlotBlockIterator* biter, int* localMinLevel, double spacing[3]) const;
243 
244  // Set the minimum level that is used
245  // and get the spacing there
246  void SetGlobalMinLevelAndSpacing(vtkSpyPlotBlockIterator* biter);
247 
248  // Set things up to process an AMR Block
249  int PrepareAMRData(vtkNonOverlappingAMR* hb, vtkSpyPlotBlock* block, int* level, int* blockId,
250  int extents[6], int realExtents[6], int realDims[3], vtkCellData** cd);
251 
252  // Set things up to process a non-AMR Block
253  int PrepareData(vtkMultiBlockDataSet* hb, vtkSpyPlotBlock* block, vtkRectilinearGrid** rg,
254  int extents[6], int realExtents[6], int realDims[3], vtkCellData** cd);
255 
256  // Update the field data (interms of ghost cells) that
257  // contain whose block did not contain any bad ghost cells
258  void UpdateFieldData(int numFields, int dims[3], int level, int blockID,
259  vtkSpyPlotUniReader* uniReader, vtkCellData* cd);
260 
261  // Update the field data (interms of ghost cells) that
262  // contain whose block did contain bad ghost cells
263  void UpdateBadGhostFieldData(int numFields, int dims[3], int realDims[3], int realExtents[6],
264  int level, int blockID, vtkSpyPlotUniReader* uniReader, vtkCellData* cd);
265 
266  // Sets up the blocks for the markers data
267  void PrepareBlocks(vtkMultiBlockDataSet* poly, int numMat);
268 
269  // Sets up the markers data on the second output port
270  int PrepareMarkers(vtkMultiBlockDataSet* poly, vtkSpyPlotUniReader* reader);
271 
272  // The array selections.
274 
275  int FillOutputPortInformation(int port, vtkInformation* info) override;
276 
277  // Create either vtkNonOverlappingAMR or vtkMultiBlockDataSet based on
278  // whether the dataset is AMR.
279  int RequestDataObject(
280  vtkInformation* req, vtkInformationVector** inV, vtkInformationVector* outV) override;
281 
282  // Read the case file and the first binary file do get meta
283  // information (number of files, number of fields, number of timestep).
284  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
285  vtkInformationVector* outputVector) override;
286 
287  // Read the data: get the number of pieces (=processors) and get
288  // my piece id (=my processor id).
289  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
290  vtkInformationVector* outputVector) override;
291 
299  int UpdateMetaData(vtkInformation* request, vtkInformationVector* outputVector);
300 
301  int UpdateFile(vtkInformation* request, vtkInformationVector* outputVector);
302 
303  void AddGhostLevelArray(int numLevels);
304  int AddBlockIdArray(vtkCompositeDataSet* cds);
305  int AddAttributes(vtkNonOverlappingAMR* hbds);
306  int AddActiveBlockArray(vtkCellData* cd, vtkIdType nCells, unsigned char status);
307 
308  // Have all the readers have the same global level structure
309  void SetGlobalLevels(vtkCompositeDataSet* cds);
310 
311  // The observer to modify this object when the array selections are
312  // modified.
313  char* FileName;
314 
315  int TimeStep; // set by the user
316  int TimeStepRange[2];
317  int CurrentTimeStep; // computed
318 
319  int IsAMR; // AMR (hierarchy of uniform grids)
320  // or flat mesh (set of rectilinear grids)?
321 
322  // access to all processes
324 
328  int UpdateTimeStep(
329  vtkInformation* requestInfo, vtkInformationVector* outputInfo, vtkCompositeDataSet* hb);
330 
334  int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
335  const int extents[6] = nullptr) override
336  {
337  return this->Superclass::UpdateTimeStep(time, piece, numPieces, ghostLevels, extents);
338  }
339 
340  // The file format stores a vector field as separated scalar component
341  // fields. This method rebuilds the vector field from those scalar
342  // component fields.
343  void MergeVectors(vtkDataSetAttributes* da);
344  int MergeVectors(vtkDataSetAttributes* da, vtkDataArray* a1, vtkDataArray* a2);
345  int MergeVectors(vtkDataSetAttributes* da, vtkDataArray* a1, vtkDataArray* a2, vtkDataArray* a3);
346 
348  int ComputeDerivedVars(
349  vtkCellData* data, vtkSpyPlotBlock* block, vtkSpyPlotUniReader* reader, const int& blockID);
350 
352 
356  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
358 
359  // vtkSpyPlotReaderMap needs access to GetCellDataArraySelection().
360  friend class vtkSpyPlotReaderMap;
362 
364 
365  vtkBoundingBox* Bounds; // bounds of the hierarchy without the bad ghostcells.
366  int BoxSize[3]; // size of boxes if they are all the same, else -1,-1,-1
367  int MinLevel; // first used level
368  double MinLevelSpacing[3]; // grid spacing on first used level
369 
370  int GenerateLevelArray; // user flag
371  int GenerateBlockIdArray; // user flag
372  int GenerateActiveBlockArray; // user flag
373  int GenerateTracerArray; // user flag
374  int GenerateMarkers; // user flag
375 
377 
379 
381 
382  // This flag is used to determine if core meta-data needs to be re-read.
384 
385 private:
386  vtkSpyPlotReader(const vtkSpyPlotReader&) = delete;
387  void operator=(const vtkSpyPlotReader&) = delete;
388 
389  class VectorOfDoubles;
390 
391  VectorOfDoubles* TimeSteps;
392  void SetTimeStepsInternal(const VectorOfDoubles&);
393 };
394 
395 #endif
virtual int RequestDataObject(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
Maps strings to vtkSpyPlotUniReaders.
vtkDataArraySelection * CellDataArraySelection
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
virtual int FillOutputPortInformation(int port, vtkInformation *info)
vtkBoundingBox * Bounds
int vtkIdType
vtkSpyPlotReaderMap * Map
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
int UpdateTimeStep(double time, int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=nullptr) override
Overwritten to avoid hiding.
virtual int UpdateTimeStep(double time, int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=0)
Read SPCTH Spy Plot file format.
static vtkCompositeDataSetAlgorithm * New()
#define VTKPVVTKEXTENSIONSIOSPCTH_EXPORT
Represents a SpyPlot Block Grid.
vtkMultiProcessController * GlobalController
void operator=(const vtkObjectBase &)
Read SPCTH Spy Plot file format.