diff --git a/src/OpenFOAM/containers/Bits/bitSet/PackedBoolList.H b/src/OpenFOAM/containers/Bits/bitSet/PackedBoolList.H index 2d8f5163eb..801d2fb0ee 100644 --- a/src/OpenFOAM/containers/Bits/bitSet/PackedBoolList.H +++ b/src/OpenFOAM/containers/Bits/bitSet/PackedBoolList.H @@ -8,8 +8,7 @@ Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License - This file is part of OpenFOAM, licensed under GNU General Public License - . + This file is part of OpenFOAM, distributed under GPL-3.0-or-later. Typedef Foam::PackedBoolList diff --git a/src/OpenFOAM/meshes/meshShapes/cell/cell.C b/src/OpenFOAM/meshes/meshShapes/cell/cell.C index 484afafa07..33f6f71cf5 100644 --- a/src/OpenFOAM/meshes/meshShapes/cell/cell.C +++ b/src/OpenFOAM/meshes/meshShapes/cell/cell.C @@ -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; diff --git a/src/OpenFOAM/meshes/meshShapes/cell/cell.H b/src/OpenFOAM/meshes/meshShapes/cell/cell.H index e100379523..afedec8543 100644 --- a/src/OpenFOAM/meshes/meshShapes/cell/cell.H +++ b/src/OpenFOAM/meshes/meshShapes/cell/cell.H @@ -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 labels - inline explicit cell(labelList&& lst); + //- Move construct from list of face labels + inline explicit cell(labelList&& list); + + //- Copy construct from list of face labels + template + inline explicit cell(const FixedList& list); + + //- Copy construct from subset of face labels + inline cell(const labelUList& list, const labelUList& indices); + + //- Copy construct from subset of face labels + template + inline cell(const labelUList& list, const FixedList& 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& 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& p, const faceUList& f) const; + point centre + ( + const UList& meshPoints, + const faceUList& meshFaces + ) const; //- Returns cell volume - scalar mag(const UList& p, const faceUList& f) const; + scalar mag + ( + const UList& meshPoints, + const faceUList& meshFaces + ) const; }; diff --git a/src/OpenFOAM/meshes/meshShapes/cell/cellI.H b/src/OpenFOAM/meshes/meshShapes/cell/cellI.H index 50e9d3dd47..56fe8947a6 100644 --- a/src/OpenFOAM/meshes/meshShapes/cell/cellI.H +++ b/src/OpenFOAM/meshes/meshShapes/cell/cellI.H @@ -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 labelUList& lst) +inline Foam::cell::cell(const labelUList& list) : - labelList(lst) + labelList(list) {} -inline Foam::cell::cell(labelList&& lst) +template +inline Foam::cell::cell(const FixedList& list) : - labelList(std::move(lst)) + labelList(list) +{} + + +inline Foam::cell::cell(labelList&& list) +: + labelList(std::move(list)) +{} + + +inline Foam::cell::cell(const labelUList& list, const labelUList& indices) +: + labelList(list, indices) +{} + + +template +inline Foam::cell::cell +( + const labelUList& list, + const FixedList& indices +) +: + labelList(list, indices) {} diff --git a/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.H b/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.H index b837c78786..178cf99470 100644 --- a/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.H +++ b/src/OpenFOAM/meshes/meshShapes/cellMatcher/cellMatcher.H @@ -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