USERD_get_part_elements_by_type.H
Go to the documentation of this file.
2 (
3  int part_number,
4  int element_type,
5  int **conn_array
6 )
7 {
8  #ifdef ENSIGHTDEBUG
9  Info<< "Entering: USERD_get_part_elements_by_type" << nl
10  << "part_number = " << part_number << nl
11  << "element_type = " << element_type;
12  if (element_type == Z_HEX08)
13  {
14  Info<< " Z_HEX08";
15  }
16  else if (element_type == Z_PEN06)
17  {
18  Info<< " Z_PEN06";
19  }
20  else if (element_type == Z_PYR05)
21  {
22  Info<< " Z_PYR05";
23  }
24  else if (element_type == Z_TET04)
25  {
26  Info<< " Z_TET04";
27  }
28  else if (element_type == Z_TRI03)
29  {
30  Info<< " Z_TRI03";
31  }
32  else if (element_type == Z_QUA04)
33  {
34  Info<< " Z_QUA04";
35  }
36  else if (element_type == Z_NFACED)
37  {
38  Info<< " Z_NFACED";
39  }
40  else if (element_type == Z_NSIDED)
41  {
42  Info<< " Z_NSIDED";
43  }
44  else
45  {
46  Info<< " unknown";
47  }
48  Info<< endl << flush;
49  #endif
50 
51  if (part_number == 1)
52  {
53  const cellShapeList& cellShapes = meshPtr->cellShapes();
54 
55  //================================
56  // hexahedron
57  //================================
58  if (element_type == Z_HEX08)
59  {
60  const cellModel& hex = *(cellModeller::lookup("hex"));
61 
62  label nHex08 = 0;
63  forAll(cellShapes, celli)
64  {
65  const cellShape& cellShape = cellShapes[celli];
66  const cellModel& cellModel = cellShape.model();
67 
68  if (cellModel == hex)
69  {
70  forAll(cellShape, ip)
71  {
72  conn_array[nHex08][ip] = cellShape[ip] + 1;
73  }
74  nHex08++;
75  }
76  }
77  }
78  //================================
79  // pentahedron
80  //================================
81  else if (element_type == Z_PEN06)
82  {
83  const cellModel& prism = *(cellModeller::lookup("prism"));
84 
85  label nPen06 = 0;
86  forAll(cellShapes, celli)
87  {
88  const cellShape& cellShape = cellShapes[celli];
89  const cellModel& cellModel = cellShape.model();
90 
91  if (cellModel == prism)
92  {
93  forAll(cellShape, ip)
94  {
95  conn_array[nPen06][ip] = cellShape[ip] + 1;
96  }
97  nPen06++;
98  }
99  }
100  }
101  //================================
102  // pyramid
103  //================================
104  else if (element_type == Z_PYR05)
105  {
106  const cellModel& pyr = *(cellModeller::lookup("pyr"));
107 
108  label nPyr05 = 0;
109  forAll(cellShapes, celli)
110  {
111  const cellShape& cellShape = cellShapes[celli];
112  const cellModel& cellModel = cellShape.model();
113 
114  if (cellModel == pyr)
115  {
116  forAll(cellShape, ip)
117  {
118  conn_array[nPyr05][ip] = cellShape[ip] + 1;
119  }
120  nPyr05++;
121  }
122  }
123  }
124  //================================
125  // tetrahedron
126  //================================
127  else if (element_type == Z_TET04)
128  {
129  const cellModel& tet = *(cellModeller::lookup("tet"));
130 
131  label nTet04 = 0;
132  forAll(cellShapes, celli)
133  {
134  const cellShape& cellShape = cellShapes[celli];
135  const cellModel& cellModel = cellShape.model();
136 
137  if (cellModel == tet)
138  {
139  forAll(cellShape, ip)
140  {
141  conn_array[nTet04][ip] = cellShape[ip] + 1;
142  }
143  nTet04++;
144  }
145  }
146  }
147  //================================
148  // polyhedra
149  //================================
150  else
151  {
152  label nCells = cellShapes.size();
153  label nFaced = 0;
154  const cellList cells = meshPtr->cells();
155 
156  for (label n=0; n<nCells; n++)
157  {
158  label nFacesInCell = cells[n].size();
159  labelList points = cellShapes[n];
160  if ((nFacesInCell == 6) && (points.size() == 8))
161  {}
162  else if ((nFacesInCell == 4) && (points.size() == 4))
163  {}
164  else if (nFacesInCell == 5)
165  {
166  if (points.size() == 6)
167  {}
168  else if (points.size() == 5)
169  {}
170  else
171  {
172  conn_array[nFaced++][0] = nFacesInCell;
173  }
174  }
175  else
176  {
177  conn_array[nFaced++][0] = nFacesInCell;
178  }
179  }
180  }
181  }
182  else if (part_number < nPatches+2)
183  {
184  label patchi = part_number - 2;
185  const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh();
186 
187  label nTri03 = 0;
188  label nQuad04 = 0;
189  if (element_type == Z_TRI03)
190  {
191  forAll(bMesh[patchi], n)
192  {
193  label nPoints = bMesh[patchi][n].size();
194  if (nPoints == 3)
195  {
196  for (label i=0; i<nPoints; i++)
197  {
198  label ip = bMesh[patchi][n][i];
199  conn_array[nTri03][i] = ip + 1;
200  }
201  nTri03++;
202  }
203  }
204  }
205  else if (element_type == Z_QUA04)
206  {
207  forAll(bMesh[patchi], n)
208  {
209  label nPoints = bMesh[patchi][n].size();
210  if (nPoints == 4)
211  {
212  for (label i=0; i<nPoints; i++)
213  {
214  label ip = bMesh[patchi][n][i];
215  conn_array[nQuad04][i] = ip + 1;
216  }
217  nQuad04++;
218  }
219  }
220 
221  }
222  else if (element_type == Z_NSIDED)
223  {
224  label nPoly = 0;
225  forAll(bMesh[patchi], n)
226  {
227  label nPoints = bMesh[patchi][n].size();
228  if ((nPoints != 3) && (nPoints != 4))
229  {
230  conn_array[nPoly++][0] = nPoints;
231  }
232  }
233  }
234  }
235  else if (part_number == nPatches+2)
236  {
237  forAll(*sprayPtr, n)
238  {
239  conn_array[n][0] = n + 1;
240  }
241  }
242  else
243  {
244  return Z_ERR;
245  }
246 
247  #ifdef ENSIGHTDEBUG
248  Info<< "Leaving: USERD_get_part_elements_by_type" << endl;
249  #endif
250 
251  return Z_OK;
252 }
label nPatches
Definition: readKivaGrid.H:402
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
IOstream & hex(IOstream &io)
Definition: IOstream.H:564
static fvMesh * meshPtr
Definition: globalFoam.H:52
static Cloud< passiveParticle > * sprayPtr
Definition: globalFoam.H:53
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
int USERD_get_part_elements_by_type(int part_number, int element_type, int **conn_array)
stressControl lookup("compactNormalStress") >> compactNormalStress
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
Definition: cellShapeList.H:43
const cellShapeList & cells
const pointField & points
label nPoints
const cellShapeList & cellShapes
List< label > labelList
A List of labels.
Definition: labelList.H:56
static const char nl
Definition: Ostream.H:262
label patchi
Ostream & flush(Ostream &os)
Flush stream.
Definition: Ostream.H:245
messageStream Info
label n
PrimitivePatch< face, List, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points) ...
Definition: bMesh.H:45
List< cell > cellList
list of cells
Definition: cellList.H:42