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 =========================================================================*/
92 #ifndef vtkMultiBlockPLOT3DReader_h
93 #define vtkMultiBlockPLOT3DReader_h
94 
95 #include <vector> // For holding function-names
96 #include "vtkIOParallelModule.h" // For export macro
98 
99 class vtkDataArray;
101 class vtkIntArray;
104 class vtkStructuredGrid;
107 
108 namespace Functors
109 {
110  class ComputeFunctor;
111  class ComputeTemperatureFunctor;
112  class ComputePressureFunctor;
113  class ComputePressureCoefficientFunctor;
114  class ComputeMachNumberFunctor;
115  class ComputeSoundSpeedFunctor;
116  class ComputeEnthalpyFunctor;
117  class ComputeKinecticEnergyFunctor;
118  class ComputeVelocityMagnitudeFunctor;
119  class ComputeEntropyFunctor;
120  class ComputeSwirlFunctor;
121  class ComputeVelocityFunctor;
122  class ComputeVorticityMagnitudeFunctor;
123  class ComputePressureGradientFunctor;
124  class ComputeVorticityFunctor;
125  class ComputeStrainRateFunctor;
126 }
127 
128 
129 class VTKIOPARALLEL_EXPORT vtkMultiBlockPLOT3DReader : public vtkMultiBlockDataSetAlgorithm
130 {
131 friend class Functors::ComputeFunctor;
132 friend class Functors::ComputeTemperatureFunctor;
133 friend class Functors::ComputePressureFunctor;
134 friend class Functors::ComputePressureCoefficientFunctor;
135 friend class Functors::ComputeMachNumberFunctor;
136 friend class Functors::ComputeSoundSpeedFunctor;
137 friend class Functors::ComputeEnthalpyFunctor;
138 friend class Functors::ComputeKinecticEnergyFunctor;
139 friend class Functors::ComputeVelocityMagnitudeFunctor;
140 friend class Functors::ComputeEntropyFunctor;
141 friend class Functors::ComputeSwirlFunctor;
142 friend class Functors::ComputeVelocityFunctor;
143 friend class Functors::ComputeVorticityMagnitudeFunctor;
144 friend class Functors::ComputePressureGradientFunctor;
145 friend class Functors::ComputeVorticityFunctor;
146 friend class Functors::ComputeStrainRateFunctor;
147 public:
148  static vtkMultiBlockPLOT3DReader *New();
150  void PrintSelf(ostream& os, vtkIndent indent) override;
151 
153 
156  void SetFileName(const char* name) { this->SetXYZFileName(name); }
157  const char* GetFileName() { return this->GetXYZFileName(); }
158  virtual void SetXYZFileName( const char* );
159  vtkGetStringMacro(XYZFileName);
161 
163 
166  vtkSetStringMacro(QFileName);
167  vtkGetStringMacro(QFileName);
169 
171 
174  vtkSetStringMacro(FunctionFileName);
175  vtkGetStringMacro(FunctionFileName);
177 
179 
189  vtkSetMacro(AutoDetectFormat, vtkTypeBool);
190  vtkGetMacro(AutoDetectFormat, vtkTypeBool);
191  vtkBooleanMacro(AutoDetectFormat, vtkTypeBool);
193 
195 
199  vtkSetMacro(BinaryFile, vtkTypeBool);
200  vtkGetMacro(BinaryFile, vtkTypeBool);
201  vtkBooleanMacro(BinaryFile, vtkTypeBool);
203 
205 
211  vtkSetMacro(MultiGrid, vtkTypeBool);
212  vtkGetMacro(MultiGrid, vtkTypeBool);
213  vtkBooleanMacro(MultiGrid, vtkTypeBool);
215 
217 
222  vtkSetMacro(HasByteCount, vtkTypeBool);
223  vtkGetMacro(HasByteCount, vtkTypeBool);
224  vtkBooleanMacro(HasByteCount, vtkTypeBool);
226 
228 
233  vtkSetMacro(IBlanking, vtkTypeBool);
234  vtkGetMacro(IBlanking, vtkTypeBool);
235  vtkBooleanMacro(IBlanking, vtkTypeBool);
237 
239 
243  vtkSetMacro(TwoDimensionalGeometry, vtkTypeBool);
244  vtkGetMacro(TwoDimensionalGeometry, vtkTypeBool);
245  vtkBooleanMacro(TwoDimensionalGeometry, vtkTypeBool);
247 
249 
254  vtkSetMacro(DoublePrecision, vtkTypeBool);
255  vtkGetMacro(DoublePrecision, vtkTypeBool);
256  vtkBooleanMacro(DoublePrecision, vtkTypeBool);
258 
260 
266  vtkSetMacro(ForceRead, vtkTypeBool);
267  vtkGetMacro(ForceRead, vtkTypeBool);
268  vtkBooleanMacro(ForceRead, vtkTypeBool);
270 
272 
278  void SetByteOrderToBigEndian();
279  void SetByteOrderToLittleEndian();
280  vtkSetMacro(ByteOrder, int);
281  vtkGetMacro(ByteOrder, int);
282  const char *GetByteOrderAsString();
284 
286 
289  vtkSetMacro(R,double);
290  vtkGetMacro(R,double);
292 
294 
297  vtkSetMacro(Gamma,double);
298  vtkGetMacro(Gamma,double);
300 
302 
310  vtkSetMacro(PreserveIntermediateFunctions, bool);
311  vtkGetMacro(PreserveIntermediateFunctions, bool);
312  vtkBooleanMacro(PreserveIntermediateFunctions, bool);
313 
315 
319  void SetScalarFunctionNumber(int num);
320  vtkGetMacro(ScalarFunctionNumber,int);
322 
324 
328  void SetVectorFunctionNumber(int num);
329  vtkGetMacro(VectorFunctionNumber,int);
331 
333 
338  void AddFunction(int functionNumber);
339  void RemoveFunction(int);
340  void RemoveAllFunctions();
342 
347  virtual int CanReadBinaryFile(const char* fname);
348 
350 
354  void SetController(vtkMultiProcessController *c);
355  vtkGetObjectMacro(Controller, vtkMultiProcessController);
357 
358  void AddFunctionName(const std::string &name) {FunctionNames.push_back(name);}
359 
360  enum
361  {
362  FILE_BIG_ENDIAN=0,
363  FILE_LITTLE_ENDIAN=1
364  };
365 
366 protected:
368  ~vtkMultiBlockPLOT3DReader() override;
369 
370  vtkDataArray* CreateFloatArray();
371 
372  int CheckFile(FILE*& fp, const char* fname);
373  int CheckGeometryFile(FILE*& xyzFp);
374  int CheckSolutionFile(FILE*& qFp);
375  int CheckFunctionFile(FILE*& fFp);
376 
377  int GetByteCountSize();
378  int SkipByteCount (FILE* fp);
379  int ReadIntBlock (FILE* fp, int n, int* block);
380 
381  vtkIdType ReadValues(
382  FILE* fp,
383  int n,
384  vtkDataArray* scalar);
385  virtual int ReadIntScalar(
386  void* vfp,
387  int extent[6], int wextent[6],
388  vtkDataArray* scalar, vtkTypeUInt64 offset,
389  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
390  virtual int ReadScalar(
391  void* vfp,
392  int extent[6], int wextent[6],
393  vtkDataArray* scalar, vtkTypeUInt64 offset,
394  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
395  virtual int ReadVector(
396  void* vfp,
397  int extent[6], int wextent[6],
398  int numDims, vtkDataArray* vector, vtkTypeUInt64 offset,
399  const vtkMultiBlockPLOT3DReaderRecord& currentRecord);
400  virtual int OpenFileForDataRead(void*& fp, const char* fname);
401  virtual void CloseFile(void* fp);
402 
403  int GetNumberOfBlocksInternal(FILE* xyzFp, int allocate);
404 
405  int ReadGeometryHeader(FILE* fp);
406  int ReadQHeader(FILE* fp, bool checkGrid, int& nq, int& nqc, int& overflow);
407  int ReadFunctionHeader(FILE* fp, int* nFunctions);
408 
409  void CalculateFileSize(FILE* fp);
410 
411  int AutoDetectionCheck(FILE* fp);
412 
413  void AssignAttribute(int fNumber, vtkStructuredGrid* output,
414  int attributeType);
415  void MapFunction(int fNumber, vtkStructuredGrid* output);
416 
418 
422  vtkDataArray* ComputeTemperature(vtkStructuredGrid* output);
423  vtkDataArray* ComputePressure(vtkStructuredGrid* output);
424  vtkDataArray* ComputeEnthalpy(vtkStructuredGrid* output);
425  vtkDataArray* ComputeKineticEnergy(vtkStructuredGrid* output);
426  vtkDataArray* ComputeVelocityMagnitude(vtkStructuredGrid* output);
427  vtkDataArray* ComputeEntropy(vtkStructuredGrid* output);
428  vtkDataArray* ComputeSwirl(vtkStructuredGrid* output);
429  vtkDataArray* ComputeVelocity(vtkStructuredGrid* output);
430  vtkDataArray* ComputeVorticity(vtkStructuredGrid* output);
431  vtkDataArray* ComputePressureGradient(vtkStructuredGrid* output);
432  vtkDataArray* ComputePressureCoefficient(vtkStructuredGrid* output);
433  vtkDataArray* ComputeMachNumber(vtkStructuredGrid* output);
434  vtkDataArray* ComputeSoundSpeed(vtkStructuredGrid* output);
435  vtkDataArray* ComputeVorticityMagnitude(vtkStructuredGrid* output);
436  vtkDataArray* ComputeStrainRate(vtkStructuredGrid* output);
438 
439  // Returns a vtkFloatArray or a vtkDoubleArray depending
440  // on DoublePrecision setting
441  vtkDataArray* NewFloatArray();
442 
443  // Delete references to any existing vtkPoints and
444  // I-blank arrays. The next Update() will (re)read
445  // the XYZ file.
446  void ClearGeometryCache();
447 
448  double GetGamma(vtkIdType idx, vtkDataArray* gamma);
449 
450  //plot3d FileNames
451  char *XYZFileName;
452  char *QFileName;
454 
464 
466 
467  size_t FileSize;
468 
469  //parameters used in computing derived functions
470  double R;
471  double Gamma;
472  double GammaInf;
473 
475 
476  //named functions from meta data
477  std::vector<std::string> FunctionNames;
478 
479  //functions to read that are not scalars or vectors
481 
484 
486 
489  vtkInformationVector*) override;
492  vtkInformationVector*) override;
493 
495 
497 
498 private:
500  void operator=(const vtkMultiBlockPLOT3DReader&) = delete;
501 
502  // Key used to flag intermediate results.
503  static vtkInformationIntegerKey* INTERMEDIATE_RESULT();
504 
508  void RemoveIntermediateFunctions(vtkDataSetAttributes* dsa);
509 };
510 
511 #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: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
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.