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