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