Go to the documentation of this file.
38 void Foam::vtk::vtuSizing::presizeMaps(foamVtkMeshMaps& maps)
const
41 maps.additionalIds().resize(this->
nAddPoints());
45 void Foam::vtk::vtuSizing::checkSizes
47 const vtk::vtuSizing& sizing,
49 const label cellTypes_size,
50 const label vertLabels_size,
51 const label vertOffset_size,
52 const label faceLabels_size,
53 const label faceOffset_size,
55 const enum contentType
output,
56 const label cellMap_size,
57 const label addPointsIds_size
63 #define CHECK_SIZING(what, sizeInput, sizeExpected) \
64 if (sizeInput != sizeExpected) \
68 FatalErrorInFunction << "VTK sizing error" << nl; \
71 << " " << what << " size=" << sizeInput \
72 << " expected " << sizeExpected << nl; \
76 CHECK_SIZING(
"cellTypes", cellTypes_size, sizing.nFieldCells());
77 CHECK_SIZING(
"cellMap", cellMap_size, sizing.nFieldCells());
78 CHECK_SIZING(
"addPointsIds", addPointsIds_size, sizing.nAddPoints());
82 case contentType::LEGACY:
84 CHECK_SIZING(
"legacy", vertLabels_size, sizing.sizeLegacy());
88 case contentType::XML:
95 sizing.sizeXml(slotType::CELLS)
101 sizing.sizeXml(slotType::CELLS_OFFSETS)
103 if (sizing.nFaceLabels())
109 sizing.sizeXml(slotType::FACES)
116 sizing.sizeXml(slotType::FACES_OFFSETS)
122 case contentType::INTERNAL1:
129 sizing.sizeInternal1(slotType::CELLS)
135 sizing.sizeInternal1(slotType::CELLS_OFFSETS)
137 if (sizing.nFaceLabels())
143 sizing.sizeInternal1(slotType::FACES)
149 sizing.sizeInternal1(slotType::FACES_OFFSETS)
155 case contentType::INTERNAL2:
162 sizing.sizeInternal2(slotType::CELLS)
168 sizing.sizeInternal2(slotType::CELLS_OFFSETS)
170 if (sizing.nFaceLabels())
176 sizing.sizeInternal2(slotType::FACES)
182 sizing.sizeInternal2(slotType::FACES_OFFSETS)
193 <<
"Total of " << nErrors <<
" sizing errors encountered!"
225 selectionMode_ = FULL_MESH;
272 const bool isSubsetMesh
280 selectionMode_ = selectionModeType::SUBSET_MESH;
284 decompose_ = decompose;
285 selectionMode_ = selectionModeType::FULL_MESH;
288 const label nInputCells =
291 ? subsetCellsIds.
size()
295 nCells_ = nInputCells;
296 nPoints_ =
mesh.nPoints();
300 nCellsPoly_ = nCells_;
305 for (label inputi = 0; inputi < nInputCells; ++inputi)
307 const label celli(isSubsetMesh ? subsetCellsIds[inputi] : inputi);
309 const cellShape& shape = shapes[celli];
310 const cellModel& model = shape.model();
322 nVertLabels_ += shape.size();
324 else if (model == tetWedge && decompose_)
328 else if (model == wedge && decompose_)
340 const cell& cFaces =
mesh.cells()[celli];
341 for (
const label facei : cFaces)
343 const face&
f =
mesh.faces()[facei];
347 label nTria = 0, nQuad = 0;
348 f.nTrianglesQuads(
mesh.points(), nTria, nQuad);
350 nAddCells_ += nTria + nQuad;
351 nAddVerts_ += (nTria * 4) + (nQuad * 5);
358 const label nvrt = (nQuad ? 5 : 4);
360 nVertLabels_ += nvrt;
377 for (
const label facei : cFaces)
379 const face&
f =
mesh.faces()[facei];
380 nFaceLabels_ +=
f.size();
382 hashUniqId.insert(
f);
387 nVertLabels_ += hashUniqId.size();
388 nVertPoly_ += hashUniqId.size();
390 nFaceLabels_ += 1 + cFaces.size();
395 decompose_ = (decompose_ && nCellsPoly_);
414 selectionMode_ = SHAPE_MESH;
416 const label nInputCells = shapes.
size();
418 nCells_ = nInputCells;
430 for (label inputi = 0; inputi < nInputCells; ++inputi)
443 nVertLabels_ += shape.size();
446 nPoints_ =
max(nPoints_,
max(shape));
458 <<
"Encountered " << nIgnored <<
" unsupported cell shapes"
459 <<
" ... this is likely not good" <<
nl
472 const enum contentType
output,
473 const enum slotType slot
478 case contentType::LEGACY:
482 case slotType::CELLS:
488 nVertLabels() + nAddVerts() - nVertPoly()
500 case contentType::XML:
504 case slotType::CELLS:
505 return (nVertLabels() + nAddVerts());
508 case slotType::CELLS_OFFSETS:
509 return nFieldCells();
512 case slotType::FACES:
513 return nFaceLabels();
516 case slotType::FACES_OFFSETS:
517 return nFaceLabels() ? nFieldCells() : 0;
523 case contentType::INTERNAL1:
527 case slotType::CELLS:
529 return (nVertLabels() + nAddVerts() + nFieldCells());
532 case slotType::CELLS_OFFSETS:
533 return nFieldCells();
536 case slotType::FACES:
537 return nFaceLabels();
540 case slotType::FACES_OFFSETS:
541 return nFaceLabels() ? nFieldCells() : 0;
547 case contentType::INTERNAL2:
551 case slotType::CELLS:
552 return (nVertLabels() + nAddVerts());
555 case slotType::CELLS_OFFSETS:
556 return (nFieldCells() + 1);
559 case slotType::FACES:
560 return nFaceLabels();
563 case slotType::FACES_OFFSETS:
564 return nFaceLabels() ? nFieldCells() : 0;
696 #undef definePopulateInternalMethod
697 #define definePopulateInternalMethod(Type) \
699 void Foam::vtk::vtuSizing::populateInternal \
701 const polyMesh& mesh, \
702 UList<uint8_t>& cellTypes, \
703 UList<Type>& connectivity, \
704 UList<Type>& offsets, \
705 UList<Type>& faces, \
706 UList<Type>& facesOffsets, \
707 foamVtkMeshMaps& maps, \
708 const enum contentType output \
724 maps.additionalIds() \
728 void Foam::vtk::vtuSizing::populateInternal \
730 const polyMesh& mesh, \
731 UList<uint8_t>& cellTypes, \
732 UList<Type>& connectivity, \
733 UList<Type>& offsets, \
734 UList<Type>& faces, \
735 UList<Type>& facesOffsets, \
736 labelUList& cellMap, \
737 labelUList& addPointsIds, \
738 const enum contentType output \
762 #undef definePopulateInternalMethod
770 const label globalPointOffset
773 if (!globalPointOffset)
779 renumberVertLabelsLegacy(
output, globalPointOffset);
788 const label globalPointOffset
791 if (!globalPointOffset)
809 auto iter = vertLabels.
begin();
810 const auto last = vertLabels.
end();
814 label nLabels = *iter;
823 *iter += globalPointOffset;
831 label nFaces = *iter;
841 *iter += globalPointOffset;
853 const label globalPointOffset
856 if (!globalPointOffset)
862 renumberVertLabelsXml(
output, globalPointOffset);
871 const label globalPointOffset
874 if (!globalPointOffset)
882 for (label& vertId : vertLabels)
884 vertId += globalPointOffset;
892 const label globalPointOffset
895 if (!globalPointOffset)
901 renumberFaceLabelsXml(
output, globalPointOffset);
910 const label globalPointOffset
913 if (!globalPointOffset)
921 auto iter = faceLabels.
begin();
922 const auto last = faceLabels.
end();
926 label nFaces = *iter;
931 label nLabels = *iter;
936 *iter += globalPointOffset;
947 const label prevOffset
956 renumberFaceOffsetsXml(
output, prevOffset);
965 const label prevOffset
976 for (label& val : faceOffsets)
990 os <<
"nFieldCells:" << nFieldCells();
993 os <<
" (" << nCells_ <<
"+" << nAddCells_ <<
")";
997 os <<
" (poly:" << nCellsPoly_ <<
")";
1000 os <<
" nFieldPoints:" << nFieldPoints();
1003 os <<
" (" << nPoints_ <<
"+" << nAddPoints_ <<
")";
1006 os <<
" nVertLabels:" << (nVertLabels_ + nAddVerts_);
1009 os <<
" (" << nVertLabels_ <<
"+" << nAddVerts_ <<
")";
1011 else if (nVertPoly_)
1013 os <<
" (poly:" << nVertPoly_ <<
")";
1016 os <<
" nFaceLabels:" << nFaceLabels_;
1017 os <<
" legacy-count:" << sizeLegacy();
1029 && nCells() == rhs.
nCells()
label nAddCells() const noexcept
List< label > labelList
A List of labels.
static void renumberFaceLabelsXml(labelUList &faceLabels, const label globalPointOffset)
label nCells() const noexcept
label nVertLabels() const noexcept
static Ostream & output(Ostream &os, const IntRange< T > &range)
void resetShapes(const UList< cellShape > &shapes)
void populateLegacy(const polyMesh &mesh, UList< uint8_t > &cellTypes, labelUList &connectivity, foamVtkMeshMaps &maps) const
label nFaceLabels() const noexcept
void info(Ostream &os) const
label nAddVerts() const noexcept
label nAddPoints() const noexcept
A HashTable with keys but without contents that is similar to std::unordered_set.
const labelList & additionalIds() const noexcept
Mesh consisting of general polyhedral cells.
static labelList copyVertLabelsLegacy(const labelUList &connectivity, const label globalPointOffset)
bool operator!=(const vtuSizing &rhs) const
#define CHECK_SIZING(what, sizeInput, sizeExpected)
void populateXml(const polyMesh &mesh, UList< uint8_t > &cellTypes, labelUList &connectivity, labelUList &offsets, labelUList &faces, labelUList &facesOffsets, foamVtkMeshMaps &maps) const
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
label nCellsPoly() const noexcept
label nFieldCells() const noexcept
static const cellModel & ref(const modelType model)
void populateShapesLegacy(const UList< cellShape > &shapes, UList< uint8_t > &cellTypes, labelUList &connectivity, foamVtkMeshMaps &maps) const
label max(const labelHashSet &set, label maxValue=labelMin)
static void renumberVertLabelsLegacy(labelUList &connectivity, const label globalPointOffset)
bool notNull(const T *ptr)
bool decompose() const noexcept
OBJstream os(runTime.globalPath()/outputName)
An analytical geometric cellShape.
label nVertPoly() const noexcept
Sizing descriptions and routines for transcribing an OpenFOAM volume mesh into a VTK unstructured gri...
static void renumberFaceOffsetsXml(labelUList &faceOffsets, const label prevOffset)
errorManipArg< error, int > exit(error &err, const int errNo=1)
IOstream & hex(IOstream &io)
meshPtr reset(new Foam::fvMesh(Foam::IOobject(regionName, runTime.timeName(), runTime, Foam::IOobject::MUST_READ), false))
static labelList copyVertLabelsXml(const labelUList &connectivity, const label globalPointOffset)
#define FatalErrorInFunction
const labelList & cellTypes
static labelList copyFaceOffsetsXml(const labelUList &faceOffsets, const label prevOffset)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static void renumberVertLabelsXml(labelUList &connectivity, const label globalPointOffset)
static labelList copyFaceLabelsXml(const labelUList &faceLabels, const label globalPointOffset)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
bool insert(const Key &key)
iterator begin() noexcept
void populateShapesXml(const UList< cellShape > &shapes, UList< uint8_t > &cellTypes, labelUList &connectivity, labelUList &offsets, labelUList &faces, labelUList &facesOffsets, foamVtkMeshMaps &maps) const
#define definePopulateInternalMethod(Type)
A face is a list of labels corresponding to mesh vertices.
Maps a geometry to a set of cell primitives.
label nPoints() const noexcept
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
const labelList & cellMap() const noexcept
static const UList< T > & null()
UList< label > labelUList
A UList of labels.
A cell is defined as a list of faces with extra functionality.
bool operator==(const vtuSizing &rhs) const
void reset(const polyMesh &mesh, const bool decompose=false)
Bookkeeping for mesh subsetting and/or polyhedral cell decomposition. Although the main use case is f...
label sizeOf(const enum contentType output, const enum slotType slot) const
const cellModel & model() const