From d25b19f6aa374b18d7c07537501e14cc70c0c97e Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Thu, 18 Jul 2019 09:59:58 +0200
Subject: [PATCH] ENH: add Barycentric2D outside() test

---
 .../primitives/Barycentric2D/Barycentric2D.H  | 30 ++++++++++++-------
 .../primitives/Barycentric2D/Barycentric2DI.H |  9 +++++-
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/src/OpenFOAM/primitives/Barycentric2D/Barycentric2D.H b/src/OpenFOAM/primitives/Barycentric2D/Barycentric2D.H
index b5c46093c98..ed29386b972 100644
--- a/src/OpenFOAM/primitives/Barycentric2D/Barycentric2D.H
+++ b/src/OpenFOAM/primitives/Barycentric2D/Barycentric2D.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) 2017 OpenFOAM Foundation
@@ -27,8 +27,8 @@ Class
     Foam::Barycentric2D
 
 Description
-    Templated 2D Barycentric derived from VectorSpace. Has 3 components, one of
-    which is redundant.
+    Templated 2D Barycentric derived from VectorSpace.
+    Has 3 components, one of which is redundant.
 
 SourceFiles
     Barycentric2DI.H
@@ -89,15 +89,25 @@ public:
 
     // Member Functions
 
-        // Access
+    // Access
 
-            inline const Cmpt& a() const;
-            inline const Cmpt& b() const;
-            inline const Cmpt& c() const;
+        inline const Cmpt& a() const;
+        inline const Cmpt& b() const;
+        inline const Cmpt& c() const;
+
+
+    // Edit
+
+        inline Cmpt& a();
+        inline Cmpt& b();
+        inline Cmpt& c();
+
+
+    // Tests
+
+        //- True if any coordinates are negative
+        inline bool outside() const;
 
-            inline Cmpt& a();
-            inline Cmpt& b();
-            inline Cmpt& c();
 };
 
 
diff --git a/src/OpenFOAM/primitives/Barycentric2D/Barycentric2DI.H b/src/OpenFOAM/primitives/Barycentric2D/Barycentric2DI.H
index 3d5893403a9..63a0e1f4686 100644
--- a/src/OpenFOAM/primitives/Barycentric2D/Barycentric2DI.H
+++ b/src/OpenFOAM/primitives/Barycentric2D/Barycentric2DI.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) 2017 OpenFOAM Foundation
@@ -97,6 +97,13 @@ inline Cmpt& Foam::Barycentric2D<Cmpt>::c()
 }
 
 
+template<class Cmpt>
+inline bool Foam::Barycentric2D<Cmpt>::outside() const
+{
+    return ((this->v_[A] < 0) || (this->v_[B]) < 0 || (this->v_[C] < 0));
+}
+
+
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
-- 
GitLab