From d7d331f4716fef1a782b12e3fabe5935729931fb Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Tue, 15 Mar 2016 22:36:56 +0000
Subject: [PATCH] MatrixSpace::Block: Added "dereference" operator for
 conversion to sub-tensor

---
 .../primitives/MatrixSpace/MatrixSpace.H      |  6 +++++
 .../primitives/MatrixSpace/MatrixSpaceI.H     | 22 +++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H
index 1d7bcec20dd..7d1b1186f4b 100644
--- a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H
+++ b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpace.H
@@ -117,6 +117,9 @@ public:
             //- Construct for the given matrix
             inline ConstBlock(const msType& matrix);
 
+            //- Construct and return the sub-ensor corresponding to this block
+            inline SubTensor operator()() const;
+
             //- (i, j) const element access operator
             inline const Cmpt& operator()
             (
@@ -178,6 +181,9 @@ public:
                 const VectorSpace<VSForm, Cmpt, SubTensor::nRows>& v
             );
 
+            //- Construct and return the sub-ensor corresponding to this block
+            inline SubTensor operator()() const;
+
             //- (i, j) const element access operator
             inline const Cmpt& operator()
             (
diff --git a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H
index e8df098a948..a7afa55fdfc 100644
--- a/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H
+++ b/src/OpenFOAM/primitives/MatrixSpace/MatrixSpaceI.H
@@ -359,6 +359,17 @@ inline Cmpt& Foam::MatrixSpace<Form, Cmpt, Nrows, Ncols>::operator()
 }
 
 
+template<class Form, class Cmpt, Foam::direction Nrows, Foam::direction Ncols>
+template<class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
+inline SubTensor
+Foam::MatrixSpace<Form, Cmpt, Nrows, Ncols>::
+ConstBlock<SubTensor, BRowStart, BColStart>::
+operator()() const
+{
+    return *this;
+}
+
+
 template<class Form, class Cmpt, Foam::direction Nrows, Foam::direction Ncols>
 template<class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
 inline const Cmpt&
@@ -370,6 +381,17 @@ operator()(const direction i, const direction j) const
 }
 
 
+template<class Form, class Cmpt, Foam::direction Nrows, Foam::direction Ncols>
+template<class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
+inline SubTensor
+Foam::MatrixSpace<Form, Cmpt, Nrows, Ncols>::
+Block<SubTensor, BRowStart, BColStart>::
+operator()() const
+{
+    return *this;
+}
+
+
 template<class Form, class Cmpt, Foam::direction Nrows, Foam::direction Ncols>
 template<class SubTensor, Foam::direction BRowStart, Foam::direction BColStart>
 inline const Cmpt&
-- 
GitLab