VTK  9.1.0
vtkMultiBlockPLOT3DReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMultiBlockPLOT3DReader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
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 class vtkDataArray;
96 class vtkIntArray;
99 class vtkStructuredGrid;
103 
104 namespace Functors
105 {
106 class ComputeFunctor;
107 class ComputeTemperatureFunctor;
108 class ComputePressureFunctor;
109 class ComputePressureCoefficientFunctor;
110 class ComputeMachNumberFunctor;
111 class ComputeSoundSpeedFunctor;
112 class ComputeEnthalpyFunctor;
113 class ComputeKinecticEnergyFunctor;
114 class ComputeVelocityMagnitudeFunctor;
115 class ComputeEntropyFunctor;
116 class ComputeSwirlFunctor;
117 class ComputeVelocityFunctor;
118 class ComputeVorticityMagnitudeFunctor;
119 class ComputePressureGradientFunctor;
120 class ComputeVorticityFunctor;
121 class ComputeStrainRateFunctor;
122 }
123 
124 class VTKIOPARALLEL_EXPORT vtkMultiBlockPLOT3DReader : public vtkParallelReader
125 {
126  friend class Functors::ComputeFunctor;
127  friend class Functors::ComputeTemperatureFunctor;
128  friend class Functors::ComputePressureFunctor;
129  friend class Functors::ComputePressureCoefficientFunctor;
130  friend class Functors::ComputeMachNumberFunctor;
131  friend class Functors::ComputeSoundSpeedFunctor;
132  friend class Functors::ComputeEnthalpyFunctor;
133  friend class Functors::ComputeKinecticEnergyFunctor;
134  friend class Functors::ComputeVelocityMagnitudeFunctor;
135  friend class Functors::ComputeEntropyFunctor;
136  friend class Functors::ComputeSwirlFunctor;
137  friend class Functors::ComputeVelocityFunctor;
138  friend class Functors::ComputeVorticityMagnitudeFunctor;
139  friend class Functors::ComputePressureGradientFunctor;
140  friend class Functors::ComputeVorticityFunctor;
141  friend class Functors::ComputeStrainRateFunctor;
142 
143 public:
146  void PrintSelf(ostream& os, vtkIndent indent) override;
147 
149 
155 
157 
160  void SetFileName(VTK_FILEPATH const char* name) { this->SetXYZFileName(name); }
161  VTK_FILEPATH const char* GetFileName() { return this->GetXYZFileName(); }
162  VTK_FILEPATH const char* GetFileName(int i) { return this->vtkParallelReader::GetFileName(i); }
163  virtual void SetXYZFileName(VTK_FILEPATH const char*);
164  vtkGetFilePathMacro(XYZFileName);
166 
168 
178  void SetQFileName(VTK_FILEPATH const char* name);
179  VTK_FILEPATH const char* GetQFileName();
181 
183 
186  vtkSetFilePathMacro(FunctionFileName);
187  vtkGetFilePathMacro(FunctionFileName);
189 
191 
201  vtkSetMacro(AutoDetectFormat, vtkTypeBool);
202  vtkGetMacro(AutoDetectFormat, vtkTypeBool);
203  vtkBooleanMacro(AutoDetectFormat, vtkTypeBool);
205 
207 
211  vtkSetMacro(BinaryFile, vtkTypeBool);
212  vtkGetMacro(BinaryFile, vtkTypeBool);
213  vtkBooleanMacro(BinaryFile, vtkTypeBool);
215 
217 
223  vtkSetMacro(MultiGrid, vtkTypeBool);
224  vtkGetMacro(MultiGrid, vtkTypeBool);
225  vtkBooleanMacro(MultiGrid, vtkTypeBool);
227 
229 
234  vtkSetMacro(HasByteCount, vtkTypeBool);
235  vtkGetMacro(HasByteCount, vtkTypeBool);
236  vtkBooleanMacro(HasByteCount, vtkTypeBool);
238 
240 
245  vtkSetMacro(IBlanking, vtkTypeBool);
246  vtkGetMacro(IBlanking, vtkTypeBool);
247  vtkBooleanMacro(IBlanking, vtkTypeBool);
249 
251 
255  vtkSetMacro(TwoDimensionalGeometry, vtkTypeBool);
256  vtkGetMacro(TwoDimensionalGeometry, vtkTypeBool);
257  vtkBooleanMacro(TwoDimensionalGeometry, vtkTypeBool);
259 
261 
266  vtkSetMacro(DoublePrecision, vtkTypeBool);
267  vtkGetMacro(DoublePrecision, vtkTypeBool);
268  vtkBooleanMacro(DoublePrecision, vtkTypeBool);
270 
272 
278  vtkSetMacro(ForceRead, vtkTypeBool);
279  vtkGetMacro(ForceRead, vtkTypeBool);
280  vtkBooleanMacro(ForceRead, vtkTypeBool);
282 
284 
292  vtkSetMacro(ByteOrder, int);
293  vtkGetMacro(ByteOrder, int);
294  const char* GetByteOrderAsString();
296 
298 
301  vtkSetMacro(R, double);
302  vtkGetMacro(R, double);
304 
306 
309  vtkSetMacro(Gamma, double);
310  vtkGetMacro(Gamma, double);
312 
314 
322  vtkSetMacro(PreserveIntermediateFunctions, bool);
323  vtkGetMacro(PreserveIntermediateFunctions, bool);
324  vtkBooleanMacro(PreserveIntermediateFunctions, bool);
325 
327 
331  void SetScalarFunctionNumber(int num);
332  vtkGetMacro(ScalarFunctionNumber, int);
334 
336 
340  void SetVectorFunctionNumber(int num);
341  vtkGetMacro(VectorFunctionNumber, int);
343 
345 
350  void AddFunction(int functionNumber);
351  void RemoveFunction(int);
354 
359  virtual int CanReadBinaryFile(VTK_FILEPATH const char* fname);
360 
362 
367  vtkGetObjectMacro(Controller, vtkMultiProcessController);
369 
370  void AddFunctionName(const std::string& name) { FunctionNames.push_back(name); }
371 
372  enum
373  {
374  FILE_BIG_ENDIAN = 0,
375  FILE_LITTLE_ENDIAN = 1
376  };
377 
379 
385  int ReadMetaData(vtkInformation* metadata) override;
386  int ReadMesh(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
387  int ReadPoints(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
388  int ReadArrays(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
390 
391 protected:
394 
396 
399  double GetTimeValue(const std::string& fname) override;
400  int ReadMesh(
401  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
403  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
405  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
407 
409 
410  int CheckFile(FILE*& fp, const char* fname);
411  int CheckGeometryFile(FILE*& xyzFp);
412  int CheckFunctionFile(FILE*& fFp);
413 
415  int SkipByteCount(FILE* fp);
416  int ReadIntBlock(FILE* fp, int n, int* block);
417 
418  vtkIdType ReadValues(FILE* fp, int n, vtkDataArray* scalar);
419  virtual int ReadIntScalar(void* vfp, int extent[6], int wextent[6], vtkDataArray* scalar,
420  vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
421  virtual int ReadScalar(void* vfp, int extent[6], int wextent[6], vtkDataArray* scalar,
422  vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
423  virtual int ReadVector(void* vfp, int extent[6], int wextent[6], int numDims,
424  vtkDataArray* vector, vtkTypeUInt64 offset,
425  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
426  virtual int OpenFileForDataRead(void*& fp, const char* fname);
427  virtual void CloseFile(void* fp);
428 
429  int GetNumberOfBlocksInternal(FILE* xyzFp, int allocate);
430 
431  int ReadGeometryHeader(FILE* fp);
432  int ReadQHeader(FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow);
433  int ReadFunctionHeader(FILE* fp, int* nFunctions);
434 
435  void CalculateFileSize(FILE* fp);
436 
437  int AutoDetectionCheck(FILE* fp);
438 
439  void AssignAttribute(int fNumber, vtkStructuredGrid* output, int attributeType);
440  void MapFunction(int fNumber, vtkStructuredGrid* output);
441 
443 
463 
464  // Returns a vtkFloatArray or a vtkDoubleArray depending
465  // on DoublePrecision setting
467 
468  // Delete references to any existing vtkPoints and
469  // I-blank arrays. The next Update() will (re)read
470  // the XYZ file.
472 
473  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
474 
476 
477  // plot3d FileNames
478  char* XYZFileName;
479  char* QFileName;
490 
492 
493  size_t FileSize;
494 
495  // parameters used in computing derived functions
496  double R;
497  double Gamma;
498  double GammaInf;
499 
501 
502  // named functions from meta data
503  std::vector<std::string> FunctionNames;
504 
505  // functions to read that are not scalars or vectors
507 
510 
512 
514 
515 private:
517  void operator=(const vtkMultiBlockPLOT3DReader&) = delete;
518 
519  // Key used to flag intermediate results.
520  static vtkInformationIntegerKey* INTERMEDIATE_RESULT();
521 
525  void RemoveIntermediateFunctions(vtkDataSetAttributes* dsa);
526 };
527 
528 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
general representation of visualization data
Definition: vtkDataObject.h:60
represent and manipulate attribute data in a dataset
a simple class to control print indentation
Definition: vtkIndent.h:34
Key for integer values in vtkInformation.
Store vtkAlgorithm input/output information.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:40
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:243
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
@ extent
Definition: vtkX3D.h:351
@ name
Definition: vtkX3D.h:225
@ offset
Definition: vtkX3D.h:444
@ string
Definition: vtkX3D.h:496
int vtkTypeBool
Definition: vtkABI.h:69
int vtkIdType
Definition: vtkType.h:332
#define VTK_FILEPATH