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 <vector> // For holding function-names
91 #include "vtkIOParallelModule.h" // For export macro
92 #include "vtkParallelReader.h"
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 
125 class VTKIOPARALLEL_EXPORT vtkMultiBlockPLOT3DReader : public vtkParallelReader
126 {
127 friend class Functors::ComputeFunctor;
128 friend class Functors::ComputeTemperatureFunctor;
129 friend class Functors::ComputePressureFunctor;
130 friend class Functors::ComputePressureCoefficientFunctor;
131 friend class Functors::ComputeMachNumberFunctor;
132 friend class Functors::ComputeSoundSpeedFunctor;
133 friend class Functors::ComputeEnthalpyFunctor;
134 friend class Functors::ComputeKinecticEnergyFunctor;
135 friend class Functors::ComputeVelocityMagnitudeFunctor;
136 friend class Functors::ComputeEntropyFunctor;
137 friend class Functors::ComputeSwirlFunctor;
138 friend class Functors::ComputeVelocityFunctor;
139 friend class Functors::ComputeVorticityMagnitudeFunctor;
140 friend class Functors::ComputePressureGradientFunctor;
141 friend class Functors::ComputeVorticityFunctor;
142 friend class Functors::ComputeStrainRateFunctor;
143 public:
144  static vtkMultiBlockPLOT3DReader *New();
146  void PrintSelf(ostream& os, vtkIndent indent) override;
147 
149 
152  vtkMultiBlockDataSet* GetOutput();
153  vtkMultiBlockDataSet* GetOutput(int);
155 
156 
158 
161  void SetFileName(const char* name) { this->SetXYZFileName(name); }
162  const char* GetFileName() { return this->GetXYZFileName(); }
163  const char* GetFileName(int i) { return this->vtkParallelReader::GetFileName(i); }
164  virtual void SetXYZFileName( const char* );
165  vtkGetStringMacro(XYZFileName);
167 
169 
179  void SetQFileName(const char* name);
180  const char* GetQFileName();
182 
184 
187  vtkSetStringMacro(FunctionFileName);
188  vtkGetStringMacro(FunctionFileName);
190 
192 
202  vtkSetMacro(AutoDetectFormat, vtkTypeBool);
203  vtkGetMacro(AutoDetectFormat, vtkTypeBool);
204  vtkBooleanMacro(AutoDetectFormat, vtkTypeBool);
206 
208 
212  vtkSetMacro(BinaryFile, vtkTypeBool);
213  vtkGetMacro(BinaryFile, vtkTypeBool);
214  vtkBooleanMacro(BinaryFile, vtkTypeBool);
216 
218 
224  vtkSetMacro(MultiGrid, vtkTypeBool);
225  vtkGetMacro(MultiGrid, vtkTypeBool);
226  vtkBooleanMacro(MultiGrid, vtkTypeBool);
228 
230 
235  vtkSetMacro(HasByteCount, vtkTypeBool);
236  vtkGetMacro(HasByteCount, vtkTypeBool);
237  vtkBooleanMacro(HasByteCount, vtkTypeBool);
239 
241 
246  vtkSetMacro(IBlanking, vtkTypeBool);
247  vtkGetMacro(IBlanking, vtkTypeBool);
248  vtkBooleanMacro(IBlanking, vtkTypeBool);
250 
252 
256  vtkSetMacro(TwoDimensionalGeometry, vtkTypeBool);
257  vtkGetMacro(TwoDimensionalGeometry, vtkTypeBool);
258  vtkBooleanMacro(TwoDimensionalGeometry, vtkTypeBool);
260 
262 
267  vtkSetMacro(DoublePrecision, vtkTypeBool);
268  vtkGetMacro(DoublePrecision, vtkTypeBool);
269  vtkBooleanMacro(DoublePrecision, vtkTypeBool);
271 
273 
279  vtkSetMacro(ForceRead, vtkTypeBool);
280  vtkGetMacro(ForceRead, vtkTypeBool);
281  vtkBooleanMacro(ForceRead, vtkTypeBool);
283 
285 
291  void SetByteOrderToBigEndian();
292  void SetByteOrderToLittleEndian();
293  vtkSetMacro(ByteOrder, int);
294  vtkGetMacro(ByteOrder, int);
295  const char *GetByteOrderAsString();
297 
299 
302  vtkSetMacro(R,double);
303  vtkGetMacro(R,double);
305 
307 
310  vtkSetMacro(Gamma,double);
311  vtkGetMacro(Gamma,double);
313 
315 
323  vtkSetMacro(PreserveIntermediateFunctions, bool);
324  vtkGetMacro(PreserveIntermediateFunctions, bool);
325  vtkBooleanMacro(PreserveIntermediateFunctions, bool);
326 
328 
332  void SetScalarFunctionNumber(int num);
333  vtkGetMacro(ScalarFunctionNumber,int);
335 
337 
341  void SetVectorFunctionNumber(int num);
342  vtkGetMacro(VectorFunctionNumber,int);
344 
346 
351  void AddFunction(int functionNumber);
352  void RemoveFunction(int);
353  void RemoveAllFunctions();
355 
360  virtual int CanReadBinaryFile(const char* fname);
361 
363 
367  void SetController(vtkMultiProcessController *c);
368  vtkGetObjectMacro(Controller, vtkMultiProcessController);
370 
371  void AddFunctionName(const std::string &name) {FunctionNames.push_back(name);}
372 
373  enum
374  {
375  FILE_BIG_ENDIAN=0,
376  FILE_LITTLE_ENDIAN=1
377  };
378 
380 
386  int ReadMetaData(vtkInformation* metadata) override;
387  int ReadMesh(
388  int piece, int npieces, int nghosts, int timestep,
389  vtkDataObject* output) override;
390  int ReadPoints(
391  int piece, int npieces, int nghosts, int timestep,
392  vtkDataObject* output) override;
393  int ReadArrays(
394  int piece, int npieces, int nghosts, int timestep,
395  vtkDataObject* output) override;
397 
398 protected:
400  ~vtkMultiBlockPLOT3DReader() override;
401 
403 
406  double GetTimeValue(const std::string& fname) override;
407  int ReadMesh(const std::string& fname,
408  int piece,
409  int npieces,
410  int nghosts,
411  vtkDataObject* output) override;
412  int ReadPoints(const std::string& fname,
413  int piece,
414  int npieces,
415  int nghosts,
416  vtkDataObject* output) override;
417  int ReadArrays(const std::string& fname,
418  int piece,
419  int npieces,
420  int nghosts,
421  vtkDataObject* output) override;
423 
424  vtkDataArray* CreateFloatArray();
425 
426  int CheckFile(FILE*& fp, const char* fname);
427  int CheckGeometryFile(FILE*& xyzFp);
428  int CheckFunctionFile(FILE*& fFp);
429 
430  int GetByteCountSize();
431  int SkipByteCount (FILE* fp);
432  int ReadIntBlock (FILE* fp, int n, int* block);
433 
434  vtkIdType ReadValues(
435  FILE* fp,
436  int n,
437  vtkDataArray* scalar);
438  virtual int ReadIntScalar(
439  void* vfp,
440  int extent[6], int wextent[6],
441  vtkDataArray* scalar, vtkTypeUInt64 offset,
442  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
443  virtual int ReadScalar(
444  void* vfp,
445  int extent[6], int wextent[6],
446  vtkDataArray* scalar, vtkTypeUInt64 offset,
447  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
448  virtual int ReadVector(
449  void* vfp,
450  int extent[6], int wextent[6],
451  int numDims, vtkDataArray* vector, vtkTypeUInt64 offset,
452  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
453  virtual int OpenFileForDataRead(void*& fp, const char* fname);
454  virtual void CloseFile(void* fp);
455 
456  int GetNumberOfBlocksInternal(FILE* xyzFp, int allocate);
457 
458  int ReadGeometryHeader(FILE* fp);
459  int ReadQHeader(FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow);
460  int ReadFunctionHeader(FILE* fp, int* nFunctions);
461 
462  void CalculateFileSize(FILE* fp);
463 
464  int AutoDetectionCheck(FILE* fp);
465 
466  void AssignAttribute(int fNumber, vtkStructuredGrid* output,
467  int attributeType);
468  void MapFunction(int fNumber, vtkStructuredGrid* output);
469 
471 
475  vtkDataArray* ComputeTemperature(vtkStructuredGrid* output);
476  vtkDataArray* ComputePressure(vtkStructuredGrid* output);
477  vtkDataArray* ComputeEnthalpy(vtkStructuredGrid* output);
478  vtkDataArray* ComputeKineticEnergy(vtkStructuredGrid* output);
479  vtkDataArray* ComputeVelocityMagnitude(vtkStructuredGrid* output);
480  vtkDataArray* ComputeEntropy(vtkStructuredGrid* output);
481  vtkDataArray* ComputeSwirl(vtkStructuredGrid* output);
482  vtkDataArray* ComputeVelocity(vtkStructuredGrid* output);
483  vtkDataArray* ComputeVorticity(vtkStructuredGrid* output);
484  vtkDataArray* ComputePressureGradient(vtkStructuredGrid* output);
485  vtkDataArray* ComputePressureCoefficient(vtkStructuredGrid* output);
486  vtkDataArray* ComputeMachNumber(vtkStructuredGrid* output);
487  vtkDataArray* ComputeSoundSpeed(vtkStructuredGrid* output);
488  vtkDataArray* ComputeVorticityMagnitude(vtkStructuredGrid* output);
489  vtkDataArray* ComputeStrainRate(vtkStructuredGrid* output);
491 
492  // Returns a vtkFloatArray or a vtkDoubleArray depending
493  // on DoublePrecision setting
494  vtkDataArray* NewFloatArray();
495 
496  // Delete references to any existing vtkPoints and
497  // I-blank arrays. The next Update() will (re)read
498  // the XYZ file.
499  void ClearGeometryCache();
500 
501  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
502 
503  //plot3d FileNames
504  char *XYZFileName;
505  char *QFileName;
507 
517 
519 
520  size_t FileSize;
521 
522  //parameters used in computing derived functions
523  double R;
524  double Gamma;
525  double GammaInf;
526 
528 
529  //named functions from meta data
530  std::vector<std::string> FunctionNames;
531 
532  //functions to read that are not scalars or vectors
534 
537 
539 
540  virtual vtkExecutive* CreateDefaultExecutive() override;
541 
543 
545 
546 private:
548  void operator=(const vtkMultiBlockPLOT3DReader&) = delete;
549 
550  // Key used to flag intermediate results.
551  static vtkInformationIntegerKey* INTERMEDIATE_RESULT();
552 
556  void RemoveIntermediateFunctions(vtkDataSetAttributes* dsa);
557 };
558 
559 #endif
void AddFunctionName(const std::string &name)
void SetFileName(const char *name)
Set/Get the PLOT3D geometry filename.
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.
virtual vtkExecutive * CreateDefaultExecutive()
Create a default executive.
Store vtkAlgorithm input/output information.
const char * GetFileName(int i)
Set/Get the PLOT3D geometry filename.
vtkMultiProcessController * Controller
int vtkIdType
Definition: vtkType.h:347
Superclass for all pipeline executives in VTK.
Definition: vtkExecutive.h:46
int vtkTypeBool
Definition: vtkABI.h:69
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
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:33
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.
Key for integer values in vtkInformation.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
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
const char * GetFileName(int i) const
Returns a particular filename stored by the reader.
topologically regular array of data
Composite dataset that organizes datasets into blocks.
static vtkAlgorithm * New()
const char * GetFileName()
Set/Get the PLOT3D geometry filename.
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:58
Multiprocessing communication superclass.