VTK  9.3.1
vtkMultiBlockPLOT3DReader.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
78 #ifndef vtkMultiBlockPLOT3DReader_h
79 #define vtkMultiBlockPLOT3DReader_h
80 
81 #include "vtkIOParallelModule.h" // For export macro
82 #include "vtkParallelReader.h"
83 #include <vector> // For holding function-names
84 
85 VTK_ABI_NAMESPACE_BEGIN
86 class vtkDataArray;
88 class vtkIntArray;
91 class vtkStructuredGrid;
95 VTK_ABI_NAMESPACE_END
96 
97 namespace Functors
98 {
99 VTK_ABI_NAMESPACE_BEGIN
100 class ComputeFunctor;
101 class ComputeTemperatureFunctor;
102 class ComputePressureFunctor;
103 class ComputePressureCoefficientFunctor;
104 class ComputeMachNumberFunctor;
105 class ComputeSoundSpeedFunctor;
106 class ComputeEnthalpyFunctor;
107 class ComputeKinecticEnergyFunctor;
108 class ComputeVelocityMagnitudeFunctor;
109 class ComputeEntropyFunctor;
110 class ComputeSwirlFunctor;
111 class ComputeVelocityFunctor;
112 class ComputeVorticityMagnitudeFunctor;
113 class ComputePressureGradientFunctor;
114 class ComputeVorticityFunctor;
115 class ComputeStrainRateFunctor;
116 VTK_ABI_NAMESPACE_END
117 }
118 
119 VTK_ABI_NAMESPACE_BEGIN
120 
121 class VTKIOPARALLEL_EXPORT vtkMultiBlockPLOT3DReader : public vtkParallelReader
122 {
123  friend class Functors::ComputeFunctor;
124  friend class Functors::ComputeTemperatureFunctor;
125  friend class Functors::ComputePressureFunctor;
126  friend class Functors::ComputePressureCoefficientFunctor;
127  friend class Functors::ComputeMachNumberFunctor;
128  friend class Functors::ComputeSoundSpeedFunctor;
129  friend class Functors::ComputeEnthalpyFunctor;
130  friend class Functors::ComputeKinecticEnergyFunctor;
131  friend class Functors::ComputeVelocityMagnitudeFunctor;
132  friend class Functors::ComputeEntropyFunctor;
133  friend class Functors::ComputeSwirlFunctor;
134  friend class Functors::ComputeVelocityFunctor;
135  friend class Functors::ComputeVorticityMagnitudeFunctor;
136  friend class Functors::ComputePressureGradientFunctor;
137  friend class Functors::ComputeVorticityFunctor;
138  friend class Functors::ComputeStrainRateFunctor;
139 
140 public:
141  static vtkMultiBlockPLOT3DReader* New();
143  void PrintSelf(ostream& os, vtkIndent indent) override;
144 
146 
149  vtkMultiBlockDataSet* GetOutput();
150  vtkMultiBlockDataSet* GetOutput(int);
152 
154 
157  void SetFileName(VTK_FILEPATH const char* name) { this->SetXYZFileName(name); }
158  VTK_FILEPATH const char* GetFileName() { return this->GetXYZFileName(); }
159  VTK_FILEPATH const char* GetFileName(int i) { return this->vtkParallelReader::GetFileName(i); }
160  virtual void SetXYZFileName(VTK_FILEPATH const char*);
161  vtkGetFilePathMacro(XYZFileName);
163 
165 
175  void SetQFileName(VTK_FILEPATH const char* name);
176  VTK_FILEPATH const char* GetQFileName();
178 
180 
183  vtkSetFilePathMacro(FunctionFileName);
184  vtkGetFilePathMacro(FunctionFileName);
186 
188 
198  vtkSetMacro(AutoDetectFormat, vtkTypeBool);
199  vtkGetMacro(AutoDetectFormat, vtkTypeBool);
200  vtkBooleanMacro(AutoDetectFormat, vtkTypeBool);
202 
204 
208  vtkSetMacro(BinaryFile, vtkTypeBool);
209  vtkGetMacro(BinaryFile, vtkTypeBool);
210  vtkBooleanMacro(BinaryFile, vtkTypeBool);
212 
214 
220  vtkSetMacro(MultiGrid, vtkTypeBool);
221  vtkGetMacro(MultiGrid, vtkTypeBool);
222  vtkBooleanMacro(MultiGrid, vtkTypeBool);
224 
226 
231  vtkSetMacro(HasByteCount, vtkTypeBool);
232  vtkGetMacro(HasByteCount, vtkTypeBool);
233  vtkBooleanMacro(HasByteCount, vtkTypeBool);
235 
237 
242  vtkSetMacro(IBlanking, vtkTypeBool);
243  vtkGetMacro(IBlanking, vtkTypeBool);
244  vtkBooleanMacro(IBlanking, vtkTypeBool);
246 
248 
252  vtkSetMacro(TwoDimensionalGeometry, vtkTypeBool);
253  vtkGetMacro(TwoDimensionalGeometry, vtkTypeBool);
254  vtkBooleanMacro(TwoDimensionalGeometry, vtkTypeBool);
256 
258 
263  vtkSetMacro(DoublePrecision, vtkTypeBool);
264  vtkGetMacro(DoublePrecision, vtkTypeBool);
265  vtkBooleanMacro(DoublePrecision, vtkTypeBool);
267 
269 
275  vtkSetMacro(ForceRead, vtkTypeBool);
276  vtkGetMacro(ForceRead, vtkTypeBool);
277  vtkBooleanMacro(ForceRead, vtkTypeBool);
279 
281 
287  void SetByteOrderToBigEndian();
288  void SetByteOrderToLittleEndian();
289  vtkSetMacro(ByteOrder, int);
290  vtkGetMacro(ByteOrder, int);
291  const char* GetByteOrderAsString();
293 
295 
298  vtkSetMacro(R, double);
299  vtkGetMacro(R, double);
301 
303 
306  vtkSetMacro(Gamma, double);
307  vtkGetMacro(Gamma, double);
309 
311 
319  vtkSetMacro(PreserveIntermediateFunctions, bool);
320  vtkGetMacro(PreserveIntermediateFunctions, bool);
321  vtkBooleanMacro(PreserveIntermediateFunctions, bool);
322 
324 
328  void SetScalarFunctionNumber(int num);
329  vtkGetMacro(ScalarFunctionNumber, int);
331 
333 
337  void SetVectorFunctionNumber(int num);
338  vtkGetMacro(VectorFunctionNumber, int);
340 
342 
347  void AddFunction(int functionNumber);
348  void RemoveFunction(int);
349  void RemoveAllFunctions();
351 
356  virtual int CanReadBinaryFile(VTK_FILEPATH const char* fname);
357 
359 
363  void SetController(vtkMultiProcessController* c);
364  vtkGetObjectMacro(Controller, vtkMultiProcessController);
366 
367  void AddFunctionName(const std::string& name) { FunctionNames.push_back(name); }
368 
369  enum
370  {
371  FILE_BIG_ENDIAN = 0,
372  FILE_LITTLE_ENDIAN = 1
373  };
374 
376 
382  int ReadMetaData(vtkInformation* metadata) override;
383  int ReadMesh(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
384  int ReadPoints(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
385  int ReadArrays(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
387 
388 protected:
390  ~vtkMultiBlockPLOT3DReader() override;
391 
393 
396  double GetTimeValue(const std::string& fname) override;
397  int ReadMesh(
398  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
399  int ReadPoints(
400  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
401  int ReadArrays(
402  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
404 
405  vtkDataArray* CreateFloatArray();
406 
407  int CheckFile(FILE*& fp, const char* fname);
408  int CheckGeometryFile(FILE*& xyzFp);
409  int CheckFunctionFile(FILE*& fFp);
410 
411  int GetByteCountSize();
412  int SkipByteCount(FILE* fp);
413  int ReadIntBlock(FILE* fp, int n, int* block);
414 
415  vtkIdType ReadValues(FILE* fp, int n, vtkDataArray* scalar);
416  virtual int ReadIntScalar(void* vfp, int extent[6], int wextent[6], vtkDataArray* scalar,
417  vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
418  virtual int ReadScalar(void* vfp, int extent[6], int wextent[6], vtkDataArray* scalar,
419  vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
420  virtual int ReadVector(void* vfp, int extent[6], int wextent[6], int numDims,
421  vtkDataArray* vector, vtkTypeUInt64 offset,
422  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
423  virtual int OpenFileForDataRead(void*& fp, const char* fname);
424  virtual void CloseFile(void* fp);
425 
426  int GetNumberOfBlocksInternal(FILE* xyzFp, int allocate);
427 
428  int ReadGeometryHeader(FILE* fp);
429  int ReadQHeader(FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow);
430  int ReadFunctionHeader(FILE* fp, int* nFunctions);
431 
432  void CalculateFileSize(FILE* fp);
433 
434  int AutoDetectionCheck(FILE* fp);
435 
436  void AssignAttribute(int fNumber, vtkStructuredGrid* output, int attributeType);
437  void MapFunction(int fNumber, vtkStructuredGrid* output);
438 
440 
444  vtkDataArray* ComputeTemperature(vtkStructuredGrid* output);
445  vtkDataArray* ComputePressure(vtkStructuredGrid* output);
446  vtkDataArray* ComputeEnthalpy(vtkStructuredGrid* output);
447  vtkDataArray* ComputeKineticEnergy(vtkStructuredGrid* output);
448  vtkDataArray* ComputeVelocityMagnitude(vtkStructuredGrid* output);
449  vtkDataArray* ComputeEntropy(vtkStructuredGrid* output);
450  vtkDataArray* ComputeSwirl(vtkStructuredGrid* output);
451  vtkDataArray* ComputeVelocity(vtkStructuredGrid* output);
452  vtkDataArray* ComputeVorticity(vtkStructuredGrid* output);
453  vtkDataArray* ComputePressureGradient(vtkStructuredGrid* output);
454  vtkDataArray* ComputePressureCoefficient(vtkStructuredGrid* output);
455  vtkDataArray* ComputeMachNumber(vtkStructuredGrid* output);
456  vtkDataArray* ComputeSoundSpeed(vtkStructuredGrid* output);
457  vtkDataArray* ComputeVorticityMagnitude(vtkStructuredGrid* output);
458  vtkDataArray* ComputeStrainRate(vtkStructuredGrid* output);
460 
461  // Returns a vtkFloatArray or a vtkDoubleArray depending
462  // on DoublePrecision setting
463  vtkDataArray* NewFloatArray();
464 
465  // Delete references to any existing vtkPoints and
466  // I-blank arrays. The next Update() will (re)read
467  // the XYZ file.
468  void ClearGeometryCache();
469 
470  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
471 
473 
474  // plot3d FileNames
475  char* XYZFileName;
476  char* QFileName;
487 
489 
490  size_t FileSize;
491 
492  // parameters used in computing derived functions
493  double R;
494  double Gamma;
495  double GammaInf;
496 
498 
499  // named functions from meta data
500  std::vector<std::string> FunctionNames;
501 
502  // functions to read that are not scalars or vectors
504 
507 
509 
511 
512 private:
514  void operator=(const vtkMultiBlockPLOT3DReader&) = delete;
515 
516  // Key used to flag intermediate results.
517  static vtkInformationIntegerKey* INTERMEDIATE_RESULT();
518 
522  void RemoveIntermediateFunctions(vtkDataSetAttributes* dsa);
523 };
524 
525 VTK_ABI_NAMESPACE_END
526 #endif
void AddFunctionName(const std::string &name)
VTK_FILEPATH const char * GetFileName(int i) const
Returns a particular filename stored by the reader.
int ReadMesh(int piece, int npieces, int nghosts, int timestep, vtkDataObject *output) override
This is the superclass API overridden by this class to provide time support internally.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int ReadMetaData(vtkInformation *metadata) override
This is the superclass API overridden by this class to provide time support internally.
Store vtkAlgorithm input/output information.
vtkMultiProcessController * Controller
int vtkIdType
Definition: vtkType.h:315
void SetFileName(VTK_FILEPATH const char *name)
Set/Get the PLOT3D geometry filename.
int vtkTypeBool
Definition: vtkABI.h:64
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:34
virtual int FillOutputPortInformation(int port, vtkInformation *info)
Fill the output port information objects for this algorithm.
std::vector< std::string > FunctionNames
a simple class to control print indentation
Definition: vtkIndent.h:28
int ReadPoints(int piece, int npieces, int nghosts, int timestep, vtkDataObject *output) override
This is the superclass API overridden by this class to provide time support internally.
VTK_FILEPATH const char * GetFileName(int i)
Set/Get the PLOT3D geometry filename.
Key for integer values in vtkInformation.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
int ReadArrays(int piece, int npieces, int nghosts, int timestep, vtkDataObject *output) override
This is the superclass API overridden by this class to provide time support internally.
vtkMultiBlockPLOT3DReaderInternals * Internal
Superclass for algorithms that are parallel aware.
represent and manipulate attribute data in a dataset
dynamic, self-adjusting array of unsigned char
VTK_FILEPATH const char * GetFileName()
Set/Get the PLOT3D geometry filename.
#define VTK_FILEPATH
topologically regular array of data
Composite dataset that organizes datasets into blocks.
static vtkAlgorithm * New()
virtual double GetTimeValue(const std::string &fname)
A subclass can override this method to provide an actual time value for a given file (this method is ...
general representation of visualization data
Definition: vtkDataObject.h:54
Multiprocessing communication superclass.