VTK  9.5.20250715
vtkOpenFOAMReader.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
38#ifndef vtkOpenFOAMReader_h
39#define vtkOpenFOAMReader_h
40
41#include "vtkIOGeometryModule.h" // For export macro
43
44#include <mutex> // For std::mutex
45
46VTK_ABI_NAMESPACE_BEGIN
47class vtkCollection;
48class vtkCharArray;
50class vtkDoubleArray;
51class vtkStringArray;
52class vtkTable;
54
55class vtkOpenFOAMReaderPrivate;
56
57#define VTK_OPENFOAM_TIME_PROFILING 0
58
59class VTKIOGEOMETRY_EXPORT vtkOpenFOAMReader : public vtkMultiBlockDataSetAlgorithm
60{
61public:
62 // Access for implementation class
63 friend class vtkOpenFOAMReaderPrivate;
64
67 void PrintSelf(ostream& os, vtkIndent indent) override;
68
72 int CanReadFile(VTK_FILEPATH const char*);
73
75
81
83
90 vtkSetMacro(SequentialProcessing, bool);
91 vtkGetMacro(SequentialProcessing, bool);
92 vtkBooleanMacro(SequentialProcessing, bool);
94
98 vtkGetObjectMacro(CellDataArraySelection, vtkDataArraySelection);
99
104 {
105 return this->GetNumberOfSelectionArrays(this->CellDataArraySelection);
106 }
107
112 int GetCellArrayStatus(const char* name)
113 {
114 return this->GetSelectionArrayStatus(this->CellDataArraySelection, name);
115 }
116 void SetCellArrayStatus(const char* name, int status)
117 {
118 this->SetSelectionArrayStatus(this->CellDataArraySelection, name, status);
119 }
120
125 const char* GetCellArrayName(int index)
126 {
127 return this->GetSelectionArrayName(this->CellDataArraySelection, index);
128 }
129
133 void DisableAllCellArrays() { this->DisableAllSelectionArrays(this->CellDataArraySelection); }
134 void EnableAllCellArrays() { this->EnableAllSelectionArrays(this->CellDataArraySelection); }
135
139 vtkGetObjectMacro(PointDataArraySelection, vtkDataArraySelection);
140
145 {
146 return this->GetNumberOfSelectionArrays(this->PointDataArraySelection);
147 }
148
153 int GetPointArrayStatus(const char* name)
154 {
155 return this->GetSelectionArrayStatus(this->PointDataArraySelection, name);
156 }
157 void SetPointArrayStatus(const char* name, int status)
158 {
159 this->SetSelectionArrayStatus(this->PointDataArraySelection, name, status);
160 }
161
166 const char* GetPointArrayName(int index)
167 {
168 return this->GetSelectionArrayName(this->PointDataArraySelection, index);
169 }
170
174 void DisableAllPointArrays() { this->DisableAllSelectionArrays(this->PointDataArraySelection); }
175 void EnableAllPointArrays() { this->EnableAllSelectionArrays(this->PointDataArraySelection); }
176
180 vtkGetObjectMacro(LagrangianDataArraySelection, vtkDataArraySelection);
181
186 {
187 return this->GetNumberOfSelectionArrays(this->LagrangianDataArraySelection);
188 }
189
194 int GetLagrangianArrayStatus(const char* name)
195 {
196 return this->GetSelectionArrayStatus(this->LagrangianDataArraySelection, name);
197 }
198 void SetLagrangianArrayStatus(const char* name, int status)
199 {
200 this->SetSelectionArrayStatus(this->LagrangianDataArraySelection, name, status);
201 }
202
207 const char* GetLagrangianArrayName(int index)
208 {
209 return this->GetSelectionArrayName(this->LagrangianDataArraySelection, index);
210 }
211
216 {
217 this->DisableAllSelectionArrays(this->LagrangianDataArraySelection);
218 }
220 {
221 this->EnableAllSelectionArrays(this->LagrangianDataArraySelection);
222 }
223
227 vtkGetObjectMacro(PatchDataArraySelection, vtkDataArraySelection);
228
233 {
234 return this->GetNumberOfSelectionArrays(this->PatchDataArraySelection);
235 }
236
241 int GetPatchArrayStatus(const char* name)
242 {
243 return this->GetSelectionArrayStatus(this->PatchDataArraySelection, name);
244 }
245 void SetPatchArrayStatus(const char* name, int status)
246 {
247 this->SetSelectionArrayStatus(this->PatchDataArraySelection, name, status);
248 }
249
254 const char* GetPatchArrayName(int index)
255 {
256 return this->GetSelectionArrayName(this->PatchDataArraySelection, index);
257 }
258
262 void DisableAllPatchArrays() { this->DisableAllSelectionArrays(this->PatchDataArraySelection); }
263 void EnableAllPatchArrays() { this->EnableAllSelectionArrays(this->PatchDataArraySelection); }
264
266
269 vtkSetMacro(CreateCellToPoint, vtkTypeBool);
270 vtkGetMacro(CreateCellToPoint, vtkTypeBool);
271 vtkBooleanMacro(CreateCellToPoint, vtkTypeBool);
273
275
282 vtkSetMacro(SizeAverageCellToPoint, vtkTypeBool);
283 vtkGetMacro(SizeAverageCellToPoint, vtkTypeBool);
284 vtkBooleanMacro(SizeAverageCellToPoint, vtkTypeBool);
286
288
291 vtkSetMacro(CacheMesh, vtkTypeBool);
292 vtkGetMacro(CacheMesh, vtkTypeBool);
293 vtkBooleanMacro(CacheMesh, vtkTypeBool);
295
296 // Option for reading old binary lagrangian/positions format
298
304 vtkSetMacro(PositionsIsIn13Format, vtkTypeBool);
305 vtkGetMacro(PositionsIsIn13Format, vtkTypeBool);
306 vtkBooleanMacro(PositionsIsIn13Format, vtkTypeBool);
308
310
314 vtkSetMacro(SkipZeroTime, bool);
315 vtkGetMacro(SkipZeroTime, bool);
316 vtkBooleanMacro(SkipZeroTime, bool);
318
320
323 vtkSetMacro(ListTimeStepsByControlDict, vtkTypeBool);
324 vtkGetMacro(ListTimeStepsByControlDict, vtkTypeBool);
325 vtkBooleanMacro(ListTimeStepsByControlDict, vtkTypeBool);
327
329
332 vtkSetMacro(AddDimensionsToArrayNames, vtkTypeBool);
333 vtkGetMacro(AddDimensionsToArrayNames, vtkTypeBool);
334 vtkBooleanMacro(AddDimensionsToArrayNames, vtkTypeBool);
336
338
341 vtkSetMacro(ReadZones, vtkTypeBool);
342 vtkGetMacro(ReadZones, vtkTypeBool);
343 vtkBooleanMacro(ReadZones, vtkTypeBool);
345
347
350 virtual void SetUse64BitLabels(bool val);
351 vtkGetMacro(Use64BitLabels, bool);
352 vtkBooleanMacro(Use64BitLabels, bool);
354
356
360 vtkGetMacro(CopyDataToCellZones, bool);
361 vtkSetMacro(CopyDataToCellZones, bool);
362 vtkBooleanMacro(CopyDataToCellZones, bool);
364
366
371 virtual void SetUse64BitFloats(bool val);
372 vtkGetMacro(Use64BitFloats, bool);
373 vtkBooleanMacro(Use64BitFloats, bool);
375
377
382 vtkGetMacro(IgnoreRestartFiles, bool);
383 vtkSetMacro(IgnoreRestartFiles, bool);
384 vtkBooleanMacro(IgnoreRestartFiles, bool);
386
388 {
389 this->Refresh = true;
390 this->Modified();
391 }
392
393 void SetParent(vtkOpenFOAMReader* parent) { this->Parent = parent; }
394
395#ifndef __VTK_WRAP__
397 vtkStringArray* timeNames = nullptr, vtkDoubleArray* timeValues = nullptr,
398 const std::vector<vtkSmartPointer<vtkUnsignedCharArray>>&
399 populateMeshIndicesFileChecksPerPrivateReader = {});
400#endif
401
402 double GetTimeValue() const;
403 bool SetTimeValue(double);
406
407#ifndef __VTK_WRAP__
408 std::vector<vtkSmartPointer<vtkUnsignedCharArray>> GetPopulateMeshIndicesFileChecksPerReader();
409 std::vector<vtkSmartPointer<vtkTable>> GetMarshalledMetadataPerReader();
411#endif
412
413 int MakeMetaDataAtTimeStep(bool listNextTimeStep, bool skipComputingMetaData = false);
414
418 virtual double ComputeProgress();
419
420#if VTK_OPENFOAM_TIME_PROFILING
421 long long GetRequestInformationTimeInMicroseconds() const;
422 long long GetRequestDataTimeInMicroseconds() const;
423 size_t GetRequestInformationBytes() const;
424 size_t GetRequestDataBytes() const;
425 virtual void InitializeRequestInformation();
426 virtual void InitializeRequestData();
427 virtual void PrintRequestInformation();
428 virtual void PrintRequestData();
429#endif
430
431protected:
432 // refresh flag
434
436
437 // for creating cell-to-point translated data
439
440 // for running size average for cell to point calculation
441 vtkTypeBool SizeAverageCellToPoint = false;
442
443 // for caching mesh
445
446 // for decomposing polyhedra on-the-fly
448 vtkGetMacro(DecomposePolyhedra, vtkTypeBool);
449
450 // for lagrangian/positions without extra data (OF 1.4 - 2.4)
452
453 // for reading point/face/cell-Zones
455
456 // Ignore 0/ directory
458
459 // determine if time directories are listed according to controlDict
461
462 // add dimensions to array names
464
465 // Expect label size to be 64-bit integers instead of 32-bit.
467
468 // Expect float data to be 64-bit floats instead of 32-bit.
469 // Note that vtkFloatArrays may still be used -- this just tells the reader how to
470 // parse the binary data.
472
473 // The data of internal mesh are copied to cell zones
475
476 char* FileName;
478 std::vector<vtkSmartPointer<vtkObject>> Readers;
479
480 // DataArraySelection for Patch / Region Data
485
486 // old selection status
488 vtkGetMacro(PatchSelectionMTimeOld, vtkMTimeType);
490 vtkGetMacro(CellSelectionMTimeOld, vtkMTimeType);
492 vtkGetMacro(PointSelectionMTimeOld, vtkMTimeType);
494 vtkGetMacro(LagrangianSelectionMTimeOld, vtkMTimeType);
495
496 // preserved old information
497 std::string FileNameOld;
498 vtkGetMacro(FileNameOld, std::string);
500 vtkGetMacro(SkipZeroTimeOld, bool);
502 vtkGetMacro(ListTimeStepsByControlDictOld, int);
504 vtkGetMacro(CreateCellToPointOld, int);
506 vtkGetMacro(DecomposePolyhedraOld, int);
508 vtkGetMacro(PositionsIsIn13FormatOld, int);
510 vtkGetMacro(AddDimensionsToArrayNamesOld, int);
512 vtkGetMacro(ReadZonesOld, int);
514 vtkGetMacro(Use64BitLabelsOld, bool);
516 vtkGetMacro(Use64BitFloatsOld, bool);
517
522
527 void UpdateProgress(vtkOpenFOAMReaderPrivate* reader, double progress);
528
529private:
530 vtkOpenFOAMReader* Parent;
531
532 vtkOpenFOAMReader(const vtkOpenFOAMReader&) = delete;
533 void operator=(const vtkOpenFOAMReader&) = delete;
534
535 int GetNumberOfSelectionArrays(vtkDataArraySelection*);
536 int GetSelectionArrayStatus(vtkDataArraySelection*, const char*);
537 void SetSelectionArrayStatus(vtkDataArraySelection*, const char*, int);
538 const char* GetSelectionArrayName(vtkDataArraySelection*, int);
539 void DisableAllSelectionArrays(vtkDataArraySelection*);
540 void EnableAllSelectionArrays(vtkDataArraySelection*);
541
542 void AddSelectionNames(vtkDataArraySelection*, vtkStringArray*);
543
544 // Print some time information (names, current time-step)
545 void PrintTimes(std::ostream& os, vtkIndent indent = vtkIndent(), bool full = false) const;
546
547 std::mutex ArraySelectionMutex;
548 std::mutex ProgressMutex;
549
550 // Ignore files with name ending by "_0".
551 bool IgnoreRestartFiles = true;
552
553#if VTK_OPENFOAM_TIME_PROFILING
554 long long RequestInformationTimeInMicroseconds = 0;
555 size_t RequestDataBytes = 0;
556 long long RequestDataTimeInMicroseconds = 0;
557 size_t RequestInformationBytes = 0;
558#endif
559};
560
561VTK_ABI_NAMESPACE_END
562#endif
dynamic, self-adjusting array of char
create and manipulate ordered lists of objects
Store on/off settings for data arrays, etc.
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
virtual void Modified()
Update the modification time for this object.
reads a dataset in OpenFOAM format
void UpdateProgress(vtkOpenFOAMReaderPrivate *reader, double progress)
vtkMTimeType CellSelectionMTimeOld
vtkCharArray * CasePath
std::vector< vtkSmartPointer< vtkUnsignedCharArray > > GetPopulateMeshIndicesFileChecksPerReader()
std::vector< vtkSmartPointer< vtkTable > > GetMarshalledMetadataPerReader()
void SetLagrangianArrayStatus(const char *name, int status)
~vtkOpenFOAMReader() override
vtkTypeBool AddDimensionsToArrayNames
void DisableAllPatchArrays()
Turn on/off all Patches including the Internal Mesh.
bool SetTimeValue(double)
int GetCellArrayStatus(const char *name)
Get/Set whether the cell array with the given name is to be read.
vtkSetFilePathMacro(FileName)
Set/Get the filename.
void SetPatchArrayStatus(const char *name, int status)
vtkDataArraySelection * PointDataArraySelection
vtkMTimeType PatchSelectionMTimeOld
double GetTimeValue() const
vtkDataArraySelection * CellDataArraySelection
vtkTypeBool PositionsIsIn13Format
int GetNumberOfCellArrays()
Get the number of cell arrays available in the input.
void CreateCasePath(vtkStdString &, vtkStdString &)
void DisableAllPointArrays()
Turn on/off all point arrays.
const char * GetLagrangianArrayName(int index)
Get the name of the Lagrangian array with the given index in the input.
int GetNumberOfPointArrays()
Get the number of point arrays available in the input.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetUse64BitLabels(bool val)
If true, labels are expected to be 64-bit, rather than 32.
void CreateCharArrayFromString(vtkCharArray *, const char *, vtkStdString &)
vtkDataArraySelection * PatchDataArraySelection
virtual double ComputeProgress()
Compute the progress of the reader.
const char * GetCellArrayName(int index)
Get the name of the cell array with the given index in the input.
int GetLagrangianArrayStatus(const char *name)
Get/Set whether the Lagrangian array with the given name is to be read.
vtkTypeBool DecomposePolyhedra
void SetMarshalledMetadataPerReader(const std::vector< vtkSmartPointer< vtkTable > > &)
void SetParent(vtkOpenFOAMReader *parent)
vtkTypeBool ListTimeStepsByControlDict
static vtkOpenFOAMReader * New()
int GetNumberOfPatchArrays()
Get the number of Patches (including Internal Mesh) available in the input.
vtkStringArray * GetTimeNames()
vtkMTimeType PointSelectionMTimeOld
vtkGetFilePathMacro(FileName)
Set/Get the filename.
void DisableAllLagrangianArrays()
Turn on/off all Lagrangian arrays.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkDataArraySelection * LagrangianDataArraySelection
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
int GetPatchArrayStatus(const char *name)
Get/Set whether the Patch with the given name is to be read.
int MakeMetaDataAtTimeStep(bool listNextTimeStep, bool skipComputingMetaData=false)
const char * GetPointArrayName(int index)
Get the name of the point array with the given index in the input.
int GetPointArrayStatus(const char *name)
Get/Set whether the point array with the given name is to be read.
const char * GetPatchArrayName(int index)
Get the name of the Patch with the given index in the input.
void DisableAllCellArrays()
Turn on/off all cell arrays.
void SetCellArrayStatus(const char *name, int status)
int MakeInformationVector(vtkInformationVector *, const vtkStdString &procDirName, vtkStringArray *timeNames=nullptr, vtkDoubleArray *timeValues=nullptr, const std::vector< vtkSmartPointer< vtkUnsignedCharArray > > &populateMeshIndicesFileChecksPerPrivateReader={})
virtual void SetUse64BitFloats(bool val)
If true, floats are expected to be 64-bit, rather than 32.
void SetTimeInformation(vtkInformationVector *, vtkDoubleArray *)
vtkTypeBool CreateCellToPoint
vtkMTimeType LagrangianSelectionMTimeOld
int CanReadFile(const char *)
Determine if the file can be read with this reader.
std::vector< vtkSmartPointer< vtkObject > > Readers
void SetPointArrayStatus(const char *name, int status)
vtkDoubleArray * GetTimeValues()
int GetNumberOfLagrangianArrays()
Get the number of Lagrangian arrays available in the input.
Hold a reference to a vtkObjectBase instance.
Wrapper around std::string to keep symbols short.
a vtkAbstractArray subclass for strings
A table, which contains similar-typed columns of data.
Definition vtkTable.h:169
dynamic, self-adjusting array of unsigned char
int vtkTypeBool
Definition vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287
#define VTK_FILEPATH