From b0891824fa0cee458098b3c55b496d55d3b7f6f9 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Tue, 1 Jun 2021 12:07:20 +0200
Subject: [PATCH] ENH: improve codeTemplates

- meshTools include/library for many (most) coded items

- add PatchFunction1 include for coded BCs to provide ready access
  to Function1 and PatchFunction1
---
 .../dynamicCode/codedFvOptionTemplate.C       | 26 ++++----
 .../dynamicCode/codedFvOptionTemplate.H       | 10 +--
 .../dynamicCode/codedPatchFunction1Template.C | 12 ++--
 .../dynamicCode/codedPatchFunction1Template.H |  7 +-
 .../codedPoints0MotionSolverTemplate.C        |  3 +-
 .../codedPoints0MotionSolverTemplate.H        |  8 ++-
 .../fixedValueFvPatchFieldTemplate.C          | 24 +++----
 .../fixedValueFvPatchFieldTemplate.H          |  7 +-
 .../fixedValuePointPatchFieldTemplate.C       | 24 +++----
 .../fixedValuePointPatchFieldTemplate.H       | 11 ++--
 .../dynamicCode/functionObjectTemplate.C      | 15 +++--
 .../dynamicCode/functionObjectTemplate.H      | 14 ++--
 .../dynamicCode/mixedFvPatchFieldTemplate.C   | 24 +++----
 .../dynamicCode/mixedFvPatchFieldTemplate.H   | 11 ++--
 .../codedFixedValuePointPatchField.C          | 47 +++++++-------
 .../codedFixedValuePointPatchField.H          | 13 ++++
 .../codedPoints0/codedPoints0MotionSolver.H   |  8 +--
 .../codedFixedValueFvPatchField.C             | 47 +++++++-------
 .../codedFixedValueFvPatchField.H             | 13 ++++
 .../codedMixed/codedMixedFvPatchField.C       | 64 +++++++++----------
 .../codedMixed/codedMixedFvPatchField.H       | 17 ++++-
 .../codedFunctionObject/codedFunctionObject.C |  5 +-
 .../codedFunctionObject/codedFunctionObject.H | 14 ++--
 .../PatchFunction1/CodedField/CodedField.C    | 17 +++--
 .../PatchFunction1/CodedField/CodedField.H    | 34 ++++++----
 .../twoSimpleRotors/system/controlDict        |  6 +-
 .../rutlandVortex2D/system/preProcess         | 19 ++----
 .../poolEvaporation/0.orig/T                  |  7 +-
 28 files changed, 288 insertions(+), 219 deletions(-)

diff --git a/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.C b/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.C
index 8ad03757984..d6c4f935d60 100644
--- a/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.C
+++ b/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2019 OpenCFD Ltd.
+    Copyright (C) 2019-2021 OpenCFD Ltd.
     Copyright (C) YEAR AUTHOR, AFFILIATION
 -------------------------------------------------------------------------------
 License
@@ -95,11 +95,11 @@ ${typeName}FvOption${SourceType}
     const fvMesh& mesh
 )
 :
-    cellSetOption(name, modelType, dict, mesh)
+    fv::cellSetOption(name, modelType, dict, mesh)
 {
     if (${verbose:-false})
     {
-        printMessage("Construct ${typeName} from components");
+        printMessage("Construct ${typeName} fvOption from dictionary");
     }
 }
 
@@ -118,14 +118,15 @@ ${typeName}FvOption${SourceType}::
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void ${typeName}FvOption${SourceType}::correct
+void
+${typeName}FvOption${SourceType}::correct
 (
     GeometricField<${TemplateType}, fvPatchField, volMesh>& fld
 )
 {
     if (${verbose:-false})
     {
-        Info<<"${typeName}FvOption${SourceType}::correct()\n";
+        Info<< "${typeName}FvOption${SourceType}::correct()\n";
     }
 
 //{{{ begin code
@@ -134,7 +135,8 @@ void ${typeName}FvOption${SourceType}::correct
 }
 
 
-void ${typeName}FvOption${SourceType}::addSup
+void
+${typeName}FvOption${SourceType}::addSup
 (
     fvMatrix<${TemplateType}>& eqn,
     const label fieldi
@@ -142,7 +144,7 @@ void ${typeName}FvOption${SourceType}::addSup
 {
     if (${verbose:-false})
     {
-        Info<<"${typeName}FvOption${SourceType}::addSup()\n";
+        Info<< "${typeName}FvOption${SourceType}::addSup()\n";
     }
 
 //{{{ begin code
@@ -151,7 +153,8 @@ void ${typeName}FvOption${SourceType}::addSup
 }
 
 
-void ${typeName}FvOption${SourceType}::addSup
+void
+${typeName}FvOption${SourceType}::addSup
 (
     const volScalarField& rho,
     fvMatrix<${TemplateType}>& eqn,
@@ -160,7 +163,7 @@ void ${typeName}FvOption${SourceType}::addSup
 {
     if (${verbose:-false})
     {
-        Info<<"${typeName}FvOption${SourceType}::addSup()\n";
+        Info<< "${typeName}FvOption${SourceType}::addSup()\n";
     }
 
 //{{{ begin code
@@ -169,7 +172,8 @@ void ${typeName}FvOption${SourceType}::addSup
 }
 
 
-void ${typeName}FvOption${SourceType}::constrain
+void
+${typeName}FvOption${SourceType}::constrain
 (
     fvMatrix<${TemplateType}>& eqn,
     const label fieldi
@@ -177,7 +181,7 @@ void ${typeName}FvOption${SourceType}::constrain
 {
     if (${verbose:-false})
     {
-        Info<<"${typeName}FvOption${SourceType}::constrain()\n";
+        Info<< "${typeName}FvOption${SourceType}::constrain()\n";
     }
 
 //{{{ begin code
diff --git a/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.H b/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.H
index cafab99cdb0..c9d397e1d1c 100644
--- a/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.H
+++ b/etc/codeTemplates/dynamicCode/codedFvOptionTemplate.H
@@ -5,8 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2019 OpenCFD Ltd.
-    Copyright (C) YEAR AUTHOR, AFFILIATION
+    Copyright (C) 2019-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -25,7 +24,7 @@ License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
 Description
-    Template for use with dynamic code generation of a source.
+    Template for use with dynamic code generation of a finiteVolume source.
     The hook functions take the following arguments:
 
     \verbatim
@@ -117,7 +116,7 @@ namespace fv
 
 class ${typeName}FvOption${SourceType}
 :
-    public cellSetOption
+    public fv::cellSetOption
 {
     // Private Member Functions
 
@@ -138,7 +137,7 @@ public:
 
     // Constructors
 
-        //- Construct from patch and internal field
+        //- Construct from mesh
         ${typeName}FvOption${SourceType}
         (
             const word& name,
@@ -147,6 +146,7 @@ public:
             const fvMesh& mesh
         );
 
+
     //- Destructor
     virtual ~${typeName}FvOption${SourceType}();
 
diff --git a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C
index 06e5eb00d75..cc7cc9e1cd0 100644
--- a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C
+++ b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.C
@@ -5,6 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
+    Copyright (C) 2021 OpenCFD Ltd.
     Copyright (C) YEAR AUTHOR,AFFILIATION
 -------------------------------------------------------------------------------
 License
@@ -37,6 +38,7 @@ License
 ${codeInclude}
 //}}} end codeInclude
 
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 namespace Foam
 {
@@ -96,11 +98,11 @@ ${typeName}PatchFunction1${FieldType}
     const bool faceValues
 )
 :
-    PatchFunction1<${TemplateType}>(pp, entryName, dict, faceValues)
+    parent_bctype(pp, entryName, dict, faceValues)
 {
     if (${verbose:-false})
     {
-        printMessage("Construct ${typeName} from components");
+        printMessage("Construct ${typeName} PatchFunction1 from dictionary");
     }
 }
 
@@ -111,7 +113,7 @@ ${typeName}PatchFunction1${FieldType}
     const ${typeName}PatchFunction1${FieldType}& rhs
 )
 :
-    PatchFunction1<${TemplateType}>(rhs)
+    parent_bctype(rhs)
 {}
 
 
@@ -122,13 +124,13 @@ ${typeName}PatchFunction1${FieldType}
     const polyPatch& pp
 )
 :
-    PatchFunction1<${TemplateType}>(rhs, pp)
+    parent_bctype(rhs, pp)
 {}
 
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-tmp<Field<${TemplateType}>>
+Foam::tmp<Foam::Field<Foam::${TemplateType}>>
 ${typeName}PatchFunction1${FieldType}::value
 (
     const scalar x
diff --git a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H
index 0aeaf7059e0..21b712f3568 100644
--- a/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H
+++ b/etc/codeTemplates/dynamicCode/codedPatchFunction1Template.H
@@ -5,8 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2020 OpenCFD Ltd.
-    Copyright (C) YEAR AUTHOR, AFFILIATION
+    Copyright (C) 2020-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -52,6 +51,10 @@ class ${typeName}PatchFunction1${FieldType}
 :
     public PatchFunction1<${TemplateType}>
 {
+    //- The parent PatchFunction1 type
+    typedef PatchFunction1<${TemplateType}> parent_bctype;
+
+
     // Private Member Functions
 
         //- Report a message with the SHA1sum
diff --git a/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.C b/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.C
index 386b870923f..d38ef18c97e 100644
--- a/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.C
+++ b/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2018-2019 OpenCFD Ltd.
+    Copyright (C) 2018-2021 OpenCFD Ltd.
     Copyright (C) YEAR AUTHOR, AFFILIATION
 -------------------------------------------------------------------------------
 License
@@ -27,6 +27,7 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "codedPoints0MotionSolverTemplate.H"
+#define namespaceFoam  // Suppress <using namespace Foam;>
 #include "fvCFD.H"
 #include "unitConversion.H"
 #include "addToRunTimeSelectionTable.H"
diff --git a/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.H b/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.H
index 8bcca47ad37..5a8c45b4309 100644
--- a/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.H
+++ b/etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.H
@@ -5,8 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2018-2019 OpenCFD Ltd.
-    Copyright (C) YEAR AUTHOR, AFFILIATION
+    Copyright (C) 2018-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -70,7 +69,10 @@ class ${typeName}Points0MotionSolver
         ) = delete;
 
         //- No copy assignment
-        void operator=(const ${typeName}Points0MotionSolver&) = delete;
+        void operator=
+        (
+            const ${typeName}Points0MotionSolver&
+        ) = delete;
 
 
 public:
diff --git a/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C
index 71494cf806e..a9db42f5fde 100644
--- a/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C
+++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2019 OpenCFD Ltd.
+    Copyright (C) 2019-2021 OpenCFD Ltd.
     Copyright (C) YEAR AUTHOR, AFFILIATION
 -------------------------------------------------------------------------------
 License
@@ -32,6 +32,7 @@ License
 #include "volFields.H"
 #include "surfaceFields.H"
 #include "unitConversion.H"
+#include "PatchFunction1.H"
 
 //{{{ begin codeInclude
 ${codeInclude}
@@ -87,7 +88,7 @@ ${typeName}FixedValueFvPatch${FieldType}
     const DimensionedField<${TemplateType}, volMesh>& iF
 )
 :
-    fixedValueFvPatchField<${TemplateType}>(p, iF)
+    parent_bctype(p, iF)
 {
     if (${verbose:-false})
     {
@@ -99,13 +100,13 @@ ${typeName}FixedValueFvPatch${FieldType}
 ${typeName}FixedValueFvPatch${FieldType}::
 ${typeName}FixedValueFvPatch${FieldType}
 (
-    const ${typeName}FixedValueFvPatch${FieldType}& ptf,
+    const ${typeName}FixedValueFvPatch${FieldType}& rhs,
     const fvPatch& p,
     const DimensionedField<${TemplateType}, volMesh>& iF,
     const fvPatchFieldMapper& mapper
 )
 :
-    fixedValueFvPatchField<${TemplateType}>(ptf, p, iF, mapper)
+    parent_bctype(rhs, p, iF, mapper)
 {
     if (${verbose:-false})
     {
@@ -122,7 +123,7 @@ ${typeName}FixedValueFvPatch${FieldType}
     const dictionary& dict
 )
 :
-    fixedValueFvPatchField<${TemplateType}>(p, iF, dict)
+    parent_bctype(p, iF, dict)
 {
     if (${verbose:-false})
     {
@@ -134,10 +135,10 @@ ${typeName}FixedValueFvPatch${FieldType}
 ${typeName}FixedValueFvPatch${FieldType}::
 ${typeName}FixedValueFvPatch${FieldType}
 (
-    const ${typeName}FixedValueFvPatch${FieldType}& ptf
+    const ${typeName}FixedValueFvPatch${FieldType}& rhs
 )
 :
-    fixedValueFvPatchField<${TemplateType}>(ptf)
+    parent_bctype(rhs)
 {
     if (${verbose:-false})
     {
@@ -149,11 +150,11 @@ ${typeName}FixedValueFvPatch${FieldType}
 ${typeName}FixedValueFvPatch${FieldType}::
 ${typeName}FixedValueFvPatch${FieldType}
 (
-    const ${typeName}FixedValueFvPatch${FieldType}& ptf,
+    const ${typeName}FixedValueFvPatch${FieldType}& rhs,
     const DimensionedField<${TemplateType}, volMesh>& iF
 )
 :
-    fixedValueFvPatchField<${TemplateType}>(ptf, iF)
+    parent_bctype(rhs, iF)
 {
     if (${verbose:-false})
     {
@@ -176,7 +177,8 @@ ${typeName}FixedValueFvPatch${FieldType}::
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
+void
+${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
 {
     if (this->updated())
     {
@@ -192,7 +194,7 @@ void ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
     ${code}
 //}}} end code
 
-    this->fixedValueFvPatchField<${TemplateType}>::updateCoeffs();
+    this->parent_bctype::updateCoeffs();
 }
 
 
diff --git a/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H
index 4be5ca0425c..ca1d2e5c49e 100644
--- a/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H
+++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H
@@ -5,8 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2019 OpenCFD Ltd.
-    Copyright (C) YEAR AUTHOR, AFFILIATION
+    Copyright (C) 2019-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -53,6 +52,10 @@ class ${typeName}FixedValueFvPatch${FieldType}
 :
     public fixedValueFvPatchField<${TemplateType}>
 {
+    //- The parent boundary condition type
+    typedef fixedValueFvPatchField<${TemplateType}> parent_bctype;
+
+
     // Private Member Functions
 
         //- Report a message with the SHA1sum
diff --git a/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.C
index d0932687266..c91a478c621 100644
--- a/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.C
+++ b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2019 OpenCFD Ltd.
+    Copyright (C) 2019-2021 OpenCFD Ltd.
     Copyright (C) YEAR AUTHOR, AFFILIATION
 -------------------------------------------------------------------------------
 License
@@ -31,6 +31,7 @@ License
 #include "pointPatchFieldMapper.H"
 #include "pointFields.H"
 #include "unitConversion.H"
+#include "PatchFunction1.H"
 
 //{{{ begin codeInclude
 ${codeInclude}
@@ -86,7 +87,7 @@ ${typeName}FixedValuePointPatch${FieldType}
     const DimensionedField<${TemplateType}, pointMesh>& iF
 )
 :
-    fixedValuePointPatchField<${TemplateType}>(p, iF)
+    parent_bctype(p, iF)
 {
     if (${verbose:-false})
     {
@@ -98,13 +99,13 @@ ${typeName}FixedValuePointPatch${FieldType}
 ${typeName}FixedValuePointPatch${FieldType}::
 ${typeName}FixedValuePointPatch${FieldType}
 (
-    const ${typeName}FixedValuePointPatch${FieldType}& ptf,
+    const ${typeName}FixedValuePointPatch${FieldType}& rhs,
     const pointPatch& p,
     const DimensionedField<${TemplateType}, pointMesh>& iF,
     const pointPatchFieldMapper& mapper
 )
 :
-    fixedValuePointPatchField<${TemplateType}>(ptf, p, iF, mapper)
+    parent_bctype(rhs, p, iF, mapper)
 {
     if (${verbose:-false})
     {
@@ -122,7 +123,7 @@ ${typeName}FixedValuePointPatch${FieldType}
     const bool valueRequired
 )
 :
-    fixedValuePointPatchField<${TemplateType}>(p, iF, dict, valueRequired)
+    parent_bctype(p, iF, dict, valueRequired)
 {
     if (${verbose:-false})
     {
@@ -134,10 +135,10 @@ ${typeName}FixedValuePointPatch${FieldType}
 ${typeName}FixedValuePointPatch${FieldType}::
 ${typeName}FixedValuePointPatch${FieldType}
 (
-    const ${typeName}FixedValuePointPatch${FieldType}& ptf
+    const ${typeName}FixedValuePointPatch${FieldType}& rhs
 )
 :
-    fixedValuePointPatchField<${TemplateType}>(ptf)
+    parent_bctype(rhs)
 {
     if (${verbose:-false})
     {
@@ -149,11 +150,11 @@ ${typeName}FixedValuePointPatch${FieldType}
 ${typeName}FixedValuePointPatch${FieldType}::
 ${typeName}FixedValuePointPatch${FieldType}
 (
-    const ${typeName}FixedValuePointPatch${FieldType}& ptf,
+    const ${typeName}FixedValuePointPatch${FieldType}& rhs,
     const DimensionedField<${TemplateType}, pointMesh>& iF
 )
 :
-    fixedValuePointPatchField<${TemplateType}>(ptf, iF)
+    parent_bctype(rhs, iF)
 {
     if (${verbose:-false})
     {
@@ -176,7 +177,8 @@ ${typeName}FixedValuePointPatch${FieldType}::
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void ${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
+void
+${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
 {
     if (this->updated())
     {
@@ -192,7 +194,7 @@ void ${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
     ${code}
 //}}} end code
 
-    this->fixedValuePointPatchField<${TemplateType}>::updateCoeffs();
+    this->parent_bctype::updateCoeffs();
 }
 
 
diff --git a/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.H b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.H
index cf412c02d0d..164d625d142 100644
--- a/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.H
+++ b/etc/codeTemplates/dynamicCode/fixedValuePointPatchFieldTemplate.H
@@ -5,8 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2019 OpenCFD Ltd.
-    Copyright (C) YEAR AUTHOR, AFFILIATION
+    Copyright (C) 2019-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -35,8 +34,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef fixedValuePointPatchTemplate${FieldType}_H
-#define fixedValuePointPatchTemplate${FieldType}_H
+#ifndef coded_fixedValuePointPatchTemplate${FieldType}_H
+#define coded_fixedValuePointPatchTemplate${FieldType}_H
 
 #include "fixedValuePointPatchFields.H"
 
@@ -53,6 +52,10 @@ class ${typeName}FixedValuePointPatch${FieldType}
 :
     public fixedValuePointPatchField<${TemplateType}>
 {
+    //- The parent boundary condition type
+    typedef fixedValuePointPatchField<${TemplateType}> parent_bctype;
+
+
     // Private Member Functions
 
         //- Report a message with the SHA1sum
diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C
index 207e2dc3c95..274fd29f7c2 100644
--- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.C
+++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2019 OpenCFD Ltd.
+    Copyright (C) 2019-2021 OpenCFD Ltd.
     Copyright (C) YEAR AUTHOR, AFFILIATION
 -------------------------------------------------------------------------------
 License
@@ -27,6 +27,7 @@ License
 \*---------------------------------------------------------------------------*/
 
 #include "functionObjectTemplate.H"
+#define namespaceFoam  // Suppress <using namespace Foam;>
 #include "fvCFD.H"
 #include "unitConversion.H"
 #include "addToRunTimeSelectionTable.H"
@@ -106,7 +107,8 @@ ${typeName}FunctionObject::~${typeName}FunctionObject()
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-bool ${typeName}FunctionObject::read(const dictionary& dict)
+bool
+${typeName}FunctionObject::read(const dictionary& dict)
 {
     if (${verbose:-false})
     {
@@ -121,7 +123,8 @@ bool ${typeName}FunctionObject::read(const dictionary& dict)
 }
 
 
-bool ${typeName}FunctionObject::execute()
+bool
+${typeName}FunctionObject::execute()
 {
     if (${verbose:-false})
     {
@@ -136,7 +139,8 @@ bool ${typeName}FunctionObject::execute()
 }
 
 
-bool ${typeName}FunctionObject::write()
+bool
+${typeName}FunctionObject::write()
 {
     if (${verbose:-false})
     {
@@ -151,7 +155,8 @@ bool ${typeName}FunctionObject::write()
 }
 
 
-bool ${typeName}FunctionObject::end()
+bool
+${typeName}FunctionObject::end()
 {
     if (${verbose:-false})
     {
diff --git a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H
index e56ae695385..3b2c2b238dc 100644
--- a/etc/codeTemplates/dynamicCode/functionObjectTemplate.H
+++ b/etc/codeTemplates/dynamicCode/functionObjectTemplate.H
@@ -76,10 +76,16 @@ class ${typeName}FunctionObject
         const fvMesh& mesh() const;
 
         //- No copy construct
-        ${typeName}FunctionObject(const ${typeName}FunctionObject&) = delete;
+        ${typeName}FunctionObject
+        (
+            const ${typeName}FunctionObject&
+        ) = delete;
 
         //- No copy assignment
-        void operator=(const ${typeName}FunctionObject&) = delete;
+        void operator=
+        (
+            const ${typeName}FunctionObject&
+        ) = delete;
 
 public:
 
@@ -97,7 +103,7 @@ public:
         (
             const word& name,
             const Time& runTime,
-            const dictionary&
+            const dictionary& dict
         );
 
 
@@ -107,7 +113,7 @@ public:
 
     // Member Functions
 
-        //- Read the dictionary
+        //- Read optional controls
         virtual bool read(const dictionary& dict);
 
         //- Execute (at time-step)
diff --git a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C
index d7658f52b5e..8602b151bec 100644
--- a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C
+++ b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2019 OpenCFD Ltd.
+    Copyright (C) 2019-2021 OpenCFD Ltd.
     Copyright (C) YEAR AUTHOR, AFFILIATION
 -------------------------------------------------------------------------------
 License
@@ -32,6 +32,7 @@ License
 #include "volFields.H"
 #include "surfaceFields.H"
 #include "unitConversion.H"
+#include "PatchFunction1.H"
 
 //{{{ begin codeInclude
 ${codeInclude}
@@ -86,7 +87,7 @@ ${typeName}MixedValueFvPatch${FieldType}
     const DimensionedField<${TemplateType}, volMesh>& iF
 )
 :
-    mixedFvPatchField<${TemplateType}>(p, iF)
+    parent_bctype(p, iF)
 {
     if (${verbose:-false})
     {
@@ -98,13 +99,13 @@ ${typeName}MixedValueFvPatch${FieldType}
 ${typeName}MixedValueFvPatch${FieldType}::
 ${typeName}MixedValueFvPatch${FieldType}
 (
-    const ${typeName}MixedValueFvPatch${FieldType}& ptf,
+    const ${typeName}MixedValueFvPatch${FieldType}& rhs,
     const fvPatch& p,
     const DimensionedField<${TemplateType}, volMesh>& iF,
     const fvPatchFieldMapper& mapper
 )
 :
-    mixedFvPatchField<${TemplateType}>(ptf, p, iF, mapper)
+    parent_bctype(rhs, p, iF, mapper)
 {
     if (${verbose:-false})
     {
@@ -121,7 +122,7 @@ ${typeName}MixedValueFvPatch${FieldType}
     const dictionary& dict
 )
 :
-    mixedFvPatchField<${TemplateType}>(p, iF, dict)
+    parent_bctype(p, iF, dict)
 {
     if (${verbose:-false})
     {
@@ -133,10 +134,10 @@ ${typeName}MixedValueFvPatch${FieldType}
 ${typeName}MixedValueFvPatch${FieldType}::
 ${typeName}MixedValueFvPatch${FieldType}
 (
-    const ${typeName}MixedValueFvPatch${FieldType}& ptf
+    const ${typeName}MixedValueFvPatch${FieldType}& rhs
 )
 :
-    mixedFvPatchField<${TemplateType}>(ptf)
+    parent_bctype(rhs)
 {
     if (${verbose:-false})
     {
@@ -148,11 +149,11 @@ ${typeName}MixedValueFvPatch${FieldType}
 ${typeName}MixedValueFvPatch${FieldType}::
 ${typeName}MixedValueFvPatch${FieldType}
 (
-    const ${typeName}MixedValueFvPatch${FieldType}& ptf,
+    const ${typeName}MixedValueFvPatch${FieldType}& rhs,
     const DimensionedField<${TemplateType}, volMesh>& iF
 )
 :
-    mixedFvPatchField<${TemplateType}>(ptf, iF)
+    parent_bctype(rhs, iF)
 {
     if (${verbose:-false})
     {
@@ -175,7 +176,8 @@ ${typeName}MixedValueFvPatch${FieldType}::
 
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-void ${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
+void
+${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
 {
     if (this->updated())
     {
@@ -191,7 +193,7 @@ void ${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
     ${code}
 //}}} end code
 
-    this->mixedFvPatchField<${TemplateType}>::updateCoeffs();
+    this->parent_bctype::updateCoeffs();
 }
 
 
diff --git a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H
index 7588639539c..5b915c4b789 100644
--- a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H
+++ b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H
@@ -5,8 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2019 OpenCFD Ltd.
-    Copyright (C) YEAR AUTHOR, AFFILIATION
+    Copyright (C) 2019-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -35,8 +34,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef mixedFvPatchTemplate${FieldType}_H
-#define mixedFvPatchTemplate${FieldType}_H
+#ifndef coded_mixedFvPatchTemplate${FieldType}_H
+#define coded_mixedFvPatchTemplate${FieldType}_H
 
 #include "mixedFvPatchFields.H"
 
@@ -53,6 +52,10 @@ class ${typeName}MixedValueFvPatch${FieldType}
 :
     public mixedFvPatchField<${TemplateType}>
 {
+    //- The parent boundary condition type
+    typedef mixedFvPatchField<${TemplateType}> parent_bctype;
+
+
     // Private Member Functions
 
         //- Report a message with the SHA1sum
diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C
index 1d6e60bd79d..b3a8be6b26c 100644
--- a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C
+++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C
@@ -124,7 +124,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
     const DimensionedField<Type, pointMesh>& iF
 )
 :
-    fixedValuePointPatchField<Type>(p, iF),
+    parent_bctype(p, iF),
     codedBase(),
     redirectPatchFieldPtr_(nullptr)
 {}
@@ -133,17 +133,17 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
 template<class Type>
 Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
 (
-    const codedFixedValuePointPatchField<Type>& ptf,
+    const codedFixedValuePointPatchField<Type>& rhs,
     const pointPatch& p,
     const DimensionedField<Type, pointMesh>& iF,
     const pointPatchFieldMapper& mapper
 )
 :
-    fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
+    parent_bctype(rhs, p, iF, mapper),
     codedBase(),
-    dict_(ptf.dict_),
-    name_(ptf.name_),
-    redirectPatchFieldPtr_()
+    dict_(rhs.dict_),
+    name_(rhs.name_),
+    redirectPatchFieldPtr_(nullptr)
 {}
 
 
@@ -156,7 +156,7 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
     const bool valueRequired
 )
 :
-    fixedValuePointPatchField<Type>(p, iF, dict, valueRequired),
+    parent_bctype(p, iF, dict, valueRequired),
     codedBase(),
     dict_
     (
@@ -182,29 +182,29 @@ Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
 template<class Type>
 Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
 (
-    const codedFixedValuePointPatchField<Type>& ptf
+    const codedFixedValuePointPatchField<Type>& rhs
 )
 :
-    fixedValuePointPatchField<Type>(ptf),
+    parent_bctype(rhs),
     codedBase(),
-    dict_(ptf.dict_),
-    name_(ptf.name_),
-    redirectPatchFieldPtr_()
+    dict_(rhs.dict_),
+    name_(rhs.name_),
+    redirectPatchFieldPtr_(nullptr)
 {}
 
 
 template<class Type>
 Foam::codedFixedValuePointPatchField<Type>::codedFixedValuePointPatchField
 (
-    const codedFixedValuePointPatchField<Type>& ptf,
+    const codedFixedValuePointPatchField<Type>& rhs,
     const DimensionedField<Type, pointMesh>& iF
 )
 :
-    fixedValuePointPatchField<Type>(ptf, iF),
+    parent_bctype(rhs, iF),
     codedBase(),
-    dict_(ptf.dict_),
-    name_(ptf.name_),
-    redirectPatchFieldPtr_()
+    dict_(rhs.dict_),
+    name_(rhs.name_),
+    redirectPatchFieldPtr_(nullptr)
 {}
 
 
@@ -220,10 +220,11 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
         // Make sure to construct the patchfield with up-to-date value
 
         OStringStream os;
-        os.writeEntry("type", name_);
         static_cast<const Field<Type>&>(*this).writeEntry("value", os);
         IStringStream is(os.str());
-        dictionary dict(is);
+        dictionary constructDict(is);
+
+        constructDict.set("type", name_);
 
         redirectPatchFieldPtr_.reset
         (
@@ -231,7 +232,7 @@ Foam::codedFixedValuePointPatchField<Type>::redirectPatchField() const
             (
                 this->patch(),
                 this->internalField(),
-                dict
+                constructDict
             ).ptr()
         );
     }
@@ -257,7 +258,7 @@ void Foam::codedFixedValuePointPatchField<Type>::updateCoeffs()
     // Copy through value
     this->operator==(fvp);
 
-    fixedValuePointPatchField<Type>::updateCoeffs();
+    parent_bctype::updateCoeffs();
 }
 
 
@@ -274,14 +275,14 @@ void Foam::codedFixedValuePointPatchField<Type>::evaluate
 
     const_cast<pointPatchField<Type>&>(fvp).evaluate(commsType);
 
-    fixedValuePointPatchField<Type>::evaluate(commsType);
+    parent_bctype::evaluate(commsType);
 }
 
 
 template<class Type>
 void Foam::codedFixedValuePointPatchField<Type>::write(Ostream& os) const
 {
-    fixedValuePointPatchField<Type>::write(os);
+    this->parent_bctype::write(os);
     os.writeEntry("name", name_);
 
     codedBase::writeCodeDict(os, dict_);
diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H
index 927bde50bf3..3a891d0b33b 100644
--- a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H
+++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.H
@@ -31,6 +31,15 @@ Description
     Constructs on-the-fly a new boundary condition (derived from
     fixedValuePointPatchField) which is then used to evaluate.
 
+    The code entries:
+    \plaintable
+       codeInclude | include files
+       codeOptions | compiler line: added to EXE_INC (Make/options)
+       codeLibs    | linker line: added to LIB_LIBS (Make/options)
+       localCode   | c++; local static functions
+       code        | c++; patch value assignment
+    \endplaintable
+
     Example:
     \verbatim
     movingWall
@@ -102,6 +111,10 @@ class codedFixedValuePointPatchField
     public fixedValuePointPatchField<Type>,
     protected codedBase
 {
+    //- The parent boundary condition type
+    typedef fixedValuePointPatchField<Type> parent_bctype;
+
+
     // Private Data
 
         //- Dictionary contents for the boundary condition
diff --git a/src/dynamicMesh/motionSolvers/displacement/codedPoints0/codedPoints0MotionSolver.H b/src/dynamicMesh/motionSolvers/displacement/codedPoints0/codedPoints0MotionSolver.H
index e99e5434419..7cc0c374aff 100644
--- a/src/dynamicMesh/motionSolvers/displacement/codedPoints0/codedPoints0MotionSolver.H
+++ b/src/dynamicMesh/motionSolvers/displacement/codedPoints0/codedPoints0MotionSolver.H
@@ -35,10 +35,10 @@ Description
     The entries are:
     \plaintable
        codeInclude | include files
-       codeOptions | include paths; inserted into EXE_INC in Make/options
-       codeLibs    | link line; inserted into LIB_LIBS in Make/options
-       localCode   | c++; local static functions;
-       code        | c++; upon motionSolver::curPoints();
+       codeOptions | compiler line: added to EXE_INC (Make/options)
+       codeLibs    | linker line: added to LIB_LIBS (Make/options)
+       localCode   | c++; local static functions
+       code        | c++; upon motionSolver::curPoints()
     \endplaintable
 
     Note that the dynamically generated motionSolver is an points0MotionSolver,
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C
index 2a3a1702f79..6882ded6ea9 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C
@@ -124,7 +124,7 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
     const DimensionedField<Type, volMesh>& iF
 )
 :
-    fixedValueFvPatchField<Type>(p, iF),
+    parent_bctype(p, iF),
     codedBase(),
     redirectPatchFieldPtr_(nullptr)
 {}
@@ -133,17 +133,17 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
 template<class Type>
 Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
 (
-    const codedFixedValueFvPatchField<Type>& ptf,
+    const codedFixedValueFvPatchField<Type>& rhs,
     const fvPatch& p,
     const DimensionedField<Type, volMesh>& iF,
     const fvPatchFieldMapper& mapper
 )
 :
-    fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
+    parent_bctype(rhs, p, iF, mapper),
     codedBase(),
-    dict_(ptf.dict_),
-    name_(ptf.name_),
-    redirectPatchFieldPtr_()
+    dict_(rhs.dict_),
+    name_(rhs.name_),
+    redirectPatchFieldPtr_(nullptr)
 {}
 
 
@@ -155,7 +155,7 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
     const dictionary& dict
 )
 :
-    fixedValueFvPatchField<Type>(p, iF, dict),
+    parent_bctype(p, iF, dict),
     codedBase(),
     dict_
     (
@@ -181,29 +181,29 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
 template<class Type>
 Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
 (
-    const codedFixedValueFvPatchField<Type>& ptf
+    const codedFixedValueFvPatchField<Type>& rhs
 )
 :
-    fixedValueFvPatchField<Type>(ptf),
+    parent_bctype(rhs),
     codedBase(),
-    dict_(ptf.dict_),
-    name_(ptf.name_),
-    redirectPatchFieldPtr_()
+    dict_(rhs.dict_),
+    name_(rhs.name_),
+    redirectPatchFieldPtr_(nullptr)
 {}
 
 
 template<class Type>
 Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField
 (
-    const codedFixedValueFvPatchField<Type>& ptf,
+    const codedFixedValueFvPatchField<Type>& rhs,
     const DimensionedField<Type, volMesh>& iF
 )
 :
-    fixedValueFvPatchField<Type>(ptf, iF),
+    parent_bctype(rhs, iF),
     codedBase(),
-    dict_(ptf.dict_),
-    name_(ptf.name_),
-    redirectPatchFieldPtr_()
+    dict_(rhs.dict_),
+    name_(rhs.name_),
+    redirectPatchFieldPtr_(nullptr)
 {}
 
 
@@ -219,10 +219,11 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
         // Make sure to construct the patchfield with up-to-date value
 
         OStringStream os;
-        os.writeEntry("type", name_);
         static_cast<const Field<Type>&>(*this).writeEntry("value", os);
         IStringStream is(os.str());
-        dictionary dict(is);
+        dictionary constructDict(is);
+
+        constructDict.set("type", name_);
 
         redirectPatchFieldPtr_.reset
         (
@@ -230,7 +231,7 @@ Foam::codedFixedValueFvPatchField<Type>::redirectPatchField() const
             (
                 this->patch(),
                 this->internalField(),
-                dict
+                constructDict
             ).ptr()
         );
     }
@@ -256,7 +257,7 @@ void Foam::codedFixedValueFvPatchField<Type>::updateCoeffs()
     // Copy through value
     this->operator==(fvp);
 
-    fixedValueFvPatchField<Type>::updateCoeffs();
+    parent_bctype::updateCoeffs();
 }
 
 
@@ -273,14 +274,14 @@ void Foam::codedFixedValueFvPatchField<Type>::evaluate
 
     const_cast<fvPatchField<Type>&>(fvp).evaluate(commsType);
 
-    fixedValueFvPatchField<Type>::evaluate(commsType);
+    parent_bctype::evaluate(commsType);
 }
 
 
 template<class Type>
 void Foam::codedFixedValueFvPatchField<Type>::write(Ostream& os) const
 {
-    fixedValueFvPatchField<Type>::write(os);
+    this->parent_bctype::write(os);
     os.writeEntry("name", name_);
 
     codedBase::writeCodeDict(os, dict_);
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H
index 9f2c91e0721..8ae89cdc44f 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H
@@ -34,6 +34,15 @@ Description
     Constructs on-the-fly a new boundary condition (derived from
     fixedValueFvPatchField) which is then used to evaluate.
 
+    The code entries:
+    \plaintable
+       codeInclude | include files
+       codeOptions | compiler line: added to EXE_INC (Make/options)
+       codeLibs    | linker line: added to LIB_LIBS (Make/options)
+       localCode   | c++; local static functions
+       code        | c++; patch value assignment
+    \endplaintable
+
 Usage
     Example:
     \verbatim
@@ -104,6 +113,10 @@ class codedFixedValueFvPatchField
     public fixedValueFvPatchField<Type>,
     protected codedBase
 {
+    //- The parent boundary condition type
+    typedef fixedValueFvPatchField<Type> parent_bctype;
+
+
     // Private Data
 
         //- Dictionary contents for the boundary condition
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C
index 1bb9e078ad7..8f73c442888 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2016-2020 OpenCFD Ltd.
+    Copyright (C) 2016-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -124,7 +124,7 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
     const DimensionedField<Type, volMesh>& iF
 )
 :
-    mixedFvPatchField<Type>(p, iF),
+    parent_bctype(p, iF),
     codedBase(),
     redirectPatchFieldPtr_(nullptr)
 {}
@@ -133,17 +133,17 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
 template<class Type>
 Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
 (
-    const codedMixedFvPatchField<Type>& ptf,
+    const codedMixedFvPatchField<Type>& rhs,
     const fvPatch& p,
     const DimensionedField<Type, volMesh>& iF,
     const fvPatchFieldMapper& mapper
 )
 :
-    mixedFvPatchField<Type>(ptf, p, iF, mapper),
+    parent_bctype(rhs, p, iF, mapper),
     codedBase(),
-    dict_(ptf.dict_),
-    name_(ptf.name_),
-    redirectPatchFieldPtr_()
+    dict_(rhs.dict_),
+    name_(rhs.name_),
+    redirectPatchFieldPtr_(nullptr)
 {}
 
 
@@ -155,7 +155,7 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
     const dictionary& dict
 )
 :
-    mixedFvPatchField<Type>(p, iF, dict),
+    parent_bctype(p, iF, dict),
     codedBase(),
     dict_
     (
@@ -181,29 +181,29 @@ Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
 template<class Type>
 Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
 (
-    const codedMixedFvPatchField<Type>& ptf
+    const codedMixedFvPatchField<Type>& rhs
 )
 :
-    mixedFvPatchField<Type>(ptf),
+    parent_bctype(rhs),
     codedBase(),
-    dict_(ptf.dict_),
-    name_(ptf.name_),
-    redirectPatchFieldPtr_()
+    dict_(rhs.dict_),
+    name_(rhs.name_),
+    redirectPatchFieldPtr_(nullptr)
 {}
 
 
 template<class Type>
 Foam::codedMixedFvPatchField<Type>::codedMixedFvPatchField
 (
-    const codedMixedFvPatchField<Type>& ptf,
+    const codedMixedFvPatchField<Type>& rhs,
     const DimensionedField<Type, volMesh>& iF
 )
 :
-    mixedFvPatchField<Type>(ptf, iF),
+    parent_bctype(rhs, iF),
     codedBase(),
-    dict_(ptf.dict_),
-    name_(ptf.name_),
-    redirectPatchFieldPtr_()
+    dict_(rhs.dict_),
+    name_(rhs.name_),
+    redirectPatchFieldPtr_(nullptr)
 {}
 
 
@@ -220,24 +220,23 @@ Foam::codedMixedFvPatchField<Type>::redirectPatchField() const
 
         // Write the data from the mixed b.c.
         OStringStream os;
-        mixedFvPatchField<Type>::write(os);
+        this->parent_bctype::write(os);
         IStringStream is(os.str());
         // Construct dictionary from it.
-        dictionary dict(is);
+        dictionary constructDict(is);
 
-        // Override the type to enforce the fvPatchField::New constructor
-        // to choose our type
-        dict.set("type", name_);
+        // Override type
+        constructDict.set("type", name_);
 
         redirectPatchFieldPtr_.reset
         (
-            dynamic_cast<mixedFvPatchField<Type>*>
+            dynamic_cast<parent_bctype*>
             (
                 fvPatchField<Type>::New
                 (
                     this->patch(),
                     this->internalField(),
-                    dict
+                    constructDict
                 ).ptr()
             )
         );
@@ -257,16 +256,15 @@ void Foam::codedMixedFvPatchField<Type>::updateCoeffs()
     // Make sure library containing user-defined fvPatchField is up-to-date
     updateLibrary(name_);
 
-    const mixedFvPatchField<Type>& fvp = redirectPatchField();
-
-    const_cast<mixedFvPatchField<Type>&>(fvp).updateCoeffs();
+    const parent_bctype& fvp = redirectPatchField();
+    const_cast<parent_bctype&>(fvp).updateCoeffs();
 
     // Copy through coefficients
     this->refValue() = fvp.refValue();
     this->refGrad() = fvp.refGrad();
     this->valueFraction() = fvp.valueFraction();
 
-    mixedFvPatchField<Type>::updateCoeffs();
+    this->parent_bctype::updateCoeffs();
 }
 
 
@@ -279,21 +277,21 @@ void Foam::codedMixedFvPatchField<Type>::evaluate
     // Make sure library containing user-defined fvPatchField is up-to-date
     updateLibrary(name_);
 
-    const mixedFvPatchField<Type>& fvp = redirectPatchField();
+    const parent_bctype& fvp = redirectPatchField();
 
     // - updates the value of fvp (though not used)
     // - resets the updated() flag
-    const_cast<mixedFvPatchField<Type>&>(fvp).evaluate(commsType);
+    const_cast<parent_bctype&>(fvp).evaluate(commsType);
 
     // Update the value (using the coefficients) locally
-    mixedFvPatchField<Type>::evaluate(commsType);
+    parent_bctype::evaluate(commsType);
 }
 
 
 template<class Type>
 void Foam::codedMixedFvPatchField<Type>::write(Ostream& os) const
 {
-    mixedFvPatchField<Type>::write(os);
+    this->parent_bctype::write(os);
     os.writeEntry("name", name_);
 
     codedBase::writeCodeDict(os, dict_);
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H
index 2ca033652ec..63430f2d34e 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H
@@ -31,8 +31,17 @@ Group
     grpGenericBoundaryConditions
 
 Description
-    Constructs on-the-fly a new boundary condition (derived from
-    mixedFvPatchField) which is then used to evaluate.
+    Constructs on-the-fly a new boundary condition
+    (derived from mixedFvPatchField) which is then used to evaluate.
+
+    The code entries:
+    \plaintable
+       codeInclude | include files
+       codeOptions | compiler line: added to EXE_INC (Make/options)
+       codeLibs    | linker line: added to LIB_LIBS (Make/options)
+       localCode   | c++; local static functions;
+       code        | c++; patch value assignment
+    \endplaintable
 
 Usage
     Example:
@@ -114,6 +123,10 @@ class codedMixedFvPatchField
     public mixedFvPatchField<Type>,
     public codedBase
 {
+    //- The parent boundary condition type
+    typedef mixedFvPatchField<Type> parent_bctype;
+
+
     // Private Data
 
         //- Dictionary contents for the boundary condition
diff --git a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C
index 829df548684..9914a37f412 100644
--- a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C
+++ b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C
@@ -32,6 +32,7 @@ License
 #include "Time.H"
 #include "dynamicCode.H"
 #include "dynamicCodeContext.H"
+#include "dictionaryContent.H"
 #include "addToRunTimeSelectionTable.H"
 
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -47,8 +48,8 @@ namespace functionObjects
         codedFunctionObject,
         dictionary
     );
-}
-}
+} // End namespace functionObjects
+} // End namespace Foam
 
 
 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
diff --git a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H
index 0ef530cb997..202365ca337 100644
--- a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H
+++ b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H
@@ -36,14 +36,14 @@ Description
     The entries are:
     \plaintable
        codeInclude | include files
-       codeOptions | include paths; inserted into EXE_INC in Make/options
-       codeLibs    | link line; inserted into LIB_LIBS in Make/options
-       codeData    | c++; local member data (default constructed);
-       localCode   | c++; local static functions;
-       codeRead    | c++; upon functionObject::read();
-       codeExecute | c++; upon functionObject::execute();
+       codeOptions | compiler line: added to EXE_INC (Make/options)
+       codeLibs    | linker line: added to LIB_LIBS (Make/options)
+       codeData    | c++; local member data (default constructed)
+       localCode   | c++; local static functions
+       codeRead    | c++; upon functionObject::read()
+       codeExecute | c++; upon functionObject::execute()
        codeWrite   | c++; upon functionObject::write()
-       codeEnd     | c++; upon functionObject::end();
+       codeEnd     | c++; upon functionObject::end()
     \endplaintable
 
 Usage
diff --git a/src/meshTools/PatchFunction1/CodedField/CodedField.C b/src/meshTools/PatchFunction1/CodedField/CodedField.C
index 40c0c4588b2..b97e16c714a 100644
--- a/src/meshTools/PatchFunction1/CodedField/CodedField.C
+++ b/src/meshTools/PatchFunction1/CodedField/CodedField.C
@@ -27,6 +27,7 @@ License
 
 #include "dynamicCode.H"
 #include "dynamicCodeContext.H"
+#include "dictionaryContent.H"
 
 // * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //
 
@@ -183,15 +184,13 @@ Foam::PatchFunction1Types::CodedField<Type>::redirectFunction() const
 {
     if (!redirectFunctionPtr_)
     {
-        // Construct a PatchFunction1 containing the input code
-        dictionary completeDict(dict_);
+        dictionary constructDict;
+        // Force 'name_' sub-dictionary into existence
+        dictionary& coeffs = constructDict.subDictOrAdd(name_);
 
-        // Override the type to enforce the PatchFunction1::New constructor
-        // to choose our type
-        completeDict.set("type", name_);
-
-        dictionary dict;
-        dict.add(name_, completeDict);
+        coeffs = dict_;  // Copy input code and coefficients
+        coeffs.remove("name");      // Redundant
+        coeffs.set("type", name_);  // Specify our new (redirect) type
 
         redirectFunctionPtr_.reset
         (
@@ -199,7 +198,7 @@ Foam::PatchFunction1Types::CodedField<Type>::redirectFunction() const
             (
                 this->patch(),
                 name_,
-                dict,
+                constructDict,
                 this->faceValues()
             )
         );
diff --git a/src/meshTools/PatchFunction1/CodedField/CodedField.H b/src/meshTools/PatchFunction1/CodedField/CodedField.H
index d034c5337e3..5751215f070 100644
--- a/src/meshTools/PatchFunction1/CodedField/CodedField.H
+++ b/src/meshTools/PatchFunction1/CodedField/CodedField.H
@@ -30,6 +30,15 @@ Description
     PatchFunction1 with the code supplied by an on-the-fly compiled C++
     expression.
 
+    The code entries:
+    \plaintable
+       codeInclude | include files
+       codeOptions | compiler line: added to EXE_INC (Make/options)
+       codeLibs    | linker line: added to LIB_LIBS (Make/options)
+       localCode   | c++; local static functions
+       code        | c++; return the patch values at (scalar x)
+    \endplaintable
+
 Usage
     Example:
     \verbatim
@@ -38,11 +47,8 @@ Usage
         type            uniformFixedValue;
         uniformValue
         {
-            type            coded;
-            // Explictly supply name of generated PatchFunction1. Only needed
-            // if entryname ('uniformValue') would clash with existing
-            // runtime selection tables.
-            name            myExpression;
+            type  coded;
+            name  myExpression;  // Name of generated PatchFunction1
 
             code
             #{
@@ -50,17 +56,17 @@ Usage
                 Pout<< "** Patch size:" << pp.size() << endl;
                 return tmp<vectorField>::New(pp.size(), vector(1, 0, 0))
             #};
-        }
 
-        //codeInclude
-        //#{
-        //    #include "fvCFD.H"
-        //#};
+            //codeInclude
+            //#{
+            //    #include "volFields.H"
+            //#};
 
-        //codeOptions
-        //#{
-        //    -I$(LIB_SRC)/finiteVolume/lnInclude
-        //#};
+            //codeOptions
+            //#{
+            //    -I$(LIB_SRC)/finiteVolume/lnInclude
+            //#};
+        }
     }
     \endverbatim
 
diff --git a/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/controlDict b/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/controlDict
index fa36ef03622..47912f4c9b0 100644
--- a/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/controlDict
+++ b/tutorials/compressible/overRhoPimpleDyMFoam/twoSimpleRotors/system/controlDict
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  v2012                                 |
+|  \\    /   O peration     | Version:  v2106                                 |
 |   \\  /    A nd           | Website:  www.openfoam.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
@@ -59,7 +59,6 @@ maxCo          1.2;
 
 functions
 {
-    // #include "catalyst"
     probes
     {
         type            probes;
@@ -82,7 +81,6 @@ functions
         (
             (0.015 0.005 0.005)
         );
-
     }
 
     mass
@@ -114,12 +112,10 @@ functions
 
         codeWrite
         #{
-
             const volScalarField& rho =
                 mesh().lookupObject<volScalarField>("rho");
 
             Info<< "rho volume = " << rho.weightedAverage(mesh().Vsc()) << endl;
-
         #};
     }
 }
diff --git a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess
index f0c0ed10cfb..18112454bc3 100644
--- a/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess
+++ b/tutorials/compressible/rhoPimpleAdiabaticFoam/rutlandVortex2D/system/preProcess
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  v2012                                 |
+|  \\    /   O peration     | Version:  v2106                                 |
 |   \\  /    A nd           | Website:  www.openfoam.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
@@ -24,19 +24,14 @@ functions
         libs    (utilityFunctionObjects);
         enabled yes;
 
-        codeInclude
-        #{
-            #include "volFields.H"
-        #};
-
         codeWrite
         #{
-            scalar D = 0.57;
-            scalar UInf = 50;
-            scalar pInf = 101325;
-            scalar TInf = 224;
-            scalar gamma = 1.4;
-            scalar A = -0.3*D*UInf;
+            const scalar D = 0.57;
+            const scalar UInf = 50;
+            const scalar pInf = 101325;
+            const scalar TInf = 224;
+            const scalar gamma = 1.4;
+            const scalar A = -0.3*D*UInf;
             const dimensionedScalar rhoRef("rhoRef", dimDensity, 1);
             const auto& rho = mesh().lookupObject<volScalarField>("rho");
 
diff --git a/tutorials/multiphase/icoReactingMultiPhaseInterFoam/poolEvaporation/0.orig/T b/tutorials/multiphase/icoReactingMultiPhaseInterFoam/poolEvaporation/0.orig/T
index 9ba5c45f94f..acce5d6b0ed 100644
--- a/tutorials/multiphase/icoReactingMultiPhaseInterFoam/poolEvaporation/0.orig/T
+++ b/tutorials/multiphase/icoReactingMultiPhaseInterFoam/poolEvaporation/0.orig/T
@@ -1,7 +1,7 @@
 /*--------------------------------*- C++ -*----------------------------------*\
 | =========                 |                                                 |
 | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
-|  \\    /   O peration     | Version:  v2012                                 |
+|  \\    /   O peration     | Version:  v2106                                 |
 |   \\  /    A nd           | Website:  www.openfoam.com                      |
 |    \\/     M anipulation  |                                                 |
 \*---------------------------------------------------------------------------*/
@@ -29,11 +29,6 @@ boundaryField
         {
             type        coded;
 
-            codeInclude
-            #{
-                #include "volFields.H"
-            #};
-
             code
             #{
                 const auto& T =
-- 
GitLab