From f76552f7f93f3299d19ac70d495ebc0f8fb6c887 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 6 Oct 2017 20:10:49 +0200 Subject: [PATCH] STYLE: rebase edge on labelPair, additional methods in Pair - use FixedList first/last in Pair first/second - consistent first/second access for line --- .../automatic/automatic.C | 2 +- .../foamyHexMeshBackgroundMesh.C | 2 +- .../surface/surfaceCheck/surfaceCheck.C | 2 +- .../surfaceFeatureExtract.C | 2 +- src/OpenFOAM/meshes/meshShapes/edge/edge.H | 83 ++++--- src/OpenFOAM/meshes/meshShapes/edge/edgeI.H | 223 +++++++----------- src/OpenFOAM/meshes/meshShapes/face/face.C | 12 +- src/OpenFOAM/meshes/meshShapes/face/face.H | 33 ++- src/OpenFOAM/meshes/meshShapes/face/faceI.H | 18 +- .../meshes/meshShapes/triFace/triFace.H | 6 +- .../meshes/meshShapes/triFace/triFaceI.H | 32 +-- .../meshes/primitiveShapes/line/line.H | 78 +++--- .../meshes/primitiveShapes/line/lineI.H | 24 +- src/OpenFOAM/primitives/Pair/Pair.H | 156 +++++------- src/OpenFOAM/primitives/Pair/PairI.H | 165 +++++++++++++ src/OpenFOAM/primitives/Tuple2/Tuple2.H | 2 +- src/surfMesh/triSurface/triSurface.C | 2 +- 17 files changed, 486 insertions(+), 356 deletions(-) create mode 100644 src/OpenFOAM/primitives/Pair/PairI.H diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C index d9bf097d1d..302bd61b55 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/cellSizeCalculationType/automatic/automatic.C @@ -282,7 +282,7 @@ Foam::tmp Foam::automatic::load() forAll(surface_, fI) { - faces[fI] = surface_.triSurface::operator[](fI).triFaceFace(); + faces[fI] = surface_.triSurface::operator[](fI); } vtkSurfaceWriter().write diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C index 410182e01c..ac840a07f7 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C @@ -721,7 +721,7 @@ int main(int argc, char *argv[]) isoFaces.setSize(iso.size()); forAll(isoFaces, i) { - isoFaces[i] = iso[i].triFaceFace(); + isoFaces[i] = iso[i]; } isoPoints = iso.points(); } diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index 09765e2d93..43812170e1 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -150,7 +150,7 @@ void writeZoning faceList faces(surf.size()); forAll(surf, i) { - faces[i] = surf[i].triFaceFace(); + faces[i] = surf[i]; } vtkSurfaceWriter().write diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index ca7cba62cc..eb7103faf1 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -368,7 +368,7 @@ int main(int argc, char *argv[]) faces.setSize(surf.size()); forAll(surf, fi) { - faces[fi] = surf[fi].triFaceFace(); + faces[fi] = surf[fi]; } } diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edge.H b/src/OpenFOAM/meshes/meshShapes/edge/edge.H index aecb9a9c2e..dabdc197ef 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edge.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edge.H @@ -28,7 +28,7 @@ Description An edge is a list of two point labels. The functionality it provides supports the discretisation on a 2-D flat mesh. - The edge is implemented as a FixedList of labels. + The edge is implemented as a Pair/FixedList of labels. As well as geometrically relevant methods, it also provides methods similar to HashSet for additional convenience. Valid point labels are always non-negative (since they correspond to @@ -37,6 +37,7 @@ Description can be filled with a HashSet-like functionality. SourceFiles + edge.C edgeI.H \*---------------------------------------------------------------------------*/ @@ -44,10 +45,9 @@ SourceFiles #ifndef edge_H #define edge_H -#include "FixedList.H" #include "labelPair.H" -#include "pointField.H" #include "linePointRef.H" +#include "pointField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,7 +60,7 @@ namespace Foam class edge : - public FixedList + public labelPair { // Private Member Functions @@ -93,19 +93,19 @@ public: //- Construct null with invalid point labels (-1) inline edge(); - //- Construct from components + //- Construct from two point labels inline edge(const label from, const label to); - //- Construct, optionally sorted with start less-than end - inline edge(const label from, const label to, const bool doSort); - - //- Construct from two labels + //- Construct from pair of labels inline edge(const labelPair& pair); - //- Construct from FixedList + //- Construct from list inline edge(const FixedList& lst); - //- Construct, optionally sorted with start less-than end + //- Construct from two point labels, sorted with first less-than second + inline edge(const label from, const label to, const bool doSort); + + //- Construct from list, sorted with first less-than second inline edge(const FixedList& lst, const bool doSort); //- Construct from Istream @@ -116,16 +116,26 @@ public: // Access - //- Return start vertex label + //- Return first vertex label + using labelPair::first; + + //- Return last (second) vertex label + using labelPair::last; + + //- Return second (last) vertex label + using labelPair::second; + + + //- Return start (first) vertex label inline label start() const; - //- Return start vertex label + //- Return start (first) vertex label inline label& start(); - //- Return end vertex label + //- Return end (last/second) vertex label inline label end() const; - //- Return end vertex label + //- Return end (last/second) vertex label inline label& end(); //- Return reverse edge as copy. @@ -143,10 +153,6 @@ public: // No special handling of negative point labels. inline label maxVertex() const; - //- True if start() is less-than end() - // No special handling of negative point labels. - inline bool sorted() const; - //- Return true if point label is found in edge. // Always false for a negative label. inline bool found(const label pointLabel) const; @@ -175,14 +181,6 @@ public: // Return the effective size after collapsing. inline label collapse(); - //- Flip the edge in-place. - // No special handling of negative point labels. - inline void flip(); - - //- Sort so that start() is less-than end() - // No special handling of negative point labels. - inline void sort(); - // Hash-like functions @@ -211,8 +209,8 @@ public: // Returns true on success. Negative labels never insert. // Return the number of slots filled. // Similar to a HashTable::insert(). - template - inline label insert(const FixedList& lst); + template + inline label insert(const FixedList& lst); //- Fill open slots with the indices if they did not previously exist. // Returns true on success. Negative labels never insert. @@ -231,8 +229,8 @@ public: //- Remove existing indices from the edge and set locations to '-1'. // Returns the number of changes. - template - inline label erase(const FixedList& lst); + template + inline label erase(const FixedList& lst); //- Remove existing indices from the edge and set locations to '-1'. // Returns the number of changes. @@ -265,7 +263,7 @@ public: // Comparison //- Compare edges - // Returns: + // \return // - 0: different // - +1: identical values and order used // - -1: identical values, but in different order @@ -274,7 +272,14 @@ public: }; -// Global Operators +// * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * * // + +//- Return reverse of an edge +inline edge reverse(const edge& e) +{ + return edge(e.second(), e.first()); +} + //- Compare edges for equal content, ignoring orientation inline bool operator==(const edge& a, const edge& b); @@ -290,15 +295,15 @@ inline unsigned Hash::operator()(const edge& e, unsigned seed) const { unsigned val = seed; - if (e[0] < e[1]) + if (e.first() < e.second()) { - val = Hash