diff --git a/applications/solvers/combustion/chemFoam/chemFoam.C b/applications/solvers/combustion/chemFoam/chemFoam.C index 8098ae464ea84b900f1636c69159d8f2c8af81c1..79037aae50bea5bc6ef588a4c386e12f9b6918b4 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 9b9d0f376b00b9ac809de1dbdec3bd19c95486e7..a43af46326350115a7e2f52dd39f041440df97ac 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<Field<vector>>(points), + xferMove<pointField>(points), faces.xfer(), owner.xfer(), neighbour.xfer() diff --git a/applications/test/boundBox/Test-boundBox.C b/applications/test/boundBox/Test-boundBox.C index 9c06ccf7113fcb8efb0806ac24aba9aed0f07690..037adb4c7f548130fe296b0455e83014db192488 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 0000000000000000000000000000000000000000..0ec888b51226282082e99b08812e382c187ca988 --- /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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/applications/test/cellModels/Test-cellModels.C b/applications/test/cellModels/Test-cellModels.C new file mode 100644 index 0000000000000000000000000000000000000000..93977511142542231293ef9b425844c49571de77 --- /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 <http://www.gnu.org/licenses/>. + +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 8cc704243dacdfa4e8f6bea44000b8c1e6388141..0ddc42f45530a93c239c7baa39e135b7129dc1cd 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 6982f4bc94c4602255764c885ba74bffb00bf5fe..61b89c279c380ffabed784a1f52e1181e6b54f2f 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 ee5b4f073b8f26fc042568bef1809063a6aa7a57..7ba911c13cac9fa1f4bc72e5993df0f8a2008b66 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 2abea60262183074e0ec283cd2b08e828d8349cd..64ae9f37c30930f03e1247c1ff9ff66479006002 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 d585725346cb380e434aac9e0f0d435d4adda491..8aa960e1c978d70225052af7aef7ebcc88b6fb16 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<const cellModel*> fluentCellModelLookup ( 7, - reinterpret_cast<const cellModel*>(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 457b555ad1ebc32b33c5a5789fbd2c3c67486660..9fbc2ed7c53c0a763e6bab7bd203c5eccb52192f 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 a2e0acf8ce04d3f772e8e5c63d0e0663e6bcde00..55809da114f2352e114b6e77aed74c3f94a34688 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 ac632fc8d86c2d5edebedd981b4d4cbcc552edd5..c3fb4fff94a0e0b68fa33ee3a4fda52f7494ac75 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 047e48be44319f39d63f35cb9f1e8f7ad2250617..496473676f6cfe0f136d5135dc64824d949f2a7a 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 23432898a609a013579fb2f62b3cd17db8b3b7ac..2970179cb7d0c0ea0c899fff33290898d7745964 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 ac8a33bcabdb5c3556f8bea5189768d6abb6f2e1..398563d9cbc4aab1cff63260cc00bfd91d7f3b33 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 398351e3f803c8eaf20b38e5b38b71feecad6421..ea44a998a6b9f00d15c6ada378fa8b05812c48a2 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 c88defe7020ba445a810df3f993a8f0f9050c12e..97ab3bd509acdd449e009f6776973ccbbd7362dc 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 57919543e57d1797cf191cda930308213ecda7a5..2c045ac6e350d187568c2241f8672ae8a936e04e 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 ac225fd735d61097c69f90c02e4f43aad8bc5e00..6a3181e80f26c4fdcbef4dae745f5d24cc052ac1 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 <fstream> @@ -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 bb8730370e29c51ac8cf8dcfddc2ce047daca81e..c51ae582e7701ac2362b08c03d81d938b88a1631 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 cc2494160244f8bc024239dcab1d70ce15628ea6..c1ce3c3446fb69a76eb9adf2ad05ac4d8d2d8c9c 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 65261399d076de189a31b6c7fbb206ac1a6f36ca..4f46a524537c2ff58bf914958eb11001430e63ae 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 de11e14a7424f4652ab193e06c643e6ebfadc16b..43b2628d347b39ecaa63c353cc0c2ad93f1ad0c7 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 ac840a07f74b0b5497ddf80e07c9f2ca638000fd..cedc0c23577fa086d72d36b7dfb42831e2125983 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<polyMesh> 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 619d84eca5aeaccdeac9c4de48dc820d21d97149..662fd0190fec7063ad50cb5e40665c72284d17e1 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 7d768159ce333f622fca385b16a887aa337e9076..0fafe21207f49ab490d806f7fd0479dc7fb65c14 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 a66e4c53c6b7af3352de0d9e68d83b8b5e8dcc4a..06cf1d8c122d44a5a6a697182b0ec8e30d2419ec 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; celli<nCells; celli++) @@ -56,7 +56,7 @@ if (which_type == Z_HEX08) // penta's if (which_type == Z_PEN06) { - const cellModel& prism = *(cellModeller::lookup("prism")); + const cellModel& prism = cellModel::ref(cellModel::PRISM); label counter = 1; for (label n=0; n<nCells; n++) @@ -74,7 +74,7 @@ if (which_type == Z_PEN06) // pyramids's if (which_type == Z_PYR05) { - const cellModel& pyr = *(cellModeller::lookup("pyr")); + const cellModel& pyr = cellModel::ref(cellModel::PYR); label counter = 1; for (label n=0; n<nCells; n++) @@ -92,7 +92,7 @@ if (which_type == Z_PYR05) // tet's if (which_type == Z_TET04) { - const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& tet = cellModel::ref(cellModel::TET); label counter = 1; for (label n=0; n<nCells; n++) diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldTensor.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldTensor.H index a7b72c65b3eb5b7a04d5ef0482a70d98d27f97d5..6c800168a455ed18bc442795fbef21b9c2a6e5ce 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldTensor.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldTensor.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 n=0; n<nCells; n++) @@ -56,7 +56,7 @@ if (which_type == Z_HEX08) // penta's if (which_type == Z_PEN06) { - const cellModel& prism = *(cellModeller::lookup("prism")); + const cellModel& prism = cellModel::ref(cellModel::PRISM); label counter = 1; for (label n=0; n<nCells; n++) @@ -74,7 +74,7 @@ if (which_type == Z_PEN06) // pyramids's if (which_type == Z_PYR05) { - const cellModel& pyr = *(cellModeller::lookup("pyr")); + const cellModel& pyr = cellModel::ref(cellModel::PYR); label counter = 1; for (label n=0; n<nCells; n++) @@ -93,7 +93,7 @@ if (which_type == Z_PYR05) // penta's if (which_type == Z_TET04) { - const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& tet = cellModel::ref(cellModel::TET); label counter = 1; diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldVector.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldVector.H index 90f9fd47171a40c482596277e170a504f31b697a..8f1f0f97da11efdbe37a4d4a8a8f89c792d6ac83 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldVector.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/getFieldVector.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 n=0; n<nCells; n++) @@ -56,7 +56,7 @@ if (which_type == Z_HEX08) // penta's if (which_type == Z_PEN06) { - const cellModel& prism = *(cellModeller::lookup("prism")); + const cellModel& prism = cellModel::ref(cellModel::PRISM); label counter = 1; for (label n=0; n<nCells; n++) @@ -74,7 +74,7 @@ if (which_type == Z_PEN06) // pyramids's if (which_type == Z_PYR05) { - const cellModel& pyr = *(cellModeller::lookup("pyr")); + const cellModel& pyr = cellModel::ref(cellModel::PYR); label counter = 1; for (label n=0; n<nCells; n++) @@ -93,7 +93,7 @@ if (which_type == Z_PYR05) // tet's if (which_type == Z_TET04) { - const cellModel& tet = *(cellModeller::lookup("tet")); + const cellModel& tet = cellModel::ref(cellModel::TET); label counter = 1; for (label n=0; n<nCells; n++) diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/libuserd.C b/applications/utilities/postProcessing/graphics/ensightFoamReader/libuserd.C index 4df3379e3c3befdb0ba2aa0998589455298a62af..54d230729f5d262a80ed34db126779480d4701d9 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/libuserd.C +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/libuserd.C @@ -43,7 +43,7 @@ Description #include "Cloud.H" #include "passiveParticle.H" #include "fvMesh.H" -#include "cellModeller.H" +#include "cellModel.H" #include "globalFoam.H" #include "foamVersion.H" diff --git a/etc/cellModels b/etc/cellModels index 6c4f4e4111cf6671e94a11e7a66e46c5677848f0..079d227bce61748df143df4b68e6edcd883cbfa4 100644 --- a/etc/cellModels +++ b/etc/cellModels @@ -6,7 +6,8 @@ | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ -// Foam Dictionary. +// An OpenFOAM dictionary of cellModels. +// The index and name must match those listed in the cellModel class. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -17,9 +18,7 @@ unknown { index 0; numberOfPoints 0; - faces 0(); - edges 0(); } diff --git a/etc/config.csh/ADIOS b/etc/config.csh/ADIOS index e0e9aa9afb5dba8d64ff268e3f5d9d0239614e39..7b33f430a9c9684696bb328e0827f53238c4794b 100644 --- a/etc/config.csh/ADIOS +++ b/etc/config.csh/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 -# <http://www.gnu.org/licenses/>. -# This file is part of OpenFOAM. +# License +# This file is part of OpenFOAM, licensed under GNU General Public License +# <http://www.gnu.org/licenses/>. # # File # etc/config.csh/ADIOS diff --git a/etc/config.sh/ADIOS b/etc/config.sh/ADIOS index 37e55feb37b7cbe51a5f5a2c9f682270dd6a87dc..f27da809738024612b504639ad60979281c0e808 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 -# <http://www.gnu.org/licenses/>. -# This file is part of OpenFOAM. +# License +# This file is part of OpenFOAM, licensed under GNU General Public License +# <http://www.gnu.org/licenses/>. # # File # etc/config.sh/ADIOS diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 130b48e5b3e32052e56d0ac36d81198ef4dc41ed..ff43bb7750b0e946dca151b5339291ae205c73c7 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 0c9f3fdf31f307c467a0ab12e184f3de5b529247..552dc011ccafc2c017a2e248ec948cae6e00b5eb 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 9aa39881ea3d3a74f5632b5a1a4fe51e8ffad402..2155fff4a592778208fe2150111245693b4a21cc 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<bool> 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 9c95a3bcb496d419e44c09e88b1b0a205997668a..6db36cdfb12fb547a44cbeaee76119aa478d66d8 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,13 +125,17 @@ public: //- Returns cell volume scalar mag(const UList<point>& p, const faceUList& f) const; +}; - // Friend Operators +// Global Operators - friend bool operator==(const cell& a, const cell& b); - friend bool operator!=(const cell& a, const cell& b); -}; +//- 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); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/meshShapes/cell/cellI.H b/src/OpenFOAM/meshes/meshShapes/cell/cellI.H index 82878d2278a7054ee1e7d801978d5899347d46f0..0c31f8e99b6501d680cd62d6c98bf2bc599614c1 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 23686e1361c2756715410401949ae0b95fec6c28..c8ec817ba3fcfb431ef8ef4170df5d392bc06ae6 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]); + // Get the other vertex + label otherVertex = e[edgeI].otherVertex(masterFace[pointi]); - if (otherVertex != -1) + 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 2ae0b4a7162b9b667c9170454b71afc902b66ad6..8575c5d6df8b829442523b8cc40e62ce17b7a944 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 1e19cc71274731f27f669b10ac677b4b7a13bd86..3e2fcad6b238a1713b35af846dc2e6016b940a4b 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 4a212e34e11b1a9431813d5ab9bf3b6b82f57fdc..ee73e7308b868fd95799533ff081a660fb8d62ca 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 bf8c545abf0ebace93e2e44c90c162603940924f..90df5d52b4e4f9a5f479b3f5872ead43b8dae202 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 c91671d9cafa4538341f61f045155b76bd1d7318..cf1061f34b222bf5df603bc233d9440c94b74484 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 30994b0aa21b0de023b1d7c5b92fd25103344e64..ae0e7b99318389af26b29655453a3e475598ed1e 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 5bafb985ee505879048428c5a3e0a09688a4274d..8959092c574c945129b86c50a67f4082b9e2b6d5 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 20e00a09f4fa3e5c06fe726a6b6ae5eaa8832903..9ff2ec7fdcd8f1471e78adfb712f96b270fd16f2 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 afbfb220c7b6f2840f0d19807613c59a6d73631e..5d4b8cfe35f5f4ce08deeba71b3634aab0cca4c6 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 b9378f42c7b0f1976a68d63a7207a77574efccc2..4ecda6ea0c9395443082a9cd69396a1e13cea725 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 2c6dc1d10541d5cbb576ef16069beb38650bed3f..b6ddc60fc2b261c21cd190cc4bc5e366b620011b 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 8aa3b8b4f2b46ac3284638d73b74e801e731a349..3a2e594a746fcc495e58841b0c5df7c06ae1b2d2 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 fe5bf02e0bcabea82a9b9f11d39fcaf270c3f4b9..e1d3627d3868c6e74c30de266e67564dfd263068 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 a5f936f3f13e96fc8fe7ce95cb7cb9709e71fa08..fa45433468e0e2d5c5bad9a4902b2d19d5650843 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 cee5714db4df87b8d49279d0431e22f1511dbe98..7da0e6ed1e3b3b73d3d3b708ac84c250065bda61 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 0055bacf8f5d9266cf78643f3c76edfb08df8e6c..b230486a142b5ecdff6766bc8fe84eb7bfe2612f 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 c4c20660ca7af3ea31e52a91018769963e05a9d1..5ec42255c8c61f1200011d9264c5949111228cab 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 309ff4a971eac920bfbaedda62eb13c66162d6e8..ca8a15464c0da73cc965bce56fd04d9e371db6a6 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 4a450b5a6a756d255c7303d7171b90833ac85c6f..d1f08405fcdfeac2aba43c74b9fb98c3bd6e7950 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: + + //- 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<modelType> 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: - //- Name + // Private Static Data + + //- PtrList of predefined models + static PtrList<cellModel> models_; + + //- Lookup of model pointers (in models_) by index + static List<const cellModel*> 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<label>& pointLabels) const; + //- Return a raw list of model faces + inline const faceList& modelFaces() const; - //- Return a raw list of model faces - inline const faceList& modelFaces() const; + //- Return list of edges + inline edgeList edges(const labelUList& pointLabels) const; - //- Return list of faces - inline faceList faces(const UList<label>& pointLabels) const; + //- Return list of faces + inline faceList faces(const labelUList& pointLabels) const; //- Vector centroid @@ -146,7 +212,7 @@ public: ) const; //- Return info proxy. - // Used to print token information to a stream + // Used to print information to a stream InfoProxy<cellModel> info() const { return *this; @@ -160,25 +226,28 @@ public: } - // Friend operators - - //- Equality operator: true => ptr to models are equal ! - friend bool operator==(const cellModel& m1, const cellModel& m2); - - //- Inequality operator: true => ptr to models are not equal ! - friend bool operator!=(const cellModel& m1, const cellModel& m2); - - // Ostream operator - friend Ostream& operator<<(Ostream& os, const cellModel& c); + friend Ostream& operator<<(Ostream& os, const cellModel& cm); + }; +// Ostream operators + template<> Ostream& operator<<(Ostream& os, const InfoProxy<cellModel>& ip); +// Global operators + +//- Equality: true when model pointers are identical +inline bool operator==(const cellModel& lhs, const cellModel& rhs); + +//- Inequality: true when model pointers are not identical +inline bool operator!=(const cellModel& lhs, const cellModel& rhs); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelI.H b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelI.H index 0e7509c684ceba7c117aec9d5c4df5a32871f856..83c75fd896eab9e538563c894aa854ff13ceb3ed 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelI.H +++ b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelI.H @@ -23,9 +23,6 @@ License \*---------------------------------------------------------------------------*/ -#include "error.H" -#include "cellModel.H" - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // inline const Foam::word& Foam::cellModel::name() const @@ -58,23 +55,35 @@ inline Foam::label Foam::cellModel::nFaces() const } +inline const Foam::edgeList& Foam::cellModel::modelEdges() const +{ + return edges_; +} + + +inline const Foam::faceList& Foam::cellModel::modelFaces() const +{ + return faces_; +} + + // Return the faces of a cellModel by untangling the geometry // supplied in terms of the face labels inline Foam::edgeList Foam::cellModel::edges ( - const UList<label>& pointLabels + const labelUList& pointLabels ) const { edgeList e(edges_.size()); - // Translate model lebels into global labels - forAll(edges_, edgeI) + // Translate model labels into global labels + forAll(edges_, edgei) { - e[edgeI] = + e[edgei] = edge ( - pointLabels[edges_[edgeI].start()], - pointLabels[edges_[edgeI].end()] + pointLabels[edges_[edgei].start()], + pointLabels[edges_[edgei].end()] ); } @@ -82,22 +91,16 @@ inline Foam::edgeList Foam::cellModel::edges } -inline const Foam::faceList& Foam::cellModel::modelFaces() const -{ - return faces_; -} - - // Return the faces of a cellModel by untangling the geometry // supplied in terms of the face labels inline Foam::faceList Foam::cellModel::faces ( - const UList<label>& pointLabels + const labelUList& pointLabels ) const { faceList f(faces_.size()); - // Translate model lebels into global labels + // Translate model labels into global labels forAll(faces_, facei) { const labelList& curModelLabels = faces_[facei]; @@ -106,9 +109,9 @@ inline Foam::faceList Foam::cellModel::faces curFace.setSize(curModelLabels.size()); - forAll(curModelLabels, labelI) + forAll(curModelLabels, labeli) { - curFace[labelI] = pointLabels[curModelLabels[labelI]]; + curFace[labeli] = pointLabels[curModelLabels[labeli]]; } } @@ -116,18 +119,17 @@ inline Foam::faceList Foam::cellModel::faces } -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // -// Equality operator: true => ptr to models are equal ! -inline bool Foam::operator==(const cellModel& m1, const cellModel& m2) +inline bool Foam::operator==(const cellModel& lhs, const cellModel& rhs) { - return (&m1 == &m2); + return (&lhs == &rhs); } -// Inequality operator: true => ptr to models are not equal ! -inline bool Foam::operator!=(const cellModel& m1, const cellModel& m2) + +inline bool Foam::operator!=(const cellModel& lhs, const cellModel& rhs) { - return (&m1 != &m2); + return (&lhs != &rhs); } diff --git a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelIO.C b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelIO.C index 1cd60ab8d26266979c9bde59c2139cd5d0844ae1..6b1a6aae04d5021209388fcd38660a9fa6b89206 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelIO.C +++ b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModelIO.C @@ -26,26 +26,29 @@ License #include "cellModel.H" #include "dictionaryEntry.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::cellModel::cellModel(Istream& is) { - dictionaryEntry entry(dictionary::null, is); - name_ = entry.keyword(); - entry.lookup("index") >> index_; - entry.lookup("numberOfPoints") >> nPoints_; - entry.lookup("faces") >> faces_; - entry.lookup("edges") >> edges_; + dictionaryEntry dict(dictionary::null, is); + + name_ = dict.keyword(); + dict.lookup("index") >> index_; + dict.lookup("numberOfPoints") >> nPoints_; + dict.lookup("faces") >> faces_; + dict.lookup("edges") >> edges_; } -Foam::Ostream& Foam::operator<<(Ostream& os, const cellModel& c) +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<<(Ostream& os, const cellModel& cm) { - os << "name" << tab << c.name_ << tab - << "index" << tab << c.index_ << tab - << "numberOfPoints" << tab << c.nPoints_ << tab - << "faces" << tab << c.faces_ << tab - << "edges" << tab << c.edges_ << endl; + os << "name" << tab << cm.name() << tab + << "index" << tab << cm.index() << tab + << "numberOfPoints" << tab << cm.nPoints() << tab + << "faces" << tab << cm.modelFaces() << tab + << "edges" << tab << cm.modelEdges() << endl; return os; } @@ -60,8 +63,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<cellModel>& ip) << "index = " << cm.index() << ", " << "number of points = " << cm.nPoints() << ", " << "number of faces = " << cm.nFaces() << ", " - << "number of edges = " << cm.nEdges() - << endl; + << "number of edges = " << cm.nEdges() << endl; return os; } diff --git a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModeller.H b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModeller.H new file mode 100644 index 0000000000000000000000000000000000000000..576f98e7d72dff43a9346b1e94b6422ba0945972 --- /dev/null +++ b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModeller.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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, licensed under GNU General Public License + <http://www.gnu.org/licenses/>. + +Namespace + Foam::cellModeller + +Description + Compatibility definitions of static cellModel lookups. + + Superseded (NOV-2017) by cellModel methods. + +\*---------------------------------------------------------------------------*/ +#ifndef cellModeller_H +#define cellModeller_H + +#include "cellModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace cellModeller +{ + + //- Equivalent to cellModel::ptr static method. + // \deprecated use cellModel::ptr instead (NOV-2017) + inline const cellModel* lookup(const word& modelName) + { + return cellModel::ptr(modelName); + } + + //- Equivalent to cellModel::ptr static method. + // \deprecated use cellModel::ptr instead (NOV-2017) + inline const cellModel* lookup(const label modelIndex) + { + return cellModel::ptr(modelIndex); + } + +} // End namespace cellModeller +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModel/cellModels.C b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModels.C new file mode 100644 index 0000000000000000000000000000000000000000..32d6869592b9ca11408d3455d6266c8ccddc357a --- /dev/null +++ b/src/OpenFOAM/meshes/meshShapes/cellModel/cellModels.C @@ -0,0 +1,200 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "cellModel.H" +#include "etcFiles.H" +#include "IFstream.H" +#include "HashSet.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +Foam::PtrList<Foam::cellModel> Foam::cellModel::models_; + +Foam::List<const Foam::cellModel*> Foam::cellModel::modelPtrs_; + +const Foam::Enum<Foam::cellModel::modelType> Foam::cellModel::modelNames +{ + { modelType::UNKNOWN, "unknown" }, + { modelType::HEX, "hex" }, + { modelType::WEDGE, "wedge" }, + { modelType::PRISM, "prism" }, + { modelType::PYR, "pyr" }, + { modelType::TET, "tet" }, + { modelType::TETWEDGE, "tetWedge" }, + { modelType::SPLITHEX, "splitHex" }, +}; + + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +void Foam::cellModel::constructModels() +{ + if (models_.size()) + { + FatalErrorInFunction + << "attempt to re-construct cellModeller when it already exists" + << exit(FatalError); + } + + IFstream is(findEtcFile("cellModels", true)); + + PtrList<cellModel> newPtrs(is); + models_.swap(newPtrs); + + ///Info<< "loading " << models_.size() + /// << " cell models from etc/controlDict" << endl; + + + // Build two lookups: by index, by name + // Since there are relatively few models, use straight lookup for the index + // and a linear (non-hashed) search for the name. + // Lookup by name is less likely than lookup by enum anyhow. + + label maxIndex = 0; + forAll(models_, i) + { + if (maxIndex < models_[i].index()) + { + maxIndex = models_[i].index(); + } + } + + modelPtrs_.clear(); + modelPtrs_.setSize(maxIndex+1, nullptr); + + wordHashSet used(2*maxIndex); + + forAll(models_, i) + { + const label modelIndex = models_[i].index(); + const word& modelName = models_[i].name(); + const cellModel* ptr = &models_[i]; + + if (used.insert(modelName)) + { + if (modelPtrs_[modelIndex]) + { + FatalErrorInFunction + << "more than one model share the index " + << modelIndex + << exit(FatalError); + } + + modelPtrs_[modelIndex] = ptr; + } + else + { + FatalErrorInFunction + << "more than one model share the name " + << modelName + << exit(FatalError); + } + } +} + + +const Foam::cellModel* Foam::cellModel::ptr(const modelType model) +{ + return ptr(label(model)); +} + + +const Foam::cellModel* Foam::cellModel::ptr(const word& modelName) +{ + if (models_.empty()) + { + constructModels(); + } + + const label n = models_.size(); + for (label i = 0; i < n; ++i) + { + if (models_[i].name() == modelName) + { + return &(models_[i]); + } + } + + return nullptr; +} + + +const Foam::cellModel* Foam::cellModel::ptr(const label modelIndex) +{ + if (models_.empty()) + { + constructModels(); + } + + return (modelIndex < modelPtrs_.size() ? modelPtrs_[modelIndex] : nullptr); +} + + +const Foam::cellModel& Foam::cellModel::ref(const modelType model) +{ + const cellModel* p = ptr(model); + + if (!p) + { + FatalErrorInFunction + << "No such cellModel: " << modelNames[model] + << exit(FatalError); + } + + return *p; +} + + +const Foam::cellModel& Foam::cellModel::ref(const word& modelName) +{ + const cellModel* p = ptr(modelName); + + if (!p) + { + FatalErrorInFunction + << "No such cellModel: " << modelName + << exit(FatalError); + } + + return *p; +} + + +const Foam::cellModel& Foam::cellModel::ref(const label modelIndex) +{ + const cellModel* p = ptr(modelIndex); + + if (!p) + { + FatalErrorInFunction + << "No such cellModel: " << modelIndex + << exit(FatalError); + } + + return *p; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C deleted file mode 100644 index 8426b1336dfaf627acd644bd4571e499d5ef051b..0000000000000000000000000000000000000000 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.C +++ /dev/null @@ -1,103 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Description - Constructor of cellModeller: just sets the cellModeller's params. - -\*---------------------------------------------------------------------------*/ - -#include "cellModeller.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::cellModeller::cellModeller() -{ - if (modelPtrs_.size()) - { - FatalErrorInFunction - << "attempt to re-construct cellModeller when it already exists" - << exit(FatalError); - } - - label maxIndex = 0; - forAll(models_, i) - { - if (models_[i].index() > maxIndex) maxIndex = models_[i].index(); - } - - modelPtrs_.setSize(maxIndex + 1); - modelPtrs_ = nullptr; - - // For all the words in the wordlist, set the details of the model - // to those specified by the word name and the other parameters - // given. This should result in an automatic 'read' of the model - // from its File (see cellModel class). - forAll(models_, i) - { - if (modelPtrs_[models_[i].index()]) - { - FatalErrorInFunction - << "more than one model share the index " - << models_[i].index() - << exit(FatalError); - } - - modelPtrs_[models_[i].index()] = &models_[i]; - - if (modelDictionary_.found(models_[i].name())) - { - FatalErrorInFunction - << "more than one model share the name " - << models_[i].name() - << exit(FatalError); - } - - modelDictionary_.insert(models_[i].name(), &models_[i]); - } -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::cellModeller::~cellModeller() -{} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -const Foam::cellModel* Foam::cellModeller::lookup(const word& name) -{ - HashTable<const cellModel*>::iterator iter = modelDictionary_.find(name); - - if (iter != modelDictionary_.end()) - { - return iter(); - } - else - { - return nullptr; - } -} - - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H b/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H deleted file mode 100644 index 490cf2eae607d73d47a382f8d333885ba7407b06..0000000000000000000000000000000000000000 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/cellModeller.H +++ /dev/null @@ -1,100 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Class - Foam::cellModeller - -Description - A static collection of cell models, and a means of looking them up. - -SourceFiles - cellModeller.C - cellModellerIO.C - globalCellModeller.C - -\*---------------------------------------------------------------------------*/ - -#ifndef cellModeller_H -#define cellModeller_H - -#include "cellModel.H" -#include "PtrList.H" -#include "HashTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class cellModeller Declaration -\*---------------------------------------------------------------------------*/ - -class cellModeller -{ - // Private data - - //- PtrList of models - static PtrList<cellModel> models_; - - //- List of model pointers - static List<cellModel*> modelPtrs_; - - //- HashTable of model pointers - static HashTable<const cellModel*> modelDictionary_; - - -public: - - // Constructors - - //- Construct from central "cellModels" file - cellModeller(); - - //- Destructor - ~cellModeller(); - - - // Member functions - - //- Look up a model by name and return a pointer to the model or nullptr - static const cellModel* lookup(const word&); - - //- Look up a model by index and return a pointer to the model or - // nullptr - static const cellModel* lookup(const label i) - { - return modelPtrs_[i]; - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C b/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C deleted file mode 100644 index 92f66696a7556cc37f35112458c80618c3426c6d..0000000000000000000000000000000000000000 --- a/src/OpenFOAM/meshes/meshShapes/cellModeller/globalCellModeller.C +++ /dev/null @@ -1,54 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ 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 <http://www.gnu.org/licenses/>. - -Description - cellModeller global initializations - -\*---------------------------------------------------------------------------*/ - -#include "cellModeller.H" -#include "etcFiles.H" -#include "IFstream.H" - -// * * * * * * * * * * * * * * * Static data * * * * * * * * * * * * * * * * // - -Foam::PtrList<Foam::cellModel> Foam::cellModeller::models_ -( - IFstream(findEtcFile("cellModels", true))() -); - -Foam::List<Foam::cellModel*> Foam::cellModeller::modelPtrs_; - -Foam::HashTable<const Foam::cellModel*> Foam::cellModeller::modelDictionary_; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // Construct a dummy cellModeller which reads the models and fills - // the above tables - cellModeller globalCellModeller_; -} - -// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H index c4905813bf95f8aa731a5e45f069a9975f591bd1..045cb3b7958867b2e046ab997e4a7b7ffb7ef1f6 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H +++ b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShape.H @@ -87,16 +87,16 @@ public: //- Construct from components inline cellShape ( - const cellModel&, - const labelList&, + const cellModel& model, + const labelUList& labels, const bool doCollapse = false ); //- Construct from components inline cellShape ( - const word& model, - const labelList&, + const word& modelName, + const labelUList& labels, const bool doCollapse = false ); diff --git a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H index 2560c5ee8c91b4ad2d80c7766364d250ed3ec832..ad1443b679660585144750adb9b33c58156cac26 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H +++ b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeI.H @@ -25,7 +25,7 @@ License #include "Istream.H" #include "cell.H" -#include "cellModeller.H" +#include "cellModel.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -37,13 +37,13 @@ inline Foam::cellShape::cellShape() inline Foam::cellShape::cellShape ( - const cellModel& M, - const labelList& l, + const cellModel& model, + const labelUList& labels, const bool doCollapse ) : - labelList(l), - m(&M) + labelList(labels), + m(&model) { if (doCollapse) { @@ -54,13 +54,13 @@ inline Foam::cellShape::cellShape inline Foam::cellShape::cellShape ( - const word& model, - const labelList& l, + const word& modelName, + const labelUList& labels, const bool doCollapse ) : - labelList(l), - m(cellModeller::lookup(model)) + labelList(labels), + m(cellModel::ptr(modelName)) { if (doCollapse) { diff --git a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeIO.C b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeIO.C index b52c8e21527cebda1a567e69c8f762f30704219a..def8f9687c0532e99adfa0aa60d4ffee874038ef 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeIO.C +++ b/src/OpenFOAM/meshes/meshShapes/cellShape/cellShapeIO.C @@ -25,7 +25,6 @@ License #include "cellShape.H" #include "token.H" -#include "cellModeller.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,14 +52,14 @@ Foam::Istream& Foam::operator>>(Istream& is, cellShape& s) } } - // it is allowed to have either a word or a number describing the model + // Model can be described by index or name if (t.isLabel()) { - s.m = cellModeller::lookup(int(t.labelToken())); + s.m = cellModel::ptr(t.labelToken()); } else if (t.isWord()) { - s.m = cellModeller::lookup(t.wordToken()); + s.m = cellModel::ptr(t.wordToken()); } else { @@ -98,13 +97,13 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const cellShape& s) os << token::BEGIN_LIST; // Write the list label for the symbol (ONE OR THE OTHER !!!) - os << (s.m)->index() << token::SPACE; + os << (s.m)->index(); // Write the model name instead of the label (ONE OR THE OTHER !!!) - // os << (s.m)->name() << token::SPACE; + // os << (s.m)->name(); // Write the geometry - os << static_cast<const labelList&>(s); + os << token::SPACE << static_cast<const labelList&>(s); // End of record os << token::END_LIST; diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edge.H b/src/OpenFOAM/meshes/meshShapes/edge/edge.H index dabdc197efa866c56d3c5818af7682019c346e42..ccfc6308e41d67ace3aaba6e435a4404c6e6fb08 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edge.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edge.H @@ -203,7 +203,7 @@ public: // Returns true on success. Negative labels never insert. // Return the number of slots filled. // Similar to a HashTable::insert(). - inline label insert(const UList<label>& lst); + inline label insert(const labelUList& lst); //- Fill open slots with the indices if they did not previously exist. // Returns true on success. Negative labels never insert. @@ -225,7 +225,7 @@ public: //- Remove existing indices from the edge and set locations to '-1'. // Returns the number of changes. - inline label erase(const UList<label>& lst); + inline label erase(const labelUList& lst); //- Remove existing indices from the edge and set locations to '-1'. // Returns the number of changes. diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H index db939da2aac5c7670af599319bf2c63d453f64e6..4957bd1336d0e32603a5f5a7a53a3031658108f7 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H @@ -199,6 +199,7 @@ inline Foam::label Foam::edge::which(const label pointLabel) const return 1; } } + return -1; } @@ -328,7 +329,7 @@ inline bool Foam::edge::insert(const label index) } -inline Foam::label Foam::edge::insert(const UList<label>& lst) +inline Foam::label Foam::edge::insert(const labelUList& lst) { return insertMultiple(lst.begin(), lst.end()); } @@ -373,7 +374,7 @@ inline Foam::label Foam::edge::erase(const label index) } -inline Foam::label Foam::edge::erase(const UList<label>& lst) +inline Foam::label Foam::edge::erase(const labelUList& lst) { return eraseMultiple(lst.begin(), lst.end()); } diff --git a/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C b/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C index 76e75829e98c4a4918cee1911df34741ba7ef73c..8fb3ebf7f89b3f54d2136e7fba5ec5f3fe94e15c 100644 --- a/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C +++ b/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C @@ -25,8 +25,6 @@ License #include "tetCell.H" #include "cellShape.H" -#include "cellModeller.H" - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -36,12 +34,10 @@ Foam::cellShape Foam::tetCell::tetCellShape() const if (!tetModelPtr_) { - tetModelPtr_ = cellModeller::lookup("tet"); + tetModelPtr_ = cellModel::ptr(cellModel::TET); } - const cellModel& tet = *tetModelPtr_; - - return cellShape(tet, labelList(*this)); + return cellShape(*tetModelPtr_, labelList(*this)); } diff --git a/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.H b/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.H index 8669efbc3c3e8b285d54fa214e86cf28ec9193e4..0208b85aca515b147dbda093e6091277ea6c1cf1 100644 --- a/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.H +++ b/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.H @@ -65,10 +65,10 @@ public: // Constructors - //- Construct null + //- Construct null, with invalid point labels (-1) inline tetCell(); - //- Construct from four points + //- Construct from four point labels inline tetCell ( const label a, @@ -77,9 +77,12 @@ public: const label d ); - //- Construct from FixedList + //- Construct from FixedList of four point labels inline tetCell(const FixedList<label, 4>& lst); + //- Construct from an initializer list of four point labels + explicit inline tetCell(std::initializer_list<label> lst); + //- Construct from Istream inline tetCell(Istream& is); @@ -92,17 +95,17 @@ public: inline triFace face(const label facei) const; //- Return first face adjacent to the given edge - inline label edgeFace(const label edgeI) const; + inline label edgeFace(const label edgei) const; //- Return face adjacent to the given face sharing the same edge inline label edgeAdjacentFace ( - const label edgeI, + const label edgei, const label facei ) const; //- Return i-th edge - inline edge tetEdge(const label edgeI) const; + inline edge tetEdge(const label edgei) const; // Operations diff --git a/src/OpenFOAM/meshes/meshShapes/tetCell/tetCellI.H b/src/OpenFOAM/meshes/meshShapes/tetCell/tetCellI.H index b1024a1696fefc09e6aa93f5bb073ef1092735ee..03faffe1abaa05a623954a57169a826aca4c3121 100644 --- a/src/OpenFOAM/meshes/meshShapes/tetCell/tetCellI.H +++ b/src/OpenFOAM/meshes/meshShapes/tetCell/tetCellI.H @@ -30,6 +30,8 @@ Description // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // inline Foam::tetCell::tetCell() +: + FixedList<label, 4>(-1) {} @@ -54,6 +56,12 @@ inline Foam::tetCell::tetCell(const FixedList<label, 4>& lst) {} +inline Foam::tetCell::tetCell(std::initializer_list<label> lst) +: + FixedList<label, 4>(lst) +{} + + inline Foam::tetCell::tetCell(Istream& is) : FixedList<label, 4>(is) @@ -66,9 +74,9 @@ inline Foam::triFace Foam::tetCell::face(const label facei) const { // Warning. Ordering of faces needs to be the same for a tetrahedron // class, a tetrahedron cell shape model and a tetCell - static const label a[] = {1, 0, 0, 0}; - static const label b[] = {2, 3, 1, 2}; - static const label c[] = {3, 2, 3, 1}; + static const label a[4] = {1, 0, 0, 0}; + static const label b[4] = {2, 3, 1, 2}; + static const label c[4] = {3, 2, 3, 1}; #ifdef FULLDEBUG if (facei < 0 || facei >= 4) @@ -88,29 +96,28 @@ inline Foam::triFace Foam::tetCell::face(const label facei) const } -inline Foam::label Foam::tetCell::edgeFace(const label edgeI) const +inline Foam::label Foam::tetCell::edgeFace(const label edgei) const { // Warning. Ordering of faces needs to be the same for a tetrahedron // class, a tetrahedron cell shape model and a tetCell - //static const label edgeFaces[6] = {2, 1, 1, 0, 0, 0}; static const label edgeFaces[6] = {2, 3, 1, 0, 0, 1}; #ifdef FULLDEBUG - if (edgeI < 0 || edgeI >= 6) + if (edgei < 0 || edgei >= 6) { FatalErrorInFunction - << "edge index out of range 0 -> 5. edgeI = " << edgeI + << "edge index out of range 0 -> 5. edgei = " << edgei << abort(FatalError); } #endif - return edgeFaces[edgeI]; + return edgeFaces[edgei]; } inline Foam::label Foam::tetCell::edgeAdjacentFace ( - const label edgeI, + const label edgei, const label facei ) const { @@ -134,36 +141,35 @@ inline Foam::label Foam::tetCell::edgeAdjacentFace << abort(FatalError); } - if (edgeI < 0 || edgeI >= 6) + if (edgei < 0 || edgei >= 6) { FatalErrorInFunction - << "edge index out of range 0 -> 5. edgeI = " << edgeI + << "edge index out of range 0 -> 5. edgei = " << edgei << abort(FatalError); } #endif - return adjacentFace[edgeI][facei]; + return adjacentFace[edgei][facei]; } -inline Foam::edge Foam::tetCell::tetEdge(const label edgeI) const +inline Foam::edge Foam::tetCell::tetEdge(const label edgei) const { // Warning. Ordering of edges needs to be the same for a tetrahedron // class, a tetrahedron cell shape model and a tetCell - // - static const label start[] = {0, 0, 0, 3, 1, 3}; - static const label end[] = {1, 2, 3, 1, 2, 2}; + static const label pt0[] = {0, 0, 0, 3, 1, 3}; + static const label pt1[] = {1, 2, 3, 1, 2, 2}; #ifdef FULLDEBUG - if (edgeI < 0 || edgeI >= 6) + if (edgei < 0 || edgei >= 6) { FatalErrorInFunction - << "index out of range 0 -> 5. edgeI = " << edgeI + << "index out of range 0 -> 5. edgei = " << edgei << abort(FatalError); } #endif - return edge(operator[](start[edgeI]), operator[](end[edgeI])); + return edge(operator[](pt0[edgei]), operator[](pt1[edgei])); } diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H index ea18b760194a8d3708a028dd8eeaacd1c40e7e6c..2b7f2e62bc09945e1887154b28a7bad063cbf514 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H @@ -86,10 +86,10 @@ public: const label c ); - //- Copy construct from a list of 3 labels. + //- Copy construct from a list of three point labels. explicit inline triFace(const labelUList& lst); - //- Construct from an initializer list of 3 labels + //- Construct from an initializer list of three point labels explicit inline triFace(std::initializer_list<label> lst); //- Construct from Istream diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H index bc99e45518cd599c81015c72f062e54ca3b4bf56..6fc2caa116aff777e2e5891f32704c47fea0ed2a 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H @@ -52,10 +52,8 @@ inline int Foam::triFace::compare(const triFace& a, const triFace& b) // same face, but reversed orientation return -1; } - else - { - return 0; - } + + return 0; } @@ -379,10 +377,8 @@ inline int Foam::triFace::edgeDirection(const edge& e) const { return -1; } - else - { - return 0; - } + + return 0; } diff --git a/src/OpenFOAM/meshes/primitiveShapes/pyramid/pyramidI.H b/src/OpenFOAM/meshes/primitiveShapes/pyramid/pyramidI.H index a657a889f8150b7ec82ea543da343926cc8332c3..f729ff36c3a8ec523681fcd28da47c95ce946352 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/pyramid/pyramidI.H +++ b/src/OpenFOAM/meshes/primitiveShapes/pyramid/pyramidI.H @@ -21,8 +21,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Description - \*---------------------------------------------------------------------------*/ #include "IOstreams.H" diff --git a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H index 2ed07ccf7d64e9d3de9a5ef7797457d1b1a573f9..9ffff4ae8c7eb37d3d95d4bdc01f1644c91fa2cd 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H +++ b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H @@ -122,13 +122,11 @@ inline Foam::triPointRef Foam::tetrahedron<Point, PointRef>::tri { return triPointRef(a_, c_, b_); } - else - { - FatalErrorInFunction - << "index out of range 0 -> 3. facei = " << facei - << abort(FatalError); - return triPointRef(b_, c_, d_); - } + + FatalErrorInFunction + << "index out of range 0 -> 3. facei = " << facei + << abort(FatalError); + return triPointRef(b_, c_, d_); } diff --git a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H index 2a552aaf76a5fec0cfdad48c35ce533b1f92caa1..571a699855119e9085debc66328fd4807016a2d4 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H +++ b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H @@ -149,11 +149,11 @@ inline Point Foam::triangle<Point, PointRef>::circumCentre() const template<class Point, class PointRef> inline Foam::scalar Foam::triangle<Point, PointRef>::circumRadius() const { - scalar d1 = (c_ - a_) & (b_ - a_); - scalar d2 = -(c_ - b_) & (b_ - a_); - scalar d3 = (c_ - a_) & (c_ - b_); + const scalar d1 = (c_ - a_) & (b_ - a_); + const scalar d2 = -(c_ - b_) & (b_ - a_); + const scalar d3 = (c_ - a_) & (c_ - b_); - scalar denom = d2*d3 + d3*d1 + d1*d2; + const scalar denom = d2*d3 + d3*d1 + d1*d2; if (Foam::mag(denom) < VSMALL) { @@ -161,12 +161,9 @@ inline Foam::scalar Foam::triangle<Point, PointRef>::circumRadius() const return GREAT; } - else - { - scalar a = (d1 + d2)*(d2 + d3)*(d3 + d1) / denom; - return 0.5*Foam::sqrt(min(GREAT, max(0, a))); - } + const scalar a = (d1 + d2)*(d2 + d3)*(d3 + d1) / denom; + return 0.5*Foam::sqrt(min(GREAT, max(0, a))); } diff --git a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxTemplates.C b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxTemplates.C index a06469fbfdf8cd20851404befc1d6acee5fffd93..5bdf9d85d3afa0b04bd9201c41b1aa98e40672b6 100644 --- a/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxTemplates.C +++ b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxTemplates.C @@ -26,10 +26,8 @@ License #include "treeBoundBox.H" #include "FixedList.H" - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - template<unsigned Size> Foam::treeBoundBox::treeBoundBox ( diff --git a/src/conversion/ccm/writer/ccmWriter.C b/src/conversion/ccm/writer/ccmWriter.C index 8cd6dfdd503573d3276d9e5c6dd5c7e4c4ca21ba..ef3e8c51a2f0aa06dd5a2a26c8bfb990e4f68b4c 100644 --- a/src/conversion/ccm/writer/ccmWriter.C +++ b/src/conversion/ccm/writer/ccmWriter.C @@ -24,7 +24,7 @@ License \*----------------------------------------------------------------------------*/ #include "ccmWriter.H" -#include "cellModeller.H" +#include "cellModel.H" #include "demandDrivenData.H" #include "ccmInternal.H" // include last to avoid any strange interactions @@ -304,12 +304,12 @@ Foam::ccm::writer::writer mesh_(mesh), // Mapping between OpenFOAM and PROSTAR primitives prostarShapeLookup_ - ({ - { cellModeller::lookup("hex")->index(), STARCDCore::starcdHex }, - { cellModeller::lookup("prism")->index(), STARCDCore::starcdPrism }, - { cellModeller::lookup("tet")->index(), STARCDCore::starcdTet }, - { cellModeller::lookup("pyr")->index(), STARCDCore::starcdPyr } - }), + { + { cellModel::ref(cellModel::HEX).index(), STARCDCore::starcdHex }, + { cellModel::ref(cellModel::PRISM).index(), STARCDCore::starcdPrism }, + { cellModel::ref(cellModel::TET).index(), STARCDCore::starcdTet }, + { cellModel::ref(cellModel::PYR).index(), STARCDCore::starcdPyr } + }, boundaryRegion_(mesh), cellTable_(mesh) { diff --git a/src/conversion/common/reader/README b/src/conversion/common/reader/README index bf24eb65a181fa838c6dd9313813480f4b0439be..a2bb1009d6546440a1bf341b7690c1bb03fe8423 100644 --- a/src/conversion/common/reader/README +++ b/src/conversion/common/reader/README @@ -1,4 +1,4 @@ -With pro-STAR version v4, the input formats have changed radically. +With PROSTAR version v4, the input formats have changed radically. * Easier to parse space-delimited input formats * No arbitrary or integral couples * No trimmed or degenerate cells @@ -11,7 +11,7 @@ incorrect lookup. Fortunately, there are only 4 primitive shapes to be concerned with. Hexa: - Foam pro-STAR + OpenFOAM PROSTAR ~~~~~~~~~~~~~~ ~~~~~~~~~~~ Face 0 (0 4 7 3) -> F5: (0 4 7 3) Face 1 (1 2 6 5) -> F6: (1 2 6 5) @@ -22,7 +22,7 @@ Hexa: Prism: - Foam pro-STAR + OpenFOAM PROSTAR ~~~~~~~~~~~~~~ ~~~~~~~~~~~ Face 0 (0 2 1) -> F1: (0 2 1) Face 1 (3 4 5) -> F2: (3 4 5) @@ -32,7 +32,7 @@ Prism: Tetra: - Foam pro-STAR + OpenFOAM PROSTAR ~~~~~~~~~~~~~~ ~~~~~~~~~~~ Face 0 (1 2 3) -> F6: (1 2 3) Face 1 (0 3 2) -> F5: (0 3 2) @@ -41,7 +41,7 @@ Tetra: Pyramid: - Foam pro-STAR + OpenFOAM PROSTAR ~~~~~~~~~~~~~~ ~~~~~~~~~~~ Face 0 (0 3 2 1) -> F1: (0 3 2 1) Face 1 (0 4 3) -> F5: (0 4 3) @@ -49,12 +49,12 @@ Pyramid: Face 3 (1 2 4) -> F6: (1 2 4) Face 4 (0 1 4) -> F3: (0 1 4) -Noting that several faces are skipped over in the pro-STAR definitions, +Noting that several faces are skipped over in the PROSTAR definitions, simply introducing a new cell modeller will be a problem. -Instead, subtract 1 from the pro-STAR faces and use lookup tables. +Instead, subtract 1 from the PROSTAR faces and use lookup tables. -Here are the pro-STAR macro snippets used for creating the primitive cells: +Here are the PROSTAR macro snippets used for creating the primitive cells: ! hexa v 10 0 0 0 diff --git a/src/conversion/common/reader/meshReader.C b/src/conversion/common/reader/meshReader.C index 69161a47cbe3fedd72acf83ecbcd2ff695c59473..d78ed75f6dd4de592b13f28ba03c1e24b0af87da 100644 --- a/src/conversion/common/reader/meshReader.C +++ b/src/conversion/common/reader/meshReader.C @@ -28,42 +28,8 @@ License #include "polyMesh.H" #include "faceSet.H" #include "emptyPolyPatch.H" -#include "cellModeller.H" #include "demandDrivenData.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -const Foam::cellModel* Foam::meshReader::unknownModel = Foam::cellModeller:: -lookup -( - "unknown" -); - -const Foam::cellModel* Foam::meshReader::tetModel = Foam::cellModeller:: -lookup -( - "tet" -); - -const Foam::cellModel* Foam::meshReader::pyrModel = Foam::cellModeller:: -lookup -( - "pyr" -); - -const Foam::cellModel* Foam::meshReader::prismModel = Foam::cellModeller:: -lookup -( - "prism" -); - -const Foam::cellModel* Foam::meshReader::hexModel = Foam::cellModeller:: -lookup -( - "hex" -); - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::meshReader::addCellZones(polyMesh& mesh) const diff --git a/src/conversion/common/reader/meshReader.H b/src/conversion/common/reader/meshReader.H index 623a3f4110116c040fbdca0ce7047818e88f7bfa..1af44e4d0438a2d167f32973e73418c1de0c04d8 100644 --- a/src/conversion/common/reader/meshReader.H +++ b/src/conversion/common/reader/meshReader.H @@ -30,7 +30,7 @@ Description The derived classes are responsible for providing the protected data. This implementation is somewhat messy, but could/should be restructured to provide a more generalized reader (at the moment it has been written - for converting pro-STAR data). + for converting PROSTAR data). The meshReader supports cellTable information (see new user's guide entry). @@ -204,13 +204,6 @@ protected: // Protected member data - //- Pointers to cell shape models - static const cellModel* unknownModel; - static const cellModel* tetModel; - static const cellModel* pyrModel; - static const cellModel* prismModel; - static const cellModel* hexModel; - //- Referenced filename fileName geometryFile_; diff --git a/src/conversion/common/writer/meshWriter.C b/src/conversion/common/writer/meshWriter.C index 760cccea7a23697c655ef3fed30b4a42bf9568d2..f5033c89151ba942509df701ba6f7858d61a67ea 100644 --- a/src/conversion/common/writer/meshWriter.C +++ b/src/conversion/common/writer/meshWriter.C @@ -24,48 +24,12 @@ License \*---------------------------------------------------------------------------*/ #include "meshWriter.H" -#include "cellModeller.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // Foam::string Foam::meshWriter::defaultMeshName = "meshExport"; -const Foam::cellModel* Foam::meshWriter::unknownModel = Foam::cellModeller:: -lookup -( - "unknown" -); - - -const Foam::cellModel* Foam::meshWriter::tetModel = Foam::cellModeller:: -lookup -( - "tet" -); - - -const Foam::cellModel* Foam::meshWriter::pyrModel = Foam::cellModeller:: -lookup -( - "pyr" -); - - -const Foam::cellModel* Foam::meshWriter::prismModel = Foam::cellModeller:: -lookup -( - "prism" -); - - -const Foam::cellModel* Foam::meshWriter::hexModel = Foam::cellModeller:: -lookup -( - "hex" -); - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::meshWriter::meshWriter diff --git a/src/conversion/common/writer/meshWriter.H b/src/conversion/common/writer/meshWriter.H index 5aedb05cdfb7548aebd1d2dd76ad14587aaf0ab5..e01a9ad6a23801f6c50344c9f4dd170ddadc1a58 100644 --- a/src/conversion/common/writer/meshWriter.H +++ b/src/conversion/common/writer/meshWriter.H @@ -107,14 +107,6 @@ protected: //- cellTable IDs for each cell labelList cellTableId_; - //- Pointers to cell shape models - static const cellModel* unknownModel; - static const cellModel* tetModel; - static const cellModel* pyrModel; - static const cellModel* prismModel; - static const cellModel* hexModel; - - public: // Static data members diff --git a/src/conversion/starcd/STARCDMeshReader.C b/src/conversion/starcd/STARCDMeshReader.C index 22af44c6fafc2965a72ceb55cc60f480598647f2..1dc14e168f976a81b99b05bc0f0f2f3169ea4fc1 100644 --- a/src/conversion/starcd/STARCDMeshReader.C +++ b/src/conversion/starcd/STARCDMeshReader.C @@ -28,7 +28,7 @@ License #include "emptyPolyPatch.H" #include "wallPolyPatch.H" #include "symmetryPolyPatch.H" -#include "cellModeller.H" +#include "cellModel.H" #include "ListOps.H" #include "IFstream.H" #include "IOMap.H" @@ -317,7 +317,10 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName) // avoid undefined shapes for polyhedra - cellShape genericShape(*unknownModel, labelList(0)); + cellShape genericShape + ( + cellModel::ref(cellModel::UNKNOWN), labelList() + ); // Pass 2: // construct cellFaces_ and possibly cellShapes_ @@ -372,23 +375,23 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName) continue; } - // determine the foam cell shape + // determine the OpenFOAM cell shape const cellModel* curModelPtr = nullptr; // fluid/solid cells switch (shapeId) { case STARCDCore::starcdHex: - curModelPtr = hexModel; + curModelPtr = cellModel::ptr(cellModel::HEX); break; case STARCDCore::starcdPrism: - curModelPtr = prismModel; + curModelPtr = cellModel::ptr(cellModel::PRISM); break; case STARCDCore::starcdTet: - curModelPtr = tetModel; + curModelPtr = cellModel::ptr(cellModel::TET); break; case STARCDCore::starcdPyr: - curModelPtr = pyrModel; + curModelPtr = cellModel::ptr(cellModel::PYR); break; } @@ -612,12 +615,12 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary // Mapping between OpenFOAM and PROSTAR primitives // - needed for face mapping // - const Map<label> prostarShapeLookup = + const Map<label> shapeLookup = { - { hexModel->index(), STARCDCore::starcdHex }, - { prismModel->index(), STARCDCore::starcdPrism }, - { tetModel->index(), STARCDCore::starcdTet }, - { pyrModel->index(), STARCDCore::starcdPyr } + { cellModel::ref(cellModel::HEX).index(), STARCDCore::starcdHex }, + { cellModel::ref(cellModel::PRISM).index(), STARCDCore::starcdPrism }, + { cellModel::ref(cellModel::TET).index(), STARCDCore::starcdTet }, + { cellModel::ref(cellModel::PYR).index(), STARCDCore::starcdPyr }, }; // Pass 1: @@ -861,9 +864,9 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary if (cellId < cellShapes_.size()) { label mapIndex = cellShapes_[cellId].model().index(); - if (prostarShapeLookup.found(mapIndex)) + if (shapeLookup.found(mapIndex)) { - mapIndex = prostarShapeLookup[mapIndex]; + mapIndex = shapeLookup[mapIndex]; cellFaceId = STARCDCore::starToFoamFaceAddr [mapIndex][cellFaceId]; diff --git a/src/conversion/starcd/STARCDMeshReader.H b/src/conversion/starcd/STARCDMeshReader.H index 9288002991546735fd32642f4d50ce03507ba7b7..048e3091281f3fef04d4c7c17ada63e01aff7914 100644 --- a/src/conversion/starcd/STARCDMeshReader.H +++ b/src/conversion/starcd/STARCDMeshReader.H @@ -25,10 +25,10 @@ Class Foam::fileFormats::STARCDMeshReader Description - Read pro-STAR vrt/cel/bnd files. + Read PROSTAR vrt/cel/bnd files. The protected data in meshReader are filled. - Starting with pro-STAR version 4, the files have become easier to read. + Starting with PROSTAR version 4, the files have become easier to read. - vertices are space-delimited. - the cell format is logical. - trimmed and degenerate cells are saved as polyhedral. diff --git a/src/conversion/starcd/STARCDMeshWriter.C b/src/conversion/starcd/STARCDMeshWriter.C index 85cba78d595e0b06700b4e1c33e2ebf6c414f785..4690072d18398013e6c0c5dd5cf03f2ef2b15aa8 100644 --- a/src/conversion/starcd/STARCDMeshWriter.C +++ b/src/conversion/starcd/STARCDMeshWriter.C @@ -35,18 +35,17 @@ Foam::label Foam::fileFormats::STARCDMeshWriter::findDefaultBoundary() const { const polyBoundaryMesh& patches = mesh_.boundaryMesh(); - label id = -1; - // find Default_Boundary_Region if it exists forAll(patches, patchi) { if (defaultBoundaryName == patches[patchi].name()) { - id = patchi; + return patchi; break; } } - return id; + + return -1; } @@ -165,29 +164,16 @@ void Foam::fileFormats::STARCDMeshWriter::writeCells OFstream os(starFileName(prefix, STARCDCore::CEL_FILE)); writeHeader(os, STARCDCore::HEADER_CEL); - // this is what we seem to need - // map foam cellModeller index -> star shape - Map<label> shapeLookupIndex; - shapeLookupIndex.insert - ( - hexModel->index(), - STARCDCore::starcdHex - ); - shapeLookupIndex.insert - ( - prismModel->index(), - STARCDCore::starcdPrism - ); - shapeLookupIndex.insert - ( - tetModel->index(), - STARCDCore::starcdTet - ); - shapeLookupIndex.insert - ( - pyrModel->index(), - STARCDCore::starcdPyr - ); + // + // Mapping between OpenFOAM and PROSTAR primitives + // + const Map<label> shapeLookupIndex + { + { cellModel::ref(cellModel::HEX).index(), STARCDCore::starcdHex }, + { cellModel::ref(cellModel::PRISM).index(), STARCDCore::starcdPrism }, + { cellModel::ref(cellModel::TET).index(), STARCDCore::starcdTet }, + { cellModel::ref(cellModel::PYR).index(), STARCDCore::starcdPyr }, + }; const cellShapeList& shapes = mesh_.cellShapes(); const cellList& cells = mesh_.cells(); @@ -336,12 +322,12 @@ void Foam::fileFormats::STARCDMeshWriter::writeBoundary // Mapping between OpenFOAM and PROSTAR primitives // - needed for face mapping // - const Map<label> prostarShapeLookup = + const Map<label> shapeLookupIndex = { - { hexModel->index(), STARCDCore::starcdHex }, - { prismModel->index(), STARCDCore::starcdPrism }, - { tetModel->index(), STARCDCore::starcdTet }, - { pyrModel->index(), STARCDCore::starcdPyr } + { cellModel::ref(cellModel::HEX).index(), STARCDCore::starcdHex }, + { cellModel::ref(cellModel::PRISM).index(), STARCDCore::starcdPrism }, + { cellModel::ref(cellModel::TET).index(), STARCDCore::starcdTet }, + { cellModel::ref(cellModel::PYR).index(), STARCDCore::starcdPyr }, }; Info<< "Writing " << os.name() << " : " @@ -396,7 +382,7 @@ void Foam::fileFormats::STARCDMeshWriter::writeBoundary label mapIndex = shape.model().index(); // A registered primitive type - if (prostarShapeLookup.found(mapIndex)) + if (shapeLookupIndex.found(mapIndex)) { const faceList sFaces = shape.faces(); forAll(sFaces, sFacei) @@ -408,7 +394,7 @@ void Foam::fileFormats::STARCDMeshWriter::writeBoundary } } - mapIndex = prostarShapeLookup[mapIndex]; + mapIndex = shapeLookupIndex[mapIndex]; cellFaceId = STARCDCore::foamToStarFaceAddr[mapIndex][cellFaceId]; } diff --git a/src/conversion/starcd/STARCDMeshWriter.H b/src/conversion/starcd/STARCDMeshWriter.H index 2b33eaa20aca6ed4490a708f22de4e4c2aecabed..f7ad1d45019d3a7db25ebbcb5cbe5b72b63c66ab 100644 --- a/src/conversion/starcd/STARCDMeshWriter.H +++ b/src/conversion/starcd/STARCDMeshWriter.H @@ -25,7 +25,7 @@ Class Foam::fileFormats::STARCDMeshWriter Description - Writes polyMesh in pro-STAR (v4) bnd/cel/vrt format + Writes polyMesh in PROSTAR (v4) bnd/cel/vrt format The cellTableId and cellTable information are used (if available). Otherwise the cellZones are used (if available). diff --git a/src/conversion/vtk/part/foamVtuSizing.C b/src/conversion/vtk/part/foamVtuSizing.C index 15c4429380e88b494ef97dac0814d6c67b933384..7ef84a08d50008d19f2e033bab1dc153cacd2fb1 100644 --- a/src/conversion/vtk/part/foamVtuSizing.C +++ b/src/conversion/vtk/part/foamVtuSizing.C @@ -27,7 +27,6 @@ License #include "foamVtkCore.H" #include "polyMesh.H" #include "cellShape.H" -#include "cellModeller.H" // Only used in this file #include "foamVtuSizingTemplates.C" @@ -74,12 +73,12 @@ void Foam::vtk::vtuSizing::reset const bool decompose ) { - const cellModel& tet = *(cellModeller::lookup("tet")); - const cellModel& pyr = *(cellModeller::lookup("pyr")); - const cellModel& prism = *(cellModeller::lookup("prism")); - const cellModel& wedge = *(cellModeller::lookup("wedge")); - const cellModel& tetWedge = *(cellModeller::lookup("tetWedge")); - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& tet = cellModel::ref(cellModel::TET); + const cellModel& pyr = cellModel::ref(cellModel::PYR); + const cellModel& prism = cellModel::ref(cellModel::PRISM); + const cellModel& wedge = cellModel::ref(cellModel::WEDGE); + const cellModel& tetWedge = cellModel::ref(cellModel::TETWEDGE); + const cellModel& hex = cellModel::ref(cellModel::HEX); const cellShapeList& shapes = mesh.cellShapes(); diff --git a/src/conversion/vtk/part/foamVtuSizingTemplates.C b/src/conversion/vtk/part/foamVtuSizingTemplates.C index 0c4ffe44ac81b1cb19a244f13d6495d2bc395b06..7f89a44aeb219a094759cd34e497623302184782 100644 --- a/src/conversion/vtk/part/foamVtuSizingTemplates.C +++ b/src/conversion/vtk/part/foamVtuSizingTemplates.C @@ -27,7 +27,6 @@ License #include "foamVtkCore.H" #include "polyMesh.H" #include "cellShape.H" -#include "cellModeller.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -212,12 +211,12 @@ void Foam::vtk::vtuSizing::populateArrays faceOffset = -1; - const cellModel& tet = *(cellModeller::lookup("tet")); - const cellModel& pyr = *(cellModeller::lookup("pyr")); - const cellModel& prism = *(cellModeller::lookup("prism")); - const cellModel& wedge = *(cellModeller::lookup("wedge")); - const cellModel& tetWedge = *(cellModeller::lookup("tetWedge")); - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& tet = cellModel::ref(cellModel::TET); + const cellModel& pyr = cellModel::ref(cellModel::PYR); + const cellModel& prism = cellModel::ref(cellModel::PRISM); + const cellModel& wedge = cellModel::ref(cellModel::WEDGE); + const cellModel& tetWedge = cellModel::ref(cellModel::TETWEDGE); + const cellModel& hex = cellModel::ref(cellModel::HEX); const cellShapeList& shapes = mesh.cellShapes(); diff --git a/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C index c3a7fcc67ffdf32f19a8643894c87002797b8af6..2e39889ab27cf8364d12d07f3dc24aab7883119b 100644 --- a/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/hexCellLooper.C @@ -26,7 +26,7 @@ License #include "hexCellLooper.H" #include "cellFeatures.H" #include "polyMesh.H" -#include "cellModeller.H" +#include "cellModel.H" #include "plane.H" #include "ListOps.H" #include "meshTools.H" @@ -153,7 +153,7 @@ void Foam::hexCellLooper::makeFace Foam::hexCellLooper::hexCellLooper(const polyMesh& mesh) : geomCellLooper(mesh), - hex_(*(cellModeller::lookup("hex"))) + hex_(cellModel::ref(cellModel::HEX)) {} diff --git a/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C b/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C index 94e9b2f24c2fbc0e708fd0cbe92065a3fa46e256..83fdea84102302d9418f47d0badd4257266e2960 100644 --- a/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C +++ b/src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C @@ -33,7 +33,7 @@ License #include "hexRef8.H" #include "mapPolyMesh.H" #include "polyTopoChange.H" -#include "cellModeller.H" +#include "cellModel.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -186,7 +186,7 @@ void Foam::multiDirRefinement::addCells Foam::labelList Foam::multiDirRefinement::splitOffHex(const primitiveMesh& mesh) { - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& hex = cellModel::ref(cellModel::HEX); const cellShapeList& cellShapes = mesh.cellShapes(); diff --git a/src/fileFormats/ensight/part/ensightCells.C b/src/fileFormats/ensight/part/ensightCells.C index 3b1161ad984f075691af3a13957ead158889169e..13781f0e863df943ffd73c7c60fc95b0d3e6c144 100644 --- a/src/fileFormats/ensight/part/ensightCells.C +++ b/src/fileFormats/ensight/part/ensightCells.C @@ -26,7 +26,7 @@ License #include "ensightCells.H" #include "error.H" #include "polyMesh.H" -#include "cellModeller.H" +#include "cellModel.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -162,10 +162,10 @@ void Foam::ensightCells::classify ) { // References to cell shape models - const cellModel& tet = *(cellModeller::lookup("tet")); - const cellModel& pyr = *(cellModeller::lookup("pyr")); - const cellModel& prism = *(cellModeller::lookup("prism")); - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& tet = cellModel::ref(cellModel::TET); + const cellModel& pyr = cellModel::ref(cellModel::PYR); + const cellModel& prism = cellModel::ref(cellModel::PRISM); + const cellModel& hex = cellModel::ref(cellModel::HEX); const cellShapeList& shapes = mesh.cellShapes(); diff --git a/src/fileFormats/starcd/STARCDCore.H b/src/fileFormats/starcd/STARCDCore.H index e4f7a03cab7a77fbcd7138c5efd9e437026e0b65..1825a28dfe0d37f0c9bbc8da0bc231efdabfdeb8 100644 --- a/src/fileFormats/starcd/STARCDCore.H +++ b/src/fileFormats/starcd/STARCDCore.H @@ -25,7 +25,7 @@ Class Foam::fileFormats::STARCDCore Description - Core routines used when reading/writing pro-STAR vrt/cel/bnd files. + Core routines used when reading/writing PROSTAR vrt/cel/bnd files. SourceFiles STARCDCore.C @@ -121,11 +121,11 @@ protected: // Protected Member Functions - //- Face addressing from pro-STAR faces to OpenFOAM faces. + //- Face addressing from PROSTAR faces to OpenFOAM faces. // For hex, prism, tet, pyr primitive shapes. static const Map<FixedList<int, 6>> starToFoamFaceAddr; - //- Face addressing from OpenFOAM faces to pro-STAR faces. + //- Face addressing from OpenFOAM faces to PROSTAR faces. // For hex, prism, tet, pyr primitive shapes. static const Map<FixedList<int, 6>> foamToStarFaceAddr; diff --git a/src/fileFormats/stl/STLCore.C b/src/fileFormats/stl/STLCore.C index b3b748bd1a60d3e4b393929909ddfaa8750df703..9761fa69a9b24847923660d74b1890639a3f9576 100644 --- a/src/fileFormats/stl/STLCore.C +++ b/src/fileFormats/stl/STLCore.C @@ -81,7 +81,7 @@ bool Foam::fileFormats::STLCore::isBinaryName // this seems to work better than the old token-based method // - using wordToken can cause an abort if non-word (binary) content // is detected ... this is not exactly what we want. -// - some programs (eg, pro-STAR) have 'solid' as the first word in +// - some programs (eg, PROSTAR) have 'solid' as the first word in // the binary header. This is just wrong and not our fault. int Foam::fileFormats::STLCore::detectBinaryHeader ( diff --git a/src/fileFormats/vtk/read/vtkUnstructuredReader.C b/src/fileFormats/vtk/read/vtkUnstructuredReader.C index 2510aca05750ce97b88d91756e4f2dd6248d3273..e0c34830f814d40deca3e015b5c29af0599d7c78 100644 --- a/src/fileFormats/vtk/read/vtkUnstructuredReader.C +++ b/src/fileFormats/vtk/read/vtkUnstructuredReader.C @@ -27,7 +27,7 @@ License #include "labelIOField.H" #include "scalarIOField.H" #include "stringIOList.H" -#include "cellModeller.H" +#include "cellModel.H" #include "vectorIOField.H" /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ @@ -104,10 +104,10 @@ void Foam::vtkUnstructuredReader::extractCells const labelList& cellVertData ) { - 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 tetPoints(4); labelList pyrPoints(5); diff --git a/src/fileFormats/vtk/read/vtkUnstructuredReaderTemplates.C b/src/fileFormats/vtk/read/vtkUnstructuredReaderTemplates.C index 86f6f6d89544c0a8f28e3f14aee6fe20ee127287..17e6ec326be05aef90d57e7ef91eca4d044cab5c 100644 --- a/src/fileFormats/vtk/read/vtkUnstructuredReaderTemplates.C +++ b/src/fileFormats/vtk/read/vtkUnstructuredReaderTemplates.C @@ -27,7 +27,7 @@ License #include "labelIOField.H" #include "scalarIOField.H" #include "stringIOList.H" -#include "cellModeller.H" +#include "cellModel.H" #include "vectorIOField.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C index 4ace695ad13528e6bc97ba8158a042fdf0b22fe2..51d0b7b670bcacc4b02cc68ee660478d6d6cd7e0 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshCreate.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshCreate.C @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "blockMesh.H" -#include "cellModeller.H" +#include "cellModel.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -94,7 +94,7 @@ void Foam::blockMesh::createPoints() const void Foam::blockMesh::createCells() const { const blockList& blocks = *this; - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& hex = cellModel::ref(cellModel::HEX); if (verboseOutput) { diff --git a/src/meshTools/edgeMesh/edgeMeshFormats/starcd/STARCDedgeFormat.H b/src/meshTools/edgeMesh/edgeMeshFormats/starcd/STARCDedgeFormat.H index 277ef7f65b189b71250f5d79c1bcf5a8c16174f6..7bed5b3d43bf742503d96b1d849cc6653a865c49 100644 --- a/src/meshTools/edgeMesh/edgeMeshFormats/starcd/STARCDedgeFormat.H +++ b/src/meshTools/edgeMesh/edgeMeshFormats/starcd/STARCDedgeFormat.H @@ -25,7 +25,7 @@ Class Foam::fileFormats::STARCDedgeFormat Description - Read/write the lines from pro-STAR vrt/cel files. + Read/write the lines from PROSTAR vrt/cel files. Note Uses the extension \a .inp (input) to denote the format. diff --git a/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C b/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C index 0e5c35bf5b60ff834fd321b88b6ba6e232a15576..2e0d9bd223a755ac4fcd48049269dbce29bad138 100644 --- a/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C +++ b/src/meshTools/sets/cellSources/rotatedBoxToCell/rotatedBoxToCell.C @@ -25,7 +25,7 @@ License #include "rotatedBoxToCell.H" #include "polyMesh.H" -#include "cellModeller.H" +#include "cellModel.H" #include "addToRunTimeSelectionTable.H" @@ -73,7 +73,7 @@ void Foam::rotatedBoxToCell::combine(topoSet& set, const bool add) const boxVerts[i] = i; } - const cellModel& hex = *(cellModeller::lookup("hex")); + const cellModel& hex = cellModel::ref(cellModel::HEX); // Get outwards pointing faces. faceList boxFaces(cellShape(hex, boxVerts).faces()); diff --git a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C index a6c033a84d391a74ca1f4d14b57552fc19521532..f98f9be0819ee780b9e1dbaef2abc042c2329a9c 100644 --- a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C +++ b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.C @@ -76,7 +76,7 @@ void Foam::shapeToCell::combine(topoSet& set, const bool add) const } else { - const cellModel& wantedModel = *(cellModeller::lookup(type_)); + const cellModel& wantedModel = cellModel::ref(type_); const cellShapeList& cellShapes = mesh_.cellShapes(); @@ -93,7 +93,6 @@ void Foam::shapeToCell::combine(topoSet& set, const bool add) const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::shapeToCell::shapeToCell ( const polyMesh& mesh, @@ -103,7 +102,7 @@ Foam::shapeToCell::shapeToCell topoSetSource(mesh), type_(type) { - if (!cellModeller::lookup(type_) && (type_ != "splitHex")) + if (!cellModel::ptr(type_) && type_ != "splitHex") { FatalErrorInFunction << "Illegal cell type " << type_ << exit(FatalError); @@ -111,7 +110,6 @@ Foam::shapeToCell::shapeToCell } -// Construct from dictionary Foam::shapeToCell::shapeToCell ( const polyMesh& mesh, @@ -121,7 +119,7 @@ Foam::shapeToCell::shapeToCell topoSetSource(mesh), type_(dict.lookup("type")) { - if (!cellModeller::lookup(type_) && (type_ != "splitHex")) + if (!cellModel::ptr(type_) && type_ != "splitHex") { FatalErrorInFunction << "Illegal cell type " << type_ << exit(FatalError); @@ -129,7 +127,6 @@ Foam::shapeToCell::shapeToCell } -// Construct from Istream Foam::shapeToCell::shapeToCell ( const polyMesh& mesh, @@ -139,13 +136,14 @@ Foam::shapeToCell::shapeToCell topoSetSource(mesh), type_(checkIs(is)) { - if (!cellModeller::lookup(type_) && (type_ != "splitHex")) + if (!cellModel::ptr(type_) && type_ != "splitHex") { FatalErrorInFunction << "Illegal cell type " << type_ << exit(FatalError); } } + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::shapeToCell::~shapeToCell() diff --git a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H index aa843c1b6fc9b771e0344c6ba3f9005536c339c6..82f2b97987ff63f4bc09e8b10aa15a6a686f092c 100644 --- a/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H +++ b/src/meshTools/sets/cellSources/shapeToCell/shapeToCell.H @@ -27,8 +27,8 @@ Class Description A topoSetSource to select cells based on cell shape. - Handles all ones from cellModeller and splitHex with 10 degrees - feature angle. + Handles all known ones from static collection in cellModel + and splitHex with 10 degrees feature angle. SourceFiles shapeToCell.C diff --git a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.H b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.H index a0e3b39da3ac380ae069766132924b1cc2faeaae..d10bb1db6ebc0b302f1d939926e4191bd135076f 100644 --- a/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.H +++ b/src/surfMesh/surfaceFormats/starcd/STARCDsurfaceFormat.H @@ -25,7 +25,7 @@ Class Foam::fileFormats::STARCDsurfaceFormat Description - Read/write the surface shells from pro-STAR vrt/cel files. + Read/write the surface shells from PROSTAR vrt/cel files. Note Uses the extension \a .inp (input) to denote the format.