From 5de5ae35ba475ce03165f295ab2fd3b3cc2489da Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Fri, 22 Feb 2019 18:11:00 +0100
Subject: [PATCH] ENH: add labelVector2D definition

- can be useful for 2D mesh dimensioning or possibly for matrices
---
 src/OpenFOAM/Make/files                       |  1 +
 .../Vector2D/labelVector2D/labelVector2D.C    | 73 +++++++++++++++++++
 .../Vector2D/labelVector2D/labelVector2D.H    | 65 +++++++++++++++++
 .../primitives/Vector2D/vector2D/vector2D.H   |  2 +-
 4 files changed, 140 insertions(+), 1 deletion(-)
 create mode 100644 src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.C
 create mode 100644 src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.H

diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
index 127e91e270c..978beb40fb5 100644
--- a/src/OpenFOAM/Make/files
+++ b/src/OpenFOAM/Make/files
@@ -88,6 +88,7 @@ primitives/Vector/lists/vectorListIOList.C
 primitives/Tensor2D/tensor2D/tensor2D.C
 primitives/SphericalTensor2D/sphericalTensor2D/sphericalTensor2D.C
 primitives/SymmTensor2D/symmTensor2D/symmTensor2D.C
+primitives/Vector2D/labelVector2D/labelVector2D.C
 primitives/Vector2D/vector2D/vector2D.C
 
 primitives/complex/complex.C
diff --git a/src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.C b/src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.C
new file mode 100644
index 00000000000..7b94cdd326a
--- /dev/null
+++ b/src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.C
@@ -0,0 +1,73 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2019 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+#include "labelVector2D.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+template<>
+const char* const Foam::labelVector2D::vsType::typeName = "labelVector2D";
+
+template<>
+const char* const Foam::labelVector2D::vsType::componentNames[] = { "x", "y" };
+
+template<>
+const Foam::labelVector2D Foam::labelVector2D::vsType::zero
+(
+    labelVector2D::uniform(0)
+);
+
+template<>
+const Foam::labelVector2D Foam::labelVector2D::vsType::one
+(
+    labelVector2D::uniform(1)
+);
+
+template<>
+const Foam::labelVector2D Foam::labelVector2D::vsType::max
+(
+    labelVector2D::uniform(labelMax)
+);
+
+template<>
+const Foam::labelVector2D Foam::labelVector2D::vsType::min
+(
+    labelVector2D::uniform(-labelMax)
+);
+
+template<>
+const Foam::labelVector2D Foam::labelVector2D::vsType::rootMax
+(
+    labelVector2D::uniform(sqrt(scalar(labelMax)))
+);
+
+template<>
+const Foam::labelVector2D Foam::labelVector2D::vsType::rootMin
+(
+    labelVector2D::uniform(-sqrt(scalar(labelMax)))
+);
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.H b/src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.H
new file mode 100644
index 00000000000..5c558f9adeb
--- /dev/null
+++ b/src/OpenFOAM/primitives/Vector2D/labelVector2D/labelVector2D.H
@@ -0,0 +1,65 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2019 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Typedef
+    Foam::labelVector2D
+
+Description
+    A 2D vector of labels obtained from the generic Vector2D.
+
+SourceFiles
+    labelVector2D.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef labelVector2D_H
+#define labelVector2D_H
+
+#include "label.H"
+#include "Vector2D.H"
+#include "contiguous.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+typedef Vector2D<label> labelVector2D;
+
+
+//- Data associated with labelVector2D type are contiguous
+template<>
+inline bool contiguous<labelVector2D>() {return true;}
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.H b/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.H
index 239dabb686f..cd7d2fa33cc 100644
--- a/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.H
+++ b/src/OpenFOAM/primitives/Vector2D/vector2D/vector2D.H
@@ -27,7 +27,7 @@ Typedef
     Foam::vector2D
 
 Description
-    vector2D obtained from generic Vector2D
+    A 2D vector of scalars obtained from the generic Vector2D.
 
 SourceFiles
     vector2D.C
-- 
GitLab