From aa9be5b5cd38e8ebe9625bf173cb9ee10b97afd8 Mon Sep 17 00:00:00 2001
From: Andrew Heather <>
Date: Wed, 11 Mar 2020 15:26:40 +0000
Subject: [PATCH] ENH: nearWallFields - updated construction of sampled field. 
 Fixes #1620

---
 .../nearWallFields/nearWallFieldsTemplates.C  | 22 +++++++++++--------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/functionObjects/field/nearWallFields/nearWallFieldsTemplates.C b/src/functionObjects/field/nearWallFields/nearWallFieldsTemplates.C
index 077ab87efc1..bc5ae6a5236 100644
--- a/src/functionObjects/field/nearWallFields/nearWallFieldsTemplates.C
+++ b/src/functionObjects/field/nearWallFields/nearWallFieldsTemplates.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2015-2018 OpenCFD Ltd.
+    Copyright (C) 2015-2020 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -64,16 +64,20 @@ void Foam::functionObjects::nearWallFields::createFields
                 io.readOpt() = IOobject::NO_READ;
                 io.writeOpt() = IOobject::NO_WRITE;
 
-                // Override bc to be calculated
-                wordList fldTypes(fld.boundaryField().types());
-                for (const label patchi : patchSet_)
-                {
-                    fldTypes[patchi] = calculatedFvPatchField<Type>::typeName;
-                }
-
                 io.rename(sampleFldName);
 
-                sflds.set(sz, new VolFieldType(io, fld, fldTypes));
+                // Override bc to be calculated
+                sflds.set
+                (
+                    sz,
+                    new VolFieldType
+                    (
+                        io,
+                        fld,
+                        patchSet_.toc(),
+                        calculatedFvPatchField<Type>::typeName
+                    )
+                );
 
                 Log << "    created " << sflds[sz].name()
                     << " to sample " << fld.name() << endl;
-- 
GitLab