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
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:
143  void PrintSelf(ostream& os, vtkIndent indent) override;
144 
146 
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 
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);
351 
356  virtual int CanReadBinaryFile(VTK_FILEPATH const char* fname);
357 
359 
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:
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;
400  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
402  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
404 
406 
407  int CheckFile(FILE*& fp, const char* fname);
408  int CheckGeometryFile(FILE*& xyzFp);
409  int CheckFunctionFile(FILE*& fFp);
410 
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 
460 
461  // Returns a vtkFloatArray or a vtkDoubleArray depending
462  // on DoublePrecision setting
464 
465  // Delete references to any existing vtkPoints and
466  // I-blank arrays. The next Update() will (re)read
467  // the XYZ file.
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
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:45
general representation of visualization data
Definition: vtkDataObject.h:55
represent and manipulate attribute data in a dataset
a simple class to control print indentation
Definition: vtkIndent.h:29
Key for integer values in vtkInformation.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:35
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