39 void Foam::vtk::vtuSizing::presizeMaps(foamVtkMeshMaps& maps)
const 42 maps.additionalIds().resize(this->
nAddPoints());
46 void Foam::vtk::vtuSizing::checkSizes
48 const vtk::vtuSizing& sizing,
50 const label cellTypes_size,
51 const label vertLabels_size,
52 const label vertOffset_size,
53 const label faceLabels_size,
54 const label faceOffset_size,
56 const enum contentType
output,
57 const label cellMap_size,
58 const label addPointsIds_size
64 #define CHECK_SIZING(what, sizeInput, sizeExpected) \ 65 if (sizeInput != sizeExpected) \ 69 FatalErrorInFunction << "VTK sizing error" << nl; \ 72 << " " << what << " size=" << sizeInput \ 73 << " expected " << sizeExpected << nl; \ 77 CHECK_SIZING(
"cellTypes", cellTypes_size, sizing.nFieldCells());
78 CHECK_SIZING(
"cellMap", cellMap_size, sizing.nFieldCells());
79 CHECK_SIZING(
"addPointsIds", addPointsIds_size, sizing.nAddPoints());
83 case contentType::LEGACY:
85 CHECK_SIZING(
"legacy", vertLabels_size, sizing.sizeLegacy());
89 case contentType::XML:
102 sizing.sizeXml(slotType::CELLS_OFFSETS)
104 if (sizing.nFaceLabels())
117 sizing.sizeXml(slotType::FACES_OFFSETS)
123 case contentType::INTERNAL1:
136 sizing.sizeInternal1(slotType::CELLS_OFFSETS)
138 if (sizing.nFaceLabels())
150 sizing.sizeInternal1(slotType::FACES_OFFSETS)
156 case contentType::INTERNAL2:
169 sizing.sizeInternal2(slotType::CELLS_OFFSETS)
171 if (sizing.nFaceLabels())
183 sizing.sizeInternal2(slotType::FACES_OFFSETS)
194 <<
"Total of " << nErrors <<
" sizing errors encountered!" 217 reset(
mesh, decompose);
227 selectionMode_ = FULL_MESH;
277 const bool isSubsetMesh
285 selectionMode_ = selectionModeType::SUBSET_MESH;
289 decompose_ = decompose;
290 selectionMode_ = selectionModeType::FULL_MESH;
296 const label nInputCells =
299 ? subsetCellsIds.
size()
303 nCells_ = nInputCells;
304 nPoints_ =
mesh.nPoints();
308 nCellsPoly_ = nCells_;
313 for (label inputi = 0; inputi < nInputCells; ++inputi)
315 const label celli(isSubsetMesh ? subsetCellsIds[inputi] : inputi);
317 const cellShape& shape = shapes[celli];
318 const cellModel& model = shape.model();
330 nVertLabels_ += shape.
size();
332 else if (model == tetWedge && decompose_)
336 else if (model == wedge && decompose_)
348 const cell& cFaces = meshCells[celli];
349 for (
const label facei : cFaces)
351 const face&
f = meshFaces[facei];
355 label nTria = 0, nQuad = 0;
356 f.nTrianglesQuads(
mesh.points(), nTria, nQuad);
358 nAddCells_ += nTria + nQuad;
359 nAddVerts_ += (nTria * 4) + (nQuad * 5);
366 const label nvrt = (nQuad ? 5 : 4);
368 nVertLabels_ += nvrt;
376 const labelList& cFaces = meshCells[celli];
385 for (
const label facei : cFaces)
387 const face&
f = meshFaces[facei];
388 nFaceLabels_ +=
f.size();
390 hashUniqId.insert(
f);
395 nVertLabels_ += hashUniqId.size();
396 nVertPoly_ += hashUniqId.size();
398 nFaceLabels_ += 1 + cFaces.size();
403 decompose_ = (decompose_ && nCellsPoly_);
424 selectionMode_ = SHAPE_MESH;
426 const label nInputCells = shapes.
size();
428 nCells_ = nInputCells;
440 for (label inputi = 0; inputi < nInputCells; ++inputi)
453 nVertLabels_ += shape.
size();
456 nPoints_ =
max(nPoints_,
max(shape));
468 <<
"Encountered " << nIgnored <<
" unsupported cell shapes" 469 <<
" ... this is likely not good" <<
nl 482 const enum contentType
output,
483 const enum slotType slot
488 case contentType::LEGACY:
498 nVertLabels() + nAddVerts() - nVertPoly()
510 case contentType::XML:
515 return (nVertLabels() + nAddVerts());
518 case slotType::CELLS_OFFSETS:
519 return nFieldCells();
526 case slotType::FACES_OFFSETS:
533 case contentType::INTERNAL1:
539 return (nVertLabels() + nAddVerts() + nFieldCells());
542 case slotType::CELLS_OFFSETS:
543 return nFieldCells();
550 case slotType::FACES_OFFSETS:
557 case contentType::INTERNAL2:
562 return (nVertLabels() + nAddVerts());
565 case slotType::CELLS_OFFSETS:
566 return (nFieldCells() + 1);
573 case slotType::FACES_OFFSETS:
706 #undef definePopulateInternalMethod 707 #define definePopulateInternalMethod(Type) \ 709 void Foam::vtk::vtuSizing::populateInternal \ 711 const polyMesh& mesh, \ 712 UList<uint8_t>& cellTypes, \ 713 UList<Type>& connectivity, \ 714 UList<Type>& offsets, \ 715 UList<Type>& faces, \ 716 UList<Type>& facesOffsets, \ 717 foamVtkMeshMaps& maps, \ 718 const enum contentType output \ 734 maps.additionalIds() \ 738 void Foam::vtk::vtuSizing::populateInternal \ 740 const polyMesh& mesh, \ 741 UList<uint8_t>& cellTypes, \ 742 UList<Type>& connectivity, \ 743 UList<Type>& offsets, \ 744 UList<Type>& faces, \ 745 UList<Type>& facesOffsets, \ 746 labelUList& cellMap, \ 747 labelUList& addPointsIds, \ 748 const enum contentType output \ 772 #undef definePopulateInternalMethod 780 const label globalPointOffset
783 if (!globalPointOffset)
789 renumberVertLabelsLegacy(
output, globalPointOffset);
798 const label globalPointOffset
801 if (!globalPointOffset)
819 auto iter = vertLabels.
begin();
820 const auto last = vertLabels.
end();
824 label nLabels = *iter;
833 *iter += globalPointOffset;
841 label nFaces = *iter;
851 *iter += globalPointOffset;
863 const label globalPointOffset
866 if (!globalPointOffset)
872 renumberVertLabelsXml(
output, globalPointOffset);
881 const label globalPointOffset
884 if (!globalPointOffset)
892 for (label& vertId : vertLabels)
894 vertId += globalPointOffset;
902 const label globalPointOffset
905 if (!globalPointOffset)
911 renumberFaceLabelsXml(
output, globalPointOffset);
920 const label globalPointOffset
923 if (!globalPointOffset)
936 label nFaces = *iter;
941 label nLabels = *iter;
946 *iter += globalPointOffset;
957 const label prevOffset
966 renumberFaceOffsetsXml(
output, prevOffset);
975 const label prevOffset
986 for (label& val : faceOffsets)
1000 os <<
"nFieldCells:" << nFieldCells();
1003 os <<
" (" << nCells_ <<
"+" << nAddCells_ <<
")";
1007 os <<
" (poly:" << nCellsPoly_ <<
")";
1010 os <<
" nFieldPoints:" << nFieldPoints();
1013 os <<
" (" << nPoints_ <<
"+" << nAddPoints_ <<
")";
1016 os <<
" nVertLabels:" << (nVertLabels_ + nAddVerts_);
1019 os <<
" (" << nVertLabels_ <<
"+" << nAddVerts_ <<
")";
1021 else if (nVertPoly_)
1023 os <<
" (poly:" << nVertPoly_ <<
")";
1026 os <<
" nFaceLabels:" << nFaceLabels_;
1027 os <<
" legacy-count:" << sizeLegacy();
1039 && nCells() == rhs.
nCells()
vtuSizing() noexcept
Default construct.
void size(const label n)
Older name for setAddressableSize.
void populateShapesLegacy(const UList< cellShape > &shapes, UList< uint8_t > &cellTypes, labelUList &connectivity, foamVtkMeshMaps &maps) const
Reset list for primitive shapes only (ADVANCED USAGE)
const labelList & cellMap() const noexcept
Original cell ids for all cells (regular and decomposed).
errorManipArg< error, int > exit(error &err, const int errNo=1)
label nVertLabels() const noexcept
Number of vertex labels for the mesh.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
IOstream & hex(IOstream &io)
static void renumberFaceOffsetsXml(labelUList &faceOffsets, const label prevOffset)
Renumber face offsets with an offset from previous - XML format.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool operator==(const vtuSizing &rhs) const
Test equality.
label nAddVerts() const noexcept
Number of additional (decomposed) vertices for the mesh.
static const manifoldCellsMeshObject & New(const polyMesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
void populateLegacy(const polyMesh &mesh, UList< uint8_t > &cellTypes, labelUList &connectivity, foamVtkMeshMaps &maps) const
Populate lists for Legacy output.
An analytical geometric cellShape.
constexpr char nl
The newline '\n' character (0x0a)
void reset(const polyMesh &mesh, const bool decompose=false)
Reset sizing by analyzing the mesh.
bool decompose() const noexcept
Query the decompose flag (normally off)
label nVertPoly() const noexcept
Number of vertex labels for polyhedral cells of the mesh.
label nFaceLabels() const noexcept
Number of polyhedral face labels for the mesh.
labelList faceLabels(nFaceLabels)
const labelList & additionalIds() const noexcept
Any additional (user) labels.
Bookkeeping for mesh subsetting and/or polyhedral cell decomposition. Although the main use case is f...
UList< label > labelUList
A UList of labels.
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
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 CHECK_SIZING(what, sizeInput, sizeExpected)
static labelList copyFaceLabelsXml(const labelUList &faceLabels, const label globalPointOffset)
Copy faces stream labels with a global point offset - XML format.
static void renumberVertLabelsLegacy(labelUList &connectivity, const label globalPointOffset)
Renumber vertex labels by global point offset - legacy format.
bool operator!=(const vtuSizing &rhs) const
Test inequality.
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.
void clear()
Clear the list, i.e. set size to zero.
void info(Ostream &os) const
Report some information.
label nAddPoints() const noexcept
Number of additional (decomposed) points for the mesh.
static labelList copyVertLabelsLegacy(const labelUList &connectivity, const label globalPointOffset)
Copy vertex labels with a global point offset - legacy format.
label nCells() const noexcept
Number of cells for the mesh.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
const labelList & cellTypes
static labelList copyVertLabelsXml(const labelUList &connectivity, const label globalPointOffset)
Copy vertex labels with a global point offset - XML format.
OBJstream os(runTime.globalPath()/outputName)
bool manifold() const
True if any manifold cells detected (globally) Triggers demand-driven filtering if required...
label nFieldCells() const noexcept
Number of field cells = nCells + nAddCells.
const cellModel & model() const
Model reference.
Sizing descriptions and routines for transcribing an OpenFOAM volume mesh into a VTK unstructured gri...
bool notNull(const T *ptr) noexcept
True if ptr is not a pointer (of type T) to the nullObject.
static void renumberFaceLabelsXml(labelUList &faceLabels, const label globalPointOffset)
Renumber faces stream labels by global point offset - XML format.
static labelList copyFaceOffsetsXml(const labelUList &faceOffsets, const label prevOffset)
Copy face offsets with an offset from previous - XML format.
label nPoints() const noexcept
Number of points for the mesh.
Maps a geometry to a set of cell primitives.
label sizeOf(const enum contentType output, const enum slotType slot) const
Return the required size for the storage slot.
static const UList< label > & null() noexcept
Return a null UList (reference to a nullObject). Behaves like an empty UList.
static Ostream & output(Ostream &os, const IntRange< T > &range)
label nAddCells() const noexcept
Number of additional (decomposed) cells for the mesh.
label nCellsPoly() const noexcept
Number of polyhedral cells for the mesh.
Mesh consisting of general polyhedral cells.
void clear() noexcept
Reset all sizes to zero.
iterator end() noexcept
Return an iterator to end traversing the UList.
List< label > labelList
A List of labels.
void resetShapes(const UList< cellShape > &shapes)
Reset sizing using primitive shapes only (ADVANCED USAGE)
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
static void renumberVertLabelsXml(labelUList &connectivity, const label globalPointOffset)
Renumber vertex labels by global point offset - XML format.
const cellList & cells() const
Return the (optionally compacted) cell list Triggers demand-driven filtering if required.
#define definePopulateInternalMethod(Type)