From 29e6c81af8daacaf6d649f671dcf1cd647ce1d9a Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Thu, 16 May 2019 14:06:40 +0100
Subject: [PATCH] STYLE: add namespace qualifiers to interpolationWeights

---
 .../interpolationWeights.C                    | 14 ++---
 .../interpolationWeights.H                    | 17 +++---
 .../interpolationWeightsTemplates.C           | 27 +++------
 .../linearInterpolationWeights.C              | 55 +++++++++----------
 .../linearInterpolationWeights.H              | 31 ++++-------
 .../splineInterpolationWeights.C              | 30 ++++------
 .../splineInterpolationWeights.H              | 19 +++----
 7 files changed, 78 insertions(+), 115 deletions(-)

diff --git a/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.C b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.C
index afb3f343fbf..cb6fa4db599 100644
--- a/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.C
+++ b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           |
+    \\  /    A nd           | Copyright (C) 2019 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
                             | Copyright (C) 2012-2015 OpenFOAM Foundation
@@ -33,9 +33,9 @@ License
 
 namespace Foam
 {
-defineTypeNameAndDebug(interpolationWeights, 0);
-defineRunTimeSelectionTable(interpolationWeights, word);
-}
+    defineTypeNameAndDebug(interpolationWeights, 0);
+    defineRunTimeSelectionTable(interpolationWeights, word);
+} // End namespace Foam
 
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
@@ -77,10 +77,4 @@ Foam::autoPtr<Foam::interpolationWeights> Foam::interpolationWeights::New
 }
 
 
-// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
-
-Foam::interpolationWeights::~interpolationWeights()
-{}
-
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.H b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.H
index e3a428a492e..3a43a12306b 100644
--- a/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.H
+++ b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           |
+    \\  /    A nd           | Copyright (C) 2019 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
                             | Copyright (C) 2012-2016 OpenFOAM Foundation
@@ -57,10 +57,14 @@ class objectRegistry;
 
 class interpolationWeights
 {
+protected:
+
+    // Protected Data
+
+        const scalarField& samples_;
 
-private:
 
-    // Private Member Functions
+    // Protected Member Functions
 
         //- No copy construct
         interpolationWeights(const interpolationWeights&) = delete;
@@ -68,9 +72,6 @@ private:
         //- No copy assignment
         void operator=(const interpolationWeights&) = delete;
 
-protected:
-
-        const scalarField& samples_;
 
 public:
 
@@ -95,7 +96,7 @@ public:
     // Constructors
 
         //- Construct from components
-        interpolationWeights(const scalarField& samples);
+        explicit interpolationWeights(const scalarField& samples);
 
 
     // Selectors
@@ -109,7 +110,7 @@ public:
 
 
     //- Destructor
-    virtual ~interpolationWeights();
+    virtual ~interpolationWeights() = default;
 
 
     // Member Functions
diff --git a/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeightsTemplates.C b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeightsTemplates.C
index aaab57f8670..301faeee07e 100644
--- a/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeightsTemplates.C
+++ b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeightsTemplates.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           |
+    \\  /    A nd           | Copyright (C) 2019 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
                             | Copyright (C) 2012-2016 OpenFOAM Foundation
@@ -26,15 +26,7 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "interpolationWeights.H"
-#include "ListOps.H"
-#include "IOobject.H"
-#include "HashSet.H"
-#include "objectRegistry.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
+#include "products.H"
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
@@ -56,24 +48,19 @@ Foam::interpolationWeights::weightedSum
         typename ListType2::value_type
     >::type returnType;
 
-    if (f1.size())
+    const label len = f1.size();
+    if (len)
     {
         returnType SumProd = f1[0]*f2[0];
-        for (label i = 1; i < f1.size(); ++i)
+        for (label i = 1; i < len; ++i)
         {
             SumProd += f1[i]*f2[i];
         }
         return SumProd;
     }
-    else
-    {
-        return Zero;
-    }
-}
 
+    return Zero;
+}
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
 
 // ************************************************************************* //
diff --git a/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.C b/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.C
index b9a2586bf47..7c482631c26 100644
--- a/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.C
+++ b/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           |
+    \\  /    A nd           | Copyright (C) 2019 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
                             | Copyright (C) 2012-2015 OpenFOAM Foundation
@@ -30,25 +30,23 @@ License
 #include "ListOps.H"
 #include "Pair.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
 namespace Foam
 {
-
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-defineTypeNameAndDebug(linearInterpolationWeights, 0);
-addToRunTimeSelectionTable
-(
-    interpolationWeights,
-    linearInterpolationWeights,
-    word
-);
+    defineTypeNameAndDebug(linearInterpolationWeights, 0);
+    addToRunTimeSelectionTable
+    (
+        interpolationWeights,
+        linearInterpolationWeights,
+        word
+    );
+} // End namespace Foam
 
 
 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
 
-Foam::Pair<Foam::scalar> linearInterpolationWeights::integrationWeights
+Foam::Pair<Foam::scalar> Foam::linearInterpolationWeights::integrationWeights
 (
     const label i,
     const scalar t
@@ -56,7 +54,7 @@ Foam::Pair<Foam::scalar> linearInterpolationWeights::integrationWeights
 {
     // t is in range samples_[i] .. samples_[i+1]
 
-    scalar s = (t-samples_[i])/(samples_[i+1]-samples_[i]);
+    const scalar s = (t-samples_[i])/(samples_[i+1]-samples_[i]);
 
     if (s < -SMALL || s > 1+SMALL)
     {
@@ -66,7 +64,7 @@ Foam::Pair<Foam::scalar> linearInterpolationWeights::integrationWeights
             << exit(FatalError);
     }
 
-    scalar d = samples_[i+1]-t;
+    const scalar d = samples_[i+1]-t;
 
     return Pair<scalar>(d*0.5*(1-s), d*0.5*(1+s));
 }
@@ -74,7 +72,7 @@ Foam::Pair<Foam::scalar> linearInterpolationWeights::integrationWeights
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-linearInterpolationWeights::linearInterpolationWeights
+Foam::linearInterpolationWeights::linearInterpolationWeights
 (
     const scalarField& samples
 )
@@ -86,7 +84,7 @@ linearInterpolationWeights::linearInterpolationWeights
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool linearInterpolationWeights::valueWeights
+bool Foam::linearInterpolationWeights::valueWeights
 (
     const scalar t,
     labelList& indices,
@@ -153,7 +151,7 @@ bool linearInterpolationWeights::valueWeights
 }
 
 
-bool linearInterpolationWeights::integrationWeights
+bool Foam::linearInterpolationWeights::integrationWeights
 (
     const scalar t1,
     const scalar t2,
@@ -172,9 +170,10 @@ bool linearInterpolationWeights::integrationWeights
     // Currently no fancy logic on cached index like in value
 
     //- Find lower or equal index
-    label i1 = findLower(samples_, t1, 0, lessEqOp<scalar>());
+    const label i1 = findLower(samples_, t1, 0, lessEqOp<scalar>());
+
     //- Find lower index
-    label i2 = findLower(samples_, t2);
+    const label i2 = findLower(samples_, t2);
 
     // For now just fail if any outside table
     if (i1 == -1 || i2 == samples_.size()-1)
@@ -185,7 +184,7 @@ bool linearInterpolationWeights::integrationWeights
             << " t1:" << t1 << " t2:" << t2 << exit(FatalError);
     }
 
-    label nIndices = i2-i1+2;
+    const label nIndices = i2-i1+2;
 
 
     // Determine if indices already correct
@@ -218,7 +217,7 @@ bool linearInterpolationWeights::integrationWeights
     // Sum from i1+1 to i2+1
     for (label i = i1+1; i <= i2; i++)
     {
-        scalar d = samples_[i+1]-samples_[i];
+        const scalar d = samples_[i+1]-samples_[i];
         indices[i-i1] = i;
         weights[i-i1] += 0.5*d;
         indices[i+1-i1] = i+1;
@@ -227,19 +226,19 @@ bool linearInterpolationWeights::integrationWeights
 
     // Add from i1 to t1
     {
-        Pair<scalar> i1Tot1 = integrationWeights(i1, t1);
+        const Pair<scalar> i1Tot1 = integrationWeights(i1, t1);
         indices[0] = i1;
-        weights[0] += i1Tot1.first();
         indices[1] = i1+1;
+        weights[0] += i1Tot1.first();
         weights[1] += i1Tot1.second();
     }
 
     // Subtract from t2 to i2+1
     {
-        Pair<scalar> wghts = integrationWeights(i2, t2);
+        const Pair<scalar> wghts = integrationWeights(i2, t2);
         indices[i2-i1] = i2;
-        weights[i2-i1] += -wghts.first();
         indices[i2-i1+1] = i2+1;
+        weights[i2-i1] += -wghts.first();
         weights[i2-i1+1] += -wghts.second();
     }
 
@@ -247,8 +246,4 @@ bool linearInterpolationWeights::integrationWeights
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.H b/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.H
index 3d25aacccea..6de0a21d181 100644
--- a/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.H
+++ b/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           |
+    \\  /    A nd           | Copyright (C) 2019 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
                             | Copyright (C) 2012 OpenFOAM Foundation
@@ -51,47 +51,39 @@ class linearInterpolationWeights
 :
     public interpolationWeights
 {
-
-private:
-
-    // Private data
+    // Private Data
 
         //- Cached index in samples from previous invocation
         mutable label index_;
 
+
     // Private Member Functions
 
         //- Get weights of i and i+1 to calculate integration from t to
-        //  samples_[i+1]
-        Pair<scalar> integrationWeights
-        (
-            const label i,
-            const scalar t
-        ) const;
+        //- samples_[i+1]
+        Pair<scalar> integrationWeights(const label i, const scalar t) const;
+
 
 public:
 
     //- Runtime type information
     TypeName("linear");
 
+
     // Constructors
 
         //- Construct from components
-        linearInterpolationWeights
-        (
-            const scalarField& samples
-        );
+        explicit linearInterpolationWeights(const scalarField& samples);
 
 
     //- Destructor
-    virtual ~linearInterpolationWeights()
-    {}
+    virtual ~linearInterpolationWeights() = default;
 
 
     // Member Functions
 
         //- Calculate weights and indices to calculate t from samples.
-        //  Returns true if indices changed.
+        //  \return true if indices changed.
         virtual bool valueWeights
         (
             const scalar t,
@@ -100,7 +92,8 @@ public:
         ) const;
 
         //- Calculate weights and indices to calculate integrand of t1..t2
-        //  from samples. Returns true if indices changed.
+        //- from samples.
+        //  \return true if indices changed.
         virtual bool integrationWeights
         (
             const scalar t1,
diff --git a/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.C b/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.C
index 5d2bb88d1b8..060aa33cc53 100644
--- a/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.C
+++ b/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           |
+    \\  /    A nd           | Copyright (C) 2019 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
                             | Copyright (C) 2012-2015 OpenFOAM Foundation
@@ -30,25 +30,23 @@ License
 #include "ListOps.H"
 #include "linearInterpolationWeights.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
 namespace Foam
 {
-
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-defineTypeNameAndDebug(splineInterpolationWeights, 0);
-addToRunTimeSelectionTable
-(
-    interpolationWeights,
-    splineInterpolationWeights,
-    word
-);
+    defineTypeNameAndDebug(splineInterpolationWeights, 0);
+    addToRunTimeSelectionTable
+    (
+        interpolationWeights,
+        splineInterpolationWeights,
+        word
+    );
+} // End namespace Foam
 
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-splineInterpolationWeights::splineInterpolationWeights
+Foam::splineInterpolationWeights::splineInterpolationWeights
 (
     const scalarField& samples,
     const bool checkEqualDistance
@@ -80,7 +78,7 @@ splineInterpolationWeights::splineInterpolationWeights
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool splineInterpolationWeights::valueWeights
+bool Foam::splineInterpolationWeights::valueWeights
 (
     const scalar t,
     labelList& indices,
@@ -220,8 +218,4 @@ bool splineInterpolationWeights::valueWeights
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.H b/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.H
index 0c08b9e9a37..e65c706402f 100644
--- a/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.H
+++ b/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           |
+    \\  /    A nd           | Copyright (C) 2019 OpenCFD Ltd.
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
                             | Copyright (C) 2012-2015 OpenFOAM Foundation
@@ -52,24 +52,23 @@ class splineInterpolationWeights
 :
     public interpolationWeights
 {
-
-private:
-
-    // Private data
+    // Private Data
 
         //- Cached index in samples from previous invocation
         mutable label index_;
 
+
 public:
 
     //- Runtime type information
     TypeName("spline");
 
+
     // Constructors
 
         //- Construct from components. By default make sure samples are
         //  equidistant.
-        splineInterpolationWeights
+        explicit splineInterpolationWeights
         (
             const scalarField& samples,
             const bool checkEqualDistance = true
@@ -77,14 +76,13 @@ public:
 
 
     //- Destructor
-    virtual ~splineInterpolationWeights()
-    {}
+    virtual ~splineInterpolationWeights() = default;
 
 
     // Member Functions
 
         //- Calculate weights and indices to calculate t from samples.
-        //  Returns true if indices changed.
+        //  \return true if indices changed.
         virtual bool valueWeights
         (
             const scalar t,
@@ -93,7 +91,8 @@ public:
         ) const;
 
         //- Calculate weights and indices to calculate integrand of t1..t2
-        //  from samples. Returns true if indices changed.
+        //- from samples.
+        //  \return true if indices changed.
         virtual bool integrationWeights
         (
             const scalar t1,
-- 
GitLab