VTK  9.2.6
vtkOpenFOAMReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOpenFOAMReader.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 =========================================================================*/
50 #ifndef vtkOpenFOAMReader_h
51 #define vtkOpenFOAMReader_h
52 
53 #include "vtkIOGeometryModule.h" // For export macro
55 
56 class vtkCollection;
57 class vtkCharArray;
59 class vtkDoubleArray;
60 class vtkStdString;
61 class vtkStringArray;
62 
63 class vtkOpenFOAMReaderPrivate;
64 
65 class VTKIOGEOMETRY_EXPORT vtkOpenFOAMReader : public vtkMultiBlockDataSetAlgorithm
66 {
67 public:
68  // Access for implementation class
69  friend class vtkOpenFOAMReaderPrivate;
70 
71  static vtkOpenFOAMReader* New();
73  void PrintSelf(ostream& os, vtkIndent indent) override;
74 
78  int CanReadFile(VTK_FILEPATH const char*);
79 
81 
84  vtkSetFilePathMacro(FileName);
85  vtkGetFilePathMacro(FileName);
87 
92  {
93  return this->GetNumberOfSelectionArrays(this->CellDataArraySelection);
94  }
95 
100  int GetCellArrayStatus(const char* name)
101  {
102  return this->GetSelectionArrayStatus(this->CellDataArraySelection, name);
103  }
104  void SetCellArrayStatus(const char* name, int status)
105  {
106  this->SetSelectionArrayStatus(this->CellDataArraySelection, name, status);
107  }
108 
113  const char* GetCellArrayName(int index)
114  {
115  return this->GetSelectionArrayName(this->CellDataArraySelection, index);
116  }
117 
121  void DisableAllCellArrays() { this->DisableAllSelectionArrays(this->CellDataArraySelection); }
122  void EnableAllCellArrays() { this->EnableAllSelectionArrays(this->CellDataArraySelection); }
123 
128  {
129  return this->GetNumberOfSelectionArrays(this->PointDataArraySelection);
130  }
131 
136  int GetPointArrayStatus(const char* name)
137  {
138  return this->GetSelectionArrayStatus(this->PointDataArraySelection, name);
139  }
140  void SetPointArrayStatus(const char* name, int status)
141  {
142  this->SetSelectionArrayStatus(this->PointDataArraySelection, name, status);
143  }
144 
149  const char* GetPointArrayName(int index)
150  {
151  return this->GetSelectionArrayName(this->PointDataArraySelection, index);
152  }
153 
157  void DisableAllPointArrays() { this->DisableAllSelectionArrays(this->PointDataArraySelection); }
158  void EnableAllPointArrays() { this->EnableAllSelectionArrays(this->PointDataArraySelection); }
159 
164  {
165  return this->GetNumberOfSelectionArrays(this->LagrangianDataArraySelection);
166  }
167 
173  {
174  return this->GetSelectionArrayStatus(this->LagrangianDataArraySelection, name);
175  }
176  void SetLagrangianArrayStatus(const char* name, int status)
177  {
178  this->SetSelectionArrayStatus(this->LagrangianDataArraySelection, name, status);
179  }
180 
185  const char* GetLagrangianArrayName(int index)
186  {
187  return this->GetSelectionArrayName(this->LagrangianDataArraySelection, index);
188  }
189 
194  {
195  this->DisableAllSelectionArrays(this->LagrangianDataArraySelection);
196  }
198  {
199  this->EnableAllSelectionArrays(this->LagrangianDataArraySelection);
200  }
201 
206  {
207  return this->GetNumberOfSelectionArrays(this->PatchDataArraySelection);
208  }
209 
214  int GetPatchArrayStatus(const char* name)
215  {
216  return this->GetSelectionArrayStatus(this->PatchDataArraySelection, name);
217  }
218  void SetPatchArrayStatus(const char* name, int status)
219  {
220  this->SetSelectionArrayStatus(this->PatchDataArraySelection, name, status);
221  }
222 
227  const char* GetPatchArrayName(int index)
228  {
229  return this->GetSelectionArrayName(this->PatchDataArraySelection, index);
230  }
231 
235  void DisableAllPatchArrays() { this->DisableAllSelectionArrays(this->PatchDataArraySelection); }
236  void EnableAllPatchArrays() { this->EnableAllSelectionArrays(this->PatchDataArraySelection); }
237 
239 
242  vtkSetMacro(CreateCellToPoint, vtkTypeBool);
243  vtkGetMacro(CreateCellToPoint, vtkTypeBool);
244  vtkBooleanMacro(CreateCellToPoint, vtkTypeBool);
246 
248 
251  vtkSetMacro(CacheMesh, vtkTypeBool);
252  vtkGetMacro(CacheMesh, vtkTypeBool);
253  vtkBooleanMacro(CacheMesh, vtkTypeBool);
255 
257 
260  vtkSetMacro(DecomposePolyhedra, vtkTypeBool);
261  vtkGetMacro(DecomposePolyhedra, vtkTypeBool);
262  vtkBooleanMacro(DecomposePolyhedra, vtkTypeBool);
264 
265  // Option for reading old binary lagrangian/positions format
267 
273  vtkSetMacro(PositionsIsIn13Format, vtkTypeBool);
274  vtkGetMacro(PositionsIsIn13Format, vtkTypeBool);
275  vtkBooleanMacro(PositionsIsIn13Format, vtkTypeBool);
277 
279 
283  vtkSetMacro(SkipZeroTime, bool);
284  vtkGetMacro(SkipZeroTime, bool);
285  vtkBooleanMacro(SkipZeroTime, bool);
287 
289 
292  vtkSetMacro(ListTimeStepsByControlDict, vtkTypeBool);
293  vtkGetMacro(ListTimeStepsByControlDict, vtkTypeBool);
294  vtkBooleanMacro(ListTimeStepsByControlDict, vtkTypeBool);
296 
298 
301  vtkSetMacro(AddDimensionsToArrayNames, vtkTypeBool);
302  vtkGetMacro(AddDimensionsToArrayNames, vtkTypeBool);
303  vtkBooleanMacro(AddDimensionsToArrayNames, vtkTypeBool);
305 
307 
310  vtkSetMacro(ReadZones, vtkTypeBool);
311  vtkGetMacro(ReadZones, vtkTypeBool);
312  vtkBooleanMacro(ReadZones, vtkTypeBool);
314 
316 
319  virtual void SetUse64BitLabels(bool val);
320  vtkGetMacro(Use64BitLabels, bool);
321  vtkBooleanMacro(Use64BitLabels, bool);
323 
325 
329  vtkGetMacro(CopyDataToCellZones, bool);
330  vtkSetMacro(CopyDataToCellZones, bool);
331  vtkBooleanMacro(CopyDataToCellZones, bool);
333 
335 
340  virtual void SetUse64BitFloats(bool val);
341  vtkGetMacro(Use64BitFloats, bool);
342  vtkBooleanMacro(Use64BitFloats, bool);
344 
345  void SetRefresh()
346  {
347  this->Refresh = true;
348  this->Modified();
349  }
350 
351  void SetParent(vtkOpenFOAMReader* parent) { this->Parent = parent; }
352 
353  int MakeInformationVector(vtkInformationVector*, const vtkStdString& procDirName,
354  vtkStringArray* timeNames = nullptr, vtkDoubleArray* timeValues = nullptr);
355 
356  double GetTimeValue() const;
357  bool SetTimeValue(const double);
358  vtkStringArray* GetTimeNames();
359  vtkDoubleArray* GetTimeValues();
360 
361  int MakeMetaDataAtTimeStep(const bool);
362 
363 protected:
364  // refresh flag
365  bool Refresh;
366 
367  // for creating cell-to-point translated data
369 
370  // for caching mesh
372 
373  // for decomposing polyhedra on-the-fly
375 
376  // for lagrangian/positions without extra data (OF 1.4 - 2.4)
378 
379  // for reading point/face/cell-Zones
381 
382  // Ignore 0/ directory
384 
385  // determine if time directories are listed according to controlDict
387 
388  // add dimensions to array names
390 
391  // Expect label size to be 64-bit integers instead of 32-bit.
393 
394  // Expect float data to be 64-bit floats instead of 32-bit.
395  // Note that vtkFloatArrays may still be used -- this just tells the reader how to
396  // parse the binary data.
398 
399  // The data of internal mesh are copied to cell zones
401 
402  char* FileName;
405 
406  // DataArraySelection for Patch / Region Data
411 
412  // old selection status
417 
418  // preserved old information
429 
430  // paths to Lagrangians
432 
433  // number of reader instances
435  // index of the active reader
437 
439  ~vtkOpenFOAMReader() override;
442 
443  void CreateCasePath(vtkStdString&, vtkStdString&);
444  void SetTimeInformation(vtkInformationVector*, vtkDoubleArray*);
445  void CreateCharArrayFromString(vtkCharArray*, const char*, vtkStdString&);
446  void UpdateStatus();
447  void UpdateProgress(double);
448 
449 private:
450  vtkOpenFOAMReader* Parent;
451 
452  vtkOpenFOAMReader(const vtkOpenFOAMReader&) = delete;
453  void operator=(const vtkOpenFOAMReader&) = delete;
454 
455  int GetNumberOfSelectionArrays(vtkDataArraySelection*);
456  int GetSelectionArrayStatus(vtkDataArraySelection*, const char*);
457  void SetSelectionArrayStatus(vtkDataArraySelection*, const char*, int);
458  const char* GetSelectionArrayName(vtkDataArraySelection*, int);
459  void DisableAllSelectionArrays(vtkDataArraySelection*);
460  void EnableAllSelectionArrays(vtkDataArraySelection*);
461 
462  void AddSelectionNames(vtkDataArraySelection*, vtkStringArray*);
463 
464  // Print some time information (names, current time-step)
465  void PrintTimes(std::ostream& os, vtkIndent indent = vtkIndent(), bool full = false) const;
466 };
467 
468 #endif
int GetCellArrayStatus(const char *name)
Get/Set whether the cell array with the given name is to be read.
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
void SetParent(vtkOpenFOAMReader *parent)
void SetLagrangianArrayStatus(const char *name, int status)
int GetPatchArrayStatus(const char *name)
Get/Set whether the Patch with the given name is to be read.
void SetPointArrayStatus(const char *name, int status)
vtkMTimeType LagrangianSelectionMTimeOld
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
int GetNumberOfCellArrays(void)
Get the number of cell arrays available in the input.
vtkDataArraySelection * LagrangianDataArraySelection
int GetPointArrayStatus(const char *name)
Get/Set whether the point array with the given name is to be read.
vtkMTimeType CellSelectionMTimeOld
const char * GetCellArrayName(int index)
Get the name of the cell array with the given index in the input.
vtkStringArray * LagrangianPaths
vtkDataArraySelection * CellDataArraySelection
a vtkAbstractArray subclass for strings
vtkTypeBool ListTimeStepsByControlDict
const char * GetPatchArrayName(int index)
Get the name of the Patch with the given index in the input.
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
int GetNumberOfLagrangianArrays(void)
Get the number of Lagrangian arrays available in the input.
const char * GetLagrangianArrayName(int index)
Get the name of the Lagrangian array with the given index in the input.
dynamic, self-adjusting array of double
vtkTypeBool CreateCellToPoint
static vtkMultiBlockDataSetAlgorithm * New()
vtkStdString * FileNameOld
int vtkTypeBool
Definition: vtkABI.h:69
void DisableAllCellArrays()
Turn on/off all cell arrays.
dynamic, self-adjusting array of char
Definition: vtkCharArray.h:51
vtkTypeBool AddDimensionsToArrayNames
int GetNumberOfPatchArrays(void)
Get the number of Patches (including Internal Mesh) available in the input.
a simple class to control print indentation
Definition: vtkIndent.h:39
Store on/off settings for data arrays, etc.
vtkDataArraySelection * PointDataArraySelection
reads a dataset in OpenFOAM format
virtual void Modified()
Update the modification time for this object.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkMTimeType PatchSelectionMTimeOld
void DisableAllPatchArrays()
Turn on/off all Patches including the Internal Mesh.
#define VTK_FILEPATH
void DisableAllLagrangianArrays()
Turn on/off all Lagrangian arrays.
const char * GetPointArrayName(int index)
Get the name of the point array with the given index in the input.
void UpdateProgress(double amount)
Update the progress of the process object.
int GetNumberOfPointArrays(void)
Get the number of point arrays available in the input.
create and manipulate ordered lists of objects
Definition: vtkCollection.h:55
vtkTypeBool PositionsIsIn13Format
void SetPatchArrayStatus(const char *name, int status)
vtkCharArray * CasePath
void DisableAllPointArrays()
Turn on/off all point arrays.
int GetLagrangianArrayStatus(const char *name)
Get/Set whether the Lagrangian array with the given name is to be read.
Store zero or more vtkInformation instances.
vtkCollection * Readers
vtkMTimeType PointSelectionMTimeOld
void SetCellArrayStatus(const char *name, int status)
vtkTypeBool DecomposePolyhedra
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
vtkDataArraySelection * PatchDataArraySelection