From f35433bdeac4bb6d252cc0527a7253a28d26f992 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Thu, 12 Sep 2013 15:25:53 +0100
Subject: [PATCH] ENH: fvPatchField: move mapping logic into Field

---
 .../fvPatchFields/fvPatchField/fvPatchField.C | 58 +++++++------------
 .../fvPatchFields/fvPatchField/fvPatchField.H |  8 +++
 2 files changed, 28 insertions(+), 38 deletions(-)

diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
index 3059eb5eeac..23d3ef9c2b2 100644
--- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C
@@ -47,6 +47,23 @@ Foam::fvPatchField<Type>::fvPatchField
 {}
 
 
+template<class Type>
+Foam::fvPatchField<Type>::fvPatchField
+(
+    const fvPatch& p,
+    const DimensionedField<Type, volMesh>& iF,
+    const word& patchType
+)
+:
+    Field<Type>(p.size()),
+    patch_(p),
+    internalField_(iF),
+    updated_(false),
+    manipulatedMatrix_(false),
+    patchType_(patchType)
+{}
+
+
 template<class Type>
 Foam::fvPatchField<Type>::fvPatchField
 (
@@ -73,7 +90,7 @@ Foam::fvPatchField<Type>::fvPatchField
     const fvPatchFieldMapper& mapper
 )
 :
-    Field<Type>(ptf, mapper),
+    Field<Type>(p.size()),
     patch_(p),
     internalField_(iF),
     updated_(false),
@@ -83,44 +100,9 @@ Foam::fvPatchField<Type>::fvPatchField
     // For unmapped faces set to internal field value (zero-gradient)
     if (&iF && iF.size())
     {
-        Field<Type>& f = *this;
-
-        if
-        (
-            mapper.direct()
-         && &mapper.directAddressing()
-         && mapper.directAddressing().size()
-        )
-        {
-            Field<Type> pif(this->patchInternalField());
-
-            const labelList& mapAddressing = mapper.directAddressing();
-
-            forAll(mapAddressing, i)
-            {
-                if (mapAddressing[i] < 0)
-                {
-                    f[i] = pif[i];
-                }
-            }
-        }
-        else if (!mapper.direct() && mapper.addressing().size())
-        {
-            Field<Type> pif(this->patchInternalField());
-
-            const labelListList& mapAddressing = mapper.addressing();
-
-            forAll(mapAddressing, i)
-            {
-                const labelList& localAddrs = mapAddressing[i];
-
-                if (!localAddrs.size())
-                {
-                    f[i] = pif[i];
-                }
-            }
-        }
+        fvPatchField<Type>::operator=(this->patchInternalField());
     }
+    this->map(ptf, mapper);
 }
 
 
diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
index 3b9d54a2d33..5e9682634f6 100644
--- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
@@ -166,6 +166,14 @@ public:
             const DimensionedField<Type, volMesh>&
         );
 
+        //- Construct from patch and internal field and patch type
+        fvPatchField
+        (
+            const fvPatch&,
+            const DimensionedField<Type, volMesh>&,
+            const word& patchType
+        );
+
         //- Construct from patch and internal field and patch field
         fvPatchField
         (
-- 
GitLab