From 8730a7622a33eead1e471d64490fc2d46891c780 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sat, 18 Nov 2017 11:05:05 +0100 Subject: [PATCH] ENH: enumerations for known cell models in cellModel, ptr/ref lookups - this provides a better typesafe means of locating predefined cell models than relying on strings. The lookup is now ptr() or ref() directly. The lookup functions behave like on-demand singletons when loading "etc/cellModels". Functionality is now located entirely in cellModel but a forwarding version of cellModeller is provided for API (but not ABI) compatibility with older existing user code. STYLE: use constexpr for cellMatcher constants --- .../solvers/combustion/chemFoam/chemFoam.C | 2 +- .../chemFoam/createSingleCellMesh.H | 5 +- applications/test/boundBox/Test-boundBox.C | 14 +- applications/test/cellModels/Make/files | 3 + applications/test/cellModels/Make/options | 0 .../test/cellModels/Test-cellModels.C | 97 +++++++++ .../mesh/advanced/splitCells/splitCells.C | 4 +- .../mesh/conversion/ansysToFoam/ansysToFoam.L | 9 +- .../mesh/conversion/cfx4ToFoam/cfx4ToFoam.C | 3 +- .../fluentMeshToFoam/cellShapeRecognition.H | 1 - .../fluentMeshToFoam/create3DCellShape.C | 10 +- .../fluentMeshToFoam/extrudedQuadCellShape.C | 2 +- .../extrudedTriangleCellShape.C | 4 +- .../foamMeshToFluent/fluentFvMesh.C | 10 +- .../foamToStarMesh/foamToStarMesh.C | 4 +- .../conversion/gambitToFoam/gambitToFoam.L | 9 +- .../mesh/conversion/gmshToFoam/gmshToFoam.C | 10 +- .../ideasUnvToFoam/ideasUnvToFoam.C | 8 +- .../mesh/conversion/kivaToFoam/kivaToFoam.C | 1 - .../mesh/conversion/kivaToFoam/readKivaGrid.H | 2 +- .../mesh/conversion/mshToFoam/mshToFoam.C | 6 +- .../netgenNeutralToFoam/netgenNeutralToFoam.C | 4 +- .../conversion/plot3dToFoam/plot3dToFoam.C | 3 +- .../mesh/conversion/star4ToFoam/star4ToFoam.C | 6 +- .../conversion/tetgenToFoam/tetgenToFoam.C | 5 +- .../foamyHexMeshBackgroundMesh.C | 3 +- .../generation/snappyHexMesh/snappyHexMesh.C | 1 - .../USERD_get_part_elements_by_type.H | 8 +- .../ensightFoamReader/getFieldScalar.H | 10 +- .../ensightFoamReader/getFieldTensor.H | 10 +- .../ensightFoamReader/getFieldVector.H | 10 +- .../graphics/ensightFoamReader/libuserd.C | 2 +- etc/cellModels | 5 +- etc/config.csh/ADIOS | 6 +- etc/config.sh/ADIOS | 6 +- src/OpenFOAM/Make/files | 4 +- src/OpenFOAM/global/global.Cver | 5 - src/OpenFOAM/meshes/meshShapes/cell/cell.C | 16 +- src/OpenFOAM/meshes/meshShapes/cell/cell.H | 25 +-- src/OpenFOAM/meshes/meshShapes/cell/cellI.H | 2 + .../meshes/meshShapes/cell/oppositeCellFace.C | 90 ++++---- .../meshShapes/cellMatcher/cellMatcher.C | 35 ++- .../meshShapes/cellMatcher/cellMatcher.H | 9 +- .../meshShapes/cellMatcher/cellMatcherI.H | 4 +- .../cellMatcher/degenerateMatcher.C | 18 +- .../cellMatcher/degenerateMatcher.H | 3 +- .../meshShapes/cellMatcher/hexMatcher.C | 19 +- .../meshShapes/cellMatcher/hexMatcher.H | 20 +- .../meshShapes/cellMatcher/prismMatcher.C | 33 +-- .../meshShapes/cellMatcher/prismMatcher.H | 18 +- .../meshShapes/cellMatcher/pyrMatcher.C | 34 +-- .../meshShapes/cellMatcher/pyrMatcher.H | 20 +- .../meshShapes/cellMatcher/tetMatcher.C | 22 +- .../meshShapes/cellMatcher/tetMatcher.H | 18 +- .../meshShapes/cellMatcher/tetWedgeMatcher.C | 35 +-- .../meshShapes/cellMatcher/tetWedgeMatcher.H | 20 +- .../meshShapes/cellMatcher/wedgeMatcher.C | 33 +-- .../meshShapes/cellMatcher/wedgeMatcher.H | 20 +- .../meshes/meshShapes/cellModel/cellModel.C | 3 +- .../meshes/meshShapes/cellModel/cellModel.H | 155 ++++++++++---- .../meshes/meshShapes/cellModel/cellModelI.H | 70 +++--- .../meshes/meshShapes/cellModel/cellModelIO.C | 32 +-- .../meshShapes/cellModel/cellModeller.H | 54 +++++ .../meshes/meshShapes/cellModel/cellModels.C | 200 ++++++++++++++++++ .../meshShapes/cellModeller/cellModeller.C | 103 --------- .../meshShapes/cellModeller/cellModeller.H | 100 --------- .../cellModeller/globalCellModeller.C | 54 ----- .../meshes/meshShapes/cellShape/cellShape.H | 8 +- .../meshes/meshShapes/cellShape/cellShapeI.H | 18 +- .../meshes/meshShapes/cellShape/cellShapeIO.C | 13 +- src/OpenFOAM/meshes/meshShapes/edge/edge.H | 4 +- src/OpenFOAM/meshes/meshShapes/edge/edgeI.H | 5 +- .../meshes/meshShapes/tetCell/tetCell.C | 8 +- .../meshes/meshShapes/tetCell/tetCell.H | 15 +- .../meshes/meshShapes/tetCell/tetCellI.H | 44 ++-- .../meshes/meshShapes/triFace/triFace.H | 4 +- .../meshes/meshShapes/triFace/triFaceI.H | 12 +- .../meshes/primitiveShapes/pyramid/pyramidI.H | 2 - .../tetrahedron/tetrahedronI.H | 12 +- .../primitiveShapes/triangle/triangleI.H | 15 +- .../treeBoundBox/treeBoundBoxTemplates.C | 2 - src/conversion/ccm/writer/ccmWriter.C | 14 +- src/conversion/common/reader/README | 16 +- src/conversion/common/reader/meshReader.C | 34 --- src/conversion/common/reader/meshReader.H | 9 +- src/conversion/common/writer/meshWriter.C | 36 ---- src/conversion/common/writer/meshWriter.H | 8 - src/conversion/starcd/STARCDMeshReader.C | 31 +-- src/conversion/starcd/STARCDMeshReader.H | 4 +- src/conversion/starcd/STARCDMeshWriter.C | 54 ++--- src/conversion/starcd/STARCDMeshWriter.H | 2 +- src/conversion/vtk/part/foamVtuSizing.C | 13 +- .../vtk/part/foamVtuSizingTemplates.C | 13 +- .../meshCut/cellLooper/hexCellLooper.C | 4 +- .../multiDirRefinement/multiDirRefinement.C | 4 +- src/fileFormats/ensight/part/ensightCells.C | 10 +- src/fileFormats/starcd/STARCDCore.H | 6 +- src/fileFormats/stl/STLCore.C | 2 +- .../vtk/read/vtkUnstructuredReader.C | 10 +- .../vtk/read/vtkUnstructuredReaderTemplates.C | 2 +- .../blockMesh/blockMesh/blockMeshCreate.C | 4 +- .../edgeMeshFormats/starcd/STARCDedgeFormat.H | 2 +- .../rotatedBoxToCell/rotatedBoxToCell.C | 4 +- .../cellSources/shapeToCell/shapeToCell.C | 12 +- .../cellSources/shapeToCell/shapeToCell.H | 4 +- .../starcd/STARCDsurfaceFormat.H | 2 +- 106 files changed, 984 insertions(+), 1035 deletions(-) create mode 100644 applications/test/cellModels/Make/files create mode 100644 applications/test/cellModels/Make/options create mode 100644 applications/test/cellModels/Test-cellModels.C create mode 100644 src/OpenFOAM/meshes/meshShapes/cellModel/cellModeller.H create mode 100644 src/OpenFOAM/meshes/meshShapes/cellModel/cellModels.C delete mode 100644 src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C delete mode 100644 src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H delete mode 100644 src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C diff --git a/applications/solvers/combustion/chemFoam/chemFoam.C b/applications/solvers/combustion/chemFoam/chemFoam.C index 8098ae464e..79037aae50 100644 --- a/applications/solvers/combustion/chemFoam/chemFoam.C +++ b/applications/solvers/combustion/chemFoam/chemFoam.C @@ -42,7 +42,7 @@ Description #include "OFstream.H" #include "thermoPhysicsTypes.H" #include "basicMultiComponentMixture.H" -#include "cellModeller.H" +#include "cellModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/combustion/chemFoam/createSingleCellMesh.H b/applications/solvers/combustion/chemFoam/createSingleCellMesh.H index 9b9d0f376b..a43af46326 100644 --- a/applications/solvers/combustion/chemFoam/createSingleCellMesh.H +++ b/applications/solvers/combustion/chemFoam/createSingleCellMesh.H @@ -13,8 +13,7 @@ points[5] = vector(1, 0, 1); points[6] = vector(1, 1, 1); points[7] = vector(0, 1, 1); -const cellModel& hexa = *(cellModeller::lookup("hex")); -faceList faces = hexa.modelFaces(); +faceList faces = cellModel::ref(cellModel::HEX).modelFaces(); fvMesh mesh ( @@ -25,7 +24,7 @@ fvMesh mesh runTime, IOobject::READ_IF_PRESENT ), - xferMove>(points), + xferMove(points), faces.xfer(), owner.xfer(), neighbour.xfer() diff --git a/applications/test/boundBox/Test-boundBox.C b/applications/test/boundBox/Test-boundBox.C index 9c06ccf711..037adb4c7f 100644 --- a/applications/test/boundBox/Test-boundBox.C +++ b/applications/test/boundBox/Test-boundBox.C @@ -31,7 +31,7 @@ Description #include "polyMesh.H" #include "boundBox.H" #include "treeBoundBox.H" -#include "cellModeller.H" +#include "cellModel.H" using namespace Foam; @@ -52,15 +52,11 @@ boundBox cube(scalar start, scalar width) int main(int argc, char *argv[]) { #include "setRootCase.H" - // #include "createTime.H" - // #include "createMesh.H" - const cellModel& hex = *(cellModeller::lookup("hex")); - - Info<<"boundBox faces: " << boundBox::faces << endl; - Info<<"hex faces: " << hex.modelFaces() << endl; - Info<<"tree-bb faces: " << treeBoundBox::faces << endl; - Info<<"tree-bb edges: " << treeBoundBox::edges << endl; + Info<<"boundBox faces: " << boundBox::faces << nl + <<"hex faces: " << cellModel::ref(cellModel::HEX).modelFaces() << nl + <<"tree-bb faces: " << treeBoundBox::faces << nl + <<"tree-bb edges: " << treeBoundBox::edges << endl; boundBox bb = boundBox::greatBox; Info<<"great box: " << bb << endl; diff --git a/applications/test/cellModels/Make/files b/applications/test/cellModels/Make/files new file mode 100644 index 0000000000..0ec888b512 --- /dev/null +++ b/applications/test/cellModels/Make/files @@ -0,0 +1,3 @@ +Test-cellModels.C + +EXE = $(FOAM_USER_APPBIN)/Test-cellModels diff --git a/applications/test/cellModels/Make/options b/applications/test/cellModels/Make/options new file mode 100644 index 0000000000..e69de29bb2 diff --git a/applications/test/cellModels/Test-cellModels.C b/applications/test/cellModels/Test-cellModels.C new file mode 100644 index 0000000000..9397751114 --- /dev/null +++ b/applications/test/cellModels/Test-cellModels.C @@ -0,0 +1,97 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Application + Test-cellModels + +Description + Print information about known cellModels + +\*---------------------------------------------------------------------------*/ + +#include "cellModel.H" +#include "cellModeller.H" + +using namespace Foam; + +void printInfo(const cellModel* mdl) +{ + if (mdl) + { + Info<< *mdl << endl; + } + else + { + Info<< "nullptr" << endl; + } +} + + +void printInfo(const cellModel::modelType type) +{ + Info<< cellModel::modelNames[type] << " = "; + printInfo(cellModel::ptr(type)); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + Info<<"lookup by enum" << nl + <<"=========================" << endl; + + printInfo(cellModel::UNKNOWN); + printInfo(cellModel::HEX); + printInfo(cellModel::WEDGE); + printInfo(cellModel::PRISM); + printInfo(cellModel::PYR); + printInfo(cellModel::TET); + printInfo(cellModel::SPLITHEX); + printInfo(cellModel::TETWEDGE); + + + Info<<"lookup by name" << nl + <<"=========================" << endl; + + printInfo(cellModel::ptr("tet")); + + Info<<"lookup by index" << nl + <<"=========================" << endl; + + printInfo(cellModel::ptr(7)); + + // Compatibility mode + Info<<"cellModeller::lookup (compatibility)" << nl + <<"=========================" << endl; + + printInfo(cellModeller::lookup("tet")); + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/advanced/splitCells/splitCells.C b/applications/utilities/mesh/advanced/splitCells/splitCells.C index 8cc704243d..0ddc42f455 100644 --- a/applications/utilities/mesh/advanced/splitCells/splitCells.C +++ b/applications/utilities/mesh/advanced/splitCells/splitCells.C @@ -52,7 +52,7 @@ Description #include "polyMesh.H" #include "cellCuts.H" #include "cellSet.H" -#include "cellModeller.H" +#include "cellModel.H" #include "meshCutter.H" #include "unitConversion.H" #include "geomCellLooper.H" @@ -387,7 +387,7 @@ void collectCuts const vectorField& faceAreas = mesh.faceAreas(); // Hex shape - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& hex = cellModel::ref(cellModel::HEX); // cut handling functions edgeVertex ev(mesh); diff --git a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L index 6982f4bc94..61b89c279c 100644 --- a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L +++ b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L @@ -56,7 +56,6 @@ using namespace Foam; #include "emptyPolyPatch.H" #include "preservePatchTypes.H" #include "cellShape.H" -#include "cellModeller.H" #include "SLList.H" #include "SLPtrList.H" @@ -363,10 +362,10 @@ int main(int argc, char *argv[]) } - const cellModel& hex = *(cellModeller::lookup("hex")); - const cellModel& prism = *(cellModeller::lookup("prism")); - const cellModel& pyr = *(cellModeller::lookup("pyr")); - const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& hex = cellModel::ref(cellModel::HEX); + const cellModel& prism = cellModel::ref(cellModel::PRISM); + const cellModel& pyr = cellModel::ref(cellModel::PYR); + const cellModel& tet = cellModel::ref(cellModel::TET); labelList labelsHex(8); labelList labelsPrism(6); diff --git a/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C b/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C index ee5b4f073b..7ba911c13c 100644 --- a/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C +++ b/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C @@ -41,7 +41,6 @@ Description #include "symmetryPolyPatch.H" #include "preservePatchTypes.H" #include "cellShape.H" -#include "cellModeller.H" using namespace Foam; @@ -545,7 +544,7 @@ int main(int argc, char *argv[]) cellShapeList cellShapes(nMeshCells); - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& hex = cellModel::ref(cellModel::HEX); label nCreatedCells = 0; diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/cellShapeRecognition.H b/applications/utilities/mesh/conversion/fluentMeshToFoam/cellShapeRecognition.H index 2abea60262..64ae9f37c3 100644 --- a/applications/utilities/mesh/conversion/fluentMeshToFoam/cellShapeRecognition.H +++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/cellShapeRecognition.H @@ -32,7 +32,6 @@ Description #define cellShapeRecognition_H #include "cellShape.H" -#include "cellModeller.H" #include "faceList.H" #include "PtrList.H" diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C b/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C index d585725346..8aa960e1c9 100644 --- a/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C +++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/create3DCellShape.C @@ -50,13 +50,13 @@ cellShape create3DCellShape static List fluentCellModelLookup ( 7, - reinterpret_cast(0) + nullptr ); - fluentCellModelLookup[2] = cellModeller::lookup("tet"); - fluentCellModelLookup[4] = cellModeller::lookup("hex"); - fluentCellModelLookup[5] = cellModeller::lookup("pyr"); - fluentCellModelLookup[6] = cellModeller::lookup("prism"); + fluentCellModelLookup[2] = cellModel::ptr(cellModel::TET); + fluentCellModelLookup[4] = cellModel::ptr(cellModel::HEX); + fluentCellModelLookup[5] = cellModel::ptr(cellModel::PYR); + fluentCellModelLookup[6] = cellModel::ptr(cellModel::PRISM); static label faceMatchingOrder[7][6] = { diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.C b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.C index 457b555ad1..9fbc2ed7c5 100644 --- a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.C +++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.C @@ -51,7 +51,7 @@ cellShape extrudedQuadCellShape if (!hexModelPtr_) { - hexModelPtr_ = cellModeller::lookup("hex"); + hexModelPtr_ = cellModel::ptr(cellModel::HEX); } const cellModel& hex = *hexModelPtr_; diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.C b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.C index a2e0acf8ce..55809da114 100644 --- a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.C +++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.C @@ -28,7 +28,7 @@ Description #include "cellShapeRecognition.H" #include "labelList.H" -#include "cellModeller.H" +#include "cellModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,7 +52,7 @@ cellShape extrudedTriangleCellShape if (!prismModelPtr_) { - prismModelPtr_ = cellModeller::lookup("prism"); + prismModelPtr_ = cellModel::ptr(cellModel::PRISM); } const cellModel& prism = *prismModelPtr_; diff --git a/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C b/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C index ac632fc8d8..c3fb4fff94 100644 --- a/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C +++ b/applications/utilities/mesh/conversion/foamMeshToFluent/fluentFvMesh.C @@ -34,7 +34,7 @@ using std::ios; #include "wallFvPatch.H" #include "symmetryPlaneFvPatch.H" #include "symmetryFvPatch.H" -#include "cellModeller.H" +#include "cellModel.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -218,10 +218,10 @@ void Foam::fluentFvMesh::writeFluentMesh() const << "(12 (1 1 " << nCells() << " 1 0)(" << std::endl; - const cellModel& hex = *(cellModeller::lookup("hex")); - const cellModel& prism = *(cellModeller::lookup("prism")); - const cellModel& pyr = *(cellModeller::lookup("pyr")); - const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& hex = cellModel::ref(cellModel::HEX); + const cellModel& prism = cellModel::ref(cellModel::PRISM); + const cellModel& pyr = cellModel::ref(cellModel::PYR); + const cellModel& tet = cellModel::ref(cellModel::TET); const cellShapeList& cells = cellShapes(); diff --git a/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C b/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C index 047e48be44..496473676f 100644 --- a/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C +++ b/applications/utilities/mesh/conversion/foamToStarMesh/foamToStarMesh.C @@ -28,7 +28,7 @@ Group grpMeshConversionUtilities Description - Reads an OpenFOAM mesh and writes a pro-STAR (v4) bnd/cel/vrt format. + Reads an OpenFOAM mesh and writes a STARCD/PROSTAR (v4) bnd/cel/vrt format. Usage \b foamToStarMesh [OPTION] @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) { argList::addNote ( - "read OpenFOAM mesh and write a pro-STAR (v4) bnd/cel/vrt format" + "read OpenFOAM mesh and write a STARCD/PROSTAR (v4) bnd/cel/vrt format" ); argList::noParallel(); timeSelector::addOptions(); diff --git a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L index 23432898a6..2970179cb7 100644 --- a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L +++ b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L @@ -53,7 +53,6 @@ using namespace Foam; #include "polyMesh.H" #include "emptyPolyPatch.H" #include "preservePatchTypes.H" -#include "cellModeller.H" #include "cellShape.H" #include "SLList.H" #include "SLPtrList.H" @@ -699,10 +698,10 @@ int main(int argc, char *argv[]) cellLookup[cellMap[celli] ] = celli; } - const cellModel& hex = *(cellModeller::lookup("hex")); - const cellModel& prism = *(cellModeller::lookup("prism")); - const cellModel& pyr = *(cellModeller::lookup("pyr")); - const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& hex = cellModel::ref(cellModel::HEX); + const cellModel& prism = cellModel::ref(cellModel::PRISM); + const cellModel& pyr = cellModel::ref(cellModel::PYR); + const cellModel& tet = cellModel::ref(cellModel::TET); labelList labelsHex(8); labelList labelsPrism(6); diff --git a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C index ac8a33bcab..398563d9cb 100644 --- a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C +++ b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C @@ -52,7 +52,7 @@ Description #include "Time.H" #include "polyMesh.H" #include "IFstream.H" -#include "cellModeller.H" +#include "cellModel.H" #include "repatchPolyTopoChanger.H" #include "cellSet.H" #include "faceSet.H" @@ -435,10 +435,10 @@ void readCells Info<< "Starting to read cells at line " << inFile.lineNumber() << endl; - const cellModel& hex = *(cellModeller::lookup("hex")); - const cellModel& prism = *(cellModeller::lookup("prism")); - const cellModel& pyr = *(cellModeller::lookup("pyr")); - const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& hex = cellModel::ref(cellModel::HEX); + const cellModel& prism = cellModel::ref(cellModel::PRISM); + const cellModel& pyr = cellModel::ref(cellModel::PYR); + const cellModel& tet = cellModel::ref(cellModel::TET); face triPoints(3); face quadPoints(4); diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index 398351e3f8..ea44a998a6 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C @@ -42,7 +42,7 @@ Description #include "polyMesh.H" #include "Time.H" #include "IFstream.H" -#include "cellModeller.H" +#include "cellModel.H" #include "cellSet.H" #include "faceSet.H" #include "DynamicList.H" @@ -291,9 +291,9 @@ void readCells labelList unvToFoam(invert(maxUnvPoint+1, unvPointID)); - const cellModel& hex = *(cellModeller::lookup("hex")); - const cellModel& prism = *(cellModeller::lookup("prism")); - const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& hex = cellModel::ref(cellModel::HEX); + const cellModel& prism = cellModel::ref(cellModel::PRISM); + const cellModel& tet = cellModel::ref(cellModel::TET); labelHashSet skippedElements; diff --git a/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C b/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C index c88defe702..97ab3bd509 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C +++ b/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C @@ -37,7 +37,6 @@ Description #include "polyMesh.H" #include "Fstream.H" #include "cellShape.H" -#include "cellModeller.H" #include "preservePatchTypes.H" #include "emptyPolyPatch.H" #include "wallPolyPatch.H" diff --git a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H index 57919543e5..2c045ac6e3 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H +++ b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H @@ -102,7 +102,7 @@ cellShapeList cellShapes(nPoints); labelList cellZoning(nPoints, -1); -const cellModel& hex = *(cellModeller::lookup("hex")); +const cellModel& hex = cellModel::ref(cellModel::HEX); labelList hexLabels(8); label activeCells = 0; diff --git a/applications/utilities/mesh/conversion/mshToFoam/mshToFoam.C b/applications/utilities/mesh/conversion/mshToFoam/mshToFoam.C index ac225fd735..6a3181e80f 100644 --- a/applications/utilities/mesh/conversion/mshToFoam/mshToFoam.C +++ b/applications/utilities/mesh/conversion/mshToFoam/mshToFoam.C @@ -48,7 +48,7 @@ Description #include "IFstream.H" #include "polyPatch.H" #include "ListOps.H" -#include "cellModeller.H" +#include "cellModel.H" #include @@ -87,8 +87,8 @@ int main(int argc, char *argv[]) cellShapeList cells(nCells); - const cellModel& tet = *(cellModeller::lookup("tet")); - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& tet = cellModel::ref(cellModel::TET); + const cellModel& hex = cellModel::ref(cellModel::HEX); labelList tetPoints(4); labelList hexPoints(8); diff --git a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C index bb8730370e..c51ae582e7 100644 --- a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C +++ b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C @@ -82,7 +82,7 @@ NOTE: #include "polyMesh.H" #include "IFstream.H" #include "polyPatch.H" -#include "cellModeller.H" +#include "cellModel.H" #include "triFace.H" using namespace Foam; @@ -124,7 +124,7 @@ int main(int argc, char *argv[]) Info<< "nTets:" << nTets << endl; - const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& tet = cellModel::ref(cellModel::TET); cellShapeList cells(nTets); diff --git a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C index cc24941602..c1ce3c3446 100644 --- a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C +++ b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C @@ -50,7 +50,6 @@ Description #include "wallPolyPatch.H" #include "symmetryPolyPatch.H" #include "cellShape.H" -#include "cellModeller.H" #include "mergePoints.H" using namespace Foam; @@ -202,7 +201,7 @@ int main(int argc, char *argv[]) cellShapeList cellShapes(nMeshCells); - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& hex = cellModel::ref(cellModel::HEX); label nCreatedCells = 0; diff --git a/applications/utilities/mesh/conversion/star4ToFoam/star4ToFoam.C b/applications/utilities/mesh/conversion/star4ToFoam/star4ToFoam.C index 65261399d0..4f46a52453 100644 --- a/applications/utilities/mesh/conversion/star4ToFoam/star4ToFoam.C +++ b/applications/utilities/mesh/conversion/star4ToFoam/star4ToFoam.C @@ -28,7 +28,7 @@ Group grpMeshConversionUtilities Description - Converts a Star-CD (v4) pro-STAR mesh into OpenFOAM format. + Converts a STARCD/PROSTAR (v4) mesh into OpenFOAM format. Usage \b star4ToFoam [OPTION] prostarMesh @@ -66,11 +66,11 @@ int main(int argc, char *argv[]) { argList::addNote ( - "convert pro-STAR (v4) mesh to OpenFOAM" + "convert STARCD/PROSTAR (v4) mesh to OpenFOAM" ); argList::noParallel(); - argList::validArgs.append("pro-STAR prefix"); + argList::validArgs.append("PROSTAR prefix"); argList::addBoolOption ( "ascii", diff --git a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C index de11e14a74..43b2628d34 100644 --- a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C +++ b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C @@ -70,7 +70,7 @@ Note #include "Time.H" #include "polyMesh.H" #include "IFstream.H" -#include "cellModeller.H" +#include "cellModel.H" using namespace Foam; @@ -276,8 +276,7 @@ int main(int argc, char *argv[]) } - - const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& tet = cellModel::ref(cellModel::TET); labelList tetPoints(4); diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C index ac840a07f7..cedc0c2357 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C @@ -39,7 +39,6 @@ Description #include "cellShapeControl.H" #include "backgroundMeshDecomposition.H" #include "cellShape.H" -#include "cellModeller.H" #include "DynamicField.H" #include "isoSurfaceCell.H" #include "vtkSurfaceWriter.H" @@ -252,7 +251,7 @@ autoPtr generateHexMesh } - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& hex = cellModel::ref(cellModel::HEX); cellShapeList cellShapes(nCells[0]*nCells[1]*nCells[2]); labelList hexPoints(8); diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 619d84eca5..662fd0190f 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -53,7 +53,6 @@ Description #include "faceSet.H" #include "motionSmoother.H" #include "polyTopoChange.H" -#include "cellModeller.H" #include "uindirectPrimitivePatch.H" #include "surfZoneIdentifierList.H" #include "UnsortedMeshedSurface.H" diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_part_elements_by_type.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_part_elements_by_type.H index 7d768159ce..0fafe21207 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_part_elements_by_type.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_part_elements_by_type.H @@ -57,7 +57,7 @@ int USERD_get_part_elements_by_type //================================ if (element_type == Z_HEX08) { - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& hex = cellModel::ref(cellModel::HEX); label nHex08 = 0; forAll(cellShapes, celli) @@ -80,7 +80,7 @@ int USERD_get_part_elements_by_type //================================ else if (element_type == Z_PEN06) { - const cellModel& prism = *(cellModeller::lookup("prism")); + const cellModel& prism = cellModel::ref(cellModel::PRISM); label nPen06 = 0; forAll(cellShapes, celli) @@ -103,7 +103,7 @@ int USERD_get_part_elements_by_type //================================ else if (element_type == Z_PYR05) { - const cellModel& pyr = *(cellModeller::lookup("pyr")); + const cellModel& pyr = cellModel::ref(cellModel::PYR); label nPyr05 = 0; forAll(cellShapes, celli) @@ -126,7 +126,7 @@ int USERD_get_part_elements_by_type //================================ else if (element_type == Z_TET04) { - const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& tet = cellModel::ref(cellModel::TET); label nTet04 = 0; forAll(cellShapes, celli) diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldScalar.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldScalar.H index a66e4c53c6..06cf1d8c12 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldScalar.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldScalar.H @@ -37,8 +37,8 @@ const cellShapeList& cellShapes = meshPtr->cellShapes(); // hexa's if (which_type == Z_HEX08) { - const cellModel& hex = *(cellModeller::lookup("hex")); - //const cellModel& wedge = *(cellModeller::lookup("wedge")); + const cellModel& hex = cellModel::ref(cellModel::HEX); + //const cellModel& wedge = cellModel::ref(cellModel::WEDGE); label counter = 1; for (label celli=0; cellicellShapes(); // hexa's if (which_type == Z_HEX08) { - const cellModel& hex = *(cellModeller::lookup("hex")); - //const cellModel& wedge = *(cellModeller::lookup("wedge")); + const cellModel& hex = cellModel::ref(cellModel::HEX); + //const cellModel& wedge = cellModel::ref(cellModel::WEDGE); label counter = 1; for (label n=0; ncellShapes(); // hexa's if (which_type == Z_HEX08) { - const cellModel& hex = *(cellModeller::lookup("hex")); - //const cellModel& wedge = *(cellModeller::lookup("wedge")); + const cellModel& hex = cellModel::ref(cellModel::HEX); + //const cellModel& wedge = cellModel::ref(cellModel::WEDGE); label counter = 1; for (label n=0; n. -# This file is part of OpenFOAM. +# License +# This file is part of OpenFOAM, licensed under GNU General Public License +# . # # File # etc/config.csh/ADIOS diff --git a/etc/config.sh/ADIOS b/etc/config.sh/ADIOS index 37e55feb37..f27da80973 100644 --- a/etc/config.sh/ADIOS +++ b/etc/config.sh/ADIOS @@ -5,9 +5,9 @@ # \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ -# This file is part of OpenFOAM, licensed under the GNU General Public License -# . -# This file is part of OpenFOAM. +# License +# This file is part of OpenFOAM, licensed under GNU General Public License +# . # # File # etc/config.sh/ADIOS diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 130b48e5b3..ff43bb7750 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -442,11 +442,9 @@ $(cell)/cellIOList.C tetCell = $(meshShapes)/tetCell $(tetCell)/tetCell.C -cellModeller = $(meshShapes)/cellModeller -$(cellModeller)/cellModeller.C - cellModel = $(meshShapes)/cellModel $(cellModel)/cellModel.C +$(cellModel)/cellModels.C $(cellModel)/cellModelIO.C cellShape = $(meshShapes)/cellShape diff --git a/src/OpenFOAM/global/global.Cver b/src/OpenFOAM/global/global.Cver index 0c9f3fdf31..552dc011cc 100644 --- a/src/OpenFOAM/global/global.Cver +++ b/src/OpenFOAM/global/global.Cver @@ -106,11 +106,6 @@ bool Foam::JobInfo::constructed(false); #include "constants.C" #include "dimensionedConstants.C" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Read and set cell models - -#include "globalCellModeller.C" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Create the jobInfo file in the $FOAM_JOB_DIR/runningJobs directory diff --git a/src/OpenFOAM/meshes/meshShapes/cell/cell.C b/src/OpenFOAM/meshes/meshShapes/cell/cell.C index 9aa39881ea..2155fff4a5 100644 --- a/src/OpenFOAM/meshes/meshShapes/cell/cell.C +++ b/src/OpenFOAM/meshes/meshShapes/cell/cell.C @@ -276,7 +276,7 @@ Foam::scalar Foam::cell::mag } -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * // bool Foam::operator==(const cell& a, const cell& b) { @@ -288,18 +288,16 @@ bool Foam::operator==(const cell& a, const cell& b) List fnd(a.size(), false); - forAll(b, bI) + for (const label curLabel : b) { - const label curLabel = b[bI]; - bool found = false; - forAll(a, aI) + forAll(a, ai) { - if (a[aI] == curLabel) + if (a[ai] == curLabel) { found = true; - fnd[aI] = true; + fnd[ai] = true; break; } } @@ -311,9 +309,9 @@ bool Foam::operator==(const cell& a, const cell& b) } // Any faces missed? - forAll(fnd, aI) + forAll(fnd, ai) { - if (!fnd[aI]) + if (!fnd[ai]) { return false; } diff --git a/src/OpenFOAM/meshes/meshShapes/cell/cell.H b/src/OpenFOAM/meshes/meshShapes/cell/cell.H index 9c95a3bcb4..6db36cdfb1 100644 --- a/src/OpenFOAM/meshes/meshShapes/cell/cell.H +++ b/src/OpenFOAM/meshes/meshShapes/cell/cell.H @@ -45,13 +45,6 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators - -class cell; -bool operator==(const cell& a, const cell& b); -inline bool operator!=(const cell& a, const cell& b); - - /*---------------------------------------------------------------------------*\ Class cell Declaration \*---------------------------------------------------------------------------*/ @@ -73,7 +66,7 @@ public: //- Construct null inline cell(); - //- Construct given size + //- Construct given size, with invalid point labels (-1) explicit inline cell(const label sz); //- Construct from list of labels @@ -132,15 +125,19 @@ public: //- Returns cell volume scalar mag(const UList& p, const faceUList& f) const; - - - // Friend Operators - - friend bool operator==(const cell& a, const cell& b); - friend bool operator!=(const cell& a, const cell& b); }; +// Global Operators + +//- Test if both cells are the same size and contain the same points +// The internal point ordering is ignored +bool operator==(const cell& a, const cell& b); + +//- Test if the cells differ (different size or different points) +inline bool operator!=(const cell& a, const cell& b); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/meshes/meshShapes/cell/cellI.H b/src/OpenFOAM/meshes/meshShapes/cell/cellI.H index 82878d2278..0c31f8e99b 100644 --- a/src/OpenFOAM/meshes/meshShapes/cell/cellI.H +++ b/src/OpenFOAM/meshes/meshShapes/cell/cellI.H @@ -61,6 +61,8 @@ inline Foam::label Foam::cell::nFaces() const } +// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * // + inline bool Foam::operator!=(const cell& a, const cell& b) { return !(a == b); diff --git a/src/OpenFOAM/meshes/meshShapes/cell/oppositeCellFace.C b/src/OpenFOAM/meshes/meshShapes/cell/oppositeCellFace.C index 23686e1361..c8ec817ba3 100644 --- a/src/OpenFOAM/meshes/meshShapes/cell/oppositeCellFace.C +++ b/src/OpenFOAM/meshes/meshShapes/cell/oppositeCellFace.C @@ -31,9 +31,6 @@ Description #include "oppositeFace.H" #include "boolList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::label Foam::cell::opposingFaceLabel @@ -125,64 +122,61 @@ Foam::oppositeFace Foam::cell::opposingFace { return oppositeFace(face(0), masterFaceLabel, oppFaceLabel); } - else + + // This is a prismatic cell. Go through all the vertices of the master + // face and find an edge going from the master face vertex to a slave + // face vertex. If all is OK, there should be only one such + // edge for every master vertex and will provide te + // master-to-slave vertex mapping. Assemble the opposite face + // in the same manner as the master. + + // Get reference to faces and prepare the return + const face& masterFace = meshFaces[masterFaceLabel]; + const face& slaveFace = meshFaces[oppFaceLabel]; + + // Get cell edges + const edgeList e = edges(meshFaces); + boolList usedEdges(e.size(), false); + + oppositeFace oppFace + ( + face(masterFace.size()), + masterFaceLabel, + oppFaceLabel + ); + + forAll(masterFace, pointi) { - // This is a prismatic cell. Go through all the vertices of the master - // face and find an edge going from the master face vertex to a slave - // face vertex. If all is OK, there should be only one such - // edge for every master vertex and will provide te - // master-to-slave vertex mapping. Assemble the opposite face - // in the same manner as the master. - - // Get reference to faces and prepare the return - const face& masterFace = meshFaces[masterFaceLabel]; - const face& slaveFace = meshFaces[oppFaceLabel]; - - // Get cell edges - const edgeList e = edges(meshFaces); - boolList usedEdges(e.size(), false); - - oppositeFace oppFace - ( - face(masterFace.size()), - masterFaceLabel, - oppFaceLabel - ); - - forAll(masterFace, pointi) + // Go through the list of edges and find the edge from this vertex + // to the slave face + forAll(e, edgeI) { - // Go through the list of edges and find the edge from this vertex - // to the slave face - forAll(e, edgeI) + if (!usedEdges[edgeI]) { - if (!usedEdges[edgeI]) + // Get the other vertex + label otherVertex = e[edgeI].otherVertex(masterFace[pointi]); + + if (otherVertex != -1) { - // Get the other vertex - label otherVertex = - e[edgeI].otherVertex(masterFace[pointi]); - - if (otherVertex != -1) + // Found an edge coming from this vertex. + // Check all vertices of the slave to find out + // if it exists. + forAll(slaveFace, slavePointi) { - // Found an edge coming from this vertex. - // Check all vertices of the slave to find out - // if it exists. - forAll(slaveFace, slavePointi) + if (slaveFace[slavePointi] == otherVertex) { - if (slaveFace[slavePointi] == otherVertex) - { - usedEdges[edgeI] = true; - oppFace[pointi] = otherVertex; + usedEdges[edgeI] = true; + oppFace[pointi] = otherVertex; - break; - } + break; } } } } } - - return oppFace; } + + return oppFace; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.C index 2ae0b4a716..8575c5d6df 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.C @@ -31,7 +31,6 @@ License #include "labelList.H" #include "ListOps.H" - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::cellMatcher::cellMatcher @@ -61,9 +60,9 @@ Foam::cellMatcher::cellMatcher f.setSize(maxVertPerFace); } - forAll(pointFaceIndex_, vertI) + forAll(pointFaceIndex_, verti) { - pointFaceIndex_[vertI].setSize(facePerCell); + pointFaceIndex_[verti].setSize(facePerCell); } } @@ -83,7 +82,7 @@ Foam::label Foam::cellMatcher::calcLocalFaces label newVertI = 0; forAll(myFaces, myFacei) { - label facei = myFaces[myFacei]; + const label facei = myFaces[myFacei]; const face& f = faces[facei]; face& localFace = localFaces_[myFacei]; @@ -202,10 +201,10 @@ void Foam::cellMatcher::calcPointFaceIndex() ( label fp = 0; fp < faceSize_[localFacei]; - fp++ + ++fp ) { - label vert = f[fp]; + const label vert = f[fp]; pointFaceIndex_[vert][localFacei] = fp; } } @@ -220,7 +219,7 @@ Foam::label Foam::cellMatcher::otherFace const label localFacei ) const { - label key = edgeKey(numVert, v0, v1); + const label key = edgeKey(numVert, v0, v1); if (edgeFaces_[key] == localFacei) { @@ -230,17 +229,15 @@ Foam::label Foam::cellMatcher::otherFace { return edgeFaces_[key]; } - else - { - FatalErrorInFunction - << "edgeFaces_ does not contain:" << localFacei - << " for edge " << v0 << " " << v1 << " at key " << key - << " edgeFaces_[key, key+1]:" << edgeFaces_[key] - << " , " << edgeFaces_[key+1] - << abort(FatalError); - return -1; - } + FatalErrorInFunction + << "edgeFaces_ does not contain:" << localFacei + << " for edge " << v0 << " " << v1 << " at key " << key + << " edgeFaces_[key, key+1]:" << edgeFaces_[key] + << " , " << edgeFaces_[key+1] + << abort(FatalError); + + return -1; } @@ -256,10 +253,10 @@ void Foam::cellMatcher::write(Foam::Ostream& os) const { os << ' ' << localFaces_[facei][fp]; } - os << endl; + os << nl; } - os << "Face map : " << faceMap_ << endl; + os << "Face map : " << faceMap_ << nl; os << "Point map : " << pointMap_ << endl; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.H b/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.H index 1e19cc7127..3e2fcad6b2 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.H +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.H @@ -79,7 +79,6 @@ SourceFiles #include "labelList.H" #include "faceList.H" -#include "boolList.H" #include "Map.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -90,8 +89,8 @@ namespace Foam // Forward declaration of classes class primitiveMesh; class cell; -class cellShape; class cellModel; +class cellShape; /*---------------------------------------------------------------------------*\ Class cellMatcher Declaration @@ -178,15 +177,15 @@ private: // Private Member Functions //- Disallow default bitwise copy construct and assignment - cellMatcher(const cellMatcher&); - void operator=(const cellMatcher&); + cellMatcher(const cellMatcher&) = delete; + cellMatcher& operator=(const cellMatcher&) = delete; public: // Constructors - //- Construct given mesh and shape factors + //- Construct for shape factors cellMatcher ( const label vertPerCell, diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcherI.H b/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcherI.H index 4a212e34e1..ee73e7308b 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcherI.H +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcherI.H @@ -24,7 +24,6 @@ License \*---------------------------------------------------------------------------*/ #include "primitiveMesh.H" -#include "cellModeller.H" #include "cellModel.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -87,13 +86,12 @@ inline const Foam::cellModel& Foam::cellMatcher::model() const { if (cellModelPtr_ == nullptr) { - cellModelPtr_ = cellModeller::lookup(cellModelName_); + cellModelPtr_ = cellModel::ptr(cellModelName_); } return *cellModelPtr_; } - // Key into edgeFaces_. key and key+1 are the entries for edge going from // v0 to v1 inline Foam::label Foam::cellMatcher::edgeKey diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/degenerateMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/degenerateMatcher.C index bf8c545abf..90df5d52b4 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/degenerateMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/degenerateMatcher.C @@ -36,6 +36,8 @@ Foam::pyrMatcher Foam::degenerateMatcher::pyr; Foam::tetMatcher Foam::degenerateMatcher::tet; +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + Foam::cellShape Foam::degenerateMatcher::match ( const faceList& faces, @@ -50,30 +52,28 @@ Foam::cellShape Foam::degenerateMatcher::match { return cellShape(hex.model(), hex.vertLabels()); } - else if (tet.matchShape(false, faces, owner, celli, cellFaces)) + if (tet.matchShape(false, faces, owner, celli, cellFaces)) { return cellShape(tet.model(), tet.vertLabels()); } - else if (prism.matchShape(false, faces, owner, celli, cellFaces)) + if (prism.matchShape(false, faces, owner, celli, cellFaces)) { return cellShape(prism.model(), prism.vertLabels()); } - else if (pyr.matchShape(false, faces, owner, celli, cellFaces)) + if (pyr.matchShape(false, faces, owner, celli, cellFaces)) { return cellShape(pyr.model(), pyr.vertLabels()); } - else if (wedge.matchShape(false, faces, owner, celli, cellFaces)) + if (wedge.matchShape(false, faces, owner, celli, cellFaces)) { return cellShape(wedge.model(), wedge.vertLabels()); } - else if (tetWedge.matchShape(false, faces, owner, celli, cellFaces)) + if (tetWedge.matchShape(false, faces, owner, celli, cellFaces)) { return cellShape(tetWedge.model(), tetWedge.vertLabels()); } - else - { - return cellShape(*(cellModeller::lookup(0)), labelList(0)); - } + + return cellShape(cellModel::ref(cellModel::UNKNOWN), labelList()); } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/degenerateMatcher.H b/src/OpenFOAM/meshes/meshShapes/cellMatcher/degenerateMatcher.H index c91671d9ca..cf1061f34b 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/degenerateMatcher.H +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/degenerateMatcher.H @@ -26,6 +26,7 @@ Class Description Collection of all hex degenerate matchers (hex, wedge, prism etc.) + Has static member function to match a shape. See also @@ -52,7 +53,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class degenerateMatcher Declaration + Class degenerateMatcher Declaration \*---------------------------------------------------------------------------*/ class degenerateMatcher diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.C index 30994b0aa2..ae0e7b9931 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.C @@ -27,13 +27,6 @@ License #include "primitiveMesh.H" #include "ListOps.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -const Foam::label Foam::hexMatcher::vertPerCell = 8; -const Foam::label Foam::hexMatcher::facePerCell = 6; -const Foam::label Foam::hexMatcher::maxVertPerFace = 4; - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::hexMatcher::hexMatcher() @@ -43,7 +36,7 @@ Foam::hexMatcher::hexMatcher() vertPerCell, facePerCell, maxVertPerFace, - "hex" + "hex" // same as cellModel::modelNames[cellModel::HEX] ) {} @@ -261,9 +254,9 @@ bool Foam::hexMatcher::faceSizeMatch return false; } - forAll(myFaces, myFacei) + for (const label facei : myFaces) { - label size = faces[myFaces[myFacei]].size(); + const label size = faces[facei].size(); if (size != 4) { @@ -325,10 +318,8 @@ bool Foam::hexMatcher::matches return true; } - else - { - return false; - } + + return false; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.H b/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.H index 5bafb985ee..8959092c57 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.H +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/hexMatcher.H @@ -25,10 +25,10 @@ Class Foam::hexMatcher Description - A cellMatcher for hex cells + A cellMatcher for hex cells (cellModel::HEX). See also - cellMatcher + cellMatcher, cellModel SourceFiles hexMatcher.C @@ -46,28 +46,28 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class hexMatcher Declaration + Class hexMatcher Declaration \*---------------------------------------------------------------------------*/ class hexMatcher : public cellMatcher { - // Static data members + // Static Data Members - //- Constants for this shape - static const label vertPerCell; - static const label facePerCell; - static const label maxVertPerFace; + // Constants for this shape + static constexpr label vertPerCell = 8; + static constexpr label facePerCell = 6; + static constexpr label maxVertPerFace = 4; // Private Member Functions //- Disallow default bitwise copy construct - hexMatcher(const hexMatcher&); + hexMatcher(const hexMatcher&) = delete; //- Disallow default bitwise assignment - void operator=(const hexMatcher&); + hexMatcher& operator=(const hexMatcher&) = delete; public: diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.C index 20e00a09f4..9ff2ec7fdc 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.C @@ -27,13 +27,6 @@ License #include "primitiveMesh.H" #include "ListOps.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -const Foam::label Foam::prismMatcher::vertPerCell = 6; -const Foam::label Foam::prismMatcher::facePerCell = 5; -const Foam::label Foam::prismMatcher::maxVertPerFace = 4; - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::prismMatcher::prismMatcher() @@ -43,7 +36,7 @@ Foam::prismMatcher::prismMatcher() vertPerCell, facePerCell, maxVertPerFace, - "prism" + "prism" // same as cellModel::modelNames[cellModel::PRISM] ) {} @@ -312,31 +305,25 @@ bool Foam::prismMatcher::faceSizeMatch label nTris = 0; label nQuads = 0; - forAll(myFaces, myFacei) + for (const label facei : myFaces) { - label size = faces[myFaces[myFacei]].size(); + const label size = faces[facei].size(); if (size == 3) { - nTris++; + ++nTris; } else if (size == 4) { - nQuads++; + ++nQuads; } else { return false; } } - if ((nTris == 2) && (nQuads == 3)) - { - return true; - } - else - { - return false; - } + + return (nTris == 2 && nQuads == 3); } @@ -390,10 +377,8 @@ bool Foam::prismMatcher::matches return true; } - else - { - return false; - } + + return false; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.H b/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.H index afbfb220c7..5d4b8cfe35 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.H +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/prismMatcher.H @@ -25,10 +25,10 @@ Class Foam::prismMatcher Description - A cellMatcher for prism cells + A cellMatcher for prism cells (cellModel::PRISM) See also - cellMatcher + cellMatcher, cellModel SourceFiles prismMatcher.C @@ -53,21 +53,21 @@ class prismMatcher : public cellMatcher { - // Static data members + // Static Data Members - //- Constants for this shape - static const label vertPerCell; - static const label facePerCell; - static const label maxVertPerFace; + // Constants for this shape + static constexpr label vertPerCell = 6; + static constexpr label facePerCell = 5; + static constexpr label maxVertPerFace = 4; // Private Member Functions //- Disallow default bitwise copy construct - prismMatcher(const prismMatcher&); + prismMatcher(const prismMatcher&) = delete; //- Disallow default bitwise assignment - void operator=(const prismMatcher&); + prismMatcher& operator=(const prismMatcher&) = delete; public: diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.C index b9378f42c7..4ecda6ea0c 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.C @@ -26,16 +26,9 @@ License #include "pyrMatcher.H" #include "cellMatcher.H" #include "primitiveMesh.H" -#include "cellModeller.H" +#include "cellModel.H" #include "ListOps.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -const Foam::label Foam::pyrMatcher::vertPerCell = 5; -const Foam::label Foam::pyrMatcher::facePerCell = 5; -const Foam::label Foam::pyrMatcher::maxVertPerFace = 4; - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::pyrMatcher::pyrMatcher() @@ -45,7 +38,7 @@ Foam::pyrMatcher::pyrMatcher() vertPerCell, facePerCell, maxVertPerFace, - "pyr" + "pyr" // same as cellModel::modelNames[cellModel::PYR] ) {} @@ -234,17 +227,17 @@ bool Foam::pyrMatcher::faceSizeMatch label nTris = 0; label nQuads = 0; - forAll(myFaces, myFacei) + for (const label facei : myFaces) { - label size = faces[myFaces[myFacei]].size(); + const label size = faces[facei].size(); if (size == 3) { - nTris++; + ++nTris; } else if (size == 4) { - nQuads++; + ++nQuads; } else { @@ -252,14 +245,7 @@ bool Foam::pyrMatcher::faceSizeMatch } } - if ((nTris == 4) && (nQuads == 1)) - { - return true; - } - else - { - return false; - } + return (nTris == 4 && nQuads == 1); } @@ -313,10 +299,8 @@ bool Foam::pyrMatcher::matches return true; } - else - { - return false; - } + + return false; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.H b/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.H index 2c6dc1d105..b6ddc60fc2 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.H +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/pyrMatcher.H @@ -25,10 +25,10 @@ Class Foam::pyrMatcher Description - A cellMatcher for pyr cells + A cellMatcher for pyr cells (cellModel::PYR) See also - cellMatcher + cellMatcher, cellModel SourceFiles pyrMatcher.C @@ -46,28 +46,28 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class pyrMatcher Declaration + Class pyrMatcher Declaration \*---------------------------------------------------------------------------*/ class pyrMatcher : public cellMatcher { - // Static data members + // Static Data Members - //- Constants for this shape - static const label vertPerCell; - static const label facePerCell; - static const label maxVertPerFace; + // Constants for this shape + static constexpr label vertPerCell = 5; + static constexpr label facePerCell = 5; + static constexpr label maxVertPerFace = 4; // Private Member Functions //- Disallow default bitwise copy construct - pyrMatcher(const pyrMatcher&); + pyrMatcher(const pyrMatcher&) = delete; //- Disallow default bitwise assignment - void operator=(const pyrMatcher&); + pyrMatcher& operator=(const pyrMatcher&) = delete; public: diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.C index 8aa3b8b4f2..3a2e594a74 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.C @@ -26,16 +26,9 @@ License #include "tetMatcher.H" #include "cellMatcher.H" #include "primitiveMesh.H" -#include "cellModeller.H" +#include "cellModel.H" #include "ListOps.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -const Foam::label Foam::tetMatcher::vertPerCell = 4; -const Foam::label Foam::tetMatcher::facePerCell = 4; -const Foam::label Foam::tetMatcher::maxVertPerFace = 3; - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::tetMatcher::tetMatcher() @@ -45,7 +38,7 @@ Foam::tetMatcher::tetMatcher() vertPerCell, facePerCell, maxVertPerFace, - "tet" + "tet" // same as cellModel::modelNames[cellModel::TET] ) {} @@ -201,15 +194,16 @@ bool Foam::tetMatcher::faceSizeMatch return false; } - forAll(myFaces, myFacei) + for (const label facei : myFaces) { - label size = faces[myFaces[myFacei]].size(); + const label size = faces[facei].size(); if (size != 3) { return false; } } + return true; } @@ -264,10 +258,8 @@ bool Foam::tetMatcher::matches return true; } - else - { - return false; - } + + return false; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.H b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.H index fe5bf02e0b..e1d3627d38 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.H +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetMatcher.H @@ -25,10 +25,10 @@ Class Foam::tetMatcher Description - A cellMatcher for tet cells + A cellMatcher for tet cells (cellModel::TET) See also - cellMatcher + cellMatcher, cellModel SourceFiles tetMatcher.C @@ -53,21 +53,21 @@ class tetMatcher : public cellMatcher { - // Static data members + // Static Data Members - //- Constants for this shape - static const label vertPerCell; - static const label facePerCell; - static const label maxVertPerFace; + // Constants for this shape + static constexpr label vertPerCell = 4; + static constexpr label facePerCell = 4; + static constexpr label maxVertPerFace = 3; // Private Member Functions //- Disallow default bitwise copy construct - tetMatcher(const tetMatcher&); + tetMatcher(const tetMatcher&) = delete; //- Disallow default bitwise assignment - void operator=(const tetMatcher&); + tetMatcher& operator=(const tetMatcher&) = delete; public: diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.C index a5f936f3f1..fa45433468 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.C @@ -26,16 +26,9 @@ License #include "tetWedgeMatcher.H" #include "cellMatcher.H" #include "primitiveMesh.H" -#include "cellModeller.H" +#include "cellModel.H" #include "ListOps.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -const Foam::label Foam::tetWedgeMatcher::vertPerCell = 5; -const Foam::label Foam::tetWedgeMatcher::facePerCell = 4; -const Foam::label Foam::tetWedgeMatcher::maxVertPerFace = 4; - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::tetWedgeMatcher::tetWedgeMatcher() @@ -45,7 +38,7 @@ Foam::tetWedgeMatcher::tetWedgeMatcher() vertPerCell, facePerCell, maxVertPerFace, - "tetWedge" + "tetWedge" // same as cellModel::modelNames[cellModel::TETWEDGE] ) {} @@ -239,31 +232,25 @@ bool Foam::tetWedgeMatcher::faceSizeMatch label nTris = 0; label nQuads = 0; - forAll(myFaces, myFacei) + for (const label facei : myFaces) { - label size = faces[myFaces[myFacei]].size(); + const label size = faces[facei].size(); if (size == 3) { - nTris++; + ++nTris; } else if (size == 4) { - nQuads++; + ++nQuads; } else { return false; } } - if ((nTris == 2) && (nQuads == 2)) - { - return true; - } - else - { - return false; - } + + return (nTris == 2 && nQuads == 2); } @@ -317,10 +304,8 @@ bool Foam::tetWedgeMatcher::matches return true; } - else - { - return false; - } + + return false; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.H b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.H index cee5714db4..7da0e6ed1e 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.H +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/tetWedgeMatcher.H @@ -25,10 +25,10 @@ Class Foam::tetWedgeMatcher Description - A cellMatcher for tetWedge cells + A cellMatcher for tetWedge cells (cellModel::TETWEDGE). See also - cellMatcher + cellMatcher, cellModel SourceFiles tetWedgeMatcher.C @@ -46,28 +46,28 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class tetWedgeMatcher Declaration + Class tetWedgeMatcher Declaration \*---------------------------------------------------------------------------*/ class tetWedgeMatcher : public cellMatcher { - // Static data members + // Static Data Members - //- Constants for this shape - static const label vertPerCell; - static const label facePerCell; - static const label maxVertPerFace; + // Constants for this shape + static constexpr label vertPerCell = 5; + static constexpr label facePerCell = 4; + static constexpr label maxVertPerFace = 4; // Private Member Functions //- Disallow default bitwise copy construct - tetWedgeMatcher(const tetWedgeMatcher&); + tetWedgeMatcher(const tetWedgeMatcher&) = delete; //- Disallow default bitwise assignment - void operator=(const tetWedgeMatcher&); + tetWedgeMatcher& operator=(const tetWedgeMatcher&) = delete; public: diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.C b/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.C index 0055bacf8f..b230486a14 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.C +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.C @@ -27,13 +27,6 @@ License #include "primitiveMesh.H" #include "ListOps.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -const Foam::label Foam::wedgeMatcher::vertPerCell = 7; -const Foam::label Foam::wedgeMatcher::facePerCell = 6; -const Foam::label Foam::wedgeMatcher::maxVertPerFace = 4; - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::wedgeMatcher::wedgeMatcher() @@ -43,7 +36,7 @@ Foam::wedgeMatcher::wedgeMatcher() vertPerCell, facePerCell, maxVertPerFace, - "wedge" + "wedge" // same as cellModel::modelNames[cellModel::WEDGE] ) {} @@ -339,31 +332,25 @@ bool Foam::wedgeMatcher::faceSizeMatch label nTris = 0; label nQuads = 0; - forAll(myFaces, myFacei) + for (const label facei : myFaces) { - label size = faces[myFaces[myFacei]].size(); + const label size = faces[facei].size(); if (size == 3) { - nTris++; + ++nTris; } else if (size == 4) { - nQuads++; + ++nQuads; } else { return false; } } - if ((nTris == 2) && (nQuads == 4)) - { - return true; - } - else - { - return false; - } + + return (nTris == 2 && nQuads == 4); } @@ -417,10 +404,8 @@ bool Foam::wedgeMatcher::matches return true; } - else - { - return false; - } + + return false; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.H b/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.H index c4c20660ca..5ec42255c8 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.H +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/wedgeMatcher.H @@ -25,10 +25,10 @@ Class Foam::wedgeMatcher Description - A cellMatcher for wedge cells + A cellMatcher for wedge cells (cellModel::WEDGE). See also - cellMatcher + cellMatcher, cellModel SourceFiles wedgeMatcher.C @@ -46,28 +46,28 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class wedgeMatcher Declaration + Class wedgeMatcher Declaration \*---------------------------------------------------------------------------*/ class wedgeMatcher : public cellMatcher { - // Static data members + // Static Data Members - //- Constants for this shape - static const label vertPerCell; - static const label facePerCell; - static const label maxVertPerFace; + // Constants for this shape + static constexpr label vertPerCell = 7; + static constexpr label facePerCell = 6; + static constexpr label maxVertPerFace = 4; // Private Member Functions //- Disallow default bitwise copy construct - wedgeMatcher(const wedgeMatcher&); + wedgeMatcher(const wedgeMatcher&) = delete; //- Disallow default bitwise assignment - void operator=(const wedgeMatcher&); + wedgeMatcher& operator=(const wedgeMatcher&) = delete; public: diff --git a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C index 309ff4a971..ca8a15464c 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C +++ b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -137,4 +137,5 @@ Foam::scalar Foam::cellModel::mag return v; } + // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.H b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.H index 4a450b5a6a..d1f08405fc 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.H +++ b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModel.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,14 +25,21 @@ Class Foam::cellModel Description - Maps a geometry to a set of cell primitives, which enables - geometric cell data to be calculated without access to the primitive - geometric level. This means mapping a 3D geometry to a set of - pyramids which are each described by a cell face and the cell centre - point. + Maps a geometry to a set of cell primitives. + + This enables geometric cell data to be calculated without access + to the primitive geometric level. This means mapping a 3D + geometry to a set of pyramids which are each described by a cell + face and the cell centre point. + + Also includes a static collection of cell models (normally loaded from + etc/cellModels), and a means of looking them up. SourceFiles cellModelI.H + cellModel.C + cellModels.C + cellModelIO.C \*---------------------------------------------------------------------------*/ @@ -44,19 +51,17 @@ SourceFiles #include "faceList.H" #include "InfoProxy.H" #include "autoPtr.H" +#include "PtrList.H" +#include "Enum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// Forward declaration of friend functions and operators - +// Forward declarations class cellModel; -inline bool operator==(const cellModel& m1, const cellModel& m2); -inline bool operator!=(const cellModel& m1, const cellModel& m2); -Ostream& operator<<(Ostream& os, const cellModel& c); - +Ostream& operator<<(Ostream& os, const cellModel& cm); /*---------------------------------------------------------------------------*\ Class cellModel Declaration @@ -64,12 +69,66 @@ Ostream& operator<<(Ostream& os, const cellModel& c); class cellModel { - // Private data +public: - //- Name + //- Enumeration of commonly used cellModel types. + // The indices must match those in "etc/cellModels" + enum modelType + { + UNKNOWN = 0, //!< unknown + HEX = 3, //!< hex + WEDGE = 4, //!< wedge + PRISM = 5, //!< prism + PYR = 6, //!< pyr + TET = 7, //!< tet + SPLITHEX = 8, //!< splitHex + TETWEDGE = 9, //!< tetWedge + }; + + //- Names of commonly used cellModels corresponding to modelType. + // The names must match those in "etc/cellModels" + static const Enum modelNames; + + + // Lookup Static Models + + //- Look up pointer to cellModel by enumeration, or nullptr on failure. + static const cellModel* ptr(const modelType model); + + //- Look up pointer to cellModel by name, or nullptr on failure. + static const cellModel* ptr(const word& modelName); + + //- Look up pointer to cellModel by index, or nullptr on failure + static const cellModel* ptr(const label modelIndex); + + + //- Look up reference to cellModel by enumeration. Fatal on failure + static const cellModel& ref(const modelType model); + + //- Look up reference to cellModel by name. Fatal on failure + static const cellModel& ref(const word& modelName); + + //- Look up reference to cellModel by index. Fatal on failure + static const cellModel& ref(const label modelIndex); + + +private: + + // Private Static Data + + //- PtrList of predefined models + static PtrList models_; + + //- Lookup of model pointers (in models_) by index + static List modelPtrs_; + + + // Private Data + + //- (Unique) model name word name_; - //- Label in the model list + //- Index in the model list label index_; //- Number of points in the model which determines the geometry @@ -82,6 +141,12 @@ class cellModel edgeList edges_; + // Private Member Functions + + //- Construct from central "etc/cellModels" file. + static void constructModels(); + + public: // Constructors @@ -104,31 +169,32 @@ public: // Member functions - // Access + //- Return model name + inline const word& name() const; - //- Return model name - inline const word& name() const; + //- Return index of model in the model list + inline label index() const; - //- Return index of model in the model list - inline label index() const; + //- Return number of points + inline label nPoints() const; - //- Return number of points - inline label nPoints() const; + //- Return number of edges + inline label nEdges() const; - //- Return number of edges - inline label nEdges() const; + //- Return number of faces + inline label nFaces() const; - //- Return number of faces - inline label nFaces() const; + //- Return a raw list of model edges + inline const edgeList& modelEdges() const; - //- Return list of edges - inline edgeList edges(const UList