Commit 0783bd28 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: additional face constructors, cellModel methods

- support construct face from subset of labels.

- additional cellModel face() method to return a single face.

- reduce some allocations in cellModel centre/mag methods

STYLE: mark old cellModeller methods as compile-time deprecated

- deprecated in 2017, but not marked as such

STYLE: indentation, spacing in some headers
parent 525ad206
......@@ -8,8 +8,7 @@
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, licensed under GNU General Public License
<http://www.gnu.org/licenses/>.
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Typedef
Foam::PackedBoolList
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -32,17 +33,15 @@ License
const char* const Foam::cell::typeName = "cell";
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::labelList Foam::cell::labels(const faceUList& f) const
{
// return the unordered list of vertex labels supporting the cell
// count the maximum size of all vertices
label maxVert = 0;
const labelList& faces = *this;
// Count the maximum size of all vertices
label maxVert = 0;
forAll(faces, facei)
{
maxVert += f[faces[facei]].size();
......@@ -65,6 +64,7 @@ Foam::labelList Foam::cell::labels(const faceUList& f) const
// go through the rest of the faces. For each vertex, check if the point is
// already inserted (up to maxVert, which now carries the number of real
// points. If not, add it at the end of the list.
for (label facei = 1; facei < faces.size(); facei++)
{
const labelList& curFace = f[faces[facei]];
......@@ -87,8 +87,7 @@ Foam::labelList Foam::cell::labels(const faceUList& f) const
if (!found)
{
p[maxVert] = curPoint;
maxVert++;
++maxVert;
}
}
}
......@@ -121,11 +120,8 @@ Foam::pointField Foam::cell::points
Foam::edgeList Foam::cell::edges(const faceUList& f) const
{
// return the lisf of cell edges
const labelList& curFaces = *this;
// create a list of edges
label maxNoEdges = 0;
forAll(curFaces, facei)
......@@ -140,10 +136,8 @@ Foam::edgeList Foam::cell::edges(const faceUList& f) const
{
const edgeList curFaceEdges = f[curFaces[facei]].edges();
forAll(curFaceEdges, faceEdgeI)
for (const edge& curEdge : curFaceEdges)
{
const edge& curEdge = curFaceEdges[faceEdgeI];
bool edgeFound = false;
for (label addedEdgeI = 0; addedEdgeI < nEdges; addedEdgeI++)
......@@ -160,7 +154,7 @@ Foam::edgeList Foam::cell::edges(const faceUList& f) const
{
// Add the new edge onto the list
allEdges[nEdges] = curEdge;
nEdges++;
++nEdges;
}
}
}
......@@ -194,6 +188,7 @@ Foam::point Foam::cell::centre
// first calculate the approximate cell centre as the average of all
// face centres
vector cEst = Zero;
scalar sumArea = 0;
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -56,27 +56,37 @@ class cell
:
public labelList
{
public:
// Static data members
// Static Data Members
static const char* const typeName;
// Constructors
//- Construct null
inline cell();
//- Default construct
constexpr cell() noexcept = default;
//- Construct given size, with invalid point labels (-1)
inline explicit cell(const label sz);
//- Copy construct from list of labels
inline explicit cell(const labelUList& lst);
//- Copy construct from list of face labels
inline explicit cell(const labelUList& list);
//- Move construct from list of face labels
inline explicit cell(labelList&& list);
//- Copy construct from list of face labels
template<unsigned N>
inline explicit cell(const FixedList<label, N>& list);
//- Move construct from list of labels
inline explicit cell(labelList&& lst);
//- Copy construct from subset of face labels
inline cell(const labelUList& list, const labelUList& indices);
//- Copy construct from subset of face labels
template<unsigned N>
inline cell(const labelUList& list, const FixedList<label, N>& indices);
//- Construct from Istream
inline cell(Istream& is);
......@@ -88,17 +98,17 @@ public:
inline label nFaces() const;
//- Return unordered list of cell vertices given the list of faces
labelList labels(const faceUList& f) const;
labelList labels(const faceUList& meshFaces) const;
//- Return the cell vertices given the list of faces and mesh points
pointField points
(
const faceUList& f,
const faceUList& meshFaces,
const UList<point>& meshPoints
) const;
//- Return cell edges
edgeList edges(const faceUList& f) const;
edgeList edges(const faceUList& meshFaces) const;
//- Return index of opposite face
label opposingFaceLabel
......@@ -124,10 +134,18 @@ public:
// future.
//- Returns cell centre
point centre(const UList<point>& p, const faceUList& f) const;
point centre
(
const UList<point>& meshPoints,
const faceUList& meshFaces
) const;
//- Returns cell volume
scalar mag(const UList<point>& p, const faceUList& f) const;
scalar mag
(
const UList<point>& meshPoints,
const faceUList& meshFaces
) const;
};
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -27,25 +28,45 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::cell::cell()
inline Foam::cell::cell(const label sz)
:
labelList(sz, -1)
{}
inline Foam::cell::cell(const label sz)
inline Foam::cell::cell(const labelUList& list)
:
labelList(sz, -1)
labelList(list)
{}
template<unsigned N>
inline Foam::cell::cell(const FixedList<label, N>& list)
:
labelList(list)
{}
inline Foam::cell::cell(labelList&& list)
:
labelList(std::move(list))
{}
inline Foam::cell::cell(const labelUList& lst)
inline Foam::cell::cell(const labelUList& list, const labelUList& indices)
:
labelList(lst)
labelList(list, indices)
{}
inline Foam::cell::cell(labelList&& lst)
template<unsigned N>
inline Foam::cell::cell
(
const labelUList& list,
const FixedList<label, N>& indices
)
:
labelList(std::move(lst))
labelList(list, indices)
{}
......
......@@ -80,8 +80,7 @@ SourceFiles
#ifndef cellMatcher_H
#define cellMatcher_H
#include "labelList.H"
#include "faceList.H"
#include "cellModel.H"
#include "Map.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -89,11 +88,10 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class primitiveMesh;
// Forward Declarations
class cell;
class cellModel;
class cellShape;
class primitiveMesh;
/*---------------------------------------------------------------------------*\
Class cellMatcher Declaration
......@@ -103,7 +101,7 @@ class cellMatcher
{
protected:
// Static functions
// Static Functions
//- Given start and end of edge generate unique key
inline static label edgeKey
......@@ -116,7 +114,8 @@ protected:
//- Step along face either in righthand or lefthand direction
inline static label nextVert(const label, const label, const bool);
// Protected data
// Protected Data
// Map from mesh to local vertex numbering
Map<label> localPoint_;
......@@ -174,11 +173,6 @@ protected:
const label localFacei
) const;
private:
// Private Member Functions
//- No copy construct
cellMatcher(const cellMatcher&) = delete;
......@@ -224,6 +218,7 @@ public:
void write(Ostream& os) const;
// Cell shape dependent
virtual label nVertPerCell() const = 0;
......@@ -271,7 +266,6 @@ public:
const label celli,
cellShape& shape
) = 0;
};
......
......@@ -25,9 +25,6 @@ License
\*---------------------------------------------------------------------------*/
#include "primitiveMesh.H"
#include "cellModel.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::Map<Foam::label>& Foam::cellMatcher::localPoint() const
......
......@@ -26,6 +26,7 @@ License
\*---------------------------------------------------------------------------*/
#include "degenerateMatcher.H"
#include "primitiveMesh.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......
......@@ -60,8 +60,7 @@ namespace Foam
class degenerateMatcher
{
// Static data members
// Static Data Members
//- Matchers for all degenerate hex shapes
static hexMatcher hex;
......@@ -71,7 +70,8 @@ class degenerateMatcher
static pyrMatcher pyr;
static tetMatcher tet;
// Static functions
// Static Functions
//- Recognize basic shape
static cellShape match
......@@ -84,13 +84,13 @@ class degenerateMatcher
public:
// Static data members
// Static Functions
//- Recognize shape given faces of a cell
static cellShape match(const faceList& faces);
//- Recognize given uncollapsed shape (usually hex) with duplicate
// vertices. cellShape just used to extract faces.
//- vertices. cellShape just used to extract faces.
static cellShape match(const cellShape& shape);
//- Recognize shape given mesh and celli
......
......@@ -38,17 +38,11 @@ Foam::hexMatcher::hexMatcher()
vertPerCell,
facePerCell,
maxVertPerFace,
"hex" // same as cellModel::modelNames[cellModel::HEX]
"hex" // == cellModel::modelNames[cellModel::HEX]
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::hexMatcher::~hexMatcher()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::hexMatcher::matchShape
......
......@@ -76,11 +76,12 @@ public:
// Constructors
//- Construct null
//- Default construct
hexMatcher();
//- Destructor
~hexMatcher();
~hexMatcher() = default;
// Member Functions
......
......@@ -38,14 +38,10 @@ Foam::prismMatcher::prismMatcher()
vertPerCell,
facePerCell,
maxVertPerFace,
"prism" // same as cellModel::modelNames[cellModel::PRISM]
"prism" // == cellModel::modelNames[cellModel::PRISM]
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::prismMatcher::~prismMatcher()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......
......@@ -76,11 +76,12 @@ public:
// Constructors
//- Construct
//- Default construct
prismMatcher();
//- Destructor
~prismMatcher();
~prismMatcher() = default;
// Member Functions
......
......@@ -40,17 +40,11 @@ Foam::pyrMatcher::pyrMatcher()
vertPerCell,
facePerCell,
maxVertPerFace,
"pyr" // same as cellModel::modelNames[cellModel::PYR]
"pyr" // == cellModel::modelNames[cellModel::PYR]
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::pyrMatcher::~pyrMatcher()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::pyrMatcher::matchShape
......
......@@ -76,11 +76,12 @@ public:
// Constructors
//- Construct null
//- Default construct
pyrMatcher();
//- Destructor
~pyrMatcher();
~pyrMatcher() = default;
// Member Functions
......
......@@ -40,20 +40,13 @@ Foam::tetMatcher::tetMatcher()
vertPerCell,
facePerCell,
maxVertPerFace,
"tet" // same as cellModel::modelNames[cellModel::TET]
"tet" // == cellModel::modelNames[cellModel::TET]
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::tetMatcher::~tetMatcher()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::tetMatcher::matchShape
(
const bool checkOnly,
......
......@@ -76,11 +76,12 @@ public:
// Constructors
//- Construct null
//- Default construct
tetMatcher();
//- Destructor
~tetMatcher();
~tetMatcher() = default;
// Member Functions
......
......@@ -40,17 +40,11 @@ Foam::tetWedgeMatcher::tetWedgeMatcher()
vertPerCell,
facePerCell,
maxVertPerFace,
"tetWedge" // same as cellModel::modelNames[cellModel::TETWEDGE]
"tetWedge" // == cellModel::modelNames[cellModel::TETWEDGE]
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::tetWedgeMatcher::~tetWedgeMatcher()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::tetWedgeMatcher::matchShape
......
......@@ -76,11 +76,12 @@ public:
// Constructors
//- Construct null
//- Default construct
tetWedgeMatcher();
//- Destructor
~tetWedgeMatcher();
~tetWedgeMatcher() = default;
// Member Functions
......
......@@ -38,17 +38,11 @@ Foam::wedgeMatcher::wedgeMatcher()
vertPerCell,
facePerCell,
maxVertPerFace,
"wedge" // same as cellModel::modelNames[cellModel::WEDGE]
"wedge" // == cellModel::modelNames[cellModel::WEDGE]
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::wedgeMatcher::~wedgeMatcher()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::wedgeMatcher::matchShape
......
......@@ -76,11 +76,12 @@ public:
// Constructors
//- Construct null
//- Default construct
wedgeMatcher();
//- Destructor
~wedgeMatcher();
~wedgeMatcher() = default;
// Member Functions
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment