VTK  9.3.20240328
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
187 #ifndef vtkMultiBlockPLOT3DReader_h
188 #define vtkMultiBlockPLOT3DReader_h
189 
190 #include "vtkIOParallelModule.h" // For export macro
191 #include "vtkParallelReader.h"
192 #include <vector> // For holding function-names
193 
194 VTK_ABI_NAMESPACE_BEGIN
195 class vtkDataArray;
197 class vtkIntArray;
200 class vtkStructuredGrid;
204 VTK_ABI_NAMESPACE_END
205 
206 namespace Functors
207 {
208 VTK_ABI_NAMESPACE_BEGIN
209 class ComputeFunctor;
210 class ComputeTemperatureFunctor;
211 class ComputePressureFunctor;
212 class ComputePressureCoefficientFunctor;
213 class ComputeMachNumberFunctor;
214 class ComputeSoundSpeedFunctor;
215 class ComputeEnthalpyFunctor;
216 class ComputeKinecticEnergyFunctor;
217 class ComputeVelocityMagnitudeFunctor;
218 class ComputeEntropyFunctor;
219 class ComputeSwirlFunctor;
220 class ComputeVelocityFunctor;
221 class ComputeVorticityMagnitudeFunctor;
222 class ComputePressureGradientFunctor;
223 class ComputeVorticityFunctor;
224 class ComputeStrainRateFunctor;
225 VTK_ABI_NAMESPACE_END
226 }
227 
228 VTK_ABI_NAMESPACE_BEGIN
229 
230 class VTKIOPARALLEL_EXPORT vtkMultiBlockPLOT3DReader : public vtkParallelReader
231 {
232  friend class Functors::ComputeFunctor;
233  friend class Functors::ComputeTemperatureFunctor;
234  friend class Functors::ComputePressureFunctor;
235  friend class Functors::ComputePressureCoefficientFunctor;
236  friend class Functors::ComputeMachNumberFunctor;
237  friend class Functors::ComputeSoundSpeedFunctor;
238  friend class Functors::ComputeEnthalpyFunctor;
239  friend class Functors::ComputeKinecticEnergyFunctor;
240  friend class Functors::ComputeVelocityMagnitudeFunctor;
241  friend class Functors::ComputeEntropyFunctor;
242  friend class Functors::ComputeSwirlFunctor;
243  friend class Functors::ComputeVelocityFunctor;
244  friend class Functors::ComputeVorticityMagnitudeFunctor;
245  friend class Functors::ComputePressureGradientFunctor;
246  friend class Functors::ComputeVorticityFunctor;
247  friend class Functors::ComputeStrainRateFunctor;
248 
249 public:
252  void PrintSelf(ostream& os, vtkIndent indent) override;
253 
255 
261 
263 
266  void SetFileName(VTK_FILEPATH const char* name) { this->SetXYZFileName(name); }
267  VTK_FILEPATH const char* GetFileName() { return this->GetXYZFileName(); }
268  VTK_FILEPATH const char* GetFileName(int i) { return this->vtkParallelReader::GetFileName(i); }
269  virtual void SetXYZFileName(VTK_FILEPATH const char*);
270  vtkGetFilePathMacro(XYZFileName);
272 
274 
284  void SetQFileName(VTK_FILEPATH const char* name);
285  VTK_FILEPATH const char* GetQFileName();
287 
289 
292  vtkSetFilePathMacro(FunctionFileName);
293  vtkGetFilePathMacro(FunctionFileName);
295 
297 
307  vtkSetMacro(AutoDetectFormat, vtkTypeBool);
308  vtkGetMacro(AutoDetectFormat, vtkTypeBool);
309  vtkBooleanMacro(AutoDetectFormat, vtkTypeBool);
311 
313 
317  vtkSetMacro(BinaryFile, vtkTypeBool);
318  vtkGetMacro(BinaryFile, vtkTypeBool);
319  vtkBooleanMacro(BinaryFile, vtkTypeBool);
321 
323 
329  vtkSetMacro(MultiGrid, vtkTypeBool);
330  vtkGetMacro(MultiGrid, vtkTypeBool);
331  vtkBooleanMacro(MultiGrid, vtkTypeBool);
333 
335 
340  vtkSetMacro(HasByteCount, vtkTypeBool);
341  vtkGetMacro(HasByteCount, vtkTypeBool);
342  vtkBooleanMacro(HasByteCount, vtkTypeBool);
344 
346 
351  vtkSetMacro(IBlanking, vtkTypeBool);
352  vtkGetMacro(IBlanking, vtkTypeBool);
353  vtkBooleanMacro(IBlanking, vtkTypeBool);
355 
357 
361  vtkSetMacro(TwoDimensionalGeometry, vtkTypeBool);
362  vtkGetMacro(TwoDimensionalGeometry, vtkTypeBool);
363  vtkBooleanMacro(TwoDimensionalGeometry, vtkTypeBool);
365 
367 
372  vtkSetMacro(DoublePrecision, vtkTypeBool);
373  vtkGetMacro(DoublePrecision, vtkTypeBool);
374  vtkBooleanMacro(DoublePrecision, vtkTypeBool);
376 
378 
384  vtkSetMacro(ForceRead, vtkTypeBool);
385  vtkGetMacro(ForceRead, vtkTypeBool);
386  vtkBooleanMacro(ForceRead, vtkTypeBool);
388 
390 
398  vtkSetMacro(ByteOrder, int);
399  vtkGetMacro(ByteOrder, int);
400  const char* GetByteOrderAsString();
402 
404 
407  vtkSetMacro(R, double);
408  vtkGetMacro(R, double);
410 
412 
415  vtkSetMacro(Gamma, double);
416  vtkGetMacro(Gamma, double);
418 
420 
428  vtkSetMacro(PreserveIntermediateFunctions, bool);
429  vtkGetMacro(PreserveIntermediateFunctions, bool);
430  vtkBooleanMacro(PreserveIntermediateFunctions, bool);
431 
433 
437  void SetScalarFunctionNumber(int num);
438  vtkGetMacro(ScalarFunctionNumber, int);
440 
442 
446  void SetVectorFunctionNumber(int num);
447  vtkGetMacro(VectorFunctionNumber, int);
449 
451 
456  void AddFunction(int functionNumber);
457  void RemoveFunction(int);
460 
465  virtual int CanReadBinaryFile(VTK_FILEPATH const char* fname);
466 
468 
473  vtkGetObjectMacro(Controller, vtkMultiProcessController);
475 
476  void AddFunctionName(const std::string& name) { FunctionNames.push_back(name); }
477 
478  enum
479  {
480  FILE_BIG_ENDIAN = 0,
481  FILE_LITTLE_ENDIAN = 1
482  };
483 
485 
491  int ReadMetaData(vtkInformation* metadata) override;
492  int ReadMesh(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
493  int ReadPoints(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
494  int ReadArrays(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
496 
497 protected:
500 
502 
505  double GetTimeValue(const std::string& fname) override;
506  int ReadMesh(
507  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
509  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
511  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
513 
515 
516  int CheckFile(FILE*& fp, const char* fname);
517  int CheckGeometryFile(FILE*& xyzFp);
518  int CheckFunctionFile(FILE*& fFp);
519 
521  int SkipByteCount(FILE* fp);
522  int ReadIntBlock(FILE* fp, int n, int* block);
523 
524  vtkIdType ReadValues(FILE* fp, int n, vtkDataArray* scalar);
525  virtual int ReadIntScalar(void* vfp, int extent[6], int wextent[6], vtkDataArray* scalar,
526  vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
527  virtual int ReadScalar(void* vfp, int extent[6], int wextent[6], vtkDataArray* scalar,
528  vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
529  virtual int ReadVector(void* vfp, int extent[6], int wextent[6], int numDims,
530  vtkDataArray* vector, vtkTypeUInt64 offset,
531  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
532  virtual int OpenFileForDataRead(void*& fp, const char* fname);
533  virtual void CloseFile(void* fp);
534 
535  int GetNumberOfBlocksInternal(FILE* xyzFp, int allocate);
536 
537  int ReadGeometryHeader(FILE* fp);
538  int ReadQHeader(FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow);
539  int ReadFunctionHeader(FILE* fp, int* nFunctions);
540 
541  void CalculateFileSize(FILE* fp);
542 
543  int AutoDetectionCheck(FILE* fp);
544 
545  void AssignAttribute(int fNumber, vtkStructuredGrid* output, int attributeType);
546  void MapFunction(int fNumber, vtkStructuredGrid* output);
547 
549 
569 
570  // Returns a vtkFloatArray or a vtkDoubleArray depending
571  // on DoublePrecision setting
573 
574  // Delete references to any existing vtkPoints and
575  // I-blank arrays. The next Update() will (re)read
576  // the XYZ file.
578 
579  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
580 
582 
583  // plot3d FileNames
584  char* XYZFileName;
585  char* QFileName;
596 
598 
599  size_t FileSize;
600 
601  // parameters used in computing derived functions
602  double R;
603  double Gamma;
604  double GammaInf;
605 
607 
608  // named functions from meta data
609  std::vector<std::string> FunctionNames;
610 
611  // functions to read that are not scalars or vectors
613 
616 
618 
620 
621 private:
623  void operator=(const vtkMultiBlockPLOT3DReader&) = delete;
624 
625  // Key used to flag intermediate results.
626  static vtkInformationIntegerKey* INTERMEDIATE_RESULT();
627 
631  void RemoveIntermediateFunctions(vtkDataSetAttributes* dsa);
632 };
633 
634 VTK_ABI_NAMESPACE_END
635 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:154
general representation of visualization data
represent and manipulate attribute data in a dataset
a simple class to control print indentation
Definition: vtkIndent.h:108
Key for integer values in vtkInformation.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:144
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