VTK
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 =========================================================================*/
48 #ifndef vtkOpenFOAMReader_h
49 #define vtkOpenFOAMReader_h
50 
51 #include "vtkIOGeometryModule.h" // For export macro
53 
54 class vtkCollection;
55 class vtkCharArray;
57 class vtkDoubleArray;
58 class vtkStdString;
59 class vtkStringArray;
60 
61 class vtkOpenFOAMReaderPrivate;
62 
63 class VTKIOGEOMETRY_EXPORT vtkOpenFOAMReader : public vtkMultiBlockDataSetAlgorithm
64 {
65 public:
66  static vtkOpenFOAMReader *New();
68  void PrintSelf(ostream &, vtkIndent) override;
69 
73  int CanReadFile(const char *);
74 
76 
79  vtkSetStringMacro(FileName);
80  vtkGetStringMacro(FileName);
82 
87  { return this->GetNumberOfSelectionArrays(this->CellDataArraySelection); }
88 
93  int GetCellArrayStatus(const char *name)
94  { return this->GetSelectionArrayStatus(this->CellDataArraySelection, name); }
95  void SetCellArrayStatus(const char *name, int status)
96  { this->SetSelectionArrayStatus(this->CellDataArraySelection, name, status); }
97 
102  const char *GetCellArrayName(int index)
103  { return this->GetSelectionArrayName(this->CellDataArraySelection, index); }
104 
109  { this->DisableAllSelectionArrays(this->CellDataArraySelection); }
111  { this->EnableAllSelectionArrays(this->CellDataArraySelection); }
112 
117  { return this->GetNumberOfSelectionArrays(this->PointDataArraySelection); }
118 
123  int GetPointArrayStatus(const char *name)
124  { return this->GetSelectionArrayStatus(this->PointDataArraySelection, name); }
125  void SetPointArrayStatus(const char *name, int status)
126  { this->SetSelectionArrayStatus(this->PointDataArraySelection,
127  name, status); }
128 
133  const char *GetPointArrayName(int index)
134  { return this->GetSelectionArrayName(this->PointDataArraySelection, index); }
135 
140  { this->DisableAllSelectionArrays(this->PointDataArraySelection); }
142  { this->EnableAllSelectionArrays(this->PointDataArraySelection); }
143 
148  { return this->GetNumberOfSelectionArrays(
149  this->LagrangianDataArraySelection); }
150 
156  { return this->GetSelectionArrayStatus(this->LagrangianDataArraySelection,
157  name); }
158  void SetLagrangianArrayStatus(const char *name, int status)
159  { this->SetSelectionArrayStatus(this->LagrangianDataArraySelection, name,
160  status); }
161 
166  const char* GetLagrangianArrayName(int index)
167  { return this->GetSelectionArrayName(this->LagrangianDataArraySelection,
168  index); }
169 
174  { this->DisableAllSelectionArrays(this->LagrangianDataArraySelection); }
176  { this->EnableAllSelectionArrays(this->LagrangianDataArraySelection); }
177 
182  { return this->GetNumberOfSelectionArrays(this->PatchDataArraySelection); }
183 
188  int GetPatchArrayStatus(const char *name)
189  { return this->GetSelectionArrayStatus(this->PatchDataArraySelection, name); }
190  void SetPatchArrayStatus(const char *name, int status)
191  { this->SetSelectionArrayStatus(this->PatchDataArraySelection, name,
192  status); }
193 
198  const char *GetPatchArrayName(int index)
199  { return this->GetSelectionArrayName(this->PatchDataArraySelection, index); }
200 
205  { this->DisableAllSelectionArrays(this->PatchDataArraySelection); }
207  { this->EnableAllSelectionArrays(this->PatchDataArraySelection); }
208 
210 
213  vtkSetMacro(CreateCellToPoint, vtkTypeBool);
214  vtkGetMacro(CreateCellToPoint, vtkTypeBool);
215  vtkBooleanMacro(CreateCellToPoint, vtkTypeBool);
217 
219 
222  vtkSetMacro(CacheMesh, vtkTypeBool);
223  vtkGetMacro(CacheMesh, vtkTypeBool);
224  vtkBooleanMacro(CacheMesh, vtkTypeBool);
226 
228 
231  vtkSetMacro(DecomposePolyhedra, vtkTypeBool);
232  vtkGetMacro(DecomposePolyhedra, vtkTypeBool);
233  vtkBooleanMacro(DecomposePolyhedra, vtkTypeBool);
235 
236  // Option for reading old binary lagrangian/positions format
238 
244  vtkSetMacro(PositionsIsIn13Format, vtkTypeBool);
245  vtkGetMacro(PositionsIsIn13Format, vtkTypeBool);
246  vtkBooleanMacro(PositionsIsIn13Format, vtkTypeBool);
248 
250 
254  vtkSetMacro(SkipZeroTime, bool);
255  vtkGetMacro(SkipZeroTime, bool);
256  vtkBooleanMacro(SkipZeroTime, bool);
258 
260 
263  vtkSetMacro(ListTimeStepsByControlDict, vtkTypeBool);
264  vtkGetMacro(ListTimeStepsByControlDict, vtkTypeBool);
265  vtkBooleanMacro(ListTimeStepsByControlDict, vtkTypeBool);
267 
269 
272  vtkSetMacro(AddDimensionsToArrayNames, vtkTypeBool);
273  vtkGetMacro(AddDimensionsToArrayNames, vtkTypeBool);
274  vtkBooleanMacro(AddDimensionsToArrayNames, vtkTypeBool);
276 
278 
281  vtkSetMacro(ReadZones, vtkTypeBool);
282  vtkGetMacro(ReadZones, vtkTypeBool);
283  vtkBooleanMacro(ReadZones, vtkTypeBool);
285 
287 
290  virtual void SetUse64BitLabels(bool val);
291  vtkGetMacro(Use64BitLabels, bool)
292  vtkBooleanMacro(Use64BitLabels, bool)
294 
296 
300  vtkGetMacro(CopyDataToCellZones, bool)
301  vtkSetMacro(CopyDataToCellZones, bool)
302  vtkBooleanMacro(CopyDataToCellZones, bool)
304 
306 
311  virtual void SetUse64BitFloats(bool val);
312  vtkGetMacro(Use64BitFloats, bool)
313  vtkBooleanMacro(Use64BitFloats, bool)
315 
316  void SetRefresh() { this->Refresh = true; this->Modified(); }
317 
318  void SetParent(vtkOpenFOAMReader *parent) { this->Parent = parent; }
319  int MakeInformationVector(vtkInformationVector *, const vtkStdString &);
320  bool SetTimeValue(const double);
321  vtkDoubleArray *GetTimeValues();
322  int MakeMetaDataAtTimeStep(const bool);
323 
324  friend class vtkOpenFOAMReaderPrivate;
325 
326 protected:
327  // refresh flag
328  bool Refresh;
329 
330  // for creating cell-to-point translated data
332 
333  // for caching mesh
335 
336  // for decomposing polyhedra on-the-fly
338 
339  // for lagrangian/positions without extra data (OF 1.4 - 2.4)
341 
342  // for reading point/face/cell-Zones
344 
345  // Ignore 0/ directory
347 
348  // determine if time directories are listed according to controlDict
350 
351  // add dimensions to array names
353 
354  // Expect label size to be 64-bit integers instead of 32-bit.
356 
357  // Expect float data to be 64-bit floats instead of 32-bit.
358  // Note that vtkFloatArrays may still be used -- this just tells the reader how to
359  // parse the binary data.
361 
362  // The data of internal mesh are copied to cell zones
364 
365  char *FileName;
368 
369  // DataArraySelection for Patch / Region Data
374 
375  // old selection status
380 
381  // preserved old information
392 
393  // paths to Lagrangians
395 
396  // number of reader instances
398  // index of the active reader
400 
402  ~vtkOpenFOAMReader() override;
404  vtkInformationVector *) override;
406  vtkInformationVector *) override;
407 
408  void CreateCasePath(vtkStdString &, vtkStdString &);
409  void SetTimeInformation(vtkInformationVector *, vtkDoubleArray *);
410  void CreateCharArrayFromString(vtkCharArray *, const char *, vtkStdString &);
411  void UpdateStatus();
412  void UpdateProgress(double);
413 
414 private:
415  vtkOpenFOAMReader *Parent;
416 
417  vtkOpenFOAMReader(const vtkOpenFOAMReader&) = delete;
418  void operator=(const vtkOpenFOAMReader&) = delete;
419 
420  int GetNumberOfSelectionArrays(vtkDataArraySelection *);
421  int GetSelectionArrayStatus(vtkDataArraySelection *, const char *);
422  void SetSelectionArrayStatus(vtkDataArraySelection *, const char *, int);
423  const char *GetSelectionArrayName(vtkDataArraySelection *, int);
424  void DisableAllSelectionArrays(vtkDataArraySelection *);
425  void EnableAllSelectionArrays(vtkDataArraySelection *);
426 
427  void AddSelectionNames(vtkDataArraySelection *, vtkStringArray *);
428 };
429 
430 #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:40
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:302
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:38
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 for a vtkSource.
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.
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:51
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