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:
101 sizing.sizeXml(slotType::CELLS_OFFSETS)
103 if (sizing.nFaceLabels())
116 sizing.sizeXml(slotType::FACES_OFFSETS)
122 case contentType::INTERNAL1:
135 sizing.sizeInternal1(slotType::CELLS_OFFSETS)
137 if (sizing.nFaceLabels())
149 sizing.sizeInternal1(slotType::FACES_OFFSETS)
155 case contentType::INTERNAL2:
168 sizing.sizeInternal2(slotType::CELLS_OFFSETS)
170 if (sizing.nFaceLabels())
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);
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)
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)
380 nFaceLabels_ +=
f.size();
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
478 case contentType::LEGACY:
488 nVertLabels() + nAddVerts() - nVertPoly()
500 case contentType::XML:
505 return (nVertLabels() + nAddVerts());
508 case slotType::CELLS_OFFSETS:
509 return nFieldCells();
513 return nFaceLabels();
516 case slotType::FACES_OFFSETS:
517 return nFaceLabels() ? nFieldCells() : 0;
523 case contentType::INTERNAL1:
529 return (nVertLabels() + nAddVerts() + nFieldCells());
532 case slotType::CELLS_OFFSETS:
533 return nFieldCells();
537 return nFaceLabels();
540 case slotType::FACES_OFFSETS:
541 return nFaceLabels() ? nFieldCells() : 0;
547 case contentType::INTERNAL2:
552 return (nVertLabels() + nAddVerts());
555 case slotType::CELLS_OFFSETS:
556 return (nFieldCells() + 1);
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
Number of additional (decomposed) cells for the mesh.
static void renumberFaceLabelsXml(labelUList &faceLabels, const label globalPointOffset)
Renumber faces stream labels by global point offset - XML format.
label nCells() const noexcept
Number of cells for the mesh.
label nVertLabels() const noexcept
Number of vertex labels for the mesh.
static Ostream & output(Ostream &os, const IntRange< T > &range)
void resetShapes(const UList< cellShape > &shapes)
Reset sizing using primitive shapes only (ADVANCED USAGE)
iterator end() noexcept
Return an iterator to end traversing the UList.
void populateLegacy(const polyMesh &mesh, UList< uint8_t > &cellTypes, labelUList &connectivity, foamVtkMeshMaps &maps) const
Populate lists for Legacy output.
label nFaceLabels() const noexcept
Number of polyhedral face labels for the mesh.
contentType
Types of content that the storage may represent.
const labelList & additionalIds() const noexcept
Any additional (user) labels.
void info(Ostream &os) const
Report some information.
label nAddVerts() const noexcept
Number of additional (decomposed) vertices for the mesh.
label nAddPoints() const noexcept
Number of additional (decomposed) points for the mesh.
Mesh consisting of general polyhedral cells.
static labelList copyVertLabelsLegacy(const labelUList &connectivity, const label globalPointOffset)
Copy vertex labels with a global point offset - legacy format.
bool operator!=(const vtuSizing &rhs) const
Test inequality.
#define CHECK_SIZING(what, sizeInput, sizeExpected)
iterator begin() noexcept
Return an iterator to begin traversing the UList.
void populateXml(const polyMesh &mesh, UList< uint8_t > &cellTypes, labelUList &connectivity, labelUList &offsets, labelUList &faces, labelUList &facesOffsets, foamVtkMeshMaps &maps) const
Populate lists for XML output.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
label nCellsPoly() const noexcept
Number of polyhedral cells for the mesh.
label nFieldCells() const noexcept
Number of field cells = nCells + nAddCells.
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
void populateShapesLegacy(const UList< cellShape > &shapes, UList< uint8_t > &cellTypes, labelUList &connectivity, foamVtkMeshMaps &maps) const
Reset list for primitive shapes only (ADVANCED USAGE)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
static void renumberVertLabelsLegacy(labelUList &connectivity, const label globalPointOffset)
Renumber vertex labels by global point offset - legacy format.
bool notNull(const T *ptr)
True if ptr is not a pointer (of type T) to the nullObject.
slotType
The possible storage 'slots' that can be used.
bool decompose() const noexcept
Query the decompose flag (normally off)
OBJstream os(runTime.globalPath()/outputName)
An analytical geometric cellShape.
label nVertPoly() const noexcept
Number of vertex labels for polyhedral cells of the mesh.
Sizing descriptions and routines for transcribing an OpenFOAM volume mesh into a VTK unstructured gri...
static void renumberFaceOffsetsXml(labelUList &faceOffsets, const label prevOffset)
Renumber face offsets with an offset from previous - XML format.
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))
void clear() noexcept
Reset all sizes to zero.
static labelList copyVertLabelsXml(const labelUList &connectivity, const label globalPointOffset)
Copy vertex labels with a global point offset - XML format.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const labelList & cellTypes
static labelList copyFaceOffsetsXml(const labelUList &faceOffsets, const label prevOffset)
Copy face offsets with an offset from previous - XML format.
static void renumberVertLabelsXml(labelUList &connectivity, const label globalPointOffset)
Renumber vertex labels by global point offset - XML format.
static labelList copyFaceLabelsXml(const labelUList &faceLabels, const label globalPointOffset)
Copy faces stream labels with a global point offset - XML format.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
void populateShapesXml(const UList< cellShape > &shapes, UList< uint8_t > &cellTypes, labelUList &connectivity, labelUList &offsets, labelUList &faces, labelUList &facesOffsets, foamVtkMeshMaps &maps) const
Reset list for primitive shapes only (ADVANCED USAGE)
#define definePopulateInternalMethod(Type)
vtuSizing() noexcept
Default construct.
A face is a list of labels corresponding to mesh vertices.
Maps a geometry to a set of cell primitives.
void size(const label n)
Older name for setAddressableSize.
label nPoints() const noexcept
Number of points for the mesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static const UList< T > & null()
Return a UList reference to a nullObject.
A cell is defined as a list of faces with extra functionality.
bool operator==(const vtuSizing &rhs) const
Test equality.
void reset(const polyMesh &mesh, const bool decompose=false)
Reset sizing by analyzing the mesh.
Bookkeeping for mesh subsetting and/or polyhedral cell decomposition. Although the main use case is f...
const labelList & cellMap() const noexcept
Original cell ids for all cells (regular and decomposed).
label sizeOf(const enum contentType output, const enum slotType slot) const
Return the required size for the storage slot.
const cellModel & model() const
Model reference.