From d09b366b3a6a1b10ee858fcd6bd076fd50d1e480 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Thu, 13 Sep 2018 10:14:52 +0200
Subject: [PATCH] STYLE: use List, FixedList find(), found() methods in
 face/triFace

---
 src/OpenFOAM/meshes/meshShapes/face/face.C    | 16 ---------------
 src/OpenFOAM/meshes/meshShapes/face/face.H    | 20 +++++++++----------
 src/OpenFOAM/meshes/meshShapes/face/faceI.H   | 14 +++++++++----
 .../meshes/meshShapes/triFace/triFace.H       | 10 +++++-----
 .../meshes/meshShapes/triFace/triFaceI.H      | 11 ++++------
 5 files changed, 29 insertions(+), 42 deletions(-)

diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C
index c5b94c38116..0b180b482c4 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/face.C
+++ b/src/OpenFOAM/meshes/meshShapes/face/face.C
@@ -622,22 +622,6 @@ Foam::face Foam::face::reverseFace() const
 }
 
 
-Foam::label Foam::face::which(const label globalIndex) const
-{
-    const labelUList& f = *this;
-
-    forAll(f, localIdx)
-    {
-        if (f[localIdx] == globalIndex)
-        {
-            return localIdx;
-        }
-    }
-
-    return -1;
-}
-
-
 Foam::scalar Foam::face::sweptVol
 (
     const UList<point>& oldPoints,
diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H
index 986a65fcb89..a0f59104d95 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/face.H
+++ b/src/OpenFOAM/meshes/meshShapes/face/face.H
@@ -212,20 +212,20 @@ public:
         //  The starting points of the original and reverse face are identical.
         face reverseFace() const;
 
-        //- Navigation through face vertices
+        // Navigation through face vertices
 
-            //- Return true if the global point label is found in face.
-            inline bool found(const label globalIndex) const;
+        //- Return true if the point label is found in face.
+        inline bool found(const label pointLabel) const;
 
-            //- Which local vertex on face given a global index.
-            //  returns -1 if not found
-            label which(const label globalIndex) const;
+        //- Find local index on face for the point label,
+        //  \return position in face (0,1,2,...) or -1 if not found.
+        inline label which(const label pointLabel) const;
 
-            //- Next vertex on face
-            inline label nextLabel(const label i) const;
+        //- Next vertex on face
+        inline label nextLabel(const label i) const;
 
-            //- Previous vertex on face
-            inline label prevLabel(const label i) const;
+        //- Previous vertex on face
+        inline label prevLabel(const label i) const;
 
 
         //- Return the volume swept out by the face when its points move
diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceI.H b/src/OpenFOAM/meshes/meshShapes/face/faceI.H
index 1c35b20adbc..fa92420659a 100644
--- a/src/OpenFOAM/meshes/meshShapes/face/faceI.H
+++ b/src/OpenFOAM/meshes/meshShapes/face/faceI.H
@@ -132,21 +132,27 @@ inline Foam::edge Foam::face::faceEdge(const label n) const
 }
 
 
-inline bool Foam::face::found(const label globalIndex) const
+inline bool Foam::face::found(const label pointLabel) const
 {
-    return which(globalIndex) != -1;
+    return labelList::found(pointLabel);
+}
+
+
+inline Foam::label Foam::face::which(const label pointLabel) const
+{
+    return labelList::find(pointLabel);
 }
 
 
 inline Foam::label Foam::face::nextLabel(const label i) const
 {
-    return this->fcValue(i);
+    return labelList::fcValue(i);
 }
 
 
 inline Foam::label Foam::face::prevLabel(const label i) const
 {
-    return this->rcValue(i);
+    return labelList::rcValue(i);
 }
 
 
diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H
index 4b599dbd949..682e5b4cc1a 100644
--- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H
+++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H
@@ -146,12 +146,12 @@ public:
         //  The starting points of the original and reverse face are identical.
         inline triFace reverseFace() const;
 
-        //- Return true if the global point label is found in face.
-        bool found(const label globalIndex) const;
+        //- Return true if the point label is found in face.
+        inline bool found(const label pointLabel) const;
 
-        //- Which local index (0,1,2) on face given a global index.
-        //  returns -1 if not found
-        label which(const label globalIndex) const;
+        //- Find local index on face for the point label.
+        //  \return position in face (0,1,2) or -1 if not found.
+        inline label which(const label pointLabel) const;
 
         //- Return swept-volume from old-points to new-points
         inline scalar sweptVol
diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H
index 0e7f1dae9d5..9f645d2d4ef 100644
--- a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H
+++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H
@@ -209,18 +209,15 @@ inline Foam::triFace Foam::triFace::reverseFace() const
 }
 
 
-inline bool Foam::triFace::found(const label globalIndex) const
+inline bool Foam::triFace::found(const label pointLabel) const
 {
-    return which(globalIndex) != -1;
+    return FixedList<label, 3>::found(pointLabel);
 }
 
 
-inline Foam::label Foam::triFace::which(const label globalIndex) const
+inline Foam::label Foam::triFace::which(const label pointLabel) const
 {
-    if (operator[](0) == globalIndex) return 0;
-    if (operator[](1) == globalIndex) return 1;
-    if (operator[](2) == globalIndex) return 2;
-    return -1;
+    return FixedList<label, 3>::find(pointLabel);
 }
 
 
-- 
GitLab