diff --git a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L index 66cb8534a5..715a9a17e6 100644 --- a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L +++ b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L @@ -401,7 +401,7 @@ int main(int argc, char *argv[]) labelsTet[2] = pointMap[labels[2]]; labelsTet[3] = pointMap[labels[4]]; - cellShapes[nCells++] = cellShape(tet, labelsTet); + cellShapes[nCells++].reset(tet, labelsTet); } else if // Square-based pyramid @@ -417,7 +417,7 @@ int main(int argc, char *argv[]) labelsPyramid[3] = pointMap[labels[3]]; labelsPyramid[4] = pointMap[labels[4]]; - cellShapes[nCells++] = cellShape(pyr, labelsPyramid); + cellShapes[nCells++].reset(pyr, labelsPyramid); } else if // Triangular prism @@ -433,7 +433,7 @@ int main(int argc, char *argv[]) labelsPrism[4] = pointMap[labels[5]]; labelsPrism[5] = pointMap[labels[6]]; - cellShapes[nCells++] = cellShape(prism, labelsPrism); + cellShapes[nCells++].reset(prism, labelsPrism); } else // Hex @@ -447,7 +447,7 @@ int main(int argc, char *argv[]) labelsHex[6] = pointMap[labels[6]]; labelsHex[7] = pointMap[labels[7]]; - cellShapes[nCells++] = cellShape(hex, labelsHex); + cellShapes[nCells++].reset(hex, labelsHex); } } diff --git a/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C b/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C index 3039c16a56..140babc1b9 100644 --- a/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C +++ b/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C @@ -574,7 +574,7 @@ int main(int argc, char *argv[]) ]; } - cellShapes[nCreatedCells] = cellShape(hex, cellPoints); + cellShapes[nCreatedCells].reset(hex, cellPoints); nCreatedCells++; } diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.C b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.C index 424d8224ff..67d2c57136 100644 --- a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.C +++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.C @@ -238,15 +238,14 @@ cellShape extrudedQuadCellShape return cellShape(hex, cellShapeLabels); } - else - { - FatalErrorInFunction - << "Problem with edge matching. Edges: " << localFaces - << abort(FatalError); - } + + + FatalErrorInFunction + << "Problem with edge matching. Edges: " << localFaces + << abort(FatalError); // Return added to keep compiler happy - return cellShape(hex, labelList(0)); + return cellShape(hex, labelList()); } diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.C b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.C index 368d74cbea..d8e95efd13 100644 --- a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.C +++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.C @@ -178,15 +178,14 @@ cellShape extrudedTriangleCellShape return cellShape(prism, cellShapeLabels); } - else - { - FatalErrorInFunction - << "Problem with edge matching. Edges: " << localFaces - << abort(FatalError); - } + + + FatalErrorInFunction + << "Problem with edge matching. Edges: " << localFaces + << abort(FatalError); // Return added to keep compiler happy - return cellShape(prism, labelList(0)); + return cellShape(prism, labelList()); } diff --git a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L index f8a226a635..7d038faf49 100644 --- a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L +++ b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L @@ -731,7 +731,7 @@ int main(int argc, char *argv[]) labelsTet[2] = pointLookup[curCellLabels[3] ]; labelsTet[3] = pointLookup[curCellLabels[1] ]; - cells[celli] = cellShape(tet, labelsTet); + cells[celli].reset(tet, labelsTet); } // Square-based pyramid @@ -743,7 +743,7 @@ int main(int argc, char *argv[]) labelsPyramid[3] = pointLookup[curCellLabels[2] ]; labelsPyramid[4] = pointLookup[curCellLabels[4] ]; - cells[celli] = cellShape(pyr, labelsPyramid); + cells[celli].reset(pyr, labelsPyramid); } // Triangular prism @@ -756,7 +756,7 @@ int main(int argc, char *argv[]) labelsPrism[4] = pointLookup[curCellLabels[4] ]; labelsPrism[5] = pointLookup[curCellLabels[5] ]; - cells[celli] = cellShape(prism, labelsPrism); + cells[celli].reset(prism, labelsPrism); } // Hex @@ -771,7 +771,7 @@ int main(int argc, char *argv[]) labelsHex[6] = pointLookup[curCellLabels[7] ]; labelsHex[7] = pointLookup[curCellLabels[6] ]; - cells[celli] = cellShape(hex, labelsHex); + cells[celli].reset(hex, labelsHex); } } diff --git a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C index b7e6909ff2..83685328e7 100644 --- a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C +++ b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C @@ -664,7 +664,7 @@ void readCellsLegacy renumber(mshToFoam, tetPoints); - cells[celli++] = cellShape(tet, tetPoints); + cells[celli++].reset(tet, tetPoints); nTet++; } @@ -685,7 +685,7 @@ void readCellsLegacy renumber(mshToFoam, pyrPoints); - cells[celli++] = cellShape(pyr, pyrPoints); + cells[celli++].reset(pyr, pyrPoints); nPyr++; } @@ -706,7 +706,7 @@ void readCellsLegacy renumber(mshToFoam, prismPoints); - cells[celli] = cellShape(prism, prismPoints); + cells[celli].reset(prism, prismPoints); const cellShape& cell = cells[celli]; @@ -721,7 +721,7 @@ void readCellsLegacy prismPoints[4] = cell[4]; prismPoints[5] = cell[5]; - cells[celli] = cellShape(prism, prismPoints); + cells[celli].reset(prism, prismPoints); } celli++; @@ -747,7 +747,7 @@ void readCellsLegacy renumber(mshToFoam, hexPoints); - cells[celli] = cellShape(hex, hexPoints); + cells[celli].reset(hex, hexPoints); const cellShape& cell = cells[celli]; @@ -764,7 +764,7 @@ void readCellsLegacy hexPoints[6] = cell[2]; hexPoints[7] = cell[3]; - cells[celli] = cellShape(hex, hexPoints); + cells[celli].reset(hex, hexPoints); } celli++; @@ -1019,7 +1019,7 @@ void readCells renumber(mshToFoam, tetPoints); - cells[celli++] = cellShape(tet, tetPoints); + cells[celli++].reset(tet, tetPoints); } } else if (elmType == MSHPYR) @@ -1046,7 +1046,7 @@ void readCells renumber(mshToFoam, pyrPoints); - cells[celli++] = cellShape(pyr, pyrPoints); + cells[celli++].reset(pyr, pyrPoints); } } else if (elmType == MSHPRISM) @@ -1073,7 +1073,7 @@ void readCells renumber(mshToFoam, prismPoints); - cells[celli] = cellShape(prism, prismPoints); + cells[celli].reset(prism, prismPoints); const cellShape& cell = cells[celli]; @@ -1088,7 +1088,7 @@ void readCells prismPoints[4] = cell[4]; prismPoints[5] = cell[5]; - cells[celli] = cellShape(prism, prismPoints); + cells[celli].reset(prism, prismPoints); } celli++; @@ -1120,7 +1120,7 @@ void readCells renumber(mshToFoam, hexPoints); - cells[celli] = cellShape(hex, hexPoints); + cells[celli].reset(hex, hexPoints); const cellShape& cell = cells[celli]; @@ -1137,7 +1137,7 @@ void readCells hexPoints[6] = cell[2]; hexPoints[7] = cell[3]; - cells[celli] = cellShape(hex, hexPoints); + cells[celli].reset(hex, hexPoints); } celli++; diff --git a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H index ef364203ba..ca08396837 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H +++ b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H @@ -128,7 +128,7 @@ for (label i=0; i> hexPoints[cp]; } - cells[celli] = cellShape(hex, hexPoints); + cells[celli].reset(hex, hexPoints); } } else @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) { mshStream >> tetPoints[cp]; } - cells[celli] = cellShape(tet, tetPoints); + cells[celli].reset(tet, tetPoints); } } diff --git a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C index 3dc8bfb9ed..79145cdae3 100644 --- a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C +++ b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C @@ -154,7 +154,7 @@ int main(int argc, char *argv[]) tetPoints[2] = readLabel(str) - 1; tetPoints[3] = readLabel(str) - 1; - cells[celli] = cellShape(tet, tetPoints); + cells[celli].reset(tet, tetPoints); } diff --git a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C index 1a95f8fec2..840a847a62 100644 --- a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C +++ b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C @@ -231,7 +231,7 @@ int main(int argc, char *argv[]) } // Do automatic collapse from hex. - cellShapes[nCreatedCells] = cellShape(hex, cellPoints, true); + cellShapes[nCreatedCells].reset(hex, cellPoints, true); nCreatedCells++; } diff --git a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C index 1d457708d8..c9928cee38 100644 --- a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C +++ b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C @@ -309,7 +309,7 @@ int main(int argc, char *argv[]) tetPoints[i] = nodeToPoint[nodeI]; } - cells[celli++] = cellShape(tet, tetPoints); + cells[celli++].reset(tet, tetPoints); // Skip attributes for (label i = 0; i < nElemAttr; i++) diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C index 31aa11ad32..38418eb6fd 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C @@ -273,7 +273,7 @@ autoPtr generateHexMesh hexPoints[5] = vtxLabel(nCells, i+1, j, k+1); hexPoints[6] = vtxLabel(nCells, i+1, j+1, k+1); hexPoints[7] = vtxLabel(nCells, i, j+1, k+1); - cellShapes[celli++] = cellShape(hex, hexPoints); + cellShapes[celli++].reset(hex, hexPoints); } } } diff --git a/applications/utilities/preProcessing/createBoxTurb/createBlockMesh.H b/applications/utilities/preProcessing/createBoxTurb/createBlockMesh.H index 3e22ad2f1f..12690b467e 100644 --- a/applications/utilities/preProcessing/createBoxTurb/createBlockMesh.H +++ b/applications/utilities/preProcessing/createBoxTurb/createBlockMesh.H @@ -34,8 +34,7 @@ pointField points; cellShapes.setSize(bCells.size()); forAll(cellShapes, celli) { - cellShapes[celli] = - cellShape(hex, labelList(bCells[celli]), false); + cellShapes[celli].reset(hex, labelList(bCells[celli]), false); } Info<< "Creating boundary faces" << endl; diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.C index 6446899751..cc6eadbd68 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.C @@ -334,8 +334,7 @@ bool Foam::hexMatcher::matches ) ) { - shape = cellShape(model(), vertLabels()); - + shape.reset(model(), vertLabels()); return true; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.C index 566d4ed522..b1355d3dd7 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.C @@ -371,8 +371,7 @@ bool Foam::prismMatcher::matches ) ) { - shape = cellShape(model(), vertLabels()); - + shape.reset(model(), vertLabels()); return true; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.C index 73ce01907f..237cb4dc3a 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.C @@ -329,8 +329,7 @@ bool Foam::pyrMatcher::matches ) ) { - shape = cellShape(model(), vertLabels()); - + shape.reset(model(), vertLabels()); return true; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.C index 27b7fc0020..c57ca66c49 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.C @@ -274,8 +274,7 @@ bool Foam::tetMatcher::matches ) ) { - shape = cellShape(model(), vertLabels()); - + shape.reset(model(), vertLabels()); return true; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.C index e85f543e95..57798eb5df 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.C @@ -296,8 +296,7 @@ bool Foam::tetWedgeMatcher::matches ) ) { - shape = cellShape(model(), vertLabels()); - + shape.reset(model(), vertLabels()); return true; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.C index e3c76909d0..374a8028bb 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.C @@ -396,8 +396,7 @@ bool Foam::wedgeMatcher::matches ) ) { - shape = cellShape(model(), vertLabels()); - + shape.reset(model(), vertLabels()); return true; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H index 200670501a..0be81406c7 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H +++ b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -105,7 +105,7 @@ public: inline cellShape ( const cellModel& model, - labelUList&& labels, + labelList&& labels, const bool doCollapse = false ); @@ -173,18 +173,26 @@ public: //- Centroid of the cell inline point centre(const UList& points) const; + //- Scalar magnitude + inline scalar mag(const UList& points) const; + + //- Reset from components + inline void reset + ( + const cellModel& model, + const labelUList& labels, + const bool doCollapse = false + ); + + //- Collapse shape to correct one after removing duplicate vertices + void collapse(); + //- Return info proxy, to print information to a stream Foam::InfoProxy info() const { return *this; } - //- Scalar magnitude - inline scalar mag(const UList& points) const; - - //- Collapse shape to correct one after removing duplicate vertices - void collapse(); - // Friend Operators diff --git a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H index 4af2f862d2..2c24a4b804 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H +++ b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -78,7 +78,7 @@ inline Foam::cellShape::cellShape inline Foam::cellShape::cellShape ( const cellModel& model, - labelUList&& labels, + labelList&& labels, const bool doCollapse ) : @@ -296,4 +296,21 @@ inline Foam::scalar Foam::cellShape::mag(const UList& points) const } +inline void Foam::cellShape::reset +( + const cellModel& model, + const labelUList& labels, + const bool doCollapse +) +{ + static_cast(*this) = labels; + m = &model; + + if (doCollapse) + { + collapse(); + } +} + + // ************************************************************************* // diff --git a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C index 4f7657e61c..a4d910ff9f 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -130,8 +130,7 @@ void Foam::blockMesh::createCells() const } // Construct collapsed cell and add to list - cells_[celli] = cellShape(hex, cellPoints, true); - + cells_[celli].reset(hex, cellPoints, true); ++celli; } } diff --git a/src/overset/cellCellStencil/trackingInverseDistance/voxelMeshSearch.C b/src/overset/cellCellStencil/trackingInverseDistance/voxelMeshSearch.C index e717c80c58..0177fd9ae7 100644 --- a/src/overset/cellCellStencil/trackingInverseDistance/voxelMeshSearch.C +++ b/src/overset/cellCellStencil/trackingInverseDistance/voxelMeshSearch.C @@ -518,8 +518,7 @@ Foam::autoPtr Foam::voxelMeshSearch::makeMesh cellShapes.setSize(bCells.size()); forAll(cellShapes, celli) { - cellShapes[celli] = - cellShape(hex, labelList(bCells[celli]), false); + cellShapes[celli].reset(hex, labelList(bCells[celli]), false); } //Info<< "Creating boundary faces" << endl;