35 template<
class LabelType,
class LabelType2>
36 void Foam::vtk::vtuSizing::populateArrays
39 const vtk::vtuSizing& sizing,
41 UList<LabelType>& vertLabels,
42 UList<LabelType>& vertOffset,
43 UList<LabelType>& faceLabels,
44 UList<LabelType>& faceOffset,
45 const enum contentType output,
46 UList<LabelType2>& cellMap,
47 UList<LabelType2>& addPointsIds
56 output == contentType::LEGACY
57 || output == contentType::INTERNAL1
63 if (
cellTypes.size() != sizing.nFieldCells())
67 <<
" expected " << sizing.nFieldCells()
71 if (cellMap.size() != sizing.nFieldCells())
74 <<
" cellMap size=" << cellMap.size()
75 <<
" expected " << sizing.nFieldCells()
79 if (addPointsIds.size() != sizing.nAddPoints())
82 <<
" addPointsIds size=" << addPointsIds.size()
83 <<
" expected " << sizing.nAddPoints()
89 case contentType::LEGACY:
91 if (vertLabels.size() != sizing.sizeLegacy())
94 <<
" legacy size=" << vertLabels.size()
95 <<
" expected " << sizing.sizeLegacy()
101 case contentType::XML:
111 <<
" connectivity size=" << vertLabels.size()
120 != sizing.sizeXml(slotType::CELLS_OFFSETS)
124 <<
" offsets size=" << vertOffset.size()
126 << sizing.sizeXml(slotType::CELLS_OFFSETS)
130 if (sizing.nFaceLabels())
139 <<
" faces size=" << faceLabels.size()
148 != sizing.sizeXml(slotType::FACES_OFFSETS)
152 <<
" facesOffsets size=" << faceOffset.size()
154 << sizing.sizeXml(slotType::FACES_OFFSETS)
161 case contentType::INTERNAL1:
171 <<
" connectivity size=" << vertLabels.size()
180 != sizing.sizeInternal1(slotType::CELLS_OFFSETS)
184 <<
" offsets size=" << vertOffset.size()
186 << sizing.sizeInternal1(slotType::CELLS_OFFSETS)
190 if (sizing.nFaceLabels())
199 <<
" faces size=" << faceLabels.size()
208 != sizing.sizeInternal1(slotType::FACES_OFFSETS)
212 <<
" facesOffsets size=" << faceOffset.size()
214 << sizing.sizeInternal1(slotType::FACES_OFFSETS)
221 case contentType::INTERNAL2:
231 <<
" connectivity size=" << vertLabels.size()
240 != sizing.sizeInternal2(slotType::CELLS_OFFSETS)
244 <<
" offsets size=" << vertOffset.size()
246 << sizing.sizeInternal2(slotType::CELLS_OFFSETS)
250 if (sizing.nFaceLabels())
259 <<
" faces size=" << faceLabels.size()
268 != sizing.sizeInternal2(slotType::FACES_OFFSETS)
272 <<
" facesOffsets size=" << faceOffset.size()
274 << sizing.sizeInternal2(slotType::FACES_OFFSETS)
290 if (vertOffset.size())
292 vertOffset.first() = 0;
293 vertOffset.last() = 0;
317 label nVertDecomp = sizing.nVertLabels() + prefix*sizing.nCells();
320 label nCellDecomp =
mesh.nCells();
323 label nPointDecomp = 0;
329 UList<LabelType>& faceOutput =
331 output == contentType::LEGACY
338 output == contentType::LEGACY
349 const label len = shapes.size();
351 for (label celli=0; celli < len; ++celli)
353 const cellShape& shape = shapes[celli];
354 const cellModel& model = shape.model();
356 cellMap[celli] = celli;
361 constexpr label nShapePoints = 4;
363 if (vertOffset.size())
365 vertOffset[celli] = nShapePoints;
372 for (
const label cpi : shape)
377 else if (model == pyr)
380 constexpr label nShapePoints = 5;
382 if (vertOffset.size())
384 vertOffset[celli] = nShapePoints;
391 for (
const label cpi : shape)
396 else if (model ==
hex)
399 constexpr label nShapePoints = 8;
401 if (vertOffset.size())
403 vertOffset[celli] = nShapePoints;
410 for (
const label cpi : shape)
415 else if (model == prism)
418 constexpr label nShapePoints = 6;
420 if (vertOffset.size())
422 vertOffset[celli] = nShapePoints;
437 else if (model == tetWedge && sizing.decompose())
441 constexpr label nShapePoints = 6;
443 if (vertOffset.size())
445 vertOffset[celli] = nShapePoints;
459 else if (model == wedge && sizing.decompose())
463 constexpr label nShapePoints = 8;
465 if (vertOffset.size())
467 vertOffset[celli] = nShapePoints;
483 else if (sizing.decompose())
495 const label newVertexLabel =
mesh.nPoints() + nPointDecomp;
497 addPointsIds[nPointDecomp++] = celli;
504 for (
const label facei : cFaces)
506 const face&
f =
mesh.faces()[facei];
507 const bool isOwner = (owner[facei] == celli);
510 label nTria = 0, nQuad = 0;
511 f.nTrianglesQuads(
mesh.points(), nTria, nQuad);
516 nTria = 0, nQuad = 0;
517 f.trianglesQuads(
mesh.points(), nTria, nQuad, faces3, faces4);
519 for (
const face& quad : faces4)
523 constexpr label nShapePoints = 5;
525 label celLoc, vrtLoc;
535 celLoc = nCellDecomp++;
536 vrtLoc = nVertDecomp;
537 nVertDecomp += prefix + nShapePoints;
539 cellMap[celLoc] = celli;
542 if (vertOffset.size())
544 vertOffset[celLoc] = nShapePoints;
548 vertLabels[vrtLoc++] = nShapePoints;
554 vertLabels[vrtLoc++] = quad[3];
555 vertLabels[vrtLoc++] = quad[2];
556 vertLabels[vrtLoc++] = quad[1];
557 vertLabels[vrtLoc++] = quad[0];
561 vertLabels[vrtLoc++] = quad[0];
562 vertLabels[vrtLoc++] = quad[1];
563 vertLabels[vrtLoc++] = quad[2];
564 vertLabels[vrtLoc++] = quad[3];
568 vertLabels[vrtLoc++] = newVertexLabel;
571 for (
const face& tria : faces3)
575 constexpr label nShapePoints = 4;
577 label celLoc, vrtLoc;
587 celLoc = nCellDecomp++;
588 vrtLoc = nVertDecomp;
589 nVertDecomp += prefix + nShapePoints;
591 cellMap[celLoc] = celli;
594 if (vertOffset.size())
596 vertOffset[celLoc] = nShapePoints;
600 vertLabels[vrtLoc++] = nShapePoints;
606 vertLabels[vrtLoc++] = tria[2];
607 vertLabels[vrtLoc++] = tria[1];
608 vertLabels[vrtLoc++] = tria[0];
612 vertLabels[vrtLoc++] = tria[0];
613 vertLabels[vrtLoc++] = tria[1];
614 vertLabels[vrtLoc++] = tria[2];
618 vertLabels[vrtLoc++] = newVertexLabel;
632 const label startLabel = faceIndexer;
634 if (output == contentType::LEGACY)
636 faceOutput[startLabel] = 0;
640 faceOutput[faceIndexer++] = cFaces.size();
642 for (
const label facei : cFaces)
644 const face&
f =
mesh.faces()[facei];
645 const bool isOwner = (owner[facei] == celli);
647 hashUniqId.insert(
f);
650 faceOutput[faceIndexer++] =
f.size();
656 faceOutput[faceIndexer++] =
f[fp];
665 faceOutput[faceIndexer++] =
f[fp];
670 if (output == contentType::LEGACY)
674 faceOutput[startLabel] = (faceIndexer - 1 - startLabel);
679 faceOffset[celli] = (faceIndexer - startLabel);
681 vertOffset[celli] = hashUniqId.size();
687 const labelList uniq = hashUniqId.sortedToc();
688 for (
const label fpi : uniq)
709 case contentType::LEGACY:
712 case contentType::XML:
717 for (label i = 1; i < vertOffset.size(); ++i)
719 vertOffset[i] += vertOffset[i-1];
723 if (sizing.nFaceLabels())
727 for (LabelType& off : faceOffset)
740 case contentType::INTERNAL1:
746 for (LabelType& off : vertOffset)
755 if (sizing.nFaceLabels())
759 for (LabelType& off : faceOffset)
772 case contentType::INTERNAL2:
783 for (LabelType& off : vertOffset)
792 if (sizing.nFaceLabels())
796 for (LabelType& off : faceOffset)