ENH: enumerations for known cell models in cellModel, ptr/ref lookups

- this provides a better typesafe means of locating predefined cell
  models than relying on strings. The lookup is now ptr() or ref()
  directly. The lookup functions behave like on-demand singletons when
  loading "etc/cellModels".

  Functionality is now located entirely in cellModel but a forwarding
  version of cellModeller is provided for API (but not ABI) compatibility
  with older existing user code.

STYLE: use constexpr for cellMatcher constants
This commit is contained in:
Mark Olesen
2017-11-18 11:05:05 +01:00
parent 810d090e34
commit 8730a7622a
106 changed files with 984 additions and 1035 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -32,7 +32,6 @@ Description
#define cellShapeRecognition_H
#include "cellShape.H"
#include "cellModeller.H"
#include "faceList.H"
#include "PtrList.H"

View File

@ -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] =
{

View File

@ -51,7 +51,7 @@ cellShape extrudedQuadCellShape
if (!hexModelPtr_)
{
hexModelPtr_ = cellModeller::lookup("hex");
hexModelPtr_ = cellModel::ptr(cellModel::HEX);
}
const cellModel& hex = *hexModelPtr_;

View File

@ -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_;

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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"

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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",

View File

@ -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);

View File

@ -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);

View File

@ -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"

View File

@ -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)

View File

@ -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++)

View File

@ -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;

View File

@ -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++)

View File

@ -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"