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  void PrintBlockList(vtkNonOverlappingAMR* hbds, int myProcId);
70 
72 
76  virtual void SetFileName(const char* filename);
77  vtkGetStringMacro(FileName);
79 
81 
85  vtkSetMacro(TimeStep, int);
86  vtkGetMacro(TimeStep, int);
88 
90 
97  vtkSetMacro(DistributeFiles, int);
98  vtkGetMacro(DistributeFiles, int);
99  vtkBooleanMacro(DistributeFiles, int);
101 
103 
108  vtkSetMacro(GenerateLevelArray, int);
109  vtkGetMacro(GenerateLevelArray, int);
110  vtkBooleanMacro(GenerateLevelArray, int);
112 
114 
119  vtkSetMacro(GenerateBlockIdArray, int);
120  vtkGetMacro(GenerateBlockIdArray, int);
121  vtkBooleanMacro(GenerateBlockIdArray, int);
123 
125 
130  vtkSetMacro(GenerateActiveBlockArray, int);
131  vtkGetMacro(GenerateActiveBlockArray, int);
132  vtkBooleanMacro(GenerateActiveBlockArray, int);
134 
136 
141  vtkSetMacro(GenerateTracerArray, int);
142  vtkGetMacro(GenerateTracerArray, int);
143  vtkBooleanMacro(GenerateTracerArray, int);
145 
147 
152  void SetGenerateMarkers(int gm);
153  vtkGetMacro(GenerateMarkers, int);
154  vtkBooleanMacro(GenerateMarkers, int);
156 
158 
162  void SetDownConvertVolumeFraction(int vf);
163  vtkGetMacro(DownConvertVolumeFraction, int);
164  vtkBooleanMacro(DownConvertVolumeFraction, int);
166 
168 
173  vtkSetMacro(ComputeDerivedVariables, int);
174  vtkGetMacro(ComputeDerivedVariables, int);
175  vtkBooleanMacro(ComputeDerivedVariables, int);
177 
179 
186  void SetMergeXYZComponents(int merge);
187  vtkGetMacro(MergeXYZComponents, int);
188  vtkBooleanMacro(MergeXYZComponents, int);
190 
192 
195  vtkGetVector2Macro(TimeStepRange, int);
197 
199 
202  int GetNumberOfCellArrays();
203  const char* GetCellArrayName(int idx);
204  int GetCellArrayStatus(const char* name);
205  void SetCellArrayStatus(const char* name, int status);
207 
213  void SetGlobalController(vtkMultiProcessController* controller);
214 
218  virtual int CanReadFile(const char* fname);
219 
220 protected:
222  ~vtkSpyPlotReader() override;
223 
224  // Determine the bounds of just this reader
225  void GetLocalBounds(vtkSpyPlotBlockIterator* biter, int nBlocks, int progressInterval);
226 
227  // Set the global bounds of all readers
228  void SetGlobalBounds(vtkSpyPlotBlockIterator* biter, int total_num_of_block, int progressInterval,
229  int* rightHasBounds, int* leftHasBounds);
230 
231  // Determine the box size on just this reader
232  // returns true if box size is a constant on this reader
233  // false if not.
234  bool GetLocalBoxSize(vtkSpyPlotBlockIterator* biter, int* localBoxSize) const;
235 
236  // Determine box size if it is a constant across the data set
237  // If not then this is set to -1,-1,-1.
238  void SetGlobalBoxSize(vtkSpyPlotBlockIterator* biter);
239 
240  // Determine the minimum level that is used on just this level
241  // and get the spacing there
242  void GetLocalMinLevelAndSpacing(
243  vtkSpyPlotBlockIterator* biter, int* localMinLevel, double spacing[3]) const;
244 
245  // Set the minimum level that is used
246  // and get the spacing there
247  void SetGlobalMinLevelAndSpacing(vtkSpyPlotBlockIterator* biter);
248 
249  // Set things up to process an AMR Block
250  int PrepareAMRData(vtkNonOverlappingAMR* hb, vtkSpyPlotBlock* block, int* level, int* blockId,
251  int extents[6], int realExtents[6], int realDims[3], vtkCellData** cd);
252 
253  // Set things up to process a non-AMR Block
254  int PrepareData(vtkMultiBlockDataSet* hb, vtkSpyPlotBlock* block, vtkRectilinearGrid** rg,
255  int extents[6], int realExtents[6], int realDims[3], vtkCellData** cd);
256 
257  // Update the field data (interms of ghost cells) that
258  // contain whose block did not contain any bad ghost cells
259  void UpdateFieldData(int numFields, int dims[3], int level, int blockID,
260  vtkSpyPlotUniReader* uniReader, vtkCellData* cd);
261 
262  // Update the field data (interms of ghost cells) that
263  // contain whose block did contain bad ghost cells
264  void UpdateBadGhostFieldData(int numFields, int dims[3], int realDims[3], int realExtents[6],
265  int level, int blockID, vtkSpyPlotUniReader* uniReader, vtkCellData* cd);
266 
267  // Sets up the blocks for the markers data
268  void PrepareBlocks(vtkMultiBlockDataSet* poly, int numMat);
269 
270  // Sets up the markers data on the second output port
271  int PrepareMarkers(vtkMultiBlockDataSet* poly, vtkSpyPlotUniReader* reader);
272 
273  // The array selections.
275 
276  int FillOutputPortInformation(int port, vtkInformation* info) override;
277 
278  // Create either vtkNonOverlappingAMR or vtkMultiBlockDataSet based on
279  // whether the dataset is AMR.
280  int RequestDataObject(
281  vtkInformation* req, vtkInformationVector** inV, vtkInformationVector* outV) override;
282 
283  // Read the case file and the first binary file do get meta
284  // information (number of files, number of fields, number of timestep).
285  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
286  vtkInformationVector* outputVector) override;
287 
288  // Read the data: get the number of pieces (=processors) and get
289  // my piece id (=my processor id).
290  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
291  vtkInformationVector* outputVector) override;
292 
300  int UpdateMetaData(vtkInformation* request, vtkInformationVector* outputVector);
301 
302  int UpdateFile(vtkInformation* request, vtkInformationVector* outputVector);
303 
304  void AddGhostLevelArray(int numLevels);
305  int AddBlockIdArray(vtkCompositeDataSet* cds);
306  int AddAttributes(vtkNonOverlappingAMR* hbds);
307  int AddActiveBlockArray(vtkCellData* cd, vtkIdType nCells, unsigned char status);
308 
309  // Have all the readers have the same global level structure
310  void SetGlobalLevels(vtkCompositeDataSet* cds);
311 
312  // The observer to modify this object when the array selections are
313  // modified.
314  char* FileName;
315 
316  int TimeStep; // set by the user
317  int TimeStepRange[2];
318  int CurrentTimeStep; // computed
319 
320  int IsAMR; // AMR (hierarchy of uniform grids)
321  // or flat mesh (set of rectilinear grids)?
322 
323  // access to all processes
325 
329  int UpdateTimeStep(
330  vtkInformation* requestInfo, vtkInformationVector* outputInfo, vtkCompositeDataSet* hb);
331 
335  int UpdateTimeStep(double time, int piece = -1, int numPieces = 1, int ghostLevels = 0,
336  const int extents[6] = nullptr) override
337  {
338  return this->Superclass::UpdateTimeStep(time, piece, numPieces, ghostLevels, extents);
339  }
340 
341  // The file format stores a vector field as separated scalar component
342  // fields. This method rebuilds the vector field from those scalar
343  // component fields.
344  void MergeVectors(vtkDataSetAttributes* da);
345  int MergeVectors(vtkDataSetAttributes* da, vtkDataArray* a1, vtkDataArray* a2);
346  int MergeVectors(vtkDataSetAttributes* da, vtkDataArray* a1, vtkDataArray* a2, vtkDataArray* a3);
347 
349  int ComputeDerivedVars(
350  vtkCellData* data, vtkSpyPlotBlock* block, vtkSpyPlotUniReader* reader, const int& blockID);
351 
353 
357  vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
359 
360  // vtkSpyPlotReaderMap needs access to GetCellDataArraySelection().
361  friend class vtkSpyPlotReaderMap;
363 
365 
366  vtkBoundingBox* Bounds; // bounds of the hierarchy without the bad ghostcells.
367  int BoxSize[3]; // size of boxes if they are all the same, else -1,-1,-1
368  int MinLevel; // first used level
369  double MinLevelSpacing[3]; // grid spacing on first used level
370 
371  int GenerateLevelArray; // user flag
372  int GenerateBlockIdArray; // user flag
373  int GenerateActiveBlockArray; // user flag
374  int GenerateTracerArray; // user flag
375  int GenerateMarkers; // user flag
376 
378 
380 
382 
383  // This flag is used to determine if core meta-data needs to be re-read.
385 
386 private:
387  vtkSpyPlotReader(const vtkSpyPlotReader&) = delete;
388  void operator=(const vtkSpyPlotReader&) = delete;
389 
390  class VectorOfDoubles;
391 
392  VectorOfDoubles* TimeSteps;
393  void SetTimeStepsInternal(const VectorOfDoubles&);
394 };
395 
396 #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.