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

@ -42,7 +42,7 @@ Description
#include "OFstream.H" #include "OFstream.H"
#include "thermoPhysicsTypes.H" #include "thermoPhysicsTypes.H"
#include "basicMultiComponentMixture.H" #include "basicMultiComponentMixture.H"
#include "cellModeller.H" #include "cellModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -13,8 +13,7 @@ points[5] = vector(1, 0, 1);
points[6] = vector(1, 1, 1); points[6] = vector(1, 1, 1);
points[7] = vector(0, 1, 1); points[7] = vector(0, 1, 1);
const cellModel& hexa = *(cellModeller::lookup("hex")); faceList faces = cellModel::ref(cellModel::HEX).modelFaces();
faceList faces = hexa.modelFaces();
fvMesh mesh fvMesh mesh
( (
@ -25,7 +24,7 @@ fvMesh mesh
runTime, runTime,
IOobject::READ_IF_PRESENT IOobject::READ_IF_PRESENT
), ),
xferMove<Field<vector>>(points), xferMove<pointField>(points),
faces.xfer(), faces.xfer(),
owner.xfer(), owner.xfer(),
neighbour.xfer() neighbour.xfer()

View File

@ -31,7 +31,7 @@ Description
#include "polyMesh.H" #include "polyMesh.H"
#include "boundBox.H" #include "boundBox.H"
#include "treeBoundBox.H" #include "treeBoundBox.H"
#include "cellModeller.H" #include "cellModel.H"
using namespace Foam; using namespace Foam;
@ -52,15 +52,11 @@ boundBox cube(scalar start, scalar width)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#include "setRootCase.H" #include "setRootCase.H"
// #include "createTime.H"
// #include "createMesh.H"
const cellModel& hex = *(cellModeller::lookup("hex")); Info<<"boundBox faces: " << boundBox::faces << nl
<<"hex faces: " << cellModel::ref(cellModel::HEX).modelFaces() << nl
Info<<"boundBox faces: " << boundBox::faces << endl; <<"tree-bb faces: " << treeBoundBox::faces << nl
Info<<"hex faces: " << hex.modelFaces() << endl; <<"tree-bb edges: " << treeBoundBox::edges << endl;
Info<<"tree-bb faces: " << treeBoundBox::faces << endl;
Info<<"tree-bb edges: " << treeBoundBox::edges << endl;
boundBox bb = boundBox::greatBox; boundBox bb = boundBox::greatBox;
Info<<"great box: " << bb << endl; Info<<"great box: " << bb << endl;

View File

@ -0,0 +1,3 @@
Test-cellModels.C
EXE = $(FOAM_USER_APPBIN)/Test-cellModels

View File

@ -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;
}
// ************************************************************************* //

View File

@ -52,7 +52,7 @@ Description
#include "polyMesh.H" #include "polyMesh.H"
#include "cellCuts.H" #include "cellCuts.H"
#include "cellSet.H" #include "cellSet.H"
#include "cellModeller.H" #include "cellModel.H"
#include "meshCutter.H" #include "meshCutter.H"
#include "unitConversion.H" #include "unitConversion.H"
#include "geomCellLooper.H" #include "geomCellLooper.H"
@ -387,7 +387,7 @@ void collectCuts
const vectorField& faceAreas = mesh.faceAreas(); const vectorField& faceAreas = mesh.faceAreas();
// Hex shape // Hex shape
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
// cut handling functions // cut handling functions
edgeVertex ev(mesh); edgeVertex ev(mesh);

View File

@ -56,7 +56,6 @@ using namespace Foam;
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "preservePatchTypes.H" #include "preservePatchTypes.H"
#include "cellShape.H" #include "cellShape.H"
#include "cellModeller.H"
#include "SLList.H" #include "SLList.H"
#include "SLPtrList.H" #include "SLPtrList.H"
@ -363,10 +362,10 @@ int main(int argc, char *argv[])
} }
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
labelList labelsHex(8); labelList labelsHex(8);
labelList labelsPrism(6); labelList labelsPrism(6);

View File

@ -41,7 +41,6 @@ Description
#include "symmetryPolyPatch.H" #include "symmetryPolyPatch.H"
#include "preservePatchTypes.H" #include "preservePatchTypes.H"
#include "cellShape.H" #include "cellShape.H"
#include "cellModeller.H"
using namespace Foam; using namespace Foam;
@ -545,7 +544,7 @@ int main(int argc, char *argv[])
cellShapeList cellShapes(nMeshCells); cellShapeList cellShapes(nMeshCells);
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
label nCreatedCells = 0; label nCreatedCells = 0;

View File

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

View File

@ -50,13 +50,13 @@ cellShape create3DCellShape
static List<const cellModel*> fluentCellModelLookup static List<const cellModel*> fluentCellModelLookup
( (
7, 7,
reinterpret_cast<const cellModel*>(0) nullptr
); );
fluentCellModelLookup[2] = cellModeller::lookup("tet"); fluentCellModelLookup[2] = cellModel::ptr(cellModel::TET);
fluentCellModelLookup[4] = cellModeller::lookup("hex"); fluentCellModelLookup[4] = cellModel::ptr(cellModel::HEX);
fluentCellModelLookup[5] = cellModeller::lookup("pyr"); fluentCellModelLookup[5] = cellModel::ptr(cellModel::PYR);
fluentCellModelLookup[6] = cellModeller::lookup("prism"); fluentCellModelLookup[6] = cellModel::ptr(cellModel::PRISM);
static label faceMatchingOrder[7][6] = static label faceMatchingOrder[7][6] =
{ {

View File

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

View File

@ -28,7 +28,7 @@ Description
#include "cellShapeRecognition.H" #include "cellShapeRecognition.H"
#include "labelList.H" #include "labelList.H"
#include "cellModeller.H" #include "cellModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,7 +52,7 @@ cellShape extrudedTriangleCellShape
if (!prismModelPtr_) if (!prismModelPtr_)
{ {
prismModelPtr_ = cellModeller::lookup("prism"); prismModelPtr_ = cellModel::ptr(cellModel::PRISM);
} }
const cellModel& prism = *prismModelPtr_; const cellModel& prism = *prismModelPtr_;

View File

@ -34,7 +34,7 @@ using std::ios;
#include "wallFvPatch.H" #include "wallFvPatch.H"
#include "symmetryPlaneFvPatch.H" #include "symmetryPlaneFvPatch.H"
#include "symmetryFvPatch.H" #include "symmetryFvPatch.H"
#include "cellModeller.H" #include "cellModel.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -218,10 +218,10 @@ void Foam::fluentFvMesh::writeFluentMesh() const
<< "(12 (1 1 " << "(12 (1 1 "
<< nCells() << " 1 0)(" << std::endl; << nCells() << " 1 0)(" << std::endl;
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
const cellShapeList& cells = cellShapes(); const cellShapeList& cells = cellShapes();

View File

@ -28,7 +28,7 @@ Group
grpMeshConversionUtilities grpMeshConversionUtilities
Description 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 Usage
\b foamToStarMesh [OPTION] \b foamToStarMesh [OPTION]
@ -67,7 +67,7 @@ int main(int argc, char *argv[])
{ {
argList::addNote 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(); argList::noParallel();
timeSelector::addOptions(); timeSelector::addOptions();

View File

@ -53,7 +53,6 @@ using namespace Foam;
#include "polyMesh.H" #include "polyMesh.H"
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "preservePatchTypes.H" #include "preservePatchTypes.H"
#include "cellModeller.H"
#include "cellShape.H" #include "cellShape.H"
#include "SLList.H" #include "SLList.H"
#include "SLPtrList.H" #include "SLPtrList.H"
@ -699,10 +698,10 @@ int main(int argc, char *argv[])
cellLookup[cellMap[celli] ] = celli; cellLookup[cellMap[celli] ] = celli;
} }
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
labelList labelsHex(8); labelList labelsHex(8);
labelList labelsPrism(6); labelList labelsPrism(6);

View File

@ -52,7 +52,7 @@ Description
#include "Time.H" #include "Time.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "IFstream.H" #include "IFstream.H"
#include "cellModeller.H" #include "cellModel.H"
#include "repatchPolyTopoChanger.H" #include "repatchPolyTopoChanger.H"
#include "cellSet.H" #include "cellSet.H"
#include "faceSet.H" #include "faceSet.H"
@ -435,10 +435,10 @@ void readCells
Info<< "Starting to read cells at line " << inFile.lineNumber() << endl; Info<< "Starting to read cells at line " << inFile.lineNumber() << endl;
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
face triPoints(3); face triPoints(3);
face quadPoints(4); face quadPoints(4);

View File

@ -42,7 +42,7 @@ Description
#include "polyMesh.H" #include "polyMesh.H"
#include "Time.H" #include "Time.H"
#include "IFstream.H" #include "IFstream.H"
#include "cellModeller.H" #include "cellModel.H"
#include "cellSet.H" #include "cellSet.H"
#include "faceSet.H" #include "faceSet.H"
#include "DynamicList.H" #include "DynamicList.H"
@ -291,9 +291,9 @@ void readCells
labelList unvToFoam(invert(maxUnvPoint+1, unvPointID)); labelList unvToFoam(invert(maxUnvPoint+1, unvPointID));
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
labelHashSet skippedElements; labelHashSet skippedElements;

View File

@ -37,7 +37,6 @@ Description
#include "polyMesh.H" #include "polyMesh.H"
#include "Fstream.H" #include "Fstream.H"
#include "cellShape.H" #include "cellShape.H"
#include "cellModeller.H"
#include "preservePatchTypes.H" #include "preservePatchTypes.H"
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "wallPolyPatch.H" #include "wallPolyPatch.H"

View File

@ -102,7 +102,7 @@ cellShapeList cellShapes(nPoints);
labelList cellZoning(nPoints, -1); labelList cellZoning(nPoints, -1);
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
labelList hexLabels(8); labelList hexLabels(8);
label activeCells = 0; label activeCells = 0;

View File

@ -48,7 +48,7 @@ Description
#include "IFstream.H" #include "IFstream.H"
#include "polyPatch.H" #include "polyPatch.H"
#include "ListOps.H" #include "ListOps.H"
#include "cellModeller.H" #include "cellModel.H"
#include <fstream> #include <fstream>
@ -87,8 +87,8 @@ int main(int argc, char *argv[])
cellShapeList cells(nCells); cellShapeList cells(nCells);
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
labelList tetPoints(4); labelList tetPoints(4);
labelList hexPoints(8); labelList hexPoints(8);

View File

@ -82,7 +82,7 @@ NOTE:
#include "polyMesh.H" #include "polyMesh.H"
#include "IFstream.H" #include "IFstream.H"
#include "polyPatch.H" #include "polyPatch.H"
#include "cellModeller.H" #include "cellModel.H"
#include "triFace.H" #include "triFace.H"
using namespace Foam; using namespace Foam;
@ -124,7 +124,7 @@ int main(int argc, char *argv[])
Info<< "nTets:" << nTets << endl; Info<< "nTets:" << nTets << endl;
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
cellShapeList cells(nTets); cellShapeList cells(nTets);

View File

@ -50,7 +50,6 @@ Description
#include "wallPolyPatch.H" #include "wallPolyPatch.H"
#include "symmetryPolyPatch.H" #include "symmetryPolyPatch.H"
#include "cellShape.H" #include "cellShape.H"
#include "cellModeller.H"
#include "mergePoints.H" #include "mergePoints.H"
using namespace Foam; using namespace Foam;
@ -202,7 +201,7 @@ int main(int argc, char *argv[])
cellShapeList cellShapes(nMeshCells); cellShapeList cellShapes(nMeshCells);
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
label nCreatedCells = 0; label nCreatedCells = 0;

View File

@ -28,7 +28,7 @@ Group
grpMeshConversionUtilities grpMeshConversionUtilities
Description Description
Converts a Star-CD (v4) pro-STAR mesh into OpenFOAM format. Converts a STARCD/PROSTAR (v4) mesh into OpenFOAM format.
Usage Usage
\b star4ToFoam [OPTION] prostarMesh \b star4ToFoam [OPTION] prostarMesh
@ -66,11 +66,11 @@ int main(int argc, char *argv[])
{ {
argList::addNote argList::addNote
( (
"convert pro-STAR (v4) mesh to OpenFOAM" "convert STARCD/PROSTAR (v4) mesh to OpenFOAM"
); );
argList::noParallel(); argList::noParallel();
argList::validArgs.append("pro-STAR prefix"); argList::validArgs.append("PROSTAR prefix");
argList::addBoolOption argList::addBoolOption
( (
"ascii", "ascii",

View File

@ -70,7 +70,7 @@ Note
#include "Time.H" #include "Time.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "IFstream.H" #include "IFstream.H"
#include "cellModeller.H" #include "cellModel.H"
using namespace Foam; using namespace Foam;
@ -276,8 +276,7 @@ int main(int argc, char *argv[])
} }
const cellModel& tet = cellModel::ref(cellModel::TET);
const cellModel& tet = *(cellModeller::lookup("tet"));
labelList tetPoints(4); labelList tetPoints(4);

View File

@ -39,7 +39,6 @@ Description
#include "cellShapeControl.H" #include "cellShapeControl.H"
#include "backgroundMeshDecomposition.H" #include "backgroundMeshDecomposition.H"
#include "cellShape.H" #include "cellShape.H"
#include "cellModeller.H"
#include "DynamicField.H" #include "DynamicField.H"
#include "isoSurfaceCell.H" #include "isoSurfaceCell.H"
#include "vtkSurfaceWriter.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]); cellShapeList cellShapes(nCells[0]*nCells[1]*nCells[2]);
labelList hexPoints(8); labelList hexPoints(8);

View File

@ -53,7 +53,6 @@ Description
#include "faceSet.H" #include "faceSet.H"
#include "motionSmoother.H" #include "motionSmoother.H"
#include "polyTopoChange.H" #include "polyTopoChange.H"
#include "cellModeller.H"
#include "uindirectPrimitivePatch.H" #include "uindirectPrimitivePatch.H"
#include "surfZoneIdentifierList.H" #include "surfZoneIdentifierList.H"
#include "UnsortedMeshedSurface.H" #include "UnsortedMeshedSurface.H"

View File

@ -57,7 +57,7 @@ int USERD_get_part_elements_by_type
//================================ //================================
if (element_type == Z_HEX08) if (element_type == Z_HEX08)
{ {
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
label nHex08 = 0; label nHex08 = 0;
forAll(cellShapes, celli) forAll(cellShapes, celli)
@ -80,7 +80,7 @@ int USERD_get_part_elements_by_type
//================================ //================================
else if (element_type == Z_PEN06) else if (element_type == Z_PEN06)
{ {
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
label nPen06 = 0; label nPen06 = 0;
forAll(cellShapes, celli) forAll(cellShapes, celli)
@ -103,7 +103,7 @@ int USERD_get_part_elements_by_type
//================================ //================================
else if (element_type == Z_PYR05) else if (element_type == Z_PYR05)
{ {
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
label nPyr05 = 0; label nPyr05 = 0;
forAll(cellShapes, celli) forAll(cellShapes, celli)
@ -126,7 +126,7 @@ int USERD_get_part_elements_by_type
//================================ //================================
else if (element_type == Z_TET04) else if (element_type == Z_TET04)
{ {
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
label nTet04 = 0; label nTet04 = 0;
forAll(cellShapes, celli) forAll(cellShapes, celli)

View File

@ -37,8 +37,8 @@ const cellShapeList& cellShapes = meshPtr->cellShapes();
// hexa's // hexa's
if (which_type == Z_HEX08) if (which_type == Z_HEX08)
{ {
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
//const cellModel& wedge = *(cellModeller::lookup("wedge")); //const cellModel& wedge = cellModel::ref(cellModel::WEDGE);
label counter = 1; label counter = 1;
for (label celli=0; celli<nCells; celli++) for (label celli=0; celli<nCells; celli++)
@ -56,7 +56,7 @@ if (which_type == Z_HEX08)
// penta's // penta's
if (which_type == Z_PEN06) if (which_type == Z_PEN06)
{ {
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
label counter = 1; label counter = 1;
for (label n=0; n<nCells; n++) for (label n=0; n<nCells; n++)
@ -74,7 +74,7 @@ if (which_type == Z_PEN06)
// pyramids's // pyramids's
if (which_type == Z_PYR05) if (which_type == Z_PYR05)
{ {
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
label counter = 1; label counter = 1;
for (label n=0; n<nCells; n++) for (label n=0; n<nCells; n++)
@ -92,7 +92,7 @@ if (which_type == Z_PYR05)
// tet's // tet's
if (which_type == Z_TET04) if (which_type == Z_TET04)
{ {
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
label counter = 1; label counter = 1;
for (label n=0; n<nCells; n++) for (label n=0; n<nCells; n++)

View File

@ -37,8 +37,8 @@ const cellShapeList& cellShapes = meshPtr->cellShapes();
// hexa's // hexa's
if (which_type == Z_HEX08) if (which_type == Z_HEX08)
{ {
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
//const cellModel& wedge = *(cellModeller::lookup("wedge")); //const cellModel& wedge = cellModel::ref(cellModel::WEDGE);
label counter = 1; label counter = 1;
for (label n=0; n<nCells; n++) for (label n=0; n<nCells; n++)
@ -56,7 +56,7 @@ if (which_type == Z_HEX08)
// penta's // penta's
if (which_type == Z_PEN06) if (which_type == Z_PEN06)
{ {
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
label counter = 1; label counter = 1;
for (label n=0; n<nCells; n++) for (label n=0; n<nCells; n++)
@ -74,7 +74,7 @@ if (which_type == Z_PEN06)
// pyramids's // pyramids's
if (which_type == Z_PYR05) if (which_type == Z_PYR05)
{ {
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
label counter = 1; label counter = 1;
for (label n=0; n<nCells; n++) for (label n=0; n<nCells; n++)
@ -93,7 +93,7 @@ if (which_type == Z_PYR05)
// penta's // penta's
if (which_type == Z_TET04) if (which_type == Z_TET04)
{ {
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
label counter = 1; label counter = 1;

View File

@ -37,8 +37,8 @@ const cellShapeList& cellShapes = meshPtr->cellShapes();
// hexa's // hexa's
if (which_type == Z_HEX08) if (which_type == Z_HEX08)
{ {
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
//const cellModel& wedge = *(cellModeller::lookup("wedge")); //const cellModel& wedge = cellModel::ref(cellModel::WEDGE);
label counter = 1; label counter = 1;
for (label n=0; n<nCells; n++) for (label n=0; n<nCells; n++)
@ -56,7 +56,7 @@ if (which_type == Z_HEX08)
// penta's // penta's
if (which_type == Z_PEN06) if (which_type == Z_PEN06)
{ {
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
label counter = 1; label counter = 1;
for (label n=0; n<nCells; n++) for (label n=0; n<nCells; n++)
@ -74,7 +74,7 @@ if (which_type == Z_PEN06)
// pyramids's // pyramids's
if (which_type == Z_PYR05) if (which_type == Z_PYR05)
{ {
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
label counter = 1; label counter = 1;
for (label n=0; n<nCells; n++) for (label n=0; n<nCells; n++)
@ -93,7 +93,7 @@ if (which_type == Z_PYR05)
// tet's // tet's
if (which_type == Z_TET04) if (which_type == Z_TET04)
{ {
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
label counter = 1; label counter = 1;
for (label n=0; n<nCells; n++) for (label n=0; n<nCells; n++)

View File

@ -43,7 +43,7 @@ Description
#include "Cloud.H" #include "Cloud.H"
#include "passiveParticle.H" #include "passiveParticle.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "cellModeller.H" #include "cellModel.H"
#include "globalFoam.H" #include "globalFoam.H"
#include "foamVersion.H" #include "foamVersion.H"

View File

@ -6,7 +6,8 @@
| \\/ M anipulation | | | \\/ 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; index 0;
numberOfPoints 0; numberOfPoints 0;
faces 0(); faces 0();
edges 0(); edges 0();
} }

View File

@ -5,9 +5,9 @@
# \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# This file is part of OpenFOAM, licensed under the GNU General Public License # License
# <http://www.gnu.org/licenses/>. # This file is part of OpenFOAM, licensed under GNU General Public License
# This file is part of OpenFOAM. # <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.csh/ADIOS # etc/config.csh/ADIOS

View File

@ -5,9 +5,9 @@
# \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. # \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# This file is part of OpenFOAM, licensed under the GNU General Public License # License
# <http://www.gnu.org/licenses/>. # This file is part of OpenFOAM, licensed under GNU General Public License
# This file is part of OpenFOAM. # <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.sh/ADIOS # etc/config.sh/ADIOS

View File

@ -442,11 +442,9 @@ $(cell)/cellIOList.C
tetCell = $(meshShapes)/tetCell tetCell = $(meshShapes)/tetCell
$(tetCell)/tetCell.C $(tetCell)/tetCell.C
cellModeller = $(meshShapes)/cellModeller
$(cellModeller)/cellModeller.C
cellModel = $(meshShapes)/cellModel cellModel = $(meshShapes)/cellModel
$(cellModel)/cellModel.C $(cellModel)/cellModel.C
$(cellModel)/cellModels.C
$(cellModel)/cellModelIO.C $(cellModel)/cellModelIO.C
cellShape = $(meshShapes)/cellShape cellShape = $(meshShapes)/cellShape

View File

@ -106,11 +106,6 @@ bool Foam::JobInfo::constructed(false);
#include "constants.C" #include "constants.C"
#include "dimensionedConstants.C" #include "dimensionedConstants.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Read and set cell models
#include "globalCellModeller.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Create the jobInfo file in the $FOAM_JOB_DIR/runningJobs directory // Create the jobInfo file in the $FOAM_JOB_DIR/runningJobs directory

View File

@ -276,7 +276,7 @@ Foam::scalar Foam::cell::mag
} }
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
bool Foam::operator==(const cell& a, const cell& b) 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); List<bool> fnd(a.size(), false);
forAll(b, bI) for (const label curLabel : b)
{ {
const label curLabel = b[bI];
bool found = false; bool found = false;
forAll(a, aI) forAll(a, ai)
{ {
if (a[aI] == curLabel) if (a[ai] == curLabel)
{ {
found = true; found = true;
fnd[aI] = true; fnd[ai] = true;
break; break;
} }
} }
@ -311,9 +309,9 @@ bool Foam::operator==(const cell& a, const cell& b)
} }
// Any faces missed? // Any faces missed?
forAll(fnd, aI) forAll(fnd, ai)
{ {
if (!fnd[aI]) if (!fnd[ai])
{ {
return false; return false;
} }

View File

@ -45,13 +45,6 @@ SourceFiles
namespace Foam 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 Class cell Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -73,7 +66,7 @@ public:
//- Construct null //- Construct null
inline cell(); inline cell();
//- Construct given size //- Construct given size, with invalid point labels (-1)
explicit inline cell(const label sz); explicit inline cell(const label sz);
//- Construct from list of labels //- Construct from list of labels
@ -132,15 +125,19 @@ public:
//- Returns cell volume //- Returns cell volume
scalar mag(const UList<point>& p, const faceUList& f) const; scalar mag(const UList<point>& p, const faceUList& f) const;
// Friend Operators
friend bool operator==(const cell& a, const cell& b);
friend bool operator!=(const cell& a, const cell& b);
}; };
// Global Operators
//- Test if both cells are the same size and contain the same points
// The internal point ordering is ignored
bool operator==(const cell& a, const cell& b);
//- Test if the cells differ (different size or different points)
inline bool operator!=(const cell& a, const cell& b);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -61,6 +61,8 @@ inline Foam::label Foam::cell::nFaces() const
} }
// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * //
inline bool Foam::operator!=(const cell& a, const cell& b) inline bool Foam::operator!=(const cell& a, const cell& b)
{ {
return !(a == b); return !(a == b);

View File

@ -31,9 +31,6 @@ Description
#include "oppositeFace.H" #include "oppositeFace.H"
#include "boolList.H" #include "boolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::cell::opposingFaceLabel Foam::label Foam::cell::opposingFaceLabel
@ -125,64 +122,61 @@ Foam::oppositeFace Foam::cell::opposingFace
{ {
return oppositeFace(face(0), masterFaceLabel, oppFaceLabel); 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 // Go through the list of edges and find the edge from this vertex
// face and find an edge going from the master face vertex to a slave // to the slave face
// face vertex. If all is OK, there should be only one such forAll(e, edgeI)
// 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 if (!usedEdges[edgeI])
// to the slave face
forAll(e, edgeI)
{ {
if (!usedEdges[edgeI]) // Get the other vertex
label otherVertex = e[edgeI].otherVertex(masterFace[pointi]);
if (otherVertex != -1)
{ {
// Get the other vertex // Found an edge coming from this vertex.
label otherVertex = // Check all vertices of the slave to find out
e[edgeI].otherVertex(masterFace[pointi]); // if it exists.
forAll(slaveFace, slavePointi)
if (otherVertex != -1)
{ {
// Found an edge coming from this vertex. if (slaveFace[slavePointi] == otherVertex)
// Check all vertices of the slave to find out
// if it exists.
forAll(slaveFace, slavePointi)
{ {
if (slaveFace[slavePointi] == otherVertex) usedEdges[edgeI] = true;
{ oppFace[pointi] = otherVertex;
usedEdges[edgeI] = true;
oppFace[pointi] = otherVertex;
break; break;
}
} }
} }
} }
} }
} }
return oppFace;
} }
return oppFace;
} }

View File

@ -31,7 +31,6 @@ License
#include "labelList.H" #include "labelList.H"
#include "ListOps.H" #include "ListOps.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cellMatcher::cellMatcher Foam::cellMatcher::cellMatcher
@ -61,9 +60,9 @@ Foam::cellMatcher::cellMatcher
f.setSize(maxVertPerFace); 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; label newVertI = 0;
forAll(myFaces, myFacei) forAll(myFaces, myFacei)
{ {
label facei = myFaces[myFacei]; const label facei = myFaces[myFacei];
const face& f = faces[facei]; const face& f = faces[facei];
face& localFace = localFaces_[myFacei]; face& localFace = localFaces_[myFacei];
@ -202,10 +201,10 @@ void Foam::cellMatcher::calcPointFaceIndex()
( (
label fp = 0; label fp = 0;
fp < faceSize_[localFacei]; fp < faceSize_[localFacei];
fp++ ++fp
) )
{ {
label vert = f[fp]; const label vert = f[fp];
pointFaceIndex_[vert][localFacei] = fp; pointFaceIndex_[vert][localFacei] = fp;
} }
} }
@ -220,7 +219,7 @@ Foam::label Foam::cellMatcher::otherFace
const label localFacei const label localFacei
) const ) const
{ {
label key = edgeKey(numVert, v0, v1); const label key = edgeKey(numVert, v0, v1);
if (edgeFaces_[key] == localFacei) if (edgeFaces_[key] == localFacei)
{ {
@ -230,17 +229,15 @@ Foam::label Foam::cellMatcher::otherFace
{ {
return edgeFaces_[key]; 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 << ' ' << localFaces_[facei][fp];
} }
os << endl; os << nl;
} }
os << "Face map : " << faceMap_ << endl; os << "Face map : " << faceMap_ << nl;
os << "Point map : " << pointMap_ << endl; os << "Point map : " << pointMap_ << endl;
} }

View File

@ -79,7 +79,6 @@ SourceFiles
#include "labelList.H" #include "labelList.H"
#include "faceList.H" #include "faceList.H"
#include "boolList.H"
#include "Map.H" #include "Map.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -90,8 +89,8 @@ namespace Foam
// Forward declaration of classes // Forward declaration of classes
class primitiveMesh; class primitiveMesh;
class cell; class cell;
class cellShape;
class cellModel; class cellModel;
class cellShape;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class cellMatcher Declaration Class cellMatcher Declaration
@ -178,15 +177,15 @@ private:
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct and assignment //- Disallow default bitwise copy construct and assignment
cellMatcher(const cellMatcher&); cellMatcher(const cellMatcher&) = delete;
void operator=(const cellMatcher&); cellMatcher& operator=(const cellMatcher&) = delete;
public: public:
// Constructors // Constructors
//- Construct given mesh and shape factors //- Construct for shape factors
cellMatcher cellMatcher
( (
const label vertPerCell, const label vertPerCell,

View File

@ -24,7 +24,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "cellModeller.H"
#include "cellModel.H" #include "cellModel.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -87,13 +86,12 @@ inline const Foam::cellModel& Foam::cellMatcher::model() const
{ {
if (cellModelPtr_ == nullptr) if (cellModelPtr_ == nullptr)
{ {
cellModelPtr_ = cellModeller::lookup(cellModelName_); cellModelPtr_ = cellModel::ptr(cellModelName_);
} }
return *cellModelPtr_; return *cellModelPtr_;
} }
// Key into edgeFaces_. key and key+1 are the entries for edge going from // Key into edgeFaces_. key and key+1 are the entries for edge going from
// v0 to v1 // v0 to v1
inline Foam::label Foam::cellMatcher::edgeKey inline Foam::label Foam::cellMatcher::edgeKey

View File

@ -36,6 +36,8 @@ Foam::pyrMatcher Foam::degenerateMatcher::pyr;
Foam::tetMatcher Foam::degenerateMatcher::tet; Foam::tetMatcher Foam::degenerateMatcher::tet;
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::cellShape Foam::degenerateMatcher::match Foam::cellShape Foam::degenerateMatcher::match
( (
const faceList& faces, const faceList& faces,
@ -50,30 +52,28 @@ Foam::cellShape Foam::degenerateMatcher::match
{ {
return cellShape(hex.model(), hex.vertLabels()); 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()); 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()); 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()); 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()); 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()); return cellShape(tetWedge.model(), tetWedge.vertLabels());
} }
else
{ return cellShape(cellModel::ref(cellModel::UNKNOWN), labelList());
return cellShape(*(cellModeller::lookup(0)), labelList(0));
}
} }

View File

@ -26,6 +26,7 @@ Class
Description Description
Collection of all hex degenerate matchers (hex, wedge, prism etc.) Collection of all hex degenerate matchers (hex, wedge, prism etc.)
Has static member function to match a shape. Has static member function to match a shape.
See also See also
@ -52,7 +53,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class degenerateMatcher Declaration Class degenerateMatcher Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class degenerateMatcher class degenerateMatcher

View File

@ -27,13 +27,6 @@ License
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "ListOps.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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::hexMatcher::hexMatcher() Foam::hexMatcher::hexMatcher()
@ -43,7 +36,7 @@ Foam::hexMatcher::hexMatcher()
vertPerCell, vertPerCell,
facePerCell, facePerCell,
maxVertPerFace, maxVertPerFace,
"hex" "hex" // same as cellModel::modelNames[cellModel::HEX]
) )
{} {}
@ -261,9 +254,9 @@ bool Foam::hexMatcher::faceSizeMatch
return false; 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) if (size != 4)
{ {
@ -325,10 +318,8 @@ bool Foam::hexMatcher::matches
return true; return true;
} }
else
{ return false;
return false;
}
} }

View File

@ -25,10 +25,10 @@ Class
Foam::hexMatcher Foam::hexMatcher
Description Description
A cellMatcher for hex cells A cellMatcher for hex cells (cellModel::HEX).
See also See also
cellMatcher cellMatcher, cellModel
SourceFiles SourceFiles
hexMatcher.C hexMatcher.C
@ -46,28 +46,28 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class hexMatcher Declaration Class hexMatcher Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class hexMatcher class hexMatcher
: :
public cellMatcher public cellMatcher
{ {
// Static data members // Static Data Members
//- Constants for this shape // Constants for this shape
static const label vertPerCell; static constexpr label vertPerCell = 8;
static const label facePerCell; static constexpr label facePerCell = 6;
static const label maxVertPerFace; static constexpr label maxVertPerFace = 4;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
hexMatcher(const hexMatcher&); hexMatcher(const hexMatcher&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const hexMatcher&); hexMatcher& operator=(const hexMatcher&) = delete;
public: public:

View File

@ -27,13 +27,6 @@ License
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "ListOps.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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::prismMatcher::prismMatcher() Foam::prismMatcher::prismMatcher()
@ -43,7 +36,7 @@ Foam::prismMatcher::prismMatcher()
vertPerCell, vertPerCell,
facePerCell, facePerCell,
maxVertPerFace, maxVertPerFace,
"prism" "prism" // same as cellModel::modelNames[cellModel::PRISM]
) )
{} {}
@ -312,31 +305,25 @@ bool Foam::prismMatcher::faceSizeMatch
label nTris = 0; label nTris = 0;
label nQuads = 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) if (size == 3)
{ {
nTris++; ++nTris;
} }
else if (size == 4) else if (size == 4)
{ {
nQuads++; ++nQuads;
} }
else else
{ {
return false; return false;
} }
} }
if ((nTris == 2) && (nQuads == 3))
{ return (nTris == 2 && nQuads == 3);
return true;
}
else
{
return false;
}
} }
@ -390,10 +377,8 @@ bool Foam::prismMatcher::matches
return true; return true;
} }
else
{ return false;
return false;
}
} }

View File

@ -25,10 +25,10 @@ Class
Foam::prismMatcher Foam::prismMatcher
Description Description
A cellMatcher for prism cells A cellMatcher for prism cells (cellModel::PRISM)
See also See also
cellMatcher cellMatcher, cellModel
SourceFiles SourceFiles
prismMatcher.C prismMatcher.C
@ -53,21 +53,21 @@ class prismMatcher
: :
public cellMatcher public cellMatcher
{ {
// Static data members // Static Data Members
//- Constants for this shape // Constants for this shape
static const label vertPerCell; static constexpr label vertPerCell = 6;
static const label facePerCell; static constexpr label facePerCell = 5;
static const label maxVertPerFace; static constexpr label maxVertPerFace = 4;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
prismMatcher(const prismMatcher&); prismMatcher(const prismMatcher&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const prismMatcher&); prismMatcher& operator=(const prismMatcher&) = delete;
public: public:

View File

@ -26,16 +26,9 @@ License
#include "pyrMatcher.H" #include "pyrMatcher.H"
#include "cellMatcher.H" #include "cellMatcher.H"
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "cellModeller.H" #include "cellModel.H"
#include "ListOps.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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pyrMatcher::pyrMatcher() Foam::pyrMatcher::pyrMatcher()
@ -45,7 +38,7 @@ Foam::pyrMatcher::pyrMatcher()
vertPerCell, vertPerCell,
facePerCell, facePerCell,
maxVertPerFace, maxVertPerFace,
"pyr" "pyr" // same as cellModel::modelNames[cellModel::PYR]
) )
{} {}
@ -234,17 +227,17 @@ bool Foam::pyrMatcher::faceSizeMatch
label nTris = 0; label nTris = 0;
label nQuads = 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) if (size == 3)
{ {
nTris++; ++nTris;
} }
else if (size == 4) else if (size == 4)
{ {
nQuads++; ++nQuads;
} }
else else
{ {
@ -252,14 +245,7 @@ bool Foam::pyrMatcher::faceSizeMatch
} }
} }
if ((nTris == 4) && (nQuads == 1)) return (nTris == 4 && nQuads == 1);
{
return true;
}
else
{
return false;
}
} }
@ -313,10 +299,8 @@ bool Foam::pyrMatcher::matches
return true; return true;
} }
else
{ return false;
return false;
}
} }

View File

@ -25,10 +25,10 @@ Class
Foam::pyrMatcher Foam::pyrMatcher
Description Description
A cellMatcher for pyr cells A cellMatcher for pyr cells (cellModel::PYR)
See also See also
cellMatcher cellMatcher, cellModel
SourceFiles SourceFiles
pyrMatcher.C pyrMatcher.C
@ -46,28 +46,28 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class pyrMatcher Declaration Class pyrMatcher Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class pyrMatcher class pyrMatcher
: :
public cellMatcher public cellMatcher
{ {
// Static data members // Static Data Members
//- Constants for this shape // Constants for this shape
static const label vertPerCell; static constexpr label vertPerCell = 5;
static const label facePerCell; static constexpr label facePerCell = 5;
static const label maxVertPerFace; static constexpr label maxVertPerFace = 4;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
pyrMatcher(const pyrMatcher&); pyrMatcher(const pyrMatcher&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const pyrMatcher&); pyrMatcher& operator=(const pyrMatcher&) = delete;
public: public:

View File

@ -26,16 +26,9 @@ License
#include "tetMatcher.H" #include "tetMatcher.H"
#include "cellMatcher.H" #include "cellMatcher.H"
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "cellModeller.H" #include "cellModel.H"
#include "ListOps.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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::tetMatcher::tetMatcher() Foam::tetMatcher::tetMatcher()
@ -45,7 +38,7 @@ Foam::tetMatcher::tetMatcher()
vertPerCell, vertPerCell,
facePerCell, facePerCell,
maxVertPerFace, maxVertPerFace,
"tet" "tet" // same as cellModel::modelNames[cellModel::TET]
) )
{} {}
@ -201,15 +194,16 @@ bool Foam::tetMatcher::faceSizeMatch
return false; 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) if (size != 3)
{ {
return false; return false;
} }
} }
return true; return true;
} }
@ -264,10 +258,8 @@ bool Foam::tetMatcher::matches
return true; return true;
} }
else
{ return false;
return false;
}
} }

View File

@ -25,10 +25,10 @@ Class
Foam::tetMatcher Foam::tetMatcher
Description Description
A cellMatcher for tet cells A cellMatcher for tet cells (cellModel::TET)
See also See also
cellMatcher cellMatcher, cellModel
SourceFiles SourceFiles
tetMatcher.C tetMatcher.C
@ -53,21 +53,21 @@ class tetMatcher
: :
public cellMatcher public cellMatcher
{ {
// Static data members // Static Data Members
//- Constants for this shape // Constants for this shape
static const label vertPerCell; static constexpr label vertPerCell = 4;
static const label facePerCell; static constexpr label facePerCell = 4;
static const label maxVertPerFace; static constexpr label maxVertPerFace = 3;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
tetMatcher(const tetMatcher&); tetMatcher(const tetMatcher&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const tetMatcher&); tetMatcher& operator=(const tetMatcher&) = delete;
public: public:

View File

@ -26,16 +26,9 @@ License
#include "tetWedgeMatcher.H" #include "tetWedgeMatcher.H"
#include "cellMatcher.H" #include "cellMatcher.H"
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "cellModeller.H" #include "cellModel.H"
#include "ListOps.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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::tetWedgeMatcher::tetWedgeMatcher() Foam::tetWedgeMatcher::tetWedgeMatcher()
@ -45,7 +38,7 @@ Foam::tetWedgeMatcher::tetWedgeMatcher()
vertPerCell, vertPerCell,
facePerCell, facePerCell,
maxVertPerFace, maxVertPerFace,
"tetWedge" "tetWedge" // same as cellModel::modelNames[cellModel::TETWEDGE]
) )
{} {}
@ -239,31 +232,25 @@ bool Foam::tetWedgeMatcher::faceSizeMatch
label nTris = 0; label nTris = 0;
label nQuads = 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) if (size == 3)
{ {
nTris++; ++nTris;
} }
else if (size == 4) else if (size == 4)
{ {
nQuads++; ++nQuads;
} }
else else
{ {
return false; return false;
} }
} }
if ((nTris == 2) && (nQuads == 2))
{ return (nTris == 2 && nQuads == 2);
return true;
}
else
{
return false;
}
} }
@ -317,10 +304,8 @@ bool Foam::tetWedgeMatcher::matches
return true; return true;
} }
else
{ return false;
return false;
}
} }

View File

@ -25,10 +25,10 @@ Class
Foam::tetWedgeMatcher Foam::tetWedgeMatcher
Description Description
A cellMatcher for tetWedge cells A cellMatcher for tetWedge cells (cellModel::TETWEDGE).
See also See also
cellMatcher cellMatcher, cellModel
SourceFiles SourceFiles
tetWedgeMatcher.C tetWedgeMatcher.C
@ -46,28 +46,28 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class tetWedgeMatcher Declaration Class tetWedgeMatcher Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class tetWedgeMatcher class tetWedgeMatcher
: :
public cellMatcher public cellMatcher
{ {
// Static data members // Static Data Members
//- Constants for this shape // Constants for this shape
static const label vertPerCell; static constexpr label vertPerCell = 5;
static const label facePerCell; static constexpr label facePerCell = 4;
static const label maxVertPerFace; static constexpr label maxVertPerFace = 4;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
tetWedgeMatcher(const tetWedgeMatcher&); tetWedgeMatcher(const tetWedgeMatcher&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const tetWedgeMatcher&); tetWedgeMatcher& operator=(const tetWedgeMatcher&) = delete;
public: public:

View File

@ -27,13 +27,6 @@ License
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "ListOps.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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::wedgeMatcher::wedgeMatcher() Foam::wedgeMatcher::wedgeMatcher()
@ -43,7 +36,7 @@ Foam::wedgeMatcher::wedgeMatcher()
vertPerCell, vertPerCell,
facePerCell, facePerCell,
maxVertPerFace, maxVertPerFace,
"wedge" "wedge" // same as cellModel::modelNames[cellModel::WEDGE]
) )
{} {}
@ -339,31 +332,25 @@ bool Foam::wedgeMatcher::faceSizeMatch
label nTris = 0; label nTris = 0;
label nQuads = 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) if (size == 3)
{ {
nTris++; ++nTris;
} }
else if (size == 4) else if (size == 4)
{ {
nQuads++; ++nQuads;
} }
else else
{ {
return false; return false;
} }
} }
if ((nTris == 2) && (nQuads == 4))
{ return (nTris == 2 && nQuads == 4);
return true;
}
else
{
return false;
}
} }
@ -417,10 +404,8 @@ bool Foam::wedgeMatcher::matches
return true; return true;
} }
else
{ return false;
return false;
}
} }

View File

@ -25,10 +25,10 @@ Class
Foam::wedgeMatcher Foam::wedgeMatcher
Description Description
A cellMatcher for wedge cells A cellMatcher for wedge cells (cellModel::WEDGE).
See also See also
cellMatcher cellMatcher, cellModel
SourceFiles SourceFiles
wedgeMatcher.C wedgeMatcher.C
@ -46,28 +46,28 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class wedgeMatcher Declaration Class wedgeMatcher Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class wedgeMatcher class wedgeMatcher
: :
public cellMatcher public cellMatcher
{ {
// Static data members // Static Data Members
//- Constants for this shape // Constants for this shape
static const label vertPerCell; static constexpr label vertPerCell = 7;
static const label facePerCell; static constexpr label facePerCell = 6;
static const label maxVertPerFace; static constexpr label maxVertPerFace = 4;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
wedgeMatcher(const wedgeMatcher&); wedgeMatcher(const wedgeMatcher&) = delete;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const wedgeMatcher&); wedgeMatcher& operator=(const wedgeMatcher&) = delete;
public: public:

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -137,4 +137,5 @@ Foam::scalar Foam::cellModel::mag
return v; return v;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -25,14 +25,21 @@ Class
Foam::cellModel Foam::cellModel
Description Description
Maps a geometry to a set of cell primitives, which enables Maps a geometry to a set of cell primitives.
geometric cell data to be calculated without access to the primitive
geometric level. This means mapping a 3D geometry to a set of This enables geometric cell data to be calculated without access
pyramids which are each described by a cell face and the cell centre to the primitive geometric level. This means mapping a 3D
point. 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 SourceFiles
cellModelI.H cellModelI.H
cellModel.C
cellModels.C
cellModelIO.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -44,19 +51,17 @@ SourceFiles
#include "faceList.H" #include "faceList.H"
#include "InfoProxy.H" #include "InfoProxy.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "PtrList.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declarations
class cellModel; class cellModel;
inline bool operator==(const cellModel& m1, const cellModel& m2); Ostream& operator<<(Ostream& os, const cellModel& cm);
inline bool operator!=(const cellModel& m1, const cellModel& m2);
Ostream& operator<<(Ostream& os, const cellModel& c);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class cellModel Declaration Class cellModel Declaration
@ -64,12 +69,66 @@ Ostream& operator<<(Ostream& os, const cellModel& c);
class cellModel class cellModel
{ {
// Private data public:
//- Name //- Enumeration of commonly used cellModel types.
// The indices must match those in "etc/cellModels"
enum modelType
{
UNKNOWN = 0, //!< unknown
HEX = 3, //!< hex
WEDGE = 4, //!< wedge
PRISM = 5, //!< prism
PYR = 6, //!< pyr
TET = 7, //!< tet
SPLITHEX = 8, //!< splitHex
TETWEDGE = 9, //!< tetWedge
};
//- Names of commonly used cellModels corresponding to modelType.
// The names must match those in "etc/cellModels"
static const Enum<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:
// 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_; word name_;
//- Label in the model list //- Index in the model list
label index_; label index_;
//- Number of points in the model which determines the geometry //- Number of points in the model which determines the geometry
@ -82,6 +141,12 @@ class cellModel
edgeList edges_; edgeList edges_;
// Private Member Functions
//- Construct from central "etc/cellModels" file.
static void constructModels();
public: public:
// Constructors // Constructors
@ -104,31 +169,32 @@ public:
// Member functions // Member functions
// Access //- Return model name
inline const word& name() const;
//- Return model name //- Return index of model in the model list
inline const word& name() const; inline label index() const;
//- Return index of model in the model list //- Return number of points
inline label index() const; inline label nPoints() const;
//- Return number of points //- Return number of edges
inline label nPoints() const; inline label nEdges() const;
//- Return number of edges //- Return number of faces
inline label nEdges() const; inline label nFaces() const;
//- Return number of faces //- Return a raw list of model edges
inline label nFaces() const; inline const edgeList& modelEdges() const;
//- Return list of edges //- Return a raw list of model faces
inline edgeList edges(const UList<label>& pointLabels) const; inline const faceList& modelFaces() const;
//- Return a raw list of model faces //- Return list of edges
inline const faceList& modelFaces() const; inline edgeList edges(const labelUList& pointLabels) const;
//- Return list of faces //- Return list of faces
inline faceList faces(const UList<label>& pointLabels) const; inline faceList faces(const labelUList& pointLabels) const;
//- Vector centroid //- Vector centroid
@ -146,7 +212,7 @@ public:
) const; ) const;
//- Return info proxy. //- Return info proxy.
// Used to print token information to a stream // Used to print information to a stream
InfoProxy<cellModel> info() const InfoProxy<cellModel> info() const
{ {
return *this; 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 // Ostream operator
friend Ostream& operator<<(Ostream& os, const cellModel& c); friend Ostream& operator<<(Ostream& os, const cellModel& cm);
}; };
// Ostream operators
template<> template<>
Ostream& operator<<(Ostream& os, const InfoProxy<cellModel>& ip); 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 } // End namespace Foam

View File

@ -23,9 +23,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "error.H"
#include "cellModel.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::word& Foam::cellModel::name() const inline const Foam::word& Foam::cellModel::name() const
@ -58,27 +55,9 @@ inline Foam::label Foam::cellModel::nFaces() const
} }
// Return the faces of a cellModel by untangling the geometry inline const Foam::edgeList& Foam::cellModel::modelEdges() const
// supplied in terms of the face labels
inline Foam::edgeList Foam::cellModel::edges
(
const UList<label>& pointLabels
) const
{ {
edgeList e(edges_.size()); return edges_;
// Translate model lebels into global labels
forAll(edges_, edgeI)
{
e[edgeI] =
edge
(
pointLabels[edges_[edgeI].start()],
pointLabels[edges_[edgeI].end()]
);
}
return e;
} }
@ -88,16 +67,40 @@ inline const Foam::faceList& Foam::cellModel::modelFaces() const
} }
// Return the faces of a cellModel by untangling the geometry
// supplied in terms of the face labels
inline Foam::edgeList Foam::cellModel::edges
(
const labelUList& pointLabels
) const
{
edgeList e(edges_.size());
// Translate model labels into global labels
forAll(edges_, edgei)
{
e[edgei] =
edge
(
pointLabels[edges_[edgei].start()],
pointLabels[edges_[edgei].end()]
);
}
return e;
}
// Return the faces of a cellModel by untangling the geometry // Return the faces of a cellModel by untangling the geometry
// supplied in terms of the face labels // supplied in terms of the face labels
inline Foam::faceList Foam::cellModel::faces inline Foam::faceList Foam::cellModel::faces
( (
const UList<label>& pointLabels const labelUList& pointLabels
) const ) const
{ {
faceList f(faces_.size()); faceList f(faces_.size());
// Translate model lebels into global labels // Translate model labels into global labels
forAll(faces_, facei) forAll(faces_, facei)
{ {
const labelList& curModelLabels = faces_[facei]; const labelList& curModelLabels = faces_[facei];
@ -106,9 +109,9 @@ inline Foam::faceList Foam::cellModel::faces
curFace.setSize(curModelLabels.size()); 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& lhs, const cellModel& rhs)
inline bool Foam::operator==(const cellModel& m1, const cellModel& m2)
{ {
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);
} }

View File

@ -26,26 +26,29 @@ License
#include "cellModel.H" #include "cellModel.H"
#include "dictionaryEntry.H" #include "dictionaryEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cellModel::cellModel(Istream& is) Foam::cellModel::cellModel(Istream& is)
{ {
dictionaryEntry entry(dictionary::null, is); dictionaryEntry dict(dictionary::null, is);
name_ = entry.keyword();
entry.lookup("index") >> index_; name_ = dict.keyword();
entry.lookup("numberOfPoints") >> nPoints_; dict.lookup("index") >> index_;
entry.lookup("faces") >> faces_; dict.lookup("numberOfPoints") >> nPoints_;
entry.lookup("edges") >> edges_; 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 os << "name" << tab << cm.name() << tab
<< "index" << tab << c.index_ << tab << "index" << tab << cm.index() << tab
<< "numberOfPoints" << tab << c.nPoints_ << tab << "numberOfPoints" << tab << cm.nPoints() << tab
<< "faces" << tab << c.faces_ << tab << "faces" << tab << cm.modelFaces() << tab
<< "edges" << tab << c.edges_ << endl; << "edges" << tab << cm.modelEdges() << endl;
return os; return os;
} }
@ -60,8 +63,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<cellModel>& ip)
<< "index = " << cm.index() << ", " << "index = " << cm.index() << ", "
<< "number of points = " << cm.nPoints() << ", " << "number of points = " << cm.nPoints() << ", "
<< "number of faces = " << cm.nFaces() << ", " << "number of faces = " << cm.nFaces() << ", "
<< "number of edges = " << cm.nEdges() << "number of edges = " << cm.nEdges() << endl;
<< endl;
return os; return os;
} }

View File

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

View File

@ -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;
}
// ************************************************************************* //

View File

@ -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;
}
}
// ************************************************************************* //

View File

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

View File

@ -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_;
}
// ************************************************************************* //

View File

@ -87,16 +87,16 @@ public:
//- Construct from components //- Construct from components
inline cellShape inline cellShape
( (
const cellModel&, const cellModel& model,
const labelList&, const labelUList& labels,
const bool doCollapse = false const bool doCollapse = false
); );
//- Construct from components //- Construct from components
inline cellShape inline cellShape
( (
const word& model, const word& modelName,
const labelList&, const labelUList& labels,
const bool doCollapse = false const bool doCollapse = false
); );

View File

@ -25,7 +25,7 @@ License
#include "Istream.H" #include "Istream.H"
#include "cell.H" #include "cell.H"
#include "cellModeller.H" #include "cellModel.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -37,13 +37,13 @@ inline Foam::cellShape::cellShape()
inline Foam::cellShape::cellShape inline Foam::cellShape::cellShape
( (
const cellModel& M, const cellModel& model,
const labelList& l, const labelUList& labels,
const bool doCollapse const bool doCollapse
) )
: :
labelList(l), labelList(labels),
m(&M) m(&model)
{ {
if (doCollapse) if (doCollapse)
{ {
@ -54,13 +54,13 @@ inline Foam::cellShape::cellShape
inline Foam::cellShape::cellShape inline Foam::cellShape::cellShape
( (
const word& model, const word& modelName,
const labelList& l, const labelUList& labels,
const bool doCollapse const bool doCollapse
) )
: :
labelList(l), labelList(labels),
m(cellModeller::lookup(model)) m(cellModel::ptr(modelName))
{ {
if (doCollapse) if (doCollapse)
{ {

View File

@ -25,7 +25,6 @@ License
#include "cellShape.H" #include "cellShape.H"
#include "token.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()) if (t.isLabel())
{ {
s.m = cellModeller::lookup(int(t.labelToken())); s.m = cellModel::ptr(t.labelToken());
} }
else if (t.isWord()) else if (t.isWord())
{ {
s.m = cellModeller::lookup(t.wordToken()); s.m = cellModel::ptr(t.wordToken());
} }
else else
{ {
@ -98,13 +97,13 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const cellShape& s)
os << token::BEGIN_LIST; os << token::BEGIN_LIST;
// Write the list label for the symbol (ONE OR THE OTHER !!!) // 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 !!!) // 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 // Write the geometry
os << static_cast<const labelList&>(s); os << token::SPACE << static_cast<const labelList&>(s);
// End of record // End of record
os << token::END_LIST; os << token::END_LIST;

View File

@ -203,7 +203,7 @@ public:
// Returns true on success. Negative labels never insert. // Returns true on success. Negative labels never insert.
// Return the number of slots filled. // Return the number of slots filled.
// Similar to a HashTable::insert(). // 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. //- Fill open slots with the indices if they did not previously exist.
// Returns true on success. Negative labels never insert. // Returns true on success. Negative labels never insert.
@ -225,7 +225,7 @@ public:
//- Remove existing indices from the edge and set locations to '-1'. //- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes. // 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'. //- Remove existing indices from the edge and set locations to '-1'.
// Returns the number of changes. // Returns the number of changes.

View File

@ -199,6 +199,7 @@ inline Foam::label Foam::edge::which(const label pointLabel) const
return 1; return 1;
} }
} }
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()); 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()); return eraseMultiple(lst.begin(), lst.end());
} }

View File

@ -25,8 +25,6 @@ License
#include "tetCell.H" #include "tetCell.H"
#include "cellShape.H" #include "cellShape.H"
#include "cellModeller.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -36,12 +34,10 @@ Foam::cellShape Foam::tetCell::tetCellShape() const
if (!tetModelPtr_) if (!tetModelPtr_)
{ {
tetModelPtr_ = cellModeller::lookup("tet"); tetModelPtr_ = cellModel::ptr(cellModel::TET);
} }
const cellModel& tet = *tetModelPtr_; return cellShape(*tetModelPtr_, labelList(*this));
return cellShape(tet, labelList(*this));
} }

View File

@ -65,10 +65,10 @@ public:
// Constructors // Constructors
//- Construct null //- Construct null, with invalid point labels (-1)
inline tetCell(); inline tetCell();
//- Construct from four points //- Construct from four point labels
inline tetCell inline tetCell
( (
const label a, const label a,
@ -77,9 +77,12 @@ public:
const label d const label d
); );
//- Construct from FixedList //- Construct from FixedList of four point labels
inline tetCell(const FixedList<label, 4>& lst); 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 //- Construct from Istream
inline tetCell(Istream& is); inline tetCell(Istream& is);
@ -92,17 +95,17 @@ public:
inline triFace face(const label facei) const; inline triFace face(const label facei) const;
//- Return first face adjacent to the given edge //- 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 //- Return face adjacent to the given face sharing the same edge
inline label edgeAdjacentFace inline label edgeAdjacentFace
( (
const label edgeI, const label edgei,
const label facei const label facei
) const; ) const;
//- Return i-th edge //- Return i-th edge
inline edge tetEdge(const label edgeI) const; inline edge tetEdge(const label edgei) const;
// Operations // Operations

View File

@ -30,6 +30,8 @@ Description
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::tetCell::tetCell() 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) inline Foam::tetCell::tetCell(Istream& is)
: :
FixedList<label, 4>(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 // Warning. Ordering of faces needs to be the same for a tetrahedron
// class, a tetrahedron cell shape model and a tetCell // class, a tetrahedron cell shape model and a tetCell
static const label a[] = {1, 0, 0, 0}; static const label a[4] = {1, 0, 0, 0};
static const label b[] = {2, 3, 1, 2}; static const label b[4] = {2, 3, 1, 2};
static const label c[] = {3, 2, 3, 1}; static const label c[4] = {3, 2, 3, 1};
#ifdef FULLDEBUG #ifdef FULLDEBUG
if (facei < 0 || facei >= 4) 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 // Warning. Ordering of faces needs to be the same for a tetrahedron
// class, a tetrahedron cell shape model and a tetCell // 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}; static const label edgeFaces[6] = {2, 3, 1, 0, 0, 1};
#ifdef FULLDEBUG #ifdef FULLDEBUG
if (edgeI < 0 || edgeI >= 6) if (edgei < 0 || edgei >= 6)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "edge index out of range 0 -> 5. edgeI = " << edgeI << "edge index out of range 0 -> 5. edgei = " << edgei
<< abort(FatalError); << abort(FatalError);
} }
#endif #endif
return edgeFaces[edgeI]; return edgeFaces[edgei];
} }
inline Foam::label Foam::tetCell::edgeAdjacentFace inline Foam::label Foam::tetCell::edgeAdjacentFace
( (
const label edgeI, const label edgei,
const label facei const label facei
) const ) const
{ {
@ -134,36 +141,35 @@ inline Foam::label Foam::tetCell::edgeAdjacentFace
<< abort(FatalError); << abort(FatalError);
} }
if (edgeI < 0 || edgeI >= 6) if (edgei < 0 || edgei >= 6)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "edge index out of range 0 -> 5. edgeI = " << edgeI << "edge index out of range 0 -> 5. edgei = " << edgei
<< abort(FatalError); << abort(FatalError);
} }
#endif #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 // Warning. Ordering of edges needs to be the same for a tetrahedron
// class, a tetrahedron cell shape model and a tetCell // class, a tetrahedron cell shape model and a tetCell
// static const label pt0[] = {0, 0, 0, 3, 1, 3};
static const label start[] = {0, 0, 0, 3, 1, 3}; static const label pt1[] = {1, 2, 3, 1, 2, 2};
static const label end[] = {1, 2, 3, 1, 2, 2};
#ifdef FULLDEBUG #ifdef FULLDEBUG
if (edgeI < 0 || edgeI >= 6) if (edgei < 0 || edgei >= 6)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "index out of range 0 -> 5. edgeI = " << edgeI << "index out of range 0 -> 5. edgei = " << edgei
<< abort(FatalError); << abort(FatalError);
} }
#endif #endif
return edge(operator[](start[edgeI]), operator[](end[edgeI])); return edge(operator[](pt0[edgei]), operator[](pt1[edgei]));
} }

View File

@ -86,10 +86,10 @@ public:
const label c 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); 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); explicit inline triFace(std::initializer_list<label> lst);
//- Construct from Istream //- Construct from Istream

View File

@ -52,10 +52,8 @@ inline int Foam::triFace::compare(const triFace& a, const triFace& b)
// same face, but reversed orientation // same face, but reversed orientation
return -1; return -1;
} }
else
{ return 0;
return 0;
}
} }
@ -379,10 +377,8 @@ inline int Foam::triFace::edgeDirection(const edge& e) const
{ {
return -1; return -1;
} }
else
{ return 0;
return 0;
}
} }

View File

@ -21,8 +21,6 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "IOstreams.H" #include "IOstreams.H"

View File

@ -122,13 +122,11 @@ inline Foam::triPointRef Foam::tetrahedron<Point, PointRef>::tri
{ {
return triPointRef(a_, c_, b_); return triPointRef(a_, c_, b_);
} }
else
{ FatalErrorInFunction
FatalErrorInFunction << "index out of range 0 -> 3. facei = " << facei
<< "index out of range 0 -> 3. facei = " << facei << abort(FatalError);
<< abort(FatalError); return triPointRef(b_, c_, d_);
return triPointRef(b_, c_, d_);
}
} }

View File

@ -149,11 +149,11 @@ inline Point Foam::triangle<Point, PointRef>::circumCentre() const
template<class Point, class PointRef> template<class Point, class PointRef>
inline Foam::scalar Foam::triangle<Point, PointRef>::circumRadius() const inline Foam::scalar Foam::triangle<Point, PointRef>::circumRadius() const
{ {
scalar d1 = (c_ - a_) & (b_ - a_); const scalar d1 = (c_ - a_) & (b_ - a_);
scalar d2 = -(c_ - b_) & (b_ - a_); const scalar d2 = -(c_ - b_) & (b_ - a_);
scalar d3 = (c_ - a_) & (c_ - b_); 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) if (Foam::mag(denom) < VSMALL)
{ {
@ -161,12 +161,9 @@ inline Foam::scalar Foam::triangle<Point, PointRef>::circumRadius() const
return GREAT; 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)));
} }

View File

@ -26,10 +26,8 @@ License
#include "treeBoundBox.H" #include "treeBoundBox.H"
#include "FixedList.H" #include "FixedList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<unsigned Size> template<unsigned Size>
Foam::treeBoundBox::treeBoundBox Foam::treeBoundBox::treeBoundBox
( (

View File

@ -24,7 +24,7 @@ License
\*----------------------------------------------------------------------------*/ \*----------------------------------------------------------------------------*/
#include "ccmWriter.H" #include "ccmWriter.H"
#include "cellModeller.H" #include "cellModel.H"
#include "demandDrivenData.H" #include "demandDrivenData.H"
#include "ccmInternal.H" // include last to avoid any strange interactions #include "ccmInternal.H" // include last to avoid any strange interactions
@ -304,12 +304,12 @@ Foam::ccm::writer::writer
mesh_(mesh), mesh_(mesh),
// Mapping between OpenFOAM and PROSTAR primitives // Mapping between OpenFOAM and PROSTAR primitives
prostarShapeLookup_ prostarShapeLookup_
({ {
{ cellModeller::lookup("hex")->index(), STARCDCore::starcdHex }, { cellModel::ref(cellModel::HEX).index(), STARCDCore::starcdHex },
{ cellModeller::lookup("prism")->index(), STARCDCore::starcdPrism }, { cellModel::ref(cellModel::PRISM).index(), STARCDCore::starcdPrism },
{ cellModeller::lookup("tet")->index(), STARCDCore::starcdTet }, { cellModel::ref(cellModel::TET).index(), STARCDCore::starcdTet },
{ cellModeller::lookup("pyr")->index(), STARCDCore::starcdPyr } { cellModel::ref(cellModel::PYR).index(), STARCDCore::starcdPyr }
}), },
boundaryRegion_(mesh), boundaryRegion_(mesh),
cellTable_(mesh) cellTable_(mesh)
{ {

View File

@ -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 * Easier to parse space-delimited input formats
* No arbitrary or integral couples * No arbitrary or integral couples
* No trimmed or degenerate cells * No trimmed or degenerate cells
@ -11,7 +11,7 @@ incorrect lookup.
Fortunately, there are only 4 primitive shapes to be concerned with. Fortunately, there are only 4 primitive shapes to be concerned with.
Hexa: Hexa:
Foam pro-STAR OpenFOAM PROSTAR
~~~~~~~~~~~~~~ ~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~
Face 0 (0 4 7 3) -> F5: (0 4 7 3) Face 0 (0 4 7 3) -> F5: (0 4 7 3)
Face 1 (1 2 6 5) -> F6: (1 2 6 5) Face 1 (1 2 6 5) -> F6: (1 2 6 5)
@ -22,7 +22,7 @@ Hexa:
Prism: Prism:
Foam pro-STAR OpenFOAM PROSTAR
~~~~~~~~~~~~~~ ~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~
Face 0 (0 2 1) -> F1: (0 2 1) Face 0 (0 2 1) -> F1: (0 2 1)
Face 1 (3 4 5) -> F2: (3 4 5) Face 1 (3 4 5) -> F2: (3 4 5)
@ -32,7 +32,7 @@ Prism:
Tetra: Tetra:
Foam pro-STAR OpenFOAM PROSTAR
~~~~~~~~~~~~~~ ~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~
Face 0 (1 2 3) -> F6: (1 2 3) Face 0 (1 2 3) -> F6: (1 2 3)
Face 1 (0 3 2) -> F5: (0 3 2) Face 1 (0 3 2) -> F5: (0 3 2)
@ -41,7 +41,7 @@ Tetra:
Pyramid: Pyramid:
Foam pro-STAR OpenFOAM PROSTAR
~~~~~~~~~~~~~~ ~~~~~~~~~~~ ~~~~~~~~~~~~~~ ~~~~~~~~~~~
Face 0 (0 3 2 1) -> F1: (0 3 2 1) Face 0 (0 3 2 1) -> F1: (0 3 2 1)
Face 1 (0 4 3) -> F5: (0 4 3) Face 1 (0 4 3) -> F5: (0 4 3)
@ -49,12 +49,12 @@ Pyramid:
Face 3 (1 2 4) -> F6: (1 2 4) Face 3 (1 2 4) -> F6: (1 2 4)
Face 4 (0 1 4) -> F3: (0 1 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. 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 ! hexa
v 10 0 0 0 v 10 0 0 0

View File

@ -28,42 +28,8 @@ License
#include "polyMesh.H" #include "polyMesh.H"
#include "faceSet.H" #include "faceSet.H"
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "cellModeller.H"
#include "demandDrivenData.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 * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::meshReader::addCellZones(polyMesh& mesh) const void Foam::meshReader::addCellZones(polyMesh& mesh) const

View File

@ -30,7 +30,7 @@ Description
The derived classes are responsible for providing the protected data. The derived classes are responsible for providing the protected data.
This implementation is somewhat messy, but could/should be restructured This implementation is somewhat messy, but could/should be restructured
to provide a more generalized reader (at the moment it has been written 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). The meshReader supports cellTable information (see new user's guide entry).
@ -204,13 +204,6 @@ protected:
// Protected member data // 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 //- Referenced filename
fileName geometryFile_; fileName geometryFile_;

View File

@ -24,48 +24,12 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "meshWriter.H" #include "meshWriter.H"
#include "cellModeller.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::string Foam::meshWriter::defaultMeshName = "meshExport"; 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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::meshWriter::meshWriter Foam::meshWriter::meshWriter

View File

@ -107,14 +107,6 @@ protected:
//- cellTable IDs for each cell //- cellTable IDs for each cell
labelList cellTableId_; 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: public:
// Static data members // Static data members

View File

@ -28,7 +28,7 @@ License
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "wallPolyPatch.H" #include "wallPolyPatch.H"
#include "symmetryPolyPatch.H" #include "symmetryPolyPatch.H"
#include "cellModeller.H" #include "cellModel.H"
#include "ListOps.H" #include "ListOps.H"
#include "IFstream.H" #include "IFstream.H"
#include "IOMap.H" #include "IOMap.H"
@ -317,7 +317,10 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
// avoid undefined shapes for polyhedra // avoid undefined shapes for polyhedra
cellShape genericShape(*unknownModel, labelList(0)); cellShape genericShape
(
cellModel::ref(cellModel::UNKNOWN), labelList()
);
// Pass 2: // Pass 2:
// construct cellFaces_ and possibly cellShapes_ // construct cellFaces_ and possibly cellShapes_
@ -372,23 +375,23 @@ void Foam::fileFormats::STARCDMeshReader::readCells(const fileName& inputName)
continue; continue;
} }
// determine the foam cell shape // determine the OpenFOAM cell shape
const cellModel* curModelPtr = nullptr; const cellModel* curModelPtr = nullptr;
// fluid/solid cells // fluid/solid cells
switch (shapeId) switch (shapeId)
{ {
case STARCDCore::starcdHex: case STARCDCore::starcdHex:
curModelPtr = hexModel; curModelPtr = cellModel::ptr(cellModel::HEX);
break; break;
case STARCDCore::starcdPrism: case STARCDCore::starcdPrism:
curModelPtr = prismModel; curModelPtr = cellModel::ptr(cellModel::PRISM);
break; break;
case STARCDCore::starcdTet: case STARCDCore::starcdTet:
curModelPtr = tetModel; curModelPtr = cellModel::ptr(cellModel::TET);
break; break;
case STARCDCore::starcdPyr: case STARCDCore::starcdPyr:
curModelPtr = pyrModel; curModelPtr = cellModel::ptr(cellModel::PYR);
break; break;
} }
@ -612,12 +615,12 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary
// Mapping between OpenFOAM and PROSTAR primitives // Mapping between OpenFOAM and PROSTAR primitives
// - needed for face mapping // - needed for face mapping
// //
const Map<label> prostarShapeLookup = const Map<label> shapeLookup =
{ {
{ hexModel->index(), STARCDCore::starcdHex }, { cellModel::ref(cellModel::HEX).index(), STARCDCore::starcdHex },
{ prismModel->index(), STARCDCore::starcdPrism }, { cellModel::ref(cellModel::PRISM).index(), STARCDCore::starcdPrism },
{ tetModel->index(), STARCDCore::starcdTet }, { cellModel::ref(cellModel::TET).index(), STARCDCore::starcdTet },
{ pyrModel->index(), STARCDCore::starcdPyr } { cellModel::ref(cellModel::PYR).index(), STARCDCore::starcdPyr },
}; };
// Pass 1: // Pass 1:
@ -861,9 +864,9 @@ void Foam::fileFormats::STARCDMeshReader::readBoundary
if (cellId < cellShapes_.size()) if (cellId < cellShapes_.size())
{ {
label mapIndex = cellShapes_[cellId].model().index(); label mapIndex = cellShapes_[cellId].model().index();
if (prostarShapeLookup.found(mapIndex)) if (shapeLookup.found(mapIndex))
{ {
mapIndex = prostarShapeLookup[mapIndex]; mapIndex = shapeLookup[mapIndex];
cellFaceId = cellFaceId =
STARCDCore::starToFoamFaceAddr STARCDCore::starToFoamFaceAddr
[mapIndex][cellFaceId]; [mapIndex][cellFaceId];

View File

@ -25,10 +25,10 @@ Class
Foam::fileFormats::STARCDMeshReader Foam::fileFormats::STARCDMeshReader
Description Description
Read pro-STAR vrt/cel/bnd files. Read PROSTAR vrt/cel/bnd files.
The protected data in meshReader are filled. 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. - vertices are space-delimited.
- the cell format is logical. - the cell format is logical.
- trimmed and degenerate cells are saved as polyhedral. - trimmed and degenerate cells are saved as polyhedral.

View File

@ -35,18 +35,17 @@ Foam::label Foam::fileFormats::STARCDMeshWriter::findDefaultBoundary() const
{ {
const polyBoundaryMesh& patches = mesh_.boundaryMesh(); const polyBoundaryMesh& patches = mesh_.boundaryMesh();
label id = -1;
// find Default_Boundary_Region if it exists // find Default_Boundary_Region if it exists
forAll(patches, patchi) forAll(patches, patchi)
{ {
if (defaultBoundaryName == patches[patchi].name()) if (defaultBoundaryName == patches[patchi].name())
{ {
id = patchi; return patchi;
break; break;
} }
} }
return id;
return -1;
} }
@ -165,29 +164,16 @@ void Foam::fileFormats::STARCDMeshWriter::writeCells
OFstream os(starFileName(prefix, STARCDCore::CEL_FILE)); OFstream os(starFileName(prefix, STARCDCore::CEL_FILE));
writeHeader(os, STARCDCore::HEADER_CEL); writeHeader(os, STARCDCore::HEADER_CEL);
// this is what we seem to need //
// map foam cellModeller index -> star shape // Mapping between OpenFOAM and PROSTAR primitives
Map<label> shapeLookupIndex; //
shapeLookupIndex.insert const Map<label> shapeLookupIndex
( {
hexModel->index(), { cellModel::ref(cellModel::HEX).index(), STARCDCore::starcdHex },
STARCDCore::starcdHex { cellModel::ref(cellModel::PRISM).index(), STARCDCore::starcdPrism },
); { cellModel::ref(cellModel::TET).index(), STARCDCore::starcdTet },
shapeLookupIndex.insert { cellModel::ref(cellModel::PYR).index(), STARCDCore::starcdPyr },
( };
prismModel->index(),
STARCDCore::starcdPrism
);
shapeLookupIndex.insert
(
tetModel->index(),
STARCDCore::starcdTet
);
shapeLookupIndex.insert
(
pyrModel->index(),
STARCDCore::starcdPyr
);
const cellShapeList& shapes = mesh_.cellShapes(); const cellShapeList& shapes = mesh_.cellShapes();
const cellList& cells = mesh_.cells(); const cellList& cells = mesh_.cells();
@ -336,12 +322,12 @@ void Foam::fileFormats::STARCDMeshWriter::writeBoundary
// Mapping between OpenFOAM and PROSTAR primitives // Mapping between OpenFOAM and PROSTAR primitives
// - needed for face mapping // - needed for face mapping
// //
const Map<label> prostarShapeLookup = const Map<label> shapeLookupIndex =
{ {
{ hexModel->index(), STARCDCore::starcdHex }, { cellModel::ref(cellModel::HEX).index(), STARCDCore::starcdHex },
{ prismModel->index(), STARCDCore::starcdPrism }, { cellModel::ref(cellModel::PRISM).index(), STARCDCore::starcdPrism },
{ tetModel->index(), STARCDCore::starcdTet }, { cellModel::ref(cellModel::TET).index(), STARCDCore::starcdTet },
{ pyrModel->index(), STARCDCore::starcdPyr } { cellModel::ref(cellModel::PYR).index(), STARCDCore::starcdPyr },
}; };
Info<< "Writing " << os.name() << " : " Info<< "Writing " << os.name() << " : "
@ -396,7 +382,7 @@ void Foam::fileFormats::STARCDMeshWriter::writeBoundary
label mapIndex = shape.model().index(); label mapIndex = shape.model().index();
// A registered primitive type // A registered primitive type
if (prostarShapeLookup.found(mapIndex)) if (shapeLookupIndex.found(mapIndex))
{ {
const faceList sFaces = shape.faces(); const faceList sFaces = shape.faces();
forAll(sFaces, sFacei) forAll(sFaces, sFacei)
@ -408,7 +394,7 @@ void Foam::fileFormats::STARCDMeshWriter::writeBoundary
} }
} }
mapIndex = prostarShapeLookup[mapIndex]; mapIndex = shapeLookupIndex[mapIndex];
cellFaceId = cellFaceId =
STARCDCore::foamToStarFaceAddr[mapIndex][cellFaceId]; STARCDCore::foamToStarFaceAddr[mapIndex][cellFaceId];
} }

View File

@ -25,7 +25,7 @@ Class
Foam::fileFormats::STARCDMeshWriter Foam::fileFormats::STARCDMeshWriter
Description 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). The cellTableId and cellTable information are used (if available).
Otherwise the cellZones are used (if available). Otherwise the cellZones are used (if available).

View File

@ -27,7 +27,6 @@ License
#include "foamVtkCore.H" #include "foamVtkCore.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "cellShape.H" #include "cellShape.H"
#include "cellModeller.H"
// Only used in this file // Only used in this file
#include "foamVtuSizingTemplates.C" #include "foamVtuSizingTemplates.C"
@ -74,12 +73,12 @@ void Foam::vtk::vtuSizing::reset
const bool decompose const bool decompose
) )
{ {
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
const cellModel& wedge = *(cellModeller::lookup("wedge")); const cellModel& wedge = cellModel::ref(cellModel::WEDGE);
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge")); const cellModel& tetWedge = cellModel::ref(cellModel::TETWEDGE);
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellShapeList& shapes = mesh.cellShapes(); const cellShapeList& shapes = mesh.cellShapes();

View File

@ -27,7 +27,6 @@ License
#include "foamVtkCore.H" #include "foamVtkCore.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "cellShape.H" #include "cellShape.H"
#include "cellModeller.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -212,12 +211,12 @@ void Foam::vtk::vtuSizing::populateArrays
faceOffset = -1; faceOffset = -1;
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
const cellModel& wedge = *(cellModeller::lookup("wedge")); const cellModel& wedge = cellModel::ref(cellModel::WEDGE);
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge")); const cellModel& tetWedge = cellModel::ref(cellModel::TETWEDGE);
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellShapeList& shapes = mesh.cellShapes(); const cellShapeList& shapes = mesh.cellShapes();

View File

@ -26,7 +26,7 @@ License
#include "hexCellLooper.H" #include "hexCellLooper.H"
#include "cellFeatures.H" #include "cellFeatures.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "cellModeller.H" #include "cellModel.H"
#include "plane.H" #include "plane.H"
#include "ListOps.H" #include "ListOps.H"
#include "meshTools.H" #include "meshTools.H"
@ -153,7 +153,7 @@ void Foam::hexCellLooper::makeFace
Foam::hexCellLooper::hexCellLooper(const polyMesh& mesh) Foam::hexCellLooper::hexCellLooper(const polyMesh& mesh)
: :
geomCellLooper(mesh), geomCellLooper(mesh),
hex_(*(cellModeller::lookup("hex"))) hex_(cellModel::ref(cellModel::HEX))
{} {}

View File

@ -33,7 +33,7 @@ License
#include "hexRef8.H" #include "hexRef8.H"
#include "mapPolyMesh.H" #include "mapPolyMesh.H"
#include "polyTopoChange.H" #include "polyTopoChange.H"
#include "cellModeller.H" #include "cellModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -186,7 +186,7 @@ void Foam::multiDirRefinement::addCells
Foam::labelList Foam::multiDirRefinement::splitOffHex(const primitiveMesh& mesh) 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(); const cellShapeList& cellShapes = mesh.cellShapes();

View File

@ -26,7 +26,7 @@ License
#include "ensightCells.H" #include "ensightCells.H"
#include "error.H" #include "error.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "cellModeller.H" #include "cellModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -162,10 +162,10 @@ void Foam::ensightCells::classify
) )
{ {
// References to cell shape models // References to cell shape models
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellShapeList& shapes = mesh.cellShapes(); const cellShapeList& shapes = mesh.cellShapes();

View File

@ -25,7 +25,7 @@ Class
Foam::fileFormats::STARCDCore Foam::fileFormats::STARCDCore
Description 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 SourceFiles
STARCDCore.C STARCDCore.C
@ -121,11 +121,11 @@ protected:
// Protected Member Functions // 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. // For hex, prism, tet, pyr primitive shapes.
static const Map<FixedList<int, 6>> starToFoamFaceAddr; 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. // For hex, prism, tet, pyr primitive shapes.
static const Map<FixedList<int, 6>> foamToStarFaceAddr; static const Map<FixedList<int, 6>> foamToStarFaceAddr;

View File

@ -81,7 +81,7 @@ bool Foam::fileFormats::STLCore::isBinaryName
// this seems to work better than the old token-based method // this seems to work better than the old token-based method
// - using wordToken can cause an abort if non-word (binary) content // - using wordToken can cause an abort if non-word (binary) content
// is detected ... this is not exactly what we want. // 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. // the binary header. This is just wrong and not our fault.
int Foam::fileFormats::STLCore::detectBinaryHeader int Foam::fileFormats::STLCore::detectBinaryHeader
( (

View File

@ -27,7 +27,7 @@ License
#include "labelIOField.H" #include "labelIOField.H"
#include "scalarIOField.H" #include "scalarIOField.H"
#include "stringIOList.H" #include "stringIOList.H"
#include "cellModeller.H" #include "cellModel.H"
#include "vectorIOField.H" #include "vectorIOField.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
@ -104,10 +104,10 @@ void Foam::vtkUnstructuredReader::extractCells
const labelList& cellVertData const labelList& cellVertData
) )
{ {
const cellModel& hex = *(cellModeller::lookup("hex")); const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& prism = cellModel::ref(cellModel::PRISM);
const cellModel& pyr = *(cellModeller::lookup("pyr")); const cellModel& pyr = cellModel::ref(cellModel::PYR);
const cellModel& tet = *(cellModeller::lookup("tet")); const cellModel& tet = cellModel::ref(cellModel::TET);
labelList tetPoints(4); labelList tetPoints(4);
labelList pyrPoints(5); labelList pyrPoints(5);

View File

@ -27,7 +27,7 @@ License
#include "labelIOField.H" #include "labelIOField.H"
#include "scalarIOField.H" #include "scalarIOField.H"
#include "stringIOList.H" #include "stringIOList.H"
#include "cellModeller.H" #include "cellModel.H"
#include "vectorIOField.H" #include "vectorIOField.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

Some files were not shown because too many files have changed in this diff Show More