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 =========================================================================*/
93 #ifndef vtkMultiBlockPLOT3DReader_h
94 #define vtkMultiBlockPLOT3DReader_h
95 
96 #include <vector> // For holding function-names
97 #include "vtkIOParallelModule.h" // For export macro
98 #include "vtkParallelReader.h"
99 
100 class vtkDataArray;
102 class vtkIntArray;
105 class vtkStructuredGrid;
109 
110 namespace Functors
111 {
112  class ComputeFunctor;
113  class ComputeTemperatureFunctor;
114  class ComputePressureFunctor;
115  class ComputePressureCoefficientFunctor;
116  class ComputeMachNumberFunctor;
117  class ComputeSoundSpeedFunctor;
118  class ComputeEnthalpyFunctor;
119  class ComputeKinecticEnergyFunctor;
120  class ComputeVelocityMagnitudeFunctor;
121  class ComputeEntropyFunctor;
122  class ComputeSwirlFunctor;
123  class ComputeVelocityFunctor;
124  class ComputeVorticityMagnitudeFunctor;
125  class ComputePressureGradientFunctor;
126  class ComputeVorticityFunctor;
127  class ComputeStrainRateFunctor;
128 }
129 
130 
131 class VTKIOPARALLEL_EXPORT vtkMultiBlockPLOT3DReader : public vtkParallelReader
132 {
133 friend class Functors::ComputeFunctor;
134 friend class Functors::ComputeTemperatureFunctor;
135 friend class Functors::ComputePressureFunctor;
136 friend class Functors::ComputePressureCoefficientFunctor;
137 friend class Functors::ComputeMachNumberFunctor;
138 friend class Functors::ComputeSoundSpeedFunctor;
139 friend class Functors::ComputeEnthalpyFunctor;
140 friend class Functors::ComputeKinecticEnergyFunctor;
141 friend class Functors::ComputeVelocityMagnitudeFunctor;
142 friend class Functors::ComputeEntropyFunctor;
143 friend class Functors::ComputeSwirlFunctor;
144 friend class Functors::ComputeVelocityFunctor;
145 friend class Functors::ComputeVorticityMagnitudeFunctor;
146 friend class Functors::ComputePressureGradientFunctor;
147 friend class Functors::ComputeVorticityFunctor;
148 friend class Functors::ComputeStrainRateFunctor;
149 public:
150  static vtkMultiBlockPLOT3DReader *New();
152  void PrintSelf(ostream& os, vtkIndent indent) override;
153 
155 
158  vtkMultiBlockDataSet* GetOutput();
159  vtkMultiBlockDataSet* GetOutput(int);
161 
162 
164 
167  void SetFileName(const char* name) { this->SetXYZFileName(name); }
168  const char* GetFileName() { return this->GetXYZFileName(); }
169  const char* GetFileName(int i) { return this->vtkParallelReader::GetFileName(i); }
170  virtual void SetXYZFileName( const char* );
171  vtkGetStringMacro(XYZFileName);
173 
175 
185  void SetQFileName(const char* name);
186  const char* GetQFileName();
188 
190 
193  vtkSetStringMacro(FunctionFileName);
194  vtkGetStringMacro(FunctionFileName);
196 
198 
208  vtkSetMacro(AutoDetectFormat, vtkTypeBool);
209  vtkGetMacro(AutoDetectFormat, vtkTypeBool);
210  vtkBooleanMacro(AutoDetectFormat, vtkTypeBool);
212 
214 
218  vtkSetMacro(BinaryFile, vtkTypeBool);
219  vtkGetMacro(BinaryFile, vtkTypeBool);
220  vtkBooleanMacro(BinaryFile, vtkTypeBool);
222 
224 
230  vtkSetMacro(MultiGrid, vtkTypeBool);
231  vtkGetMacro(MultiGrid, vtkTypeBool);
232  vtkBooleanMacro(MultiGrid, vtkTypeBool);
234 
236 
241  vtkSetMacro(HasByteCount, vtkTypeBool);
242  vtkGetMacro(HasByteCount, vtkTypeBool);
243  vtkBooleanMacro(HasByteCount, vtkTypeBool);
245 
247 
252  vtkSetMacro(IBlanking, vtkTypeBool);
253  vtkGetMacro(IBlanking, vtkTypeBool);
254  vtkBooleanMacro(IBlanking, vtkTypeBool);
256 
258 
262  vtkSetMacro(TwoDimensionalGeometry, vtkTypeBool);
263  vtkGetMacro(TwoDimensionalGeometry, vtkTypeBool);
264  vtkBooleanMacro(TwoDimensionalGeometry, vtkTypeBool);
266 
268 
273  vtkSetMacro(DoublePrecision, vtkTypeBool);
274  vtkGetMacro(DoublePrecision, vtkTypeBool);
275  vtkBooleanMacro(DoublePrecision, vtkTypeBool);
277 
279 
285  vtkSetMacro(ForceRead, vtkTypeBool);
286  vtkGetMacro(ForceRead, vtkTypeBool);
287  vtkBooleanMacro(ForceRead, vtkTypeBool);
289 
291 
297  void SetByteOrderToBigEndian();
298  void SetByteOrderToLittleEndian();
299  vtkSetMacro(ByteOrder, int);
300  vtkGetMacro(ByteOrder, int);
301  const char *GetByteOrderAsString();
303 
305 
308  vtkSetMacro(R,double);
309  vtkGetMacro(R,double);
311 
313 
316  vtkSetMacro(Gamma,double);
317  vtkGetMacro(Gamma,double);
319 
321 
329  vtkSetMacro(PreserveIntermediateFunctions, bool);
330  vtkGetMacro(PreserveIntermediateFunctions, bool);
331  vtkBooleanMacro(PreserveIntermediateFunctions, bool);
332 
334 
338  void SetScalarFunctionNumber(int num);
339  vtkGetMacro(ScalarFunctionNumber,int);
341 
343 
347  void SetVectorFunctionNumber(int num);
348  vtkGetMacro(VectorFunctionNumber,int);
350 
352 
357  void AddFunction(int functionNumber);
358  void RemoveFunction(int);
359  void RemoveAllFunctions();
361 
366  virtual int CanReadBinaryFile(const char* fname);
367 
369 
373  void SetController(vtkMultiProcessController *c);
374  vtkGetObjectMacro(Controller, vtkMultiProcessController);
376 
377  void AddFunctionName(const std::string &name) {FunctionNames.push_back(name);}
378 
379  enum
380  {
381  FILE_BIG_ENDIAN=0,
382  FILE_LITTLE_ENDIAN=1
383  };
384 
386 
392  int ReadMetaData(vtkInformation* metadata) override;
393  int ReadMesh(
394  int piece, int npieces, int nghosts, int timestep,
395  vtkDataObject* output) override;
396  int ReadPoints(
397  int piece, int npieces, int nghosts, int timestep,
398  vtkDataObject* output) override;
399  int ReadArrays(
400  int piece, int npieces, int nghosts, int timestep,
401  vtkDataObject* output) override;
403 
404 protected:
406  ~vtkMultiBlockPLOT3DReader() override;
407 
409 
412  double GetTimeValue(const std::string& fname) override;
413  int ReadMesh(const std::string& fname,
414  int piece,
415  int npieces,
416  int nghosts,
417  vtkDataObject* output) override;
418  int ReadPoints(const std::string& fname,
419  int piece,
420  int npieces,
421  int nghosts,
422  vtkDataObject* output) override;
423  int ReadArrays(const std::string& fname,
424  int piece,
425  int npieces,
426  int nghosts,
427  vtkDataObject* output) override;
429 
430  vtkDataArray* CreateFloatArray();
431 
432  int CheckFile(FILE*& fp, const char* fname);
433  int CheckGeometryFile(FILE*& xyzFp);
434  int CheckFunctionFile(FILE*& fFp);
435 
436  int GetByteCountSize();
437  int SkipByteCount (FILE* fp);
438  int ReadIntBlock (FILE* fp, int n, int* block);
439 
440  vtkIdType ReadValues(
441  FILE* fp,
442  int n,
443  vtkDataArray* scalar);
444  virtual int ReadIntScalar(
445  void* vfp,
446  int extent[6], int wextent[6],
447  vtkDataArray* scalar, vtkTypeUInt64 offset,
448  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
449  virtual int ReadScalar(
450  void* vfp,
451  int extent[6], int wextent[6],
452  vtkDataArray* scalar, vtkTypeUInt64 offset,
453  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
454  virtual int ReadVector(
455  void* vfp,
456  int extent[6], int wextent[6],
457  int numDims, vtkDataArray* vector, vtkTypeUInt64 offset,
458  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
459  virtual int OpenFileForDataRead(void*& fp, const char* fname);
460  virtual void CloseFile(void* fp);
461 
462  int GetNumberOfBlocksInternal(FILE* xyzFp, int allocate);
463 
464  int ReadGeometryHeader(FILE* fp);
465  int ReadQHeader(FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow);
466  int ReadFunctionHeader(FILE* fp, int* nFunctions);
467 
468  void CalculateFileSize(FILE* fp);
469 
470  int AutoDetectionCheck(FILE* fp);
471 
472  void AssignAttribute(int fNumber, vtkStructuredGrid* output,
473  int attributeType);
474  void MapFunction(int fNumber, vtkStructuredGrid* output);
475 
477 
481  vtkDataArray* ComputeTemperature(vtkStructuredGrid* output);
482  vtkDataArray* ComputePressure(vtkStructuredGrid* output);
483  vtkDataArray* ComputeEnthalpy(vtkStructuredGrid* output);
484  vtkDataArray* ComputeKineticEnergy(vtkStructuredGrid* output);
485  vtkDataArray* ComputeVelocityMagnitude(vtkStructuredGrid* output);
486  vtkDataArray* ComputeEntropy(vtkStructuredGrid* output);
487  vtkDataArray* ComputeSwirl(vtkStructuredGrid* output);
488  vtkDataArray* ComputeVelocity(vtkStructuredGrid* output);
489  vtkDataArray* ComputeVorticity(vtkStructuredGrid* output);
490  vtkDataArray* ComputePressureGradient(vtkStructuredGrid* output);
491  vtkDataArray* ComputePressureCoefficient(vtkStructuredGrid* output);
492  vtkDataArray* ComputeMachNumber(vtkStructuredGrid* output);
493  vtkDataArray* ComputeSoundSpeed(vtkStructuredGrid* output);
494  vtkDataArray* ComputeVorticityMagnitude(vtkStructuredGrid* output);
495  vtkDataArray* ComputeStrainRate(vtkStructuredGrid* output);
497 
498  // Returns a vtkFloatArray or a vtkDoubleArray depending
499  // on DoublePrecision setting
500  vtkDataArray* NewFloatArray();
501 
502  // Delete references to any existing vtkPoints and
503  // I-blank arrays. The next Update() will (re)read
504  // the XYZ file.
505  void ClearGeometryCache();
506 
507  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
508 
509  //plot3d FileNames
510  char *XYZFileName;
511  char *QFileName;
513 
523 
525 
526  size_t FileSize;
527 
528  //parameters used in computing derived functions
529  double R;
530  double Gamma;
531  double GammaInf;
532 
534 
535  //named functions from meta data
536  std::vector<std::string> FunctionNames;
537 
538  //functions to read that are not scalars or vectors
540 
543 
544  int FillOutputPortInformation(int port, vtkInformation* info) override;
545 
547 
549 
550 private:
552  void operator=(const vtkMultiBlockPLOT3DReader&) = delete;
553 
554  // Key used to flag intermediate results.
555  static vtkInformationIntegerKey* INTERMEDIATE_RESULT();
556 
560  void RemoveIntermediateFunctions(vtkDataSetAttributes* dsa);
561 };
562 
563 #endif
void AddFunctionName(const std::string &name)
void SetFileName(const char *name)
Set/Get the PLOT3D geometry filename.
Store vtkAlgorithm input/output information.
const char * GetFileName(int i)
Set/Get the PLOT3D geometry filename.
vtkMultiProcessController * Controller
int vtkIdType
Definition: vtkType.h:347
int vtkTypeBool
Definition: vtkABI.h:69
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:45
std::vector< std::string > FunctionNames
a simple class to control print indentation
Definition: vtkIndent.h:39
Key for integer values in vtkInformation.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
vtkMultiBlockPLOT3DReaderInternals * Internal
Superclass for algorithms that are parallel aware.
represent and manipulate attribute data in a dataset
dynamic, self-adjusting array of unsigned char
topologically regular array of data
Composite dataset that organizes datasets into blocks.
const char * GetFileName(int i) const
Returns a particular filename stored by the reader.
const char * GetFileName()
Set/Get the PLOT3D geometry filename.
general representation of visualization data
Definition: vtkDataObject.h:64
Multiprocessing communication superclass.