VTK
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:
144  static vtkMultiBlockPLOT3DReader* New();
146  void PrintSelf(ostream& os, vtkIndent indent) override;
147 
149 
152  vtkMultiBlockDataSet* GetOutput();
153  vtkMultiBlockDataSet* GetOutput(int);
155 
157 
160  void SetFileName(const char* name) { this->SetXYZFileName(name); }
161  const char* GetFileName() { return this->GetXYZFileName(); }
162  const char* GetFileName(int i) { return this->vtkParallelReader::GetFileName(i); }
163  virtual void SetXYZFileName(const char*);
164  vtkGetStringMacro(XYZFileName);
166 
168 
178  void SetQFileName(const char* name);
179  const char* GetQFileName();
181 
183 
186  vtkSetStringMacro(FunctionFileName);
187  vtkGetStringMacro(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 
290  void SetByteOrderToBigEndian();
291  void SetByteOrderToLittleEndian();
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);
352  void RemoveAllFunctions();
354 
359  virtual int CanReadBinaryFile(const char* fname);
360 
362 
366  void SetController(vtkMultiProcessController* c);
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:
393  ~vtkMultiBlockPLOT3DReader() override;
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;
402  int ReadPoints(
403  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
404  int ReadArrays(
405  const std::string& fname, int piece, int npieces, int nghosts, vtkDataObject* output) override;
407 
408  vtkDataArray* CreateFloatArray();
409 
410  int CheckFile(FILE*& fp, const char* fname);
411  int CheckGeometryFile(FILE*& xyzFp);
412  int CheckFunctionFile(FILE*& fFp);
413 
414  int GetByteCountSize();
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 
447  vtkDataArray* ComputeTemperature(vtkStructuredGrid* output);
448  vtkDataArray* ComputePressure(vtkStructuredGrid* output);
449  vtkDataArray* ComputeEnthalpy(vtkStructuredGrid* output);
450  vtkDataArray* ComputeKineticEnergy(vtkStructuredGrid* output);
451  vtkDataArray* ComputeVelocityMagnitude(vtkStructuredGrid* output);
452  vtkDataArray* ComputeEntropy(vtkStructuredGrid* output);
453  vtkDataArray* ComputeSwirl(vtkStructuredGrid* output);
454  vtkDataArray* ComputeVelocity(vtkStructuredGrid* output);
455  vtkDataArray* ComputeVorticity(vtkStructuredGrid* output);
456  vtkDataArray* ComputePressureGradient(vtkStructuredGrid* output);
457  vtkDataArray* ComputePressureCoefficient(vtkStructuredGrid* output);
458  vtkDataArray* ComputeMachNumber(vtkStructuredGrid* output);
459  vtkDataArray* ComputeSoundSpeed(vtkStructuredGrid* output);
460  vtkDataArray* ComputeVorticityMagnitude(vtkStructuredGrid* output);
461  vtkDataArray* ComputeStrainRate(vtkStructuredGrid* output);
463 
464  // Returns a vtkFloatArray or a vtkDoubleArray depending
465  // on DoublePrecision setting
466  vtkDataArray* NewFloatArray();
467 
468  // Delete references to any existing vtkPoints and
469  // I-blank arrays. The next Update() will (re)read
470  // the XYZ file.
471  void ClearGeometryCache();
472 
473  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
474 
475  // plot3d FileNames
476  char* XYZFileName;
477  char* QFileName;
479 
489 
491 
492  size_t FileSize;
493 
494  // parameters used in computing derived functions
495  double R;
496  double Gamma;
497  double GammaInf;
498 
500 
501  // named functions from meta data
502  std::vector<std::string> FunctionNames;
503 
504  // functions to read that are not scalars or vectors
506 
509 
511 
513 
515 
516 private:
518  void operator=(const vtkMultiBlockPLOT3DReader&) = delete;
519 
520  // Key used to flag intermediate results.
521  static vtkInformationIntegerKey* INTERMEDIATE_RESULT();
522 
526  void RemoveIntermediateFunctions(vtkDataSetAttributes* dsa);
527 };
528 
529 #endif
vtkParallelReader.h
vtkX3D::vector
Definition: vtkX3D.h:243
Functors
Definition: vtkMultiBlockPLOT3DReader.h:104
vtkMultiBlockPLOT3DReader::XYZFileName
char * XYZFileName
Definition: vtkMultiBlockPLOT3DReader.h:476
vtkParallelReader::ReadMesh
int ReadMesh(int piece, int npieces, int nghosts, int timestep, vtkDataObject *output) override
Read the mesh (connectivity) for a given set of data partitioning, number of ghost levels and time st...
vtkIdType
int vtkIdType
Definition: vtkType.h:349
vtkMultiBlockPLOT3DReader::VectorFunctionNumber
int VectorFunctionNumber
Definition: vtkMultiBlockPLOT3DReader.h:508
vtkDataSetAttributes
represent and manipulate attribute data in a dataset
Definition: vtkDataSetAttributes.h:53
vtkMultiBlockPLOT3DReader::FunctionNames
std::vector< std::string > FunctionNames
Definition: vtkMultiBlockPLOT3DReader.h:502
vtkMultiBlockPLOT3DReader::AutoDetectFormat
vtkTypeBool AutoDetectFormat
Definition: vtkMultiBlockPLOT3DReader.h:488
vtkUnsignedCharArray
dynamic, self-adjusting array of unsigned char
Definition: vtkUnsignedCharArray.h:35
vtkStructuredGrid
topologically regular array of data
Definition: vtkStructuredGrid.h:57
vtkMultiBlockPLOT3DReader::SetFileName
void SetFileName(const char *name)
Set/Get the PLOT3D geometry filename.
Definition: vtkMultiBlockPLOT3DReader.h:160
vtkMultiBlockPLOT3DReader
read PLOT3D data files
Definition: vtkMultiBlockPLOT3DReader.h:124
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:49
vtkMultiBlockPLOT3DReader::PreserveIntermediateFunctions
bool PreserveIntermediateFunctions
Definition: vtkMultiBlockPLOT3DReader.h:499
vtkMultiBlockPLOT3DReader::R
double R
Definition: vtkMultiBlockPLOT3DReader.h:495
vtkMultiBlockPLOT3DReader::ExecutedGhostLevels
int ExecutedGhostLevels
Definition: vtkMultiBlockPLOT3DReader.h:490
vtkMultiBlockDataSet
Composite dataset that organizes datasets into blocks.
Definition: vtkMultiBlockDataSet.h:45
vtkMultiBlockPLOT3DReader::GetFileName
const char * GetFileName()
Definition: vtkMultiBlockPLOT3DReader.h:161
vtkMultiBlockPLOT3DReader::ForceRead
vtkTypeBool ForceRead
Definition: vtkMultiBlockPLOT3DReader.h:484
vtkX3D::port
Definition: vtkX3D.h:453
vtkMultiBlockPLOT3DReader::Controller
vtkMultiProcessController * Controller
Definition: vtkMultiBlockPLOT3DReader.h:514
vtkMultiBlockPLOT3DReader::IBlanking
vtkTypeBool IBlanking
Definition: vtkMultiBlockPLOT3DReader.h:486
vtkMultiBlockPLOT3DReader::AddFunctionName
void AddFunctionName(const std::string &name)
Definition: vtkMultiBlockPLOT3DReader.h:370
vtkMultiBlockPLOT3DReaderInternals
Definition: vtkMultiBlockPLOT3DReaderInternals.h:39
vtkX3D::offset
Definition: vtkX3D.h:444
vtkMultiProcessController
Multiprocessing communication superclass.
Definition: vtkMultiProcessController.h:75
vtkInformationIntegerKey
Key for integer values in vtkInformation.
Definition: vtkInformationIntegerKey.h:31
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkParallelReader::ReadPoints
int ReadPoints(int piece, int npieces, int nghosts, int timestep, vtkDataObject *output) override
Read the points.
vtkParallelReader::GetFileName
const char * GetFileName(int i) const
Returns a particular filename stored by the reader.
vtkIntArray
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
vtkMultiBlockPLOT3DReader::QFileName
char * QFileName
Definition: vtkMultiBlockPLOT3DReader.h:477
vtkMultiBlockPLOT3DReader::ScalarFunctionNumber
int ScalarFunctionNumber
Definition: vtkMultiBlockPLOT3DReader.h:507
vtkMultiBlockPLOT3DReader::HasByteCount
vtkTypeBool HasByteCount
Definition: vtkMultiBlockPLOT3DReader.h:481
vtkMultiBlockPLOT3DReader::FileSize
size_t FileSize
Definition: vtkMultiBlockPLOT3DReader.h:492
vtkMultiBlockPLOT3DReader::GammaInf
double GammaInf
Definition: vtkMultiBlockPLOT3DReader.h:497
vtkX3D::name
Definition: vtkX3D.h:225
vtkMultiBlockPLOT3DReader::FunctionList
vtkIntArray * FunctionList
Definition: vtkMultiBlockPLOT3DReader.h:505
vtkMultiBlockPLOT3DReader::MultiGrid
vtkTypeBool MultiGrid
Definition: vtkMultiBlockPLOT3DReader.h:483
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:64
vtkMultiBlockPLOT3DReader::FunctionFileName
char * FunctionFileName
Definition: vtkMultiBlockPLOT3DReader.h:478
vtkX3D::info
Definition: vtkX3D.h:382
vtkParallelReader::ReadArrays
int ReadArrays(int piece, int npieces, int nghosts, int timestep, vtkDataObject *output) override
Read all the arrays (point, cell, field etc.).
vtkAlgorithm::New
static vtkAlgorithm * New()
vtkParallelReader
Superclass for algorithms that are parallel aware.
Definition: vtkParallelReader.h:36
vtkX3D::string
Definition: vtkX3D.h:496
vtkMultiBlockPLOT3DReader::DoublePrecision
vtkTypeBool DoublePrecision
Definition: vtkMultiBlockPLOT3DReader.h:487
vtkMultiBlockPLOT3DReader::Gamma
double Gamma
Definition: vtkMultiBlockPLOT3DReader.h:496
vtkX3D::extent
Definition: vtkX3D.h:351
vtkMultiBlockPLOT3DReader::BinaryFile
vtkTypeBool BinaryFile
Definition: vtkMultiBlockPLOT3DReader.h:480
vtkMultiBlockPLOT3DReader::ByteOrder
int ByteOrder
Definition: vtkMultiBlockPLOT3DReader.h:485
vtkMultiBlockPLOT3DReader::Internal
vtkMultiBlockPLOT3DReaderInternals * Internal
Definition: vtkMultiBlockPLOT3DReader.h:512
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkParallelReader::GetTimeValue
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 ...
vtkMultiBlockPLOT3DReaderRecord
Definition: vtkMultiBlockPLOT3DReaderInternals.h:119
vtkParallelReader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkMultiBlockPLOT3DReader::GetFileName
const char * GetFileName(int i)
Definition: vtkMultiBlockPLOT3DReader.h:162
vtkAlgorithm::FillOutputPortInformation
virtual int FillOutputPortInformation(int port, vtkInformation *info)
Fill the output port information objects for this algorithm.
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkMultiBlockPLOT3DReader::TwoDimensionalGeometry
vtkTypeBool TwoDimensionalGeometry
Definition: vtkMultiBlockPLOT3DReader.h:482
vtkParallelReader::ReadMetaData
int ReadMetaData(vtkInformation *metadata) override
This is the superclass API overridden by this class to provide time support internally.