VTK  9.2.6
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 =========================================================================*/
90 #ifndef vtkMultiBlockPLOT3DReader_h
91 #define vtkMultiBlockPLOT3DReader_h
92 
93 #include "vtkIOParallelModule.h" // For export macro
94 #include "vtkParallelReader.h"
95 #include <vector> // For holding function-names
96 
97 class vtkDataArray;
99 class vtkIntArray;
102 class vtkStructuredGrid;
106 
107 namespace Functors
108 {
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 }
126 
127 class VTKIOPARALLEL_EXPORT vtkMultiBlockPLOT3DReader : public vtkParallelReader
128 {
129  friend class Functors::ComputeFunctor;
130  friend class Functors::ComputeTemperatureFunctor;
131  friend class Functors::ComputePressureFunctor;
132  friend class Functors::ComputePressureCoefficientFunctor;
133  friend class Functors::ComputeMachNumberFunctor;
134  friend class Functors::ComputeSoundSpeedFunctor;
135  friend class Functors::ComputeEnthalpyFunctor;
136  friend class Functors::ComputeKinecticEnergyFunctor;
137  friend class Functors::ComputeVelocityMagnitudeFunctor;
138  friend class Functors::ComputeEntropyFunctor;
139  friend class Functors::ComputeSwirlFunctor;
140  friend class Functors::ComputeVelocityFunctor;
141  friend class Functors::ComputeVorticityMagnitudeFunctor;
142  friend class Functors::ComputePressureGradientFunctor;
143  friend class Functors::ComputeVorticityFunctor;
144  friend class Functors::ComputeStrainRateFunctor;
145 
146 public:
147  static vtkMultiBlockPLOT3DReader* New();
149  void PrintSelf(ostream& os, vtkIndent indent) override;
150 
152 
155  vtkMultiBlockDataSet* GetOutput();
156  vtkMultiBlockDataSet* GetOutput(int);
158 
160 
163  void SetFileName(VTK_FILEPATH const char* name) { this->SetXYZFileName(name); }
164  VTK_FILEPATH const char* GetFileName() { return this->GetXYZFileName(); }
165  VTK_FILEPATH const char* GetFileName(int i) { return this->vtkParallelReader::GetFileName(i); }
166  virtual void SetXYZFileName(VTK_FILEPATH const char*);
167  vtkGetFilePathMacro(XYZFileName);
169 
171 
181  void SetQFileName(VTK_FILEPATH const char* name);
182  VTK_FILEPATH const char* GetQFileName();
184 
186 
189  vtkSetFilePathMacro(FunctionFileName);
190  vtkGetFilePathMacro(FunctionFileName);
192 
194 
204  vtkSetMacro(AutoDetectFormat, vtkTypeBool);
205  vtkGetMacro(AutoDetectFormat, vtkTypeBool);
206  vtkBooleanMacro(AutoDetectFormat, vtkTypeBool);
208 
210 
214  vtkSetMacro(BinaryFile, vtkTypeBool);
215  vtkGetMacro(BinaryFile, vtkTypeBool);
216  vtkBooleanMacro(BinaryFile, vtkTypeBool);
218 
220 
226  vtkSetMacro(MultiGrid, vtkTypeBool);
227  vtkGetMacro(MultiGrid, vtkTypeBool);
228  vtkBooleanMacro(MultiGrid, vtkTypeBool);
230 
232 
237  vtkSetMacro(HasByteCount, vtkTypeBool);
238  vtkGetMacro(HasByteCount, vtkTypeBool);
239  vtkBooleanMacro(HasByteCount, vtkTypeBool);
241 
243 
248  vtkSetMacro(IBlanking, vtkTypeBool);
249  vtkGetMacro(IBlanking, vtkTypeBool);
250  vtkBooleanMacro(IBlanking, vtkTypeBool);
252 
254 
258  vtkSetMacro(TwoDimensionalGeometry, vtkTypeBool);
259  vtkGetMacro(TwoDimensionalGeometry, vtkTypeBool);
260  vtkBooleanMacro(TwoDimensionalGeometry, vtkTypeBool);
262 
264 
269  vtkSetMacro(DoublePrecision, vtkTypeBool);
270  vtkGetMacro(DoublePrecision, vtkTypeBool);
271  vtkBooleanMacro(DoublePrecision, vtkTypeBool);
273 
275 
281  vtkSetMacro(ForceRead, vtkTypeBool);
282  vtkGetMacro(ForceRead, vtkTypeBool);
283  vtkBooleanMacro(ForceRead, vtkTypeBool);
285 
287 
293  void SetByteOrderToBigEndian();
294  void SetByteOrderToLittleEndian();
295  vtkSetMacro(ByteOrder, int);
296  vtkGetMacro(ByteOrder, int);
297  const char* GetByteOrderAsString();
299 
301 
304  vtkSetMacro(R, double);
305  vtkGetMacro(R, double);
307 
309 
312  vtkSetMacro(Gamma, double);
313  vtkGetMacro(Gamma, double);
315 
317 
325  vtkSetMacro(PreserveIntermediateFunctions, bool);
326  vtkGetMacro(PreserveIntermediateFunctions, bool);
327  vtkBooleanMacro(PreserveIntermediateFunctions, bool);
328 
330 
334  void SetScalarFunctionNumber(int num);
335  vtkGetMacro(ScalarFunctionNumber, int);
337 
339 
343  void SetVectorFunctionNumber(int num);
344  vtkGetMacro(VectorFunctionNumber, int);
346 
348 
353  void AddFunction(int functionNumber);
354  void RemoveFunction(int);
355  void RemoveAllFunctions();
357 
362  virtual int CanReadBinaryFile(VTK_FILEPATH const char* fname);
363 
365 
369  void SetController(vtkMultiProcessController* c);
370  vtkGetObjectMacro(Controller, vtkMultiProcessController);
372 
373  void AddFunctionName(const std::string& name) { FunctionNames.push_back(name); }
374 
375  enum
376  {
377  FILE_BIG_ENDIAN = 0,
378  FILE_LITTLE_ENDIAN = 1
379  };
380 
382 
388  int ReadMetaData(vtkInformation* metadata) override;
389  int ReadMesh(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
390  int ReadPoints(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
391  int ReadArrays(int piece, int npieces, int nghosts, int timestep, vtkDataObject* output) override;
393 
394 protected:
396  ~vtkMultiBlockPLOT3DReader() override;
397 
399 
402  double GetTimeValue(const std::string& fname) override;
403  int ReadMesh(
404  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
405  int ReadPoints(
406  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
407  int ReadArrays(
408  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
410 
411  vtkDataArray* CreateFloatArray();
412 
413  int CheckFile(FILE*& fp, const char* fname);
414  int CheckGeometryFile(FILE*& xyzFp);
415  int CheckFunctionFile(FILE*& fFp);
416 
417  int GetByteCountSize();
418  int SkipByteCount(FILE* fp);
419  int ReadIntBlock(FILE* fp, int n, int* block);
420 
421  vtkIdType ReadValues(FILE* fp, int n, vtkDataArray* scalar);
422  virtual int ReadIntScalar(void* vfp, int extent[6], int wextent[6], vtkDataArray* scalar,
423  vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
424  virtual int ReadScalar(void* vfp, int extent[6], int wextent[6], vtkDataArray* scalar,
425  vtkTypeUInt64 offset, const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
426  virtual int ReadVector(void* vfp, int extent[6], int wextent[6], int numDims,
427  vtkDataArray* vector, vtkTypeUInt64 offset,
428  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
429  virtual int OpenFileForDataRead(void*& fp, const char* fname);
430  virtual void CloseFile(void* fp);
431 
432  int GetNumberOfBlocksInternal(FILE* xyzFp, int allocate);
433 
434  int ReadGeometryHeader(FILE* fp);
435  int ReadQHeader(FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow);
436  int ReadFunctionHeader(FILE* fp, int* nFunctions);
437 
438  void CalculateFileSize(FILE* fp);
439 
440  int AutoDetectionCheck(FILE* fp);
441 
442  void AssignAttribute(int fNumber, vtkStructuredGrid* output, int attributeType);
443  void MapFunction(int fNumber, vtkStructuredGrid* output);
444 
446 
450  vtkDataArray* ComputeTemperature(vtkStructuredGrid* output);
451  vtkDataArray* ComputePressure(vtkStructuredGrid* output);
452  vtkDataArray* ComputeEnthalpy(vtkStructuredGrid* output);
453  vtkDataArray* ComputeKineticEnergy(vtkStructuredGrid* output);
454  vtkDataArray* ComputeVelocityMagnitude(vtkStructuredGrid* output);
455  vtkDataArray* ComputeEntropy(vtkStructuredGrid* output);
456  vtkDataArray* ComputeSwirl(vtkStructuredGrid* output);
457  vtkDataArray* ComputeVelocity(vtkStructuredGrid* output);
458  vtkDataArray* ComputeVorticity(vtkStructuredGrid* output);
459  vtkDataArray* ComputePressureGradient(vtkStructuredGrid* output);
460  vtkDataArray* ComputePressureCoefficient(vtkStructuredGrid* output);
461  vtkDataArray* ComputeMachNumber(vtkStructuredGrid* output);
462  vtkDataArray* ComputeSoundSpeed(vtkStructuredGrid* output);
463  vtkDataArray* ComputeVorticityMagnitude(vtkStructuredGrid* output);
464  vtkDataArray* ComputeStrainRate(vtkStructuredGrid* output);
466 
467  // Returns a vtkFloatArray or a vtkDoubleArray depending
468  // on DoublePrecision setting
469  vtkDataArray* NewFloatArray();
470 
471  // Delete references to any existing vtkPoints and
472  // I-blank arrays. The next Update() will (re)read
473  // the XYZ file.
474  void ClearGeometryCache();
475 
476  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
477 
479 
480  // plot3d FileNames
481  char* XYZFileName;
482  char* QFileName;
493 
495 
496  size_t FileSize;
497 
498  // parameters used in computing derived functions
499  double R;
500  double Gamma;
501  double GammaInf;
502 
504 
505  // named functions from meta data
506  std::vector<std::string> FunctionNames;
507 
508  // functions to read that are not scalars or vectors
510 
513 
515 
517 
518 private:
520  void operator=(const vtkMultiBlockPLOT3DReader&) = delete;
521 
522  // Key used to flag intermediate results.
523  static vtkInformationIntegerKey* INTERMEDIATE_RESULT();
524 
528  void RemoveIntermediateFunctions(vtkDataSetAttributes* dsa);
529 };
530 
531 #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:332
void SetFileName(VTK_FILEPATH const char *name)
Set/Get the PLOT3D geometry filename.
int vtkTypeBool
Definition: vtkABI.h:69
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
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:39
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:55
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:65
Multiprocessing communication superclass.