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

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

View File

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

View File

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

View File

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