42 {
"none",
"polyhedra",
"all"};
50 polyhedra_(polyhedra),
53 addPointCellLabels_(),
56 const cellModel& tet = *(cellModeller::lookup(
"tet"));
57 const cellModel& pyr = *(cellModeller::lookup(
"pyr"));
58 const cellModel& prism = *(cellModeller::lookup(
"prism"));
59 const cellModel& wedge = *(cellModeller::lookup(
"wedge"));
60 const cellModel& tetWedge = *(cellModeller::lookup(
"tetWedge"));
61 const cellModel&
hex = *(cellModeller::lookup(
"hex"));
67 label nAddPoints = 0, nAddCells = 0;
71 if (polyhedra_ == vtkPolyhedra::none)
75 const cellModel& model =
cellShapes[celli].model();
87 const cell& cFaces = mesh_.cells()[celli];
91 const face&
f = mesh_.faces()[cFaces[cFacei]];
95 nAddCells +=
f.nTriangles();
111 addPointCellLabels_.setSize(nAddPoints);
115 superCells_.setSize(nAddCells);
118 vertLabels_.setSize(
cellShapes.size() + nAddCells);
121 cellTypes_.setSize(
cellShapes.size() + nAddCells);
124 polygonTriangulate triEngine;
127 label addPointi = 0, addCelli = 0;
131 const cellShape& cellShape =
cellShapes[celli];
132 const cellModel& cellModel = cellShape.model();
134 labelList& vtkVerts = vertLabels_[celli];
136 if (polyhedra_ != vtkPolyhedra::all && cellModel == tet)
138 vtkVerts = cellShape;
140 cellTypes_[celli] = VTK_TETRA;
142 else if (polyhedra_ != vtkPolyhedra::all && cellModel == pyr)
144 vtkVerts = cellShape;
146 cellTypes_[celli] = VTK_PYRAMID;
148 else if (polyhedra_ != vtkPolyhedra::all && cellModel == prism)
152 vtkVerts = cellShape;
157 cellTypes_[celli] = VTK_WEDGE;
159 else if (polyhedra_ == vtkPolyhedra::none && cellModel == tetWedge)
163 vtkVerts[0] = cellShape[0];
164 vtkVerts[1] = cellShape[2];
165 vtkVerts[2] = cellShape[1];
166 vtkVerts[3] = cellShape[3];
167 vtkVerts[4] = cellShape[4];
168 vtkVerts[5] = cellShape[3];
170 cellTypes_[celli] = VTK_WEDGE;
172 else if (polyhedra_ != vtkPolyhedra::all && cellModel == wedge)
176 vtkVerts[0] = cellShape[0];
177 vtkVerts[1] = cellShape[1];
178 vtkVerts[2] = cellShape[2];
179 vtkVerts[3] = cellShape[2];
180 vtkVerts[4] = cellShape[3];
181 vtkVerts[5] = cellShape[4];
182 vtkVerts[6] = cellShape[5];
183 vtkVerts[7] = cellShape[6];
185 cellTypes_[celli] = VTK_HEXAHEDRON;
187 else if (polyhedra_ != vtkPolyhedra::all && cellModel ==
hex)
189 vtkVerts = cellShape;
191 cellTypes_[celli] = VTK_HEXAHEDRON;
193 else if (polyhedra_ == vtkPolyhedra::none)
198 addPointCellLabels_[addPointi] = celli;
201 const label newVertexLabel = mesh_.nPoints() + addPointi;
204 bool substituteCell =
true;
206 const labelList& cFaces = mesh_.cells()[celli];
209 const face&
f = mesh_.faces()[cFaces[cFacei]];
210 const bool isOwner = faceOwner[cFaces[cFacei]] == celli;
213 faceList triFcs(
f.size() == 4 ? 0 :
f.nTriangles());
217 triEngine.triangulate
221 forAll(triEngine.triPoints(), trii)
223 triFcs[trii] = triEngine.triPoints(trii,
f);
238 substituteCell =
false;
242 thisCelli = mesh_.nCells() + addCelli;
243 superCells_[addCelli++] = celli;
246 labelList& addVtkVerts = vertLabels_[thisCelli];
250 const face& quad = quadFcs[quadI];
261 addVtkVerts[0] = quad[3];
262 addVtkVerts[1] = quad[2];
263 addVtkVerts[2] = quad[1];
264 addVtkVerts[3] = quad[0];
268 addVtkVerts[0] = quad[0];
269 addVtkVerts[1] = quad[1];
270 addVtkVerts[2] = quad[2];
271 addVtkVerts[3] = quad[3];
273 addVtkVerts[4] = newVertexLabel;
275 cellTypes_[thisCelli] = VTK_PYRAMID;
285 substituteCell =
false;
289 thisCelli = mesh_.nCells() + addCelli;
290 superCells_[addCelli++] = celli;
294 labelList& addVtkVerts = vertLabels_[thisCelli];
296 const face& tri = triFcs[triI];
298 addVtkVerts.setSize(4);
303 addVtkVerts[0] = tri[2];
304 addVtkVerts[1] = tri[1];
305 addVtkVerts[2] = tri[0];
309 addVtkVerts[0] = tri[0];
310 addVtkVerts[1] = tri[1];
311 addVtkVerts[2] = tri[2];
313 addVtkVerts[3] = newVertexLabel;
315 cellTypes_[thisCelli] = VTK_TETRA;
324 cellTypes_[celli] = VTK_POLYHEDRON;
326 const labelList& cFaces = mesh_.cells()[celli];
329 label nData = 1 + cFaces.size();
338 vtkVerts.setSize(nData);
341 vtkVerts[nData++] = cFaces.size();
347 const bool isOwner = faceOwner[cFaces[cFacei]] == celli;
350 vtkVerts[nData++] =
f.size();
356 vtkVerts[nData++] =
f[fp];
365 vtkVerts[nData++] =
f[fp];
372 if (polyhedra_ == vtkPolyhedra::none)
374 Pout<<
" Original cells:" << mesh_.nCells()
375 <<
" points:" << mesh_.nPoints()
376 <<
" Additional cells:" << superCells_.size()
377 <<
" additional points:" << addPointCellLabels_.size()
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
void setSize(const label)
Reset size of List.
Initialise the NamedEnum HashTable from the static list of names.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
virtual const pointField & points() const
Return raw points.
vtkTopo(const polyMesh &mesh, const vtkPolyhedra &polyhedra)
Construct from components.
static const NamedEnum< vtkPolyhedra, 3 > vtkPolyhedraNames_
Names of groups of cell types retain as polyhedra.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const cellShapeList & cellShapes
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOstream & hex(IOstream &io)
prefixOSstream Pout(cout, "Pout")