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 =========================================================================*/
86 #ifndef vtkMultiBlockPLOT3DReader_h
87 #define vtkMultiBlockPLOT3DReader_h
88 
89 #include <vector> // For holding function-names
90 #include "vtkIOParallelModule.h" // For export macro
92 
93 class vtkDataArray;
95 class vtkIntArray;
98 class vtkStructuredGrid;
101 
102 namespace Functors
103 {
104  class ComputeFunctor;
105  class ComputeTemperatureFunctor;
106  class ComputePressureFunctor;
107  class ComputePressureCoefficientFunctor;
108  class ComputeMachNumberFunctor;
109  class ComputeSoundSpeedFunctor;
110  class ComputeEnthalpyFunctor;
111  class ComputeKinecticEnergyFunctor;
112  class ComputeVelocityMagnitudeFunctor;
113  class ComputeEntropyFunctor;
114  class ComputeSwirlFunctor;
115  class ComputeVelocityFunctor;
116  class ComputeVorticityMagnitudeFunctor;
117  class ComputePressureGradientFunctor;
118  class ComputeVorticityFunctor;
119  class ComputeStrainRateFunctor;
120 }
121 
122 
123 class VTKIOPARALLEL_EXPORT vtkMultiBlockPLOT3DReader : public vtkMultiBlockDataSetAlgorithm
124 {
125 friend class Functors::ComputeFunctor;
126 friend class Functors::ComputeTemperatureFunctor;
127 friend class Functors::ComputePressureFunctor;
128 friend class Functors::ComputePressureCoefficientFunctor;
129 friend class Functors::ComputeMachNumberFunctor;
130 friend class Functors::ComputeSoundSpeedFunctor;
131 friend class Functors::ComputeEnthalpyFunctor;
132 friend class Functors::ComputeKinecticEnergyFunctor;
133 friend class Functors::ComputeVelocityMagnitudeFunctor;
134 friend class Functors::ComputeEntropyFunctor;
135 friend class Functors::ComputeSwirlFunctor;
136 friend class Functors::ComputeVelocityFunctor;
137 friend class Functors::ComputeVorticityMagnitudeFunctor;
138 friend class Functors::ComputePressureGradientFunctor;
139 friend class Functors::ComputeVorticityFunctor;
140 friend class Functors::ComputeStrainRateFunctor;
141 public:
142  static vtkMultiBlockPLOT3DReader *New();
144  void PrintSelf(ostream& os, vtkIndent indent) override;
145 
147 
150  void SetFileName(const char* name) { this->SetXYZFileName(name); }
151  const char* GetFileName() { return this->GetXYZFileName(); }
152  virtual void SetXYZFileName( const char* );
153  vtkGetStringMacro(XYZFileName);
155 
157 
160  vtkSetStringMacro(QFileName);
161  vtkGetStringMacro(QFileName);
163 
165 
168  vtkSetStringMacro(FunctionFileName);
169  vtkGetStringMacro(FunctionFileName);
171 
173 
183  vtkSetMacro(AutoDetectFormat, vtkTypeBool);
184  vtkGetMacro(AutoDetectFormat, vtkTypeBool);
185  vtkBooleanMacro(AutoDetectFormat, vtkTypeBool);
187 
189 
193  vtkSetMacro(BinaryFile, vtkTypeBool);
194  vtkGetMacro(BinaryFile, vtkTypeBool);
195  vtkBooleanMacro(BinaryFile, vtkTypeBool);
197 
199 
205  vtkSetMacro(MultiGrid, vtkTypeBool);
206  vtkGetMacro(MultiGrid, vtkTypeBool);
207  vtkBooleanMacro(MultiGrid, vtkTypeBool);
209 
211 
216  vtkSetMacro(HasByteCount, vtkTypeBool);
217  vtkGetMacro(HasByteCount, vtkTypeBool);
218  vtkBooleanMacro(HasByteCount, vtkTypeBool);
220 
222 
227  vtkSetMacro(IBlanking, vtkTypeBool);
228  vtkGetMacro(IBlanking, vtkTypeBool);
229  vtkBooleanMacro(IBlanking, vtkTypeBool);
231 
233 
237  vtkSetMacro(TwoDimensionalGeometry, vtkTypeBool);
238  vtkGetMacro(TwoDimensionalGeometry, vtkTypeBool);
239  vtkBooleanMacro(TwoDimensionalGeometry, vtkTypeBool);
241 
243 
248  vtkSetMacro(DoublePrecision, vtkTypeBool);
249  vtkGetMacro(DoublePrecision, vtkTypeBool);
250  vtkBooleanMacro(DoublePrecision, vtkTypeBool);
252 
254 
260  vtkSetMacro(ForceRead, vtkTypeBool);
261  vtkGetMacro(ForceRead, vtkTypeBool);
262  vtkBooleanMacro(ForceRead, vtkTypeBool);
264 
266 
272  void SetByteOrderToBigEndian();
273  void SetByteOrderToLittleEndian();
274  vtkSetMacro(ByteOrder, int);
275  vtkGetMacro(ByteOrder, int);
276  const char *GetByteOrderAsString();
278 
280 
283  vtkSetMacro(R,double);
284  vtkGetMacro(R,double);
286 
288 
291  vtkSetMacro(Gamma,double);
292  vtkGetMacro(Gamma,double);
294 
296 
304  vtkSetMacro(PreserveIntermediateFunctions, bool);
305  vtkGetMacro(PreserveIntermediateFunctions, bool);
306  vtkBooleanMacro(PreserveIntermediateFunctions, bool);
307 
309 
313  void SetScalarFunctionNumber(int num);
314  vtkGetMacro(ScalarFunctionNumber,int);
316 
318 
322  void SetVectorFunctionNumber(int num);
323  vtkGetMacro(VectorFunctionNumber,int);
325 
327 
332  void AddFunction(int functionNumber);
333  void RemoveFunction(int);
334  void RemoveAllFunctions();
336 
341  virtual int CanReadBinaryFile(const char* fname);
342 
344 
348  void SetController(vtkMultiProcessController *c);
349  vtkGetObjectMacro(Controller, vtkMultiProcessController);
351 
352  void AddFunctionName(const std::string &name) {FunctionNames.push_back(name);}
353 
354  enum
355  {
356  FILE_BIG_ENDIAN=0,
357  FILE_LITTLE_ENDIAN=1
358  };
359 
360 protected:
362  ~vtkMultiBlockPLOT3DReader() override;
363 
364  vtkDataArray* CreateFloatArray();
365 
366  int CheckFile(FILE*& fp, const char* fname);
367  int CheckGeometryFile(FILE*& xyzFp);
368  int CheckSolutionFile(FILE*& qFp);
369  int CheckFunctionFile(FILE*& fFp);
370 
371  int GetByteCountSize();
372  int SkipByteCount (FILE* fp);
373  int ReadIntBlock (FILE* fp, int n, int* block);
374 
375  vtkIdType ReadValues(
376  FILE* fp,
377  int n,
378  vtkDataArray* scalar);
379  virtual int ReadIntScalar(
380  void* vfp,
381  int extent[6], int wextent[6],
382  vtkDataArray* scalar, vtkTypeUInt64 offset,
383  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
384  virtual int ReadScalar(
385  void* vfp,
386  int extent[6], int wextent[6],
387  vtkDataArray* scalar, vtkTypeUInt64 offset,
388  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
389  virtual int ReadVector(
390  void* vfp,
391  int extent[6], int wextent[6],
392  int numDims, vtkDataArray* vector, vtkTypeUInt64 offset,
393  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
394  virtual int OpenFileForDataRead(void*& fp, const char* fname);
395  virtual void CloseFile(void* fp);
396 
397  int GetNumberOfBlocksInternal(FILE* xyzFp, int allocate);
398 
399  int ReadGeometryHeader(FILE* fp);
400  int ReadQHeader(FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow);
401  int ReadFunctionHeader(FILE* fp, int* nFunctions);
402 
403  void CalculateFileSize(FILE* fp);
404 
405  int AutoDetectionCheck(FILE* fp);
406 
407  void AssignAttribute(int fNumber, vtkStructuredGrid* output,
408  int attributeType);
409  void MapFunction(int fNumber, vtkStructuredGrid* output);
410 
412 
416  vtkDataArray* ComputeTemperature(vtkStructuredGrid* output);
417  vtkDataArray* ComputePressure(vtkStructuredGrid* output);
418  vtkDataArray* ComputeEnthalpy(vtkStructuredGrid* output);
419  vtkDataArray* ComputeKineticEnergy(vtkStructuredGrid* output);
420  vtkDataArray* ComputeVelocityMagnitude(vtkStructuredGrid* output);
421  vtkDataArray* ComputeEntropy(vtkStructuredGrid* output);
422  vtkDataArray* ComputeSwirl(vtkStructuredGrid* output);
423  vtkDataArray* ComputeVelocity(vtkStructuredGrid* output);
424  vtkDataArray* ComputeVorticity(vtkStructuredGrid* output);
425  vtkDataArray* ComputePressureGradient(vtkStructuredGrid* output);
426  vtkDataArray* ComputePressureCoefficient(vtkStructuredGrid* output);
427  vtkDataArray* ComputeMachNumber(vtkStructuredGrid* output);
428  vtkDataArray* ComputeSoundSpeed(vtkStructuredGrid* output);
429  vtkDataArray* ComputeVorticityMagnitude(vtkStructuredGrid* output);
430  vtkDataArray* ComputeStrainRate(vtkStructuredGrid* output);
432 
433  // Returns a vtkFloatArray or a vtkDoubleArray depending
434  // on DoublePrecision setting
435  vtkDataArray* NewFloatArray();
436 
437  // Delete references to any existing vtkPoints and
438  // I-blank arrays. The next Update() will (re)read
439  // the XYZ file.
440  void ClearGeometryCache();
441 
442  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
443 
444  //plot3d FileNames
445  char *XYZFileName;
446  char *QFileName;
448 
458 
460 
461  size_t FileSize;
462 
463  //parameters used in computing derived functions
464  double R;
465  double Gamma;
466  double GammaInf;
467 
469 
470  //named functions from meta data
471  std::vector<std::string> FunctionNames;
472 
473  //functions to read that are not scalars or vectors
475 
478 
480 
483  vtkInformationVector*) override;
486  vtkInformationVector*) override;
487 
489 
491 
492 private:
494  void operator=(const vtkMultiBlockPLOT3DReader&) = delete;
495 
496  // Key used to flag intermediate results.
497  static vtkInformationIntegerKey* INTERMEDIATE_RESULT();
498 
502  void RemoveIntermediateFunctions(vtkDataSetAttributes* dsa);
503 };
504 
505 #endif
void AddFunctionName(const std::string &name)
void SetFileName(const char *name)
Set/Get the PLOT3D geometry filename.
Store vtkAlgorithm input/output information.
vtkMultiProcessController * Controller
int vtkIdType
Definition: vtkType.h:345
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
int FillOutputPortInformation(int port, vtkInformation *info) override
Fill the output port information objects for this algorithm.
static vtkMultiBlockDataSetAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:69
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
std::vector< std::string > FunctionNames
a simple class to control print indentation
Definition: vtkIndent.h:33
Key for integer values in vtkInformation.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
vtkMultiBlockPLOT3DReaderInternals * Internal
represent and manipulate attribute data in a dataset
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
dynamic, self-adjusting array of unsigned char
topologically regular array of data
Store zero or more vtkInformation instances.
const char * GetFileName()
Set/Get the PLOT3D geometry filename.
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
Multiprocessing communication superclass.