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;
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.
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
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 
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
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
86 
87  int GetNumberOfParts() const;
88 
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);
104  const vtkIdType& startId, const vtkIdType& numCells, const int& numPropertiesInCell);
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:
122 
125 
126  // Builds up the basic meta information needed for topology storage
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>
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
LSDYNA_TYPES
LS-Dyna cell types.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:165
a simple class to control print indentation
Definition: vtkIndent.h:119
void FillCellProperties(float *buffer, const LSDynaMetaData::LSDYNA_TYPES &type, const vtkIdType &startId, const vtkIdType &numCells, const int &numPropertiesInCell)
void FillPointProperty(const vtkIdType &numTuples, const vtkIdType &numComps, vtkLSDynaPart **parts, const vtkIdType numParts)
vtkUnstructuredGrid * GetGridForPart(const int &index) const
int GetNumberOfParts() const
void InitCollection(LSDynaMetaData *metaData, vtkIdType *mins=nullptr, vtkIdType *maxs=nullptr)
void SetCellDeadFlags(const int &partType, vtkUnsignedCharArray *death, const int &deadCellsAsGhostArray)
~vtkLSDynaPartCollection() override
void FillCellUserIdArray(T *buffer, const LSDynaMetaData::LSDYNA_TYPES &type, const vtkIdType &startId, vtkIdType numCells)
void InsertCell(const int &partType, const vtkIdType &matIdx, const int &cellType, const vtkIdType &npts, vtkIdType conn[8])
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void RegisterCellIndexToPart(const int &partType, const vtkIdType &matIdx, const vtkIdType &cellIndex, const vtkIdType &npts)
bool IsActivePart(const int &id) const
void FillCellProperties(double *buffer, const LSDynaMetaData::LSDYNA_TYPES &type, const vtkIdType &startId, const vtkIdType &numCells, const int &numPropertiesInCell)
void SetupPointPropertyForReading(const vtkIdType &numTuples, const vtkIdType &numComps, const char *name, const bool &isIdType, const bool &isProperty, const bool &isGeometryPoints, const bool &isRoadPoints)
void FillCellArray(T *buffer, const LSDynaMetaData::LSDYNA_TYPES &type, const vtkIdType &startId, vtkIdType numCells, const int &numTuples)
void GetPartReadInfo(const int &partType, vtkIdType &numberOfCells, vtkIdType &numCellsToSkip, vtkIdType &numCellsToSkipEnd) const
void ReadPointProperty(const vtkIdType &numTuples, const vtkIdType &numComps, const char *name, const bool &isProperty=true, const bool &isGeometryPoints=false, const bool &isRoadPoints=false)
void ReadPointUserIds(const vtkIdType &numTuples, const char *name)
void FillCellUserId(T *buffer, const LSDynaMetaData::LSDYNA_TYPES &type, const vtkIdType &startId, const vtkIdType &numCells)
void ReadCellUserIds(const LSDynaMetaData::LSDYNA_TYPES &type, const int &status)
static vtkLSDynaPartCollection * New()
void AddProperty(const LSDynaMetaData::LSDYNA_TYPES &type, const char *name, const int &offset, const int &numComps)
abstract base class for most VTK objects
Definition: vtkObject.h:82
represent and manipulate 3D points
Definition: vtkPoints.h:149
dynamic, self-adjusting array of unsigned char
dataset represents arbitrary combinations of all possible cell types
@ type
Definition: vtkX3D.h:522
@ name
Definition: vtkX3D.h:225
@ index
Definition: vtkX3D.h:252
@ offset
Definition: vtkX3D.h:444
int vtkIdType
Definition: vtkType.h:332