VTK  9.3.0
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
87 #ifndef vtkMultiBlockPLOT3DReader_h
88 #define vtkMultiBlockPLOT3DReader_h
89 
90 #include "vtkIOParallelModule.h" // For export macro
91 #include "vtkParallelReader.h"
92 #include <vector> // For holding function-names
93 
94 VTK_ABI_NAMESPACE_BEGIN
95 class vtkDataArray;
97 class vtkIntArray;
100 class vtkStructuredGrid;
104 VTK_ABI_NAMESPACE_END
105 
106 namespace Functors
107 {
108 VTK_ABI_NAMESPACE_BEGIN
109 class ComputeFunctor;
110 class ComputeTemperatureFunctor;
111 class ComputePressureFunctor;
112 class ComputePressureCoefficientFunctor;
113 class ComputeMachNumberFunctor;
114 class ComputeSoundSpeedFunctor;
115 class ComputeEnthalpyFunctor;
116 class ComputeKinecticEnergyFunctor;
117 class ComputeVelocityMagnitudeFunctor;
118 class ComputeEntropyFunctor;
119 class ComputeSwirlFunctor;
120 class ComputeVelocityFunctor;
121 class ComputeVorticityMagnitudeFunctor;
122 class ComputePressureGradientFunctor;
123 class ComputeVorticityFunctor;
124 class ComputeStrainRateFunctor;
125 VTK_ABI_NAMESPACE_END
126 }
127 
128 VTK_ABI_NAMESPACE_BEGIN
129 
130 class VTKIOPARALLEL_EXPORT vtkMultiBlockPLOT3DReader : public vtkParallelReader
131 {
132  friend class Functors::ComputeFunctor;
133  friend class Functors::ComputeTemperatureFunctor;
134  friend class Functors::ComputePressureFunctor;
135  friend class Functors::ComputePressureCoefficientFunctor;
136  friend class Functors::ComputeMachNumberFunctor;
137  friend class Functors::ComputeSoundSpeedFunctor;
138  friend class Functors::ComputeEnthalpyFunctor;
139  friend class Functors::ComputeKinecticEnergyFunctor;
140  friend class Functors::ComputeVelocityMagnitudeFunctor;
141  friend class Functors::ComputeEntropyFunctor;
142  friend class Functors::ComputeSwirlFunctor;
143  friend class Functors::ComputeVelocityFunctor;
144  friend class Functors::ComputeVorticityMagnitudeFunctor;
145  friend class Functors::ComputePressureGradientFunctor;
146  friend class Functors::ComputeVorticityFunctor;
147  friend class Functors::ComputeStrainRateFunctor;
148 
149 public:
152  void PrintSelf(ostream& os, vtkIndent indent) override;
153 
155 
161 
163 
166  void SetFileName(VTK_FILEPATH const char* name) { this->SetXYZFileName(name); }
167  VTK_FILEPATH const char* GetFileName() { return this->GetXYZFileName(); }
168  VTK_FILEPATH const char* GetFileName(int i) { return this->vtkParallelReader::GetFileName(i); }
169  virtual void SetXYZFileName(VTK_FILEPATH const char*);
170  vtkGetFilePathMacro(XYZFileName);
172 
174 
184  void SetQFileName(VTK_FILEPATH const char* name);
185  VTK_FILEPATH const char* GetQFileName();
187 
189 
192  vtkSetFilePathMacro(FunctionFileName);
193  vtkGetFilePathMacro(FunctionFileName);
195 
197 
207  vtkSetMacro(AutoDetectFormat, vtkTypeBool);
208  vtkGetMacro(AutoDetectFormat, vtkTypeBool);
209  vtkBooleanMacro(AutoDetectFormat, vtkTypeBool);
211 
213 
217  vtkSetMacro(BinaryFile, vtkTypeBool);
218  vtkGetMacro(BinaryFile, vtkTypeBool);
219  vtkBooleanMacro(BinaryFile, vtkTypeBool);
221 
223 
229  vtkSetMacro(MultiGrid, vtkTypeBool);
230  vtkGetMacro(MultiGrid, vtkTypeBool);
231  vtkBooleanMacro(MultiGrid, vtkTypeBool);
233 
235 
240  vtkSetMacro(HasByteCount, vtkTypeBool);
241  vtkGetMacro(HasByteCount, vtkTypeBool);
242  vtkBooleanMacro(HasByteCount, vtkTypeBool);
244 
246 
251  vtkSetMacro(IBlanking, vtkTypeBool);
252  vtkGetMacro(IBlanking, vtkTypeBool);
253  vtkBooleanMacro(IBlanking, vtkTypeBool);
255 
257 
261  vtkSetMacro(TwoDimensionalGeometry, vtkTypeBool);
262  vtkGetMacro(TwoDimensionalGeometry, vtkTypeBool);
263  vtkBooleanMacro(TwoDimensionalGeometry, vtkTypeBool);
265 
267 
272  vtkSetMacro(DoublePrecision, vtkTypeBool);
273  vtkGetMacro(DoublePrecision, vtkTypeBool);
274  vtkBooleanMacro(DoublePrecision, vtkTypeBool);
276 
278 
284  vtkSetMacro(ForceRead, vtkTypeBool);
285  vtkGetMacro(ForceRead, vtkTypeBool);
286  vtkBooleanMacro(ForceRead, vtkTypeBool);
288 
290 
298  vtkSetMacro(ByteOrder, int);
299  vtkGetMacro(ByteOrder, int);
300  const char* GetByteOrderAsString();
302 
304 
307  vtkSetMacro(R, double);
308  vtkGetMacro(R, double);
310 
312 
315  vtkSetMacro(Gamma, double);
316  vtkGetMacro(Gamma, double);
318 
320 
328  vtkSetMacro(PreserveIntermediateFunctions, bool);
329  vtkGetMacro(PreserveIntermediateFunctions, bool);
330  vtkBooleanMacro(PreserveIntermediateFunctions, bool);
331 
333 
337  void SetScalarFunctionNumber(int num);
338  vtkGetMacro(ScalarFunctionNumber, int);
340 
342 
346  void SetVectorFunctionNumber(int num);
347  vtkGetMacro(VectorFunctionNumber, int);
349 
351 
356  void AddFunction(int functionNumber);
357  void RemoveFunction(int);
360 
365  virtual int CanReadBinaryFile(VTK_FILEPATH const char* fname);
366 
368 
373  vtkGetObjectMacro(Controller, vtkMultiProcessController);
375 
376  void AddFunctionName(const std::string& name) { FunctionNames.push_back(name); }
377 
378  enum
379  {
380  FILE_BIG_ENDIAN = 0,
381  FILE_LITTLE_ENDIAN = 1
382  };
383 
385 
391  int ReadMetaData(vtkInformation* metadata) override;
392  int ReadMesh(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
393  int ReadPoints(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
394  int ReadArrays(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
396 
397 protected:
400 
402 
405  double GetTimeValue(const std::string& fname) override;
406  int ReadMesh(
407  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
409  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
411  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
413 
415 
416  int CheckFile(FILE*& fp, const char* fname);
417  int CheckGeometryFile(FILE*& xyzFp);
418  int CheckFunctionFile(FILE*& fFp);
419 
421  int SkipByteCount(FILE* fp);
422  int ReadIntBlock(FILE* fp, int n, int* block);
423 
424  vtkIdType ReadValues(FILE* fp, int n, vtkDataArray* scalar);
425  virtual int ReadIntScalar(void* vfp, int extent[6], int wextent[6], vtkDataArray* scalar,
426  vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
427  virtual int ReadScalar(void* vfp, int extent[6], int wextent[6], vtkDataArray* scalar,
428  vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
429  virtual int ReadVector(void* vfp, int extent[6], int wextent[6], int numDims,
430  vtkDataArray* vector, vtkTypeUInt64 offset,
431  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
432  virtual int OpenFileForDataRead(void*& fp, const char* fname);
433  virtual void CloseFile(void* fp);
434 
435  int GetNumberOfBlocksInternal(FILE* xyzFp, int allocate);
436 
437  int ReadGeometryHeader(FILE* fp);
438  int ReadQHeader(FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow);
439  int ReadFunctionHeader(FILE* fp, int* nFunctions);
440 
441  void CalculateFileSize(FILE* fp);
442 
443  int AutoDetectionCheck(FILE* fp);
444 
445  void AssignAttribute(int fNumber, vtkStructuredGrid* output, int attributeType);
446  void MapFunction(int fNumber, vtkStructuredGrid* output);
447 
449 
469 
470  // Returns a vtkFloatArray or a vtkDoubleArray depending
471  // on DoublePrecision setting
473 
474  // Delete references to any existing vtkPoints and
475  // I-blank arrays. The next Update() will (re)read
476  // the XYZ file.
478 
479  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
480 
482 
483  // plot3d FileNames
484  char* XYZFileName;
485  char* QFileName;
496 
498 
499  size_t FileSize;
500 
501  // parameters used in computing derived functions
502  double R;
503  double Gamma;
504  double GammaInf;
505 
507 
508  // named functions from meta data
509  std::vector<std::string> FunctionNames;
510 
511  // functions to read that are not scalars or vectors
513 
516 
518 
520 
521 private:
523  void operator=(const vtkMultiBlockPLOT3DReader&) = delete;
524 
525  // Key used to flag intermediate results.
526  static vtkInformationIntegerKey* INTERMEDIATE_RESULT();
527 
531  void RemoveIntermediateFunctions(vtkDataSetAttributes* dsa);
532 };
533 
534 VTK_ABI_NAMESPACE_END
535 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
general representation of visualization data
Definition: vtkDataObject.h:64
represent and manipulate attribute data in a dataset
a simple class to control print indentation
Definition: vtkIndent.h:38
Key for integer values in vtkInformation.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:44
Composite dataset that organizes datasets into blocks.
virtual int OpenFileForDataRead(void *&fp, const char *fname)
vtkDataArray * ComputeSoundSpeed(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
vtkDataArray * NewFloatArray()
int ReadFunctionHeader(FILE *fp, int *nFunctions)
const char * GetByteOrderAsString()
Set the byte order of the file (remember, more Unix workstations write big endian whereas PCs write l...
void SetByteOrderToLittleEndian()
Set the byte order of the file (remember, more Unix workstations write big endian whereas PCs write l...
VTK_FILEPATH const char * GetQFileName()
Set/Get the PLOT3D solution filename.
vtkGetFilePathMacro(FunctionFileName)
Set/Get the PLOT3D function filename.
int ReadPoints(int piece, int npieces, int nghosts, int timestep, vtkDataObject *output) override
These methods have to be overwritten from superclass because Plot3D actually uses the XYZ file to rea...
vtkIdType ReadValues(FILE *fp, int n, vtkDataArray *scalar)
virtual int CanReadBinaryFile(VTK_FILEPATH const char *fname)
Return 1 if the reader can read the given file name.
vtkMultiBlockDataSet * GetOutput()
Get the output data object for a port on this algorithm.
vtkDataArray * ComputeStrainRate(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
int ReadArrays(int piece, int npieces, int nghosts, int timestep, vtkDataObject *output) override
These methods have to be overwritten from superclass because Plot3D actually uses the XYZ file to rea...
void SetVectorFunctionNumber(int num)
Specify the vector function to extract.
vtkDataArray * ComputeEnthalpy(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
int ReadArrays(const std::string &fname, int piece, int npieces, int nghosts, vtkDataObject *output) override
Overridden from superclass to do actual reading.
virtual void SetXYZFileName(VTK_FILEPATH const char *)
Set/Get the PLOT3D geometry filename.
vtkDataArray * ComputeVelocity(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
vtkDataArray * ComputeVorticity(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
vtkDataArray * ComputeSwirl(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
vtkDataArray * ComputeMachNumber(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
vtkDataArray * ComputeKineticEnergy(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
void CalculateFileSize(FILE *fp)
virtual int ReadVector(void *vfp, int extent[6], int wextent[6], int numDims, vtkDataArray *vector, vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord &currentRecord)
int ReadQHeader(FILE *fp, bool checkGrid, int &nq, int &nqc, int &overflow)
virtual void CloseFile(void *fp)
virtual int ReadIntScalar(void *vfp, int extent[6], int wextent[6], vtkDataArray *scalar, vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord &currentRecord)
int ReadMesh(const std::string &fname, int piece, int npieces, int nghosts, vtkDataObject *output) override
Overridden from superclass to do actual reading.
int CheckFunctionFile(FILE *&fFp)
vtkDataArray * ComputeVelocityMagnitude(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
int ReadPoints(const std::string &fname, int piece, int npieces, int nghosts, vtkDataObject *output) override
Overridden from superclass to do actual reading.
int CheckGeometryFile(FILE *&xyzFp)
int AutoDetectionCheck(FILE *fp)
vtkMultiProcessController * Controller
void SetQFileName(VTK_FILEPATH const char *name)
Set/Get the PLOT3D solution filename.
void RemoveAllFunctions()
Specify additional functions to read.
int ReadIntBlock(FILE *fp, int n, int *block)
vtkDataArray * CreateFloatArray()
vtkDataArray * ComputeTemperature(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
double GetTimeValue(const std::string &fname) override
Overridden from superclass to do actual reading.
~vtkMultiBlockPLOT3DReader() override
virtual int ReadScalar(void *vfp, int extent[6], int wextent[6], vtkDataArray *scalar, vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord &currentRecord)
double GetGamma(vtkIdType idx, vtkDataArray *gamma)
int ReadMesh(int piece, int npieces, int nghosts, int timestep, vtkDataObject *output) override
These methods have to be overwritten from superclass because Plot3D actually uses the XYZ file to rea...
void SetByteOrderToBigEndian()
Set the byte order of the file (remember, more Unix workstations write big endian whereas PCs write l...
std::vector< std::string > FunctionNames
vtkDataArray * ComputePressure(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
vtkDataArray * ComputeVorticityMagnitude(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
void AddFunction(int functionNumber)
Specify additional functions to read.
VTK_FILEPATH const char * GetFileName()
Set/Get the PLOT3D geometry filename.
void RemoveFunction(int)
Specify additional functions to read.
int FillOutputPortInformation(int port, vtkInformation *info) override
Fill the output port information objects for this algorithm.
vtkDataArray * ComputeEntropy(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
vtkSetFilePathMacro(FunctionFileName)
Set/Get the PLOT3D function filename.
int CheckFile(FILE *&fp, const char *fname)
void SetScalarFunctionNumber(int num)
Specify the scalar function to extract.
int ReadGeometryHeader(FILE *fp)
void MapFunction(int fNumber, vtkStructuredGrid *output)
vtkDataArray * ComputePressureGradient(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
int SkipByteCount(FILE *fp)
void SetFileName(VTK_FILEPATH const char *name)
Set/Get the PLOT3D geometry filename.
void AssignAttribute(int fNumber, vtkStructuredGrid *output, int attributeType)
vtkMultiBlockPLOT3DReaderInternals * Internal
int ReadMetaData(vtkInformation *metadata) override
These methods have to be overwritten from superclass because Plot3D actually uses the XYZ file to rea...
void AddFunctionName(const std::string &name)
static vtkMultiBlockPLOT3DReader * New()
vtkMultiBlockDataSet * GetOutput(int)
Get the output data object for a port on this algorithm.
int GetNumberOfBlocksInternal(FILE *xyzFp, int allocate)
vtkDataArray * ComputePressureCoefficient(vtkStructuredGrid *output)
Each of these methods compute a derived quantity.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
VTK_FILEPATH const char * GetFileName(int i)
Set/Get the PLOT3D geometry filename.
vtkGetFilePathMacro(XYZFileName)
Set/Get the PLOT3D geometry filename.
void SetController(vtkMultiProcessController *c)
Set/Get the communicator object (we'll use global World controller if you don't set a different one).
Multiprocessing communication superclass.
Superclass for algorithms that are parallel aware.
VTK_FILEPATH const char * GetFileName(int i) const
Returns a particular filename stored by the reader.
topologically regular array of data
dynamic, self-adjusting array of unsigned char
@ vector
Definition: vtkX3D.h:237
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447
@ extent
Definition: vtkX3D.h:345
@ name
Definition: vtkX3D.h:219
@ offset
Definition: vtkX3D.h:438
@ string
Definition: vtkX3D.h:490
int vtkTypeBool
Definition: vtkABI.h:64
int vtkIdType
Definition: vtkType.h:315
#define VTK_FILEPATH