36 template<
class LabelType>
37 void Foam::vtk::vtuSizing::adjustOffsets
39 UList<LabelType>& vertOffset,
40 UList<LabelType>& faceOffset,
41 const enum contentType
output,
42 const bool hasFaceStream
58 case contentType::LEGACY:
61 case contentType::XML:
66 for (label i = 1; i < vertOffset.size(); ++i)
68 vertOffset[i] += vertOffset[i-1];
76 for (LabelType& off : faceOffset)
78 const LabelType sz(off);
89 case contentType::INTERNAL1:
95 for (LabelType& off : vertOffset)
97 const LabelType sz(off);
108 for (LabelType& off : faceOffset)
110 const LabelType sz(off);
121 case contentType::INTERNAL2:
132 for (LabelType& off : vertOffset)
134 const LabelType sz(off);
145 for (LabelType& off : faceOffset)
147 const LabelType sz(off);
161 template<
class LabelType>
162 void Foam::vtk::vtuSizing::populateArrays
164 const polyMesh&
mesh,
165 const vtk::vtuSizing& sizing,
168 UList<LabelType>& vertLabels,
169 UList<LabelType>& vertOffset,
171 UList<LabelType>& faceOffset,
172 const enum contentType
output,
177 if (sizing.selectionMode() == selectionModeType::SHAPE_MESH)
180 <<
"Programming error ... attempting to populate a VTU mesh" 181 <<
" but it was originally sized using independent cell shapes" 191 vertLabels.size(), vertOffset.size(),
206 output == contentType::LEGACY
207 ||
output == contentType::INTERNAL1
218 if (vertOffset.size())
220 vertOffset.first() = 0;
221 vertOffset.last() = 0;
244 label nVertLabels = 0;
248 label nVertDecomp = sizing.nVertLabels() + prefix*sizing.nCells();
251 label nCellDecomp =
mesh.nCells();
254 label nPointDecomp =
mesh.nPoints();
260 UList<LabelType>& faceOutput =
262 output == contentType::LEGACY
269 output == contentType::LEGACY
284 const bool isSubsetMesh
286 sizing.selectionMode() == selectionModeType::SUBSET_MESH
289 const label nInputCells =
299 label inputi = 0, cellIndex = 0;
300 inputi < nInputCells;
301 ++inputi, ++cellIndex
304 const label celli(isSubsetMesh ? cellMap[inputi] : inputi);
306 const cellShape& shape = shapes[celli];
307 const cellModel& model = shape.model();
311 cellMap[cellIndex] = celli;
317 constexpr label nShapePoints = 4;
319 if (vertOffset.size())
321 vertOffset[cellIndex] = nShapePoints;
325 vertLabels[nVertLabels++] = nShapePoints;
328 for (
const label cpi : shape)
330 vertLabels[nVertLabels++] = cpi;
333 else if (model == pyr)
336 constexpr label nShapePoints = 5;
338 if (vertOffset.size())
340 vertOffset[cellIndex] = nShapePoints;
344 vertLabels[nVertLabels++] = nShapePoints;
347 for (
const label cpi : shape)
349 vertLabels[nVertLabels++] = cpi;
352 else if (model ==
hex)
355 constexpr label nShapePoints = 8;
357 if (vertOffset.size())
359 vertOffset[cellIndex] = nShapePoints;
363 vertLabels[nVertLabels++] = nShapePoints;
366 for (
const label cpi : shape)
368 vertLabels[nVertLabels++] = cpi;
371 else if (model == prism)
374 constexpr label nShapePoints = 6;
376 if (vertOffset.size())
378 vertOffset[cellIndex] = nShapePoints;
382 vertLabels[nVertLabels++] = nShapePoints;
386 vertLabels[nVertLabels++] = shape[0];
387 vertLabels[nVertLabels++] = shape[2];
388 vertLabels[nVertLabels++] = shape[1];
389 vertLabels[nVertLabels++] = shape[3];
390 vertLabels[nVertLabels++] = shape[5];
391 vertLabels[nVertLabels++] = shape[4];
393 else if (model == tetWedge && sizing.decompose())
397 constexpr label nShapePoints = 6;
399 if (vertOffset.size())
401 vertOffset[cellIndex] = nShapePoints;
405 vertLabels[nVertLabels++] = nShapePoints;
408 vertLabels[nVertLabels++] = shape[0];
409 vertLabels[nVertLabels++] = shape[2];
410 vertLabels[nVertLabels++] = shape[1];
411 vertLabels[nVertLabels++] = shape[3];
412 vertLabels[nVertLabels++] = shape[4];
413 vertLabels[nVertLabels++] = shape[3];
415 else if (model == wedge && sizing.decompose())
419 constexpr label nShapePoints = 8;
421 if (vertOffset.size())
423 vertOffset[cellIndex] = nShapePoints;
427 vertLabels[nVertLabels++] = nShapePoints;
430 vertLabels[nVertLabels++] = shape[0];
431 vertLabels[nVertLabels++] = shape[1];
432 vertLabels[nVertLabels++] = shape[2];
433 vertLabels[nVertLabels++] = shape[2];
434 vertLabels[nVertLabels++] = shape[3];
435 vertLabels[nVertLabels++] = shape[4];
436 vertLabels[nVertLabels++] = shape[5];
437 vertLabels[nVertLabels++] = shape[6];
439 else if (sizing.decompose())
451 const label newVertexLabel = nPointDecomp;
453 addPointsIds[nPointDecomp++] = celli;
456 bool firstCell =
true;
458 const labelList& cFaces = meshCells[celli];
460 for (
const label facei : cFaces)
462 const face&
f = meshFaces[facei];
463 const bool isOwner = (owner[facei] == celli);
466 label nTria = 0, nQuad = 0;
467 f.nTrianglesQuads(
mesh.points(), nTria, nQuad);
472 nTria = 0, nQuad = 0;
473 f.trianglesQuads(
mesh.points(), nTria, nQuad, faces3, faces4);
475 for (
const face& quad : faces4)
479 constexpr label nShapePoints = 5;
481 label celLoc, vrtLoc;
486 vrtLoc = nVertLabels;
487 nVertLabels += prefix + nShapePoints;
491 celLoc = nCellDecomp++;
492 vrtLoc = nVertDecomp;
493 nVertDecomp += prefix + nShapePoints;
495 cellMap[celLoc] = celli;
498 if (vertOffset.size())
500 vertOffset[celLoc] = nShapePoints;
504 vertLabels[vrtLoc++] = nShapePoints;
510 vertLabels[vrtLoc++] = quad[0];
511 vertLabels[vrtLoc++] = quad[3];
512 vertLabels[vrtLoc++] = quad[2];
513 vertLabels[vrtLoc++] = quad[1];
517 vertLabels[vrtLoc++] = quad[0];
518 vertLabels[vrtLoc++] = quad[1];
519 vertLabels[vrtLoc++] = quad[2];
520 vertLabels[vrtLoc++] = quad[3];
524 vertLabels[vrtLoc++] = newVertexLabel;
527 for (
const face& tria : faces3)
531 constexpr label nShapePoints = 4;
533 label celLoc, vrtLoc;
538 vrtLoc = nVertLabels;
539 nVertLabels += prefix + nShapePoints;
543 celLoc = nCellDecomp++;
544 vrtLoc = nVertDecomp;
545 nVertDecomp += prefix + nShapePoints;
547 cellMap[celLoc] = celli;
550 if (vertOffset.size())
552 vertOffset[celLoc] = nShapePoints;
556 vertLabels[vrtLoc++] = nShapePoints;
562 vertLabels[vrtLoc++] = tria[0];
563 vertLabels[vrtLoc++] = tria[2];
564 vertLabels[vrtLoc++] = tria[1];
568 vertLabels[vrtLoc++] = tria[0];
569 vertLabels[vrtLoc++] = tria[1];
570 vertLabels[vrtLoc++] = tria[2];
574 vertLabels[vrtLoc++] = newVertexLabel;
587 const labelList& cFaces = meshCells[celli];
589 const label startLabel = faceIndexer;
591 if (
output == contentType::LEGACY)
593 faceOutput[startLabel] = 0;
597 faceOutput[faceIndexer++] = cFaces.
size();
599 for (
const label facei : cFaces)
601 const face&
f =
mesh.faces()[facei];
602 const bool isOwner = (owner[facei] == celli);
603 const label nFacePoints =
f.size();
605 hashUniqId.insert(
f);
608 faceOutput[faceIndexer++] = nFacePoints;
610 faceOutput[faceIndexer++] =
f[0];
613 for (label fp = 1; fp < nFacePoints; ++fp)
615 faceOutput[faceIndexer++] =
f[fp];
620 for (label fp = nFacePoints - 1; fp > 0; --fp)
622 faceOutput[faceIndexer++] =
f[fp];
627 if (
output == contentType::LEGACY)
631 faceOutput[startLabel] = (faceIndexer - 1 - startLabel);
636 faceOffset[cellIndex] = (faceIndexer - startLabel);
638 vertOffset[cellIndex] = hashUniqId.size();
641 vertLabels[nVertLabels++] = hashUniqId.size();
644 for (
const label pointi : hashUniqId.sortedToc())
646 vertLabels[nVertLabels++] = pointi;
663 adjustOffsets<LabelType>
678 template<
class LabelType>
679 void Foam::vtk::vtuSizing::populateArrays
681 const UList<cellShape>& shapes,
682 const vtk::vtuSizing& sizing,
685 UList<LabelType>& vertLabels,
686 UList<LabelType>& vertOffset,
688 UList<LabelType>& faceOffset,
689 const enum contentType
output,
694 if (sizing.selectionMode() != selectionModeType::SHAPE_MESH)
697 <<
"Programming error ... attempting to populate a VTU mesh" 698 <<
" from cell shapes, but sizing originated from a different" 699 <<
" representation" <<
nl 709 vertLabels.size(), vertOffset.size(),
724 output == contentType::LEGACY
725 ||
output == contentType::INTERNAL1
736 if (vertOffset.size())
738 vertOffset.first() = 0;
739 vertOffset.last() = 0;
749 label nVertLabels = 0;
757 const label nInputCells = shapes.size();
763 label inputi = 0, cellIndex = 0;
764 inputi < nInputCells;
765 ++inputi, ++cellIndex
768 const cellShape& shape = shapes[inputi];
769 const cellModel& model = shape.model();
774 constexpr label nShapePoints = 4;
776 if (vertOffset.size())
778 vertOffset[cellIndex] = nShapePoints;
782 vertLabels[nVertLabels++] = nShapePoints;
785 for (
const label cpi : shape)
787 vertLabels[nVertLabels++] = cpi;
790 else if (model == pyr)
793 constexpr label nShapePoints = 5;
795 if (vertOffset.size())
797 vertOffset[cellIndex] = nShapePoints;
801 vertLabels[nVertLabels++] = nShapePoints;
804 for (
const label cpi : shape)
806 vertLabels[nVertLabels++] = cpi;
809 else if (model ==
hex)
812 constexpr label nShapePoints = 8;
814 if (vertOffset.size())
816 vertOffset[cellIndex] = nShapePoints;
820 vertLabels[nVertLabels++] = nShapePoints;
823 for (
const label cpi : shape)
825 vertLabels[nVertLabels++] = cpi;
828 else if (model == prism)
831 constexpr label nShapePoints = 6;
833 if (vertOffset.size())
835 vertOffset[cellIndex] = nShapePoints;
839 vertLabels[nVertLabels++] = nShapePoints;
843 vertLabels[nVertLabels++] = shape[0];
844 vertLabels[nVertLabels++] = shape[2];
845 vertLabels[nVertLabels++] = shape[1];
846 vertLabels[nVertLabels++] = shape[3];
847 vertLabels[nVertLabels++] = shape[5];
848 vertLabels[nVertLabels++] = shape[4];
874 adjustOffsets<LabelType>
void size(const label n)
Older name for setAddressableSize.
List< cell > cellList
List of cell.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
IOstream & hex(IOstream &io)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static const manifoldCellsMeshObject & New(const polyMesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
constexpr char nl
The newline '\n' character (0x0a)
List< cellShape > cellShapeList
List of cellShape.
labelList faceLabels(nFaceLabels)
UList< label > labelUList
A UList of labels.
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
List< face > faceList
List of faces.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
const labelList & cellTypes
static Ostream & output(Ostream &os, const IntRange< T > &range)
List< label > labelList
A List of labels.
const cellList & cells() const
Return the (optionally compacted) cell list Triggers demand-driven filtering if required.