From 14a1aeaf7b5edf40f9275936fa501dc61d696d1f Mon Sep 17 00:00:00 2001
From: andy <andy>
Date: Wed, 9 Jan 2013 10:03:26 +0000
Subject: [PATCH] BUG: Added missing function implementation for Xi

---
 .../interpolation2DTable.C                    | 94 ++++++++++++++++++-
 1 file changed, 93 insertions(+), 1 deletion(-)

diff --git a/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C b/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C
index 54edd5a027e..98dd6f524a6 100644
--- a/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C
+++ b/src/OpenFOAM/interpolations/interpolation2DTable/interpolation2DTable.C
@@ -244,6 +244,98 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
 }
 
 
+template<class Type>
+template<class BinaryOp>
+Foam::label Foam::interpolation2DTable<Type>::Xi
+(
+    const BinaryOp& bop,
+    const scalar valueX,
+    const bool reverse
+) const
+{
+    const table& t = *this;
+
+    label limitI = 0;
+    if (reverse)
+    {
+        limitI = t.size() - 1;
+    }
+
+    if (bop(valueX, t[limitI].first()))
+    {
+        switch (boundsHandling_)
+        {
+            case interpolation2DTable::ERROR:
+            {
+                FatalErrorIn
+                (
+                    "Foam::label Foam::interpolation2DTable<Type>::Xi"
+                    "("
+                        "const BinaryOp&, "
+                        "const scalar, "
+                        "const bool"
+                    ") const"
+                )   << "value (" << valueX << ") out of bounds"
+                    << exit(FatalError);
+                break;
+            }
+            case interpolation2DTable::WARN:
+            {
+                WarningIn
+                (
+                    "Foam::label Foam::interpolation2DTable<Type>::Xi"
+                    "("
+                        "const BinaryOp&, "
+                        "const scalar, "
+                        "const bool"
+                )   << "value (" << valueX << ") out of bounds"
+                    << endl;
+                // fall-through to 'CLAMP'
+            }
+            case interpolation2DTable::CLAMP:
+            {
+                return limitI;
+            }
+            default:
+            {
+                FatalErrorIn
+                (
+                    "Foam::label Foam::interpolation2DTable<Type>::Xi"
+                    "("
+                        "const BinaryOp&, "
+                        "const scalar, "
+                        "const bool"
+                    ") const"
+                )
+                    << "Un-handled enumeration " << boundsHandling_
+                    << abort(FatalError);
+            }
+        }
+    }
+
+    label i = 0;
+    if (reverse)
+    {
+        label nX = t.size();
+        i = 0;
+        while ((i < nX) && (valueX > t[i].first()))
+        {
+            i++;
+        }
+    }
+    else
+    {
+        i = t.size() - 1;
+        while ((i > 0) && (valueX < t[i].first()))
+        {
+            i--;
+        }
+    }
+
+    return i;
+}
+
+
 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
 
 template<class Type>
@@ -262,7 +354,7 @@ Type Foam::interpolation2DTable<Type>::operator()
     {
         WarningIn
         (
-            "Type Foam::interpolation2DMatrix<Type>::operator()"
+            "Type Foam::interpolation2DTable<Type>::operator()"
             "("
                 "const scalar, "
                 "const scalar"
-- 
GitLab