VTK  9.3.1
vtkLSDynaPartCollection.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 vtkLSDynaPartCollection_h
5 #define vtkLSDynaPartCollection_h
6 
7 #include "LSDynaMetaData.h" //needed for LSDynaMetaData::LSDYNA_TYPES enum
8 #include "vtkIOLSDynaModule.h" // For export macro
9 #include "vtkObject.h"
10 
11 VTK_ABI_NAMESPACE_BEGIN
12 class vtkDataArray;
14 class vtkPoints;
16 class vtkLSDynaPart;
17 
18 class VTKIOLSDYNA_EXPORT vtkLSDynaPartCollection : public vtkObject
19 {
20 public:
21  class LSDynaPart;
22  static vtkLSDynaPartCollection* New();
23 
25  void PrintSelf(ostream& os, vtkIndent indent) override;
26 
27  // Description:
28  // Pass in the metadata to setup this collection.
29  // The optional min and max cell Id are used when in parallel to load balance the nodes.
30  // Meaning the collection will only store subsections of parts that fall within
31  // the range of the min and max
32  // Note: min is included, and max is excluded from the valid range of cells.
33  void InitCollection(
34  LSDynaMetaData* metaData, vtkIdType* mins = nullptr, vtkIdType* maxs = nullptr);
35 
36  // Description:
37  // For a given part type returns the number of cells to read and the number
38  // of cells to skip first to not read
39  void GetPartReadInfo(const int& partType, vtkIdType& numberOfCells, vtkIdType& numCellsToSkip,
40  vtkIdType& numCellsToSkipEnd) const;
41 
42  // Description:
43  // Finalizes the cell topology by mapping the cells point indexes
44  // to a relative number based on the cells this collection is storing
45  void FinalizeTopology();
46 
47  // Description: Register a cell of a given type and material index to the
48  // correct part
49  // NOTE: the cellIndex is relative to the collection. So in parallel
50  // the cellIndex will be from 0 to MaxId-MinId
51  void RegisterCellIndexToPart(const int& partType, const vtkIdType& matIdx,
52  const vtkIdType& cellIndex, const vtkIdType& npts);
53 
54  void InitCellInsertion();
55 
56  void AllocateParts();
57 
58  // Description: Insert a cell of a given type and material index to the
59  // collection.
60  // NOTE: the cellIndex is relative to the collection. So in parallel
61  // the cellIndex will be from 0 to MaxId-MinId
62  void InsertCell(const int& partType, const vtkIdType& matIdx, const int& cellType,
63  const vtkIdType& npts, vtkIdType conn[8]);
64 
65  // Description:
66  // Set for each part type what cells are deleted/dead
67  void SetCellDeadFlags(
68  const int& partType, vtkUnsignedCharArray* death, const int& deadCellsAsGhostArray);
69 
70  bool IsActivePart(const int& id) const;
71 
72  // Description:
73  // Given a part will return the unstructured grid for the part.
74  // Note: You must call finalize before using this method
75  vtkUnstructuredGrid* GetGridForPart(const int& index) const;
76 
77  int GetNumberOfParts() const;
78 
79  void DisbleDeadCells();
80 
81  // Description:
82  void ReadPointUserIds(const vtkIdType& numTuples, const char* name);
83 
84  // Description:
85  void ReadPointProperty(const vtkIdType& numTuples, const vtkIdType& numComps, const char* name,
86  const bool& isProperty = true, const bool& isGeometryPoints = false,
87  const bool& isRoadPoints = false);
88 
89  // Description:
90  // Adds a property for all parts of a certain type
91  void AddProperty(const LSDynaMetaData::LSDYNA_TYPES& type, const char* name, const int& offset,
92  const int& numComps);
93  void FillCellProperties(float* buffer, const LSDynaMetaData::LSDYNA_TYPES& type,
94  const vtkIdType& startId, const vtkIdType& numCells, const int& numPropertiesInCell);
95  void FillCellProperties(double* buffer, const LSDynaMetaData::LSDYNA_TYPES& type,
96  const vtkIdType& startId, const vtkIdType& numCells, const int& numPropertiesInCell);
97 
98  // Description:
99  // Adds User Ids for all parts of a certain type
100  void ReadCellUserIds(const LSDynaMetaData::LSDYNA_TYPES& type, const int& status);
101 
102  template <typename T>
103  void FillCellUserId(T* buffer, const LSDynaMetaData::LSDYNA_TYPES& type, const vtkIdType& startId,
104  const vtkIdType& numCells)
105  {
106  this->FillCellUserIdArray(buffer, type, startId, numCells);
107  }
108 
109 protected:
111  ~vtkLSDynaPartCollection() override;
112 
115 
116  // Builds up the basic meta information needed for topology storage
117  void BuildPartInfo();
118 
119  // Description:
120  // Breaks down the buffer of cell properties to the cell properties we
121  // are interested in. This will remove all properties that aren't active or
122  // for parts we are not loading
123  template <typename T>
124  void FillCellArray(T* buffer, const LSDynaMetaData::LSDYNA_TYPES& type, const vtkIdType& startId,
125  vtkIdType numCells, const int& numTuples);
126 
127  template <typename T>
128  void FillCellUserIdArray(T* buffer, const LSDynaMetaData::LSDYNA_TYPES& type,
129  const vtkIdType& startId, vtkIdType numCells);
130 
131  // Description:
132  // Methods for adding points to the collection
133  void SetupPointPropertyForReading(const vtkIdType& numTuples, const vtkIdType& numComps,
134  const char* name, const bool& isIdType, const bool& isProperty, const bool& isGeometryPoints,
135  const bool& isRoadPoints);
136  template <typename T>
137  void FillPointProperty(const vtkIdType& numTuples, const vtkIdType& numComps,
138  vtkLSDynaPart** parts, vtkIdType numParts);
139 
140 private:
142  void operator=(const vtkLSDynaPartCollection&) = delete;
143 
144  LSDynaMetaData* MetaData;
145 
146  class LSDynaPartStorage;
147  LSDynaPartStorage* Storage;
148 };
149 
150 VTK_ABI_NAMESPACE_END
151 #endif // vtkLSDynaPartCollection_h
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int vtkIdType
Definition: vtkType.h:315
a simple class to control print indentation
Definition: vtkIndent.h:28
dataset represents arbitrary combinations of all possible cell types
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
dynamic, self-adjusting array of unsigned char
LSDYNA_TYPES
LS-Dyna cell types.
void FillCellUserId(T *buffer, const LSDynaMetaData::LSDYNA_TYPES &type, const vtkIdType &startId, const vtkIdType &numCells)
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
represent and manipulate 3D points
Definition: vtkPoints.h:28