VTK  9.4.20241103
EnSightDataSet.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
3
4#ifndef EnSightDataSet_h
5#define EnSightDataSet_h
6
7#include "EnSightFile.h"
8
9#include "vtkSmartPointer.h"
10#include "vtkTransform.h"
11
12#include <string>
13#include <vector>
14
15VTK_ABI_NAMESPACE_BEGIN
18class vtkDataSet;
19class vtkFloatArray;
20class vtkIdTypeArray;
23class vtkStringArray;
25class vtkUniformGrid;
27VTK_ABI_NAMESPACE_END
28
29namespace ensight_gold
30{
31VTK_ABI_NAMESPACE_BEGIN
32
33enum class GridType
34{
35 Unknown,
36 Uniform,
40};
41
43{
45 bool IBlanked = false;
46 bool WithGhost = false;
47 bool HasRange = false;
48};
49
50enum class ElementType
51{
52 Unknown,
53 Point,
54 Bar2,
55 Bar3,
56 Tria3,
57 Tria6,
58 Quad4,
59 Quad8,
60 Tetra4,
61 Tetra10,
64 Penta6,
65 Penta15,
66 Hexa8,
67 Hexa20,
68 NSided,
69 NFaced,
70 GPoint,
71 GBar2,
72 GBar3,
73 GTria3,
74 GTria6,
75 GQuad4,
76 GQuad8,
77 GTetra4,
81 GPenta6,
83 GHexa8,
84 GHexa20,
85 GNSided,
87};
88
90{
91 std::string Name;
92 int NumNodes = 0;
93 // For structured grids only
94 int NumElements = 0;
95 std::vector<int> NumElementsPerType;
96
97 // index into the partitioned dataset collection
98 int PDCIndex = -1;
99
101 : NumElementsPerType(static_cast<int>(ElementType::GNFaced) + 1, 0)
102 {
103 }
104};
105
106using PartInfoMapType = std::map<int, PartInfo>;
107
108enum class VariableType
109{
110 Unknown,
128};
129
131{
133 std::string Name;
134 int Frequency; // only for complex variables
136 EnSightFile ImaginaryFile; // only for complex variables
137 std::vector<float> Constants;
138};
139
145{
146public:
151 bool CheckVersion(const char* casefilename);
152
156 bool ParseCaseFile(const char* casefilename);
157
161 std::vector<double> GetTimeSteps();
162
167 bool outputStructureOnly);
168
173 vtkDataArraySelection* selection, bool outputStructureOnly);
174
179
185 bool GetPartInfo(vtkDataArraySelection* partSelection, vtkDataArraySelection* pointArraySelection,
186 vtkDataArraySelection* cellArraySelection, vtkDataArraySelection* fieldArraySelection,
187 vtkStringArray* partNames);
188
193 vtkDataArraySelection* pointArraySelection, vtkDataArraySelection* cellArraySelection,
194 vtkDataArraySelection* fieldArraySelection);
195
200
205
209 std::vector<double> GetEulerTimeSteps();
210
214 void SetActualTimeValue(double time);
215
219 bool UseStaticMeshCache() const;
220
222
223 /*
224 * Set if this casefile is being read as part of an SOS file. If so, it is expected
225 * that some coordination is handled by the vtkEnSightSOSGoldReader
226 */
227 void SetPartOfSOSFile(bool partOfSOS);
228
247
248private:
249 bool ParseFormatSection();
250 void ParseGeometrySection();
251 void ParseVariableSection();
252 void ParseTimeSection();
253 void ParseFileSection();
254
255 std::string GetFullPath(const std::string& fname);
256 void SetVariableFileFormat();
257 bool IsSectionHeader(std::string line);
258
259 void CreateUniformGridOutput(const GridOptions& opts, vtkUniformGrid* output);
260 void CreateRectilinearGridOutput(const GridOptions& opts, vtkRectilinearGrid* output);
261 void CreateStructuredGridOutput(const GridOptions& opts, vtkStructuredGrid* output);
262 void CreateUnstructuredGridOutput(const GridOptions& opts, vtkUnstructuredGrid* output);
263
264 void PassThroughUniformGrid(const GridOptions& opts, int partId);
265 void PassThroughRectilinearGrid(const GridOptions& opts, int partId);
266 void PassThroughStructuredGrid(const GridOptions& opts, int partId);
267 void PassThroughUnstructuredGrid(const GridOptions& opts, int partId);
268 void PassThroughOptionalSections(const GridOptions& opts, int numPts, int numCells);
269
270 int ReadPartId(EnSightFile& file);
271 void ReadDimensions(bool hasRange, int dimensions[3], int& numPts, int& numCells);
272 void ReadRange(int range[6]);
273 void ReadOptionalValues(int numVals, int* data, std::string sectionName = "");
274 void CheckForOptionalHeader(const std::string& sectionName);
275
276 void ReadCell(
277 ElementType eType, vtkUnstructuredGrid* output, bool padBegin = false, bool padEnd = false);
278 void ReadCell(int cellType, int numNodes, vtkUnstructuredGrid* output, bool padBegin = false,
279 bool padEnd = false);
280 void ReadNSidedSection(int& numElements, vtkUnstructuredGrid* output);
281 void ReadNFacedSection(int& numElements, vtkUnstructuredGrid* output);
282
284
287 void SkipNSidedSection(int& numElements);
288 void SkipNFacedSection(int& numElements);
290
291 void ReadVariableNodes(EnSightFile& file, const std::string& arrayName, int numComponents,
293 bool isComplex = false, bool isReal = true);
294 void ReadVariableMeasuredNodes(EnSightFile& file, const std::string& arrayName, int numComponents,
296 void ReadVariableElements(EnSightFile& file, const std::string& arrayName, int numComponents,
298 bool isComplex = false, bool isReal = true);
299 vtkSmartPointer<vtkFloatArray> ReadVariableArray(
300 EnSightFile& file, const std::string& sectionHeader, vtkIdType numElements, int numComponents);
301 void ReadVariableConstantCase(VariableOptions& var, vtkPartitionedDataSetCollection* output);
302
303 void ProcessNodeIds(int numPts, vtkDataSet* output);
304 void ProcessElementIds(int numCells, vtkDataSet* output);
305
306 void ProcessGhostCells(int numCells, vtkDataSet* output);
307
308 bool CurrentGeometryFileContainsConnectivity();
309
316 bool ReadRigidBodyEulerParameterFile(const std::string& path);
317
321 bool ReadRigidBodyMatrixLines(
322 std::string& line, const std::string& transType, vtkTransform* transform, bool& applyToVectors);
323
327 bool ApplyRigidBodyTransforms(int partId, std::string partName, vtkDataSet* output);
328
329 EnSightFile CaseFile;
330
331 std::string GeometryFileName;
332 EnSightFile GeometryFile;
333
334 bool IsStaticGeometry = false;
335 // indicates that changing geometry is only coordinates, not connectivity
336 bool GeometryChangeCoordsOnly = false;
337
338 // zero based time step that contains the connectivity.
339 // only used when GeometryChangeCoordsOnly == true
340 int GeometryCStep = -1;
341
343
344 std::string MeasuredFileName;
345 EnSightFile MeasuredFile;
346 int MeasuredPartitionId = -1;
347 std::string MeasuredPartName = "measured particles";
348
349 std::vector<std::string> FilePath;
350
351 bool NodeIdsListed = false;
352 bool ElementIdsListed = false;
353
354 PartInfoMapType PartInfoMap;
355 TimeSetInfoMapType TimeSetInfoMap;
356 FileSetInfoMapType FileSetInfoMap;
357 std::vector<double> AllTimeSteps;
358
359 std::vector<VariableOptions> Variables;
360 double ActualTimeValue = 0.0;
361
362 std::string RigidBodyFileName;
363 EnSightFile RigidBodyFile;
364 EnSightFile EETFile;
365 // We support only version 2 of rigid body transform files for only ensight gold files.
366 // For rigid body transforms, we need to track per part:
367 // 1. transforms to be applied before the Euler transformation
368 // 2. Information about which data to use in the Euler Transform file (eet file)
369 // 3. transforms to be applied after the Euler transformation
370 struct PartTransforms
371 {
372 // Pre and post transforms do not change over time
373 // We have to track each transform separately, because some transforms need to be
374 // applied to geometry and vectors, while others should only be applied to the geometry
375 std::vector<vtkSmartPointer<vtkTransform>> PreTransforms;
376 std::vector<bool> PreTransformsApplyToVectors;
377 std::vector<vtkSmartPointer<vtkTransform>> PostTransforms;
378 std::vector<bool> PostTransformsApplyToVectors;
379
380 // EnSight format requires specifying the eet file per part, but according to the user manual
381 // use of different eet files for the same dataset is not actually allowed
382 std::string EETFilename;
383
384 // title is related to, but not necessarily a part name. for instance, if you have 4 wheel parts
385 // there may only be a single "wheel" title that all wheel parts use, applying the same Euler
386 // rotation to all wheels
387 std::string EETTransTitle;
388 };
389
390 // rigid body files allows for using either part names or part Ids to specify
391 // transforms for parts;
392 bool UsePartNamesRB = true;
393
394 // keeps track of all transforms for each part
395 // if UsePartNamesRB == true, the key is the part name
396 // otherwise, the key name is the partId converted to a string
397 std::map<std::string, PartTransforms> RigidBodyTransforms;
398
399 // map time step to the Euler transform for a part
400 using TimeToEulerTransMapType = std::map<double, vtkSmartPointer<vtkTransform>>;
401
402 // map a title to all of its Euler transforms
403 using TitleToTimeStepMapType = std::map<std::string, TimeToEulerTransMapType>;
404
405 TitleToTimeStepMapType EulerTransformsMap;
406
407 // It's possible for an EnSight dataset to not contain transient data, except for the
408 // Euler transforms. In this case, we will populate EulerTimeSteps so we can use it for
409 // time information, instead of the usual time set
410 bool UseEulerTimeSteps = false;
411 std::vector<double> EulerTimeSteps;
412
413 int NumberOfLoadedParts = 0;
414 vtkSmartPointer<vtkStringArray> LoadedPartNames;
415 bool PartOfSOSFile = true;
416};
417
418VTK_ABI_NAMESPACE_END
419} // end namespace ensight_gold
420
421#endif // EnSightDataSet_h
Handles reading a full EnSight Gold dataset.
void SetPartOfSOSFile(bool partOfSOS)
bool ReadRigidBodyGeometryFile()
Read the rigid body file.
bool UseRigidBodyTimeSteps()
Returns true if the time steps specified in the rigid body files should be used.
std::vector< double > GetTimeSteps()
returns a vector containing all time steps in the dataset
vtkDataObjectMeshCache * GetMeshCache()
bool UseStaticMeshCache() const
Returns true if the static mesh cache will be used.
bool ReadMeasuredGeometry(vtkPartitionedDataSetCollection *output, vtkDataArraySelection *selection, bool outputStructureOnly)
Reads Measured Geometry file.
bool CheckVersion(const char *casefilename)
Parses through case file until version information is found.
bool GetPartInfo(vtkDataArraySelection *partSelection, vtkDataArraySelection *pointArraySelection, vtkDataArraySelection *cellArraySelection, vtkDataArraySelection *fieldArraySelection, vtkStringArray *partNames)
Only grabs Part (block) information from the Geometry file to be used in a vtkDataArraySelection to e...
void SetActualTimeValue(double time)
Set the time value to be used in the next read.
bool HasRigidBodyFile()
Returns true if a rigid body file is specified in the case file.
bool ParseCaseFile(const char *casefilename)
Parses all sections of a case file to get information such as filenames.
void SetPDCInfoForLoadedParts(vtkSmartPointer< vtkIdTypeArray > indices, vtkSmartPointer< vtkStringArray > names)
Sets information about parts to be loaded.
bool ReadVariables(vtkPartitionedDataSetCollection *output, vtkDataArraySelection *partSelection, vtkDataArraySelection *pointArraySelection, vtkDataArraySelection *cellArraySelection, vtkDataArraySelection *fieldArraySelection)
Reads Variable file(s)
std::vector< double > GetEulerTimeSteps()
Get the array of time steps from the rigid body files.
bool ReadGeometry(vtkPartitionedDataSetCollection *output, vtkDataArraySelection *selection, bool outputStructureOnly)
Reads Geometry file, caching the data if not transient.
Store on/off settings for data arrays, etc.
vtkDataObjectMeshCache is a class to store and reuse the mesh of a vtkDataSet, while forwarding data ...
abstract class to specify dataset behavior
Definition vtkDataSet.h:166
dynamic, self-adjusting array of float
dynamic, self-adjusting array of vtkIdType
Composite dataset that groups datasets as a collection.
a dataset that is topologically regular with variable spacing in the three coordinate directions
Hold a reference to a vtkObjectBase instance.
a vtkAbstractArray subclass for strings
topologically regular array of data
describes linear transformations via a 4x4 matrix
image data with blanking
dataset represents arbitrary combinations of all possible cell types
std::map< int, std::shared_ptr< TimeSetInfo > > TimeSetInfoMapType
Definition EnSightFile.h:48
std::map< int, PartInfo > PartInfoMapType
std::map< int, std::shared_ptr< FileSetInfo > > FileSetInfoMapType
Definition EnSightFile.h:57
EnSightFile performs processing on a single file, whether it's a case file, geometry,...
Definition EnSightFile.h:64
std::vector< int > NumElementsPerType
std::vector< float > Constants
int vtkIdType
Definition vtkType.h:315