39void Foam::vtk::vtuSizing::presizeMaps(foamVtkMeshMaps& maps)
const
42 maps.additionalIds().resize(this->
nAddPoints());
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:
96 sizing.sizeXml(slotType::CELLS)
102 sizing.sizeXml(slotType::CELLS_OFFSETS)
104 if (sizing.nFaceLabels())
110 sizing.sizeXml(slotType::FACES)
117 sizing.sizeXml(slotType::FACES_OFFSETS)
123 case contentType::INTERNAL1:
130 sizing.sizeInternal1(slotType::CELLS)
136 sizing.sizeInternal1(slotType::CELLS_OFFSETS)
138 if (sizing.nFaceLabels())
144 sizing.sizeInternal1(slotType::FACES)
150 sizing.sizeInternal1(slotType::FACES_OFFSETS)
156 case contentType::INTERNAL2:
163 sizing.sizeInternal2(slotType::CELLS)
169 sizing.sizeInternal2(slotType::CELLS_OFFSETS)
171 if (sizing.nFaceLabels())
177 sizing.sizeInternal2(slotType::FACES)
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);
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();
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
488 case contentType::LEGACY:
492 case slotType::CELLS:
498 nVertLabels() + nAddVerts() - nVertPoly()
510 case contentType::XML:
514 case slotType::CELLS:
515 return (nVertLabels() + nAddVerts());
518 case slotType::CELLS_OFFSETS:
519 return nFieldCells();
522 case slotType::FACES:
523 return nFaceLabels();
526 case slotType::FACES_OFFSETS:
527 return nFaceLabels() ? nFieldCells() : 0;
533 case contentType::INTERNAL1:
537 case slotType::CELLS:
539 return (nVertLabels() + nAddVerts() + nFieldCells());
542 case slotType::CELLS_OFFSETS:
543 return nFieldCells();
546 case slotType::FACES:
547 return nFaceLabels();
550 case slotType::FACES_OFFSETS:
551 return nFaceLabels() ? nFieldCells() : 0;
557 case contentType::INTERNAL2:
561 case slotType::CELLS:
562 return (nVertLabels() + nAddVerts());
565 case slotType::CELLS_OFFSETS:
566 return (nFieldCells() + 1);
569 case slotType::FACES:
570 return nFaceLabels();
573 case slotType::FACES_OFFSETS:
574 return nFaceLabels() ? nFieldCells() : 0;
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;
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)
931 auto iter = faceLabels.
begin();
932 const auto last = faceLabels.
end();
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()
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
void clear()
Clear all entries from table.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
iterator end() noexcept
Return an iterator to end traversing the UList.
void size(const label n)
Older name for setAddressableSize.
Maps a geometry to a set of cell primitives.
An analytical geometric cellShape.
const cellModel & model() const
Model reference.
A cell is defined as a list of faces with extra functionality.
reference ref() const
A reference to the entry (Error if not found)
InfoProxy< ensightCells > info() const
Return info proxy.
void reset()
Reset to defaults.
A face is a list of labels corresponding to mesh vertices.
Bookkeeping for mesh subsetting and/or polyhedral cell decomposition. Although the main use case is f...
const labelList & additionalIds() const noexcept
Any additional (user) labels.
const labelList & cellMap() const noexcept
Original cell ids for all cells (regular and decomposed).
void checkSizes() const
Check that all components of sizes() are non-negative.
Mesh consisting of general polyhedral cells.
friend bool operator!=(const refineCell &rc1, const refineCell &rc2)
friend bool operator==(const refineCell &rc1, const refineCell &rc2)
Sizing descriptions and routines for transcribing an OpenFOAM volume mesh into a VTK unstructured gri...
label nAddCells() const noexcept
Number of additional (decomposed) cells for the mesh.
void clear() noexcept
Reset all sizes to zero.
vtuSizing() noexcept
Default construct.
void resetShapes(const UList< cellShape > &shapes)
Reset sizing using primitive shapes only (ADVANCED USAGE)
label sizeOf(const enum contentType output, const enum slotType slot) const
Return the required size for the storage slot.
static void renumberVertLabelsLegacy(labelUList &connectivity, const label globalPointOffset)
Renumber vertex labels by global point offset - legacy format.
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)
label nCellsPoly() const noexcept
Number of polyhedral cells for the mesh.
static labelList copyFaceLabelsXml(const labelUList &faceLabels, const label globalPointOffset)
Copy faces stream labels with a 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 nAddPoints() const noexcept
Number of additional (decomposed) points for 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.
static void renumberFaceLabelsXml(labelUList &faceLabels, const label globalPointOffset)
Renumber faces stream labels by global point offset - XML format.
void populateShapesLegacy(const UList< cellShape > &shapes, UList< uint8_t > &cellTypes, labelUList &connectivity, foamVtkMeshMaps &maps) const
Reset list for primitive shapes only (ADVANCED USAGE)
slotType
The possible storage 'slots' that can be used.
contentType
Types of content that the storage may represent.
static labelList copyVertLabelsXml(const labelUList &connectivity, const label globalPointOffset)
Copy vertex labels with a global point offset - XML format.
label nAddVerts() const noexcept
Number of additional (decomposed) vertices for the mesh.
static void renumberFaceOffsetsXml(labelUList &faceOffsets, const label prevOffset)
Renumber face offsets with an offset from previous - XML format.
static labelList copyVertLabelsLegacy(const labelUList &connectivity, const label globalPointOffset)
Copy vertex labels with a global point offset - legacy format.
label nVertLabels() const noexcept
Number of vertex labels for the mesh.
label nPoints() const noexcept
Number of points for the mesh.
static void renumberVertLabelsXml(labelUList &connectivity, const label globalPointOffset)
Renumber vertex labels by global point offset - XML format.
label nCells() const noexcept
Number of cells for the mesh.
label nFaceLabels() const noexcept
Number of polyhedral face labels for the mesh.
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 populateLegacy(const polyMesh &mesh, UList< uint8_t > &cellTypes, labelUList &connectivity, foamVtkMeshMaps &maps) const
Populate lists for Legacy output.
label nFieldCells() const noexcept
Number of field cells = nCells + nAddCells.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
#define CHECK_SIZING(what, sizeInput, sizeExpected)
#define definePopulateInternalMethod(Type)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
static Ostream & output(Ostream &os, const IntRange< T > &range)
bool notNull(const T *ptr)
True if ptr is not a pointer (of type T) to the nullObject.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
const labelList & cellTypes