From 1f89e6562438dd43ee30fe6d09db167aa8a42ec8 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Sat, 19 Mar 2016 21:19:14 +0000
Subject: [PATCH] SubList, SubField: Added assignment to UList

---
 .../containers/Lists/SubList/SubList.H        |  3 +++
 .../containers/Lists/SubList/SubListI.H       |  7 ++++++
 src/OpenFOAM/fields/Fields/Field/SubField.H   |  8 +++++++
 src/OpenFOAM/fields/Fields/Field/SubFieldI.H  | 24 ++++++++++++++++++-
 4 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/src/OpenFOAM/containers/Lists/SubList/SubList.H b/src/OpenFOAM/containers/Lists/SubList/SubList.H
index b75745382ae..efaff633e7b 100644
--- a/src/OpenFOAM/containers/Lists/SubList/SubList.H
+++ b/src/OpenFOAM/containers/Lists/SubList/SubList.H
@@ -87,6 +87,9 @@ public:
         //- Allow cast to a const List<T>&
         inline operator const Foam::List<T>&() const;
 
+        //- Assignment of all entries to the given list
+        inline void operator=(const UList<T>&);
+
         //- Assignment of all entries to the given value
         inline void operator=(const T&);
 };
diff --git a/src/OpenFOAM/containers/Lists/SubList/SubListI.H b/src/OpenFOAM/containers/Lists/SubList/SubListI.H
index 90b6ce6d288..2a7f5c19ef0 100644
--- a/src/OpenFOAM/containers/Lists/SubList/SubListI.H
+++ b/src/OpenFOAM/containers/Lists/SubList/SubListI.H
@@ -87,6 +87,13 @@ inline Foam::SubList<T>::operator const Foam::List<T>&() const
 }
 
 
+template<class T>
+inline void Foam::SubList<T>::operator=(const UList<T>& l)
+{
+    UList<T>::assign(l);
+}
+
+
 template<class T>
 inline void Foam::SubList<T>::operator=(const T& t)
 {
diff --git a/src/OpenFOAM/fields/Fields/Field/SubField.H b/src/OpenFOAM/fields/Fields/Field/SubField.H
index ec3d1502953..07ecd1443fc 100644
--- a/src/OpenFOAM/fields/Fields/Field/SubField.H
+++ b/src/OpenFOAM/fields/Fields/Field/SubField.H
@@ -41,6 +41,7 @@ SourceFiles
 
 #include "SubList.H"
 #include "Field.H"
+#include "VectorSpace.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -112,6 +113,13 @@ public:
         //- Assignment via UList operator. Takes linear time.
         inline void operator=(const SubField<Type>&);
 
+        //- Assignment via UList operator. Takes linear time.
+        inline void operator=(const Field<Type>&);
+
+        //- Assignment via UList operator. Takes linear time.
+        template<class Form, direction Ncmpts>
+        inline void operator=(const VectorSpace<Form, Type, Ncmpts>&);
+
         //- Allow cast to a const Field\<Type\>&
         inline operator const Field<Type>&() const;
 };
diff --git a/src/OpenFOAM/fields/Fields/Field/SubFieldI.H b/src/OpenFOAM/fields/Fields/Field/SubFieldI.H
index 796b2995c22..8ba1ee89291 100644
--- a/src/OpenFOAM/fields/Fields/Field/SubFieldI.H
+++ b/src/OpenFOAM/fields/Fields/Field/SubFieldI.H
@@ -111,7 +111,29 @@ inline Foam::tmp<Foam::Field<Type>> Foam::SubField<Type>::T() const
 template<class Type>
 inline void Foam::SubField<Type>::operator=(const SubField<Type>& rhs)
 {
-    UList<Type>::operator=(rhs);
+    SubList<Type>::operator=(rhs);
+}
+
+
+template<class Type>
+inline void Foam::SubField<Type>::operator=(const Field<Type>& rhs)
+{
+    SubList<Type>::operator=(rhs);
+    InfoInFunction << *this << endl;
+}
+
+
+template<class Type>
+template<class Form, Foam::direction Ncmpts>
+inline void Foam::SubField<Type>::operator=
+(
+    const VectorSpace<Form, Type, Ncmpts>& rhs
+)
+{
+    forAll(rhs, i)
+    {
+        this->operator[](i) = rhs[i];
+    }
 }
 
 
-- 
GitLab