VTK
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 "vtkIOLSDynaModule.h" // For export macro
20 #include "LSDynaMetaData.h" //needed for LSDynaMetaData::LSDYNA_TYPES enum
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;
33  static vtkLSDynaPartCollection *New();
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.
44  void InitCollection(LSDynaMetaData *metaData,
45  vtkIdType* mins=nullptr, vtkIdType* maxs=nullptr);
46 
47 
48  //Description:
49  //For a given part type returns the number of cells to read and the number
50  //of cells to skip first to not read
51  void GetPartReadInfo(const int& partType, vtkIdType& numberOfCells,
52  vtkIdType& numCellsToSkip,vtkIdType& numCellsToSkipEnd) const;
53 
54  //Description:
55  //Finalizes the cell topology by mapping the cells point indexes
56  //to a relative number based on the cells this collection is storing
57  void FinalizeTopology();
58 
59 
60  //Description: Register a cell of a given type and material index to the
61  //correct part
62  //NOTE: the cellIndex is relative to the collection. So in parallel
63  //the cellIndex will be from 0 to MaxId-MinId
64  void RegisterCellIndexToPart(const int& partType,const vtkIdType& matIdx,
65  const vtkIdType& cellIndex,const vtkIdType& npts);
66 
67  void InitCellInsertion();
68 
69  void AllocateParts();
70 
71  //Description: Insert a cell of a given type and material index to the
72  //collection.
73  //NOTE: the cellIndex is relative to the collection. So in parallel
74  //the cellIndex will be from 0 to MaxId-MinId
75  void InsertCell(const int& partType,const vtkIdType& matIdx,
76  const int& cellType,const vtkIdType& npts, vtkIdType conn[8]);
77 
78  //Description:
79  //Set for each part type what cells are deleted/dead
80  void SetCellDeadFlags(const int& partType, vtkUnsignedCharArray *death,
81  const int& deadCellsAsGhostArray);
82 
83  bool IsActivePart(const int& id) const;
84 
85  //Description:
86  //Given a part will return the unstructured grid for the part.
87  //Note: You must call finalize before using this method
88  vtkUnstructuredGrid* GetGridForPart(const int& index) const;
89 
90  int GetNumberOfParts() const;
91 
92  void DisbleDeadCells();
93 
94  //Description:
95  void ReadPointUserIds(const vtkIdType& numTuples,const char* name);
96 
97  //Description:
98  void ReadPointProperty(
99  const vtkIdType& numTuples,
100  const vtkIdType& numComps,
101  const char* name,
102  const bool &isProperty=true,
103  const bool& isGeometryPoints=false,
104  const bool& isRoadPoints=false);
105 
106 
107 
108  //Description:
109  //Adds a property for all parts of a certain type
110  void AddProperty(const LSDynaMetaData::LSDYNA_TYPES& type, const char* name,
111  const int& offset, const int& numComps);
112  void FillCellProperties(float *buffer,const LSDynaMetaData::LSDYNA_TYPES& type,
113  const vtkIdType& startId, const vtkIdType& numCells,
114  const int& numPropertiesInCell);
115  void FillCellProperties(double *buffer,const LSDynaMetaData::LSDYNA_TYPES& type,
116  const vtkIdType& startId, const vtkIdType& numCells,
117  const int& numPropertiesInCell);
118 
119  //Description:
120  //Adds User Ids for all parts of a certain type
121  void ReadCellUserIds(
122  const LSDynaMetaData::LSDYNA_TYPES& type, const int& status);
123 
124  template<typename T>
126  const vtkIdType& startId, const vtkIdType& numCells)
127  {
128  this->FillCellUserIdArray(buffer,type,startId,numCells);
129  }
130 
131 protected:
133  ~vtkLSDynaPartCollection() override;
134 
137 
138  //Builds up the basic meta information needed for topology storage
139  void BuildPartInfo();
140 
141  //Description:
142  //Breaks down the buffer of cell properties to the cell properties we
143  //are interested in. This will remove all properties that aren't active or
144  //for parts we are not loading
145  template<typename T>
146  void FillCellArray(T *buffer,const LSDynaMetaData::LSDYNA_TYPES& type,
147  const vtkIdType& startId, vtkIdType numCells, const int& numTuples);
148 
149  template<typename T>
150  void FillCellUserIdArray(T *buffer,const LSDynaMetaData::LSDYNA_TYPES& type,
151  const vtkIdType& startId, vtkIdType numCells);
152 
153  //Description:
154  //Methods for adding points to the collection
155  void SetupPointPropertyForReading(
156  const vtkIdType& numTuples,
157  const vtkIdType& numComps,
158  const char* name,
159  const bool& isIdType,
160  const bool& isProperty,
161  const bool& isGeometryPoints,
162  const bool& isRoadPoints);
163  template<typename T>
164  void FillPointProperty(const vtkIdType& numTuples,
165  const vtkIdType& numComps,
166  vtkLSDynaPart** parts, const vtkIdType numParts);
167 
168 private:
170  void operator = ( const vtkLSDynaPartCollection& ) = delete;
171 
172  LSDynaMetaData *MetaData;
173 
174  class LSDynaPartStorage;
175  LSDynaPartStorage* Storage;
176 };
177 
178 #endif
179 #endif // LSDYNAPARTS_H
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int vtkIdType
Definition: vtkType.h:347
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:54
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