VTK  9.7.1
vtkFLUENTCFFReader.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 vtkFLUENTCFFReader_h
39 #define vtkFLUENTCFFReader_h
40 
41 #include <map> // std::map
42 #include <memory> // std::unique_ptr
43 
44 #include "vtkIOFLUENTCFFModule.h" // For export macro
45 
47 #include "vtkNew.h" // For vtkNew
48 
49 VTK_ABI_NAMESPACE_BEGIN
52 class vtkPoints;
53 class vtkTriangle;
54 class vtkTetra;
55 class vtkQuad;
56 class vtkHexahedron;
57 class vtkPyramid;
59 class vtkWedge;
60 
61 class VTKIOFLUENTCFF_EXPORT vtkFLUENTCFFReader : public vtkMultiBlockDataSetAlgorithm
62 {
63 public:
64  static vtkFLUENTCFFReader* New();
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
69 
72  vtkSetMacro(FileName, std::string);
73  vtkGetMacro(FileName, std::string);
75 
77 
82  vtkSetMacro(RenameArrays, bool);
83  vtkGetMacro(RenameArrays, bool);
85 
87 
91  vtkGetMacro(NumberOfCells, vtkIdType);
93 
97  int GetNumberOfCellArrays();
98 
103  const char* GetCellArrayName(int index);
104 
106 
110  int GetCellArrayStatus(const char* name);
111  void SetCellArrayStatus(const char* name, int status);
113 
115 
118  void DisableAllCellArrays();
119  void EnableAllCellArrays();
121 
125  int GetNumberOfFaceArrays();
126 
131  const char* GetFaceArrayName(int index);
132 
134 
138  int GetFaceArrayStatus(const char* name);
139  void SetFaceArrayStatus(const char* name, int status);
141 
143 
146  void DisableAllFaceArrays();
147  void EnableAllFaceArrays();
149 
151 
155  vtkSetMacro(ReadFaces, bool);
156  vtkGetMacro(ReadFaces, bool);
157  vtkBooleanMacro(ReadFaces, bool);
159 
163  vtkMTimeType GetMTime() override;
164 
166  //
167  // Structures
168  //
169  struct Cell
170  {
171  int type;
172  int zone;
173  std::vector<int> faces;
174  int parent;
175  int child;
176  std::vector<int> nodes;
177  std::vector<int> nodesOffset;
178  std::vector<int> childId;
179  };
180  struct Face
181  {
182  int type;
183  unsigned int zone;
184  std::vector<int> nodes;
185  int c0;
186  int c1;
188  int parent;
189  int child;
193  int ncgChild;
194  };
196 
197 protected:
199  ~vtkFLUENTCFFReader() override;
202 
207  {
208  NOT_LOADED = 0,
209  AVAILABLE = 1,
210  LOADED = 2,
211  ERROR = 3
212  };
213 
215 
218  virtual bool OpenCaseFile(const std::string& filename);
219  virtual DataState OpenDataFile(const std::string& filename);
221 
225  virtual void GetNumberOfCellZones();
226 
230  virtual int ParseCaseFile();
231 
235  virtual int GetDimension();
236 
238 
241  virtual void GetNodesGlobal();
242  virtual void GetCellsGlobal();
243  virtual void GetFacesGlobal();
245 
249  virtual void GetNodes();
250 
254  virtual void GetCells();
255 
259  virtual void GetFaces();
260 
265  virtual void GetPeriodicShadowFaces();
266 
271  virtual void GetCellOverset();
272 
276  virtual void GetCellTree();
277 
281  virtual void GetFaceTree();
282 
286  virtual void GetInterfaceFaceParents();
287 
292  virtual void GetNonconformalGridInterfaceFaceInformation();
293 
297  virtual void CleanCells();
298 
300 
304  virtual void PopulateCellNodes();
305  virtual void PopulateCellTree();
307 
309 
312  virtual void PopulateTriangleCell(int i);
313  virtual void PopulateTetraCell(int i);
314  virtual void PopulateQuadCell(int i);
315  virtual void PopulateHexahedronCell(int i);
316  virtual void PopulatePyramidCell(int i);
317  virtual void PopulateWedgeCell(int i);
318  virtual void PopulatePolyhedronCell(int i);
320 
324  virtual int GetData();
325 
329  virtual int GetMetaData();
330 
331  //
332  // Variables
333  //
336  bool RenameArrays = false;
337  vtkIdType NumberOfCells = 0;
338  int NumberOfCellArrays = 0;
339 
340  struct vtkInternals;
341  std::unique_ptr<vtkInternals> HDFImpl;
342 
350 
351  std::vector<Cell> Cells;
352  std::vector<Face> Faces;
353  std::vector<int> CellZones;
354 
355  vtkTypeBool SwapBytes = 0;
356  int GridDimension = 0;
357  DataState FileState = DataState::NOT_LOADED;
358 
359 private:
360  vtkFLUENTCFFReader(const vtkFLUENTCFFReader&) = delete;
361  void operator=(const vtkFLUENTCFFReader&) = delete;
362 
363  struct FaceZone
364  {
366  int minId;
367  int maxId;
368  int zoneType;
369  };
370 
371  struct DataChunk
372  {
373  std::string variableName;
374  vtkIdType zoneId;
375  size_t dim;
376  std::vector<double> dataVector;
377  };
378 
379  typedef long long hid_t;
380  void ReadFieldMetaData(hid_t parentGroup, int iphase, std::vector<std::string>& container);
381 
385  void ParseUDMData(
386  std::vector<vtkSmartPointer<vtkUnstructuredGrid>>& grid, const DataChunk& vectorDataChunk);
387 
391  void CreateFaces(vtkMultiBlockDataSet* output);
392 
398  void FillDataArrayForFaceZone(const FaceZone& zone, vtkUnstructuredGrid* faceGrid,
399  const std::map<unsigned int, vtkIdType>& faceIdToLocalIndex);
400 
401  std::vector<DataChunk> DataChunks;
402  std::vector<std::string> PreReadData;
403  std::vector<std::string> PreReadFaceData;
404  int NumberOfArrays = 0;
405 
406  std::map<int, FaceZone> FaceZonesById;
407 
408  vtkNew<vtkDataArraySelection> FaceDataArraySelection;
409  bool ReadFaces = false;
410 };
411 VTK_ABI_NAMESPACE_END
412 #endif
vtkNew< vtkPoints > Points
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
a 3D cell that represents a linear pyramid
Definition: vtkPyramid.h:35
std::vector< int > nodesOffset
std::vector< int > childId
std::unique_ptr< vtkInternals > HDFImpl
a cell that represents a 2D quadrilateral
Definition: vtkQuad.h:27
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:23
int vtkIdType
Definition: vtkType.h:363
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
std::vector< Cell > Cells
static vtkMultiBlockDataSetAlgorithm * New()
int vtkTypeBool
Definition: vtkABI.h:64
a 3D cell that represents a tetrahedron
Definition: vtkTetra.h:33
vtkNew< vtkHexahedron > Hexahedron
int64_t hid_t
Definition: vtkHDFWriter.h:63
reads a dataset in Fluent CFF file format
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkNew< vtkTriangle > Triangle
Store on/off settings for data arrays, etc.
dataset represents arbitrary combinations of all possible cell types
virtual vtkMTimeType GetMTime()
Return this object's modified time.
vtkNew< vtkDataArraySelection > CellDataArraySelection
a cell that represents a linear 3D hexahedron
Definition: vtkHexahedron.h:33
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSmartPointer< vtkDataArray > GetData(const Ioss::GroupingEntity *entity, const std::string &fieldname, Ioss::Transform *transform=nullptr, Cache *cache=nullptr, const std::string &cachekey=std::string())
Returns a VTK array for a given field (fieldname) on the chosen block (or set) entity.
vtkNew< vtkPyramid > Pyramid
std::vector< Face > Faces
vtkNew< vtkTetra > Tetra
std::vector< int > CellZones
a cell that represents a triangle
Definition: vtkTriangle.h:27
Composite dataset that organizes datasets into blocks.
Store zero or more vtkInformation instances.
vtkNew< vtkQuad > Quad
a 3D cell that represents a linear wedge
Definition: vtkWedge.h:35
represent and manipulate 3D points
Definition: vtkPoints.h:30
vtkNew< vtkWedge > Wedge
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.