From bfab5b55a41bd8982435226e85edd863ace3ed6e Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Thu, 21 Apr 2022 21:50:48 +0200
Subject: [PATCH] ENH: add GeometricBoundaryField evaluateCoupled method
 (#2436)

- allows restricted evaluation to specific coupled patch types.
  Code relocated/refactored from redistributePar.

STYLE: ensure use of waitRequests() also corresponds to nonBlocking

ENH: additional copy/move construct GeometricField from DimensionedField

STYLE: processorPointPatch owner()/neighbour() as per processorPolyPatch

STYLE: orientedType with bool cast operator and noexcept
---
 .../redistributePar/redistributePar.C         |  80 +----------
 .../preProcessing/mapFieldsPar/MapVolFields.H |  29 ++--
 .../DimensionedField/DimensionedField.C       |   2 -
 .../DimensionedField/DimensionedField.H       |   8 +-
 .../GeometricField/GeometricBoundaryField.C   | 129 +++++++++++++++---
 .../GeometricField/GeometricBoundaryField.H   |  14 +-
 .../GeometricField/GeometricField.C           | 128 +++++++++++++++++
 .../GeometricField/GeometricField.H           |  58 +++++++-
 .../pointPatchField/pointPatchField.H         |   8 ++
 src/OpenFOAM/meshes/pointMesh/pointMesh.H     |  17 ++-
 .../basic/coupled/coupledPointPatch.C         |  10 +-
 .../basic/coupled/coupledPointPatch.H         |  25 ++--
 .../cyclicSlip/cyclicSlipPointPatch.H         |   5 +-
 .../processor/processorPointPatch.C           |  16 +--
 .../processor/processorPointPatch.H           |  31 +++--
 .../processorCyclicPointPatch.H               |  19 +--
 .../derived/coupled/coupledFacePointPatch.C   |   8 +-
 .../derived/coupled/coupledFacePointPatch.H   |  26 ++--
 .../facePointPatch/facePointPatch.H           |   8 +-
 .../pointPatches/pointPatch/pointPatch.H      |   5 +-
 src/OpenFOAM/meshes/polyMesh/polyMesh.H       |   5 +-
 .../constraint/cyclic/cyclicPolyPatch.C       |   4 +-
 .../processorCyclicPolyPatch.C                |   2 +-
 src/OpenFOAM/orientedType/orientedType.C      |  16 +--
 src/OpenFOAM/orientedType/orientedType.H      |  32 +++--
 src/finiteArea/faMesh/faMesh.H                |   3 +
 .../faMesh/faPatches/faPatch/faPatch.H        |   2 +
 .../faPatchFields/faPatchField/faPatchField.H |   6 +
 .../faePatchField/faePatchField.H             |  12 +-
 .../fvPatchFields/fvPatchField/fvPatchField.H |  12 +-
 .../fvsPatchField/fvsPatchField.H             |  12 +-
 src/finiteVolume/fvMesh/fvMesh.H              |   5 +-
 .../fvMesh/fvPatches/fvPatch/fvPatch.H        |   1 +
 .../volPointInterpolate.C                     |  13 +-
 .../field/mapFields/mapFieldsTemplates.C      |  28 ++--
 .../dynamicOversetFvMeshTemplates.C           |  28 ++--
 36 files changed, 515 insertions(+), 292 deletions(-)

diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
index dfc2572961d..788cfc42524 100644
--- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
+++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
@@ -948,84 +948,10 @@ void correctCoupledBoundaryConditions(fvMesh& mesh)
         mesh.objectRegistry::lookupClass<GeoField>()
     );
 
-    forAllIters(flds, iter)
+    for (const word& fldName : flds.sortedToc())
     {
-        GeoField& fld = *iter();
-
-        typename GeoField::Boundary& bfld = fld.boundaryFieldRef();
-        if
-        (
-            Pstream::defaultCommsType == Pstream::commsTypes::blocking
-         || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
-        )
-        {
-            const label nReq = Pstream::nRequests();
-
-            forAll(bfld, patchi)
-            {
-                auto& pfld = bfld[patchi];
-                const auto& fvp = mesh.boundary()[patchi];
-
-                const auto* ppPtr = isA<CoupledPatchType>(fvp);
-                if (ppPtr && ppPtr->coupled())
-                {
-                    pfld.initEvaluate(Pstream::defaultCommsType);
-                }
-            }
-
-            // Block for any outstanding requests
-            if
-            (
-                Pstream::parRun()
-             && Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
-            )
-            {
-                Pstream::waitRequests(nReq);
-            }
-
-            for (auto& pfld : bfld)
-            {
-                const auto& fvp = pfld.patch();
-
-                const auto* ppPtr = isA<CoupledPatchType>(fvp);
-                if (ppPtr && ppPtr->coupled())
-                {
-                    pfld.evaluate(Pstream::defaultCommsType);
-                }
-            }
-        }
-        else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
-        {
-            const lduSchedule& patchSchedule =
-                fld.mesh().globalData().patchSchedule();
-
-            for (const auto& schedEval : patchSchedule)
-            {
-                const label patchi = schedEval.patch;
-                const auto& fvp = mesh.boundary()[patchi];
-                auto& pfld = bfld[patchi];
-
-                const auto* ppPtr = isA<CoupledPatchType>(fvp);
-                if (ppPtr && ppPtr->coupled())
-                {
-                    if (schedEval.init)
-                    {
-                        pfld.initEvaluate(Pstream::commsTypes::scheduled);
-                    }
-                    else
-                    {
-                        pfld.evaluate(Pstream::commsTypes::scheduled);
-                    }
-                }
-            }
-        }
-        else
-        {
-            FatalErrorInFunction
-                << "Unsupported communications type "
-                << Pstream::commsTypeNames[Pstream::defaultCommsType]
-                << exit(FatalError);
-        }
+        GeoField& fld = *(flds[fldName]);
+        fld.boundaryFieldRef().template evaluateCoupled<CoupledPatchType>();
     }
 }
 
diff --git a/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H b/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H
index f2b787754d7..956f90daec3 100644
--- a/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H
+++ b/applications/utilities/preProcessing/mapFieldsPar/MapVolFields.H
@@ -41,16 +41,17 @@ namespace Foam
 template<class Type>
 void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
 {
-    typename GeometricField<Type, fvPatchField, volMesh>::
-        Boundary& fldBf = fld.boundaryFieldRef();
+    auto& fldBf = fld.boundaryFieldRef();
+
+    const UPstream::commsTypes commsType(UPstream::defaultCommsType);
 
     if
     (
-        Pstream::defaultCommsType == Pstream::commsTypes::blocking
-     || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
+        commsType == UPstream::commsTypes::blocking
+     || commsType == UPstream::commsTypes::nonBlocking
     )
     {
-        const label nReq = Pstream::nRequests();
+        const label startOfRequests = UPstream::nRequests();
 
         forAll(fldBf, patchi)
         {
@@ -62,18 +63,18 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
              && polyPatch::constraintType(tgtField.patch().patch().type())
             )
             {
-                tgtField.initEvaluate(Pstream::defaultCommsType);
+                tgtField.initEvaluate(commsType);
             }
         }
 
-        // Block for any outstanding requests
+        // Wait for outstanding requests
         if
         (
-            Pstream::parRun()
-         && Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
+            UPstream::parRun()
+         && commsType == UPstream::commsTypes::nonBlocking
         )
         {
-            Pstream::waitRequests(nReq);
+            UPstream::waitRequests(startOfRequests);
         }
 
         forAll(fldBf, patchi)
@@ -86,11 +87,11 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
              && polyPatch::constraintType(tgtField.patch().patch().type())
             )
             {
-                tgtField.evaluate(Pstream::defaultCommsType);
+                tgtField.evaluate(commsType);
             }
         }
     }
-    else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
+    else if (commsType == UPstream::commsTypes::scheduled)
     {
         const lduSchedule& patchSchedule =
             fld.mesh().globalData().patchSchedule();
@@ -109,11 +110,11 @@ void evaluateConstraintTypes(GeometricField<Type, fvPatchField, volMesh>& fld)
             {
                 if (schedEval.init)
                 {
-                    tgtField.initEvaluate(Pstream::commsTypes::scheduled);
+                    tgtField.initEvaluate(commsType);
                 }
                 else
                 {
-                    tgtField.evaluate(Pstream::commsTypes::scheduled);
+                    tgtField.evaluate(commsType);
                 }
             }
         }
diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C
index e7e9f06f833..81b415b7c30 100644
--- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C
+++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C
@@ -99,7 +99,6 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
     mesh_(mesh),
     dimensions_(dims)
 {
-    //Info<<"Move construct dimensioned for " << io.name() << nl;
     checkFieldSize();
 }
 
@@ -118,7 +117,6 @@ Foam::DimensionedField<Type, GeoMesh>::DimensionedField
     mesh_(mesh),
     dimensions_(dims)
 {
-    //Info<<"Move construct dimensioned for " << io.name() << nl;
     checkFieldSize();
 }
 
diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H
index 6b6931051b8..52c3ffd3450 100644
--- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H
+++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H
@@ -38,8 +38,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef DimensionedField_H
-#define DimensionedField_H
+#ifndef Foam_DimensionedField_H
+#define Foam_DimensionedField_H
 
 #include "regIOobject.H"
 #include "Field.H"
@@ -51,7 +51,7 @@ SourceFiles
 namespace Foam
 {
 
-// Forward declarations
+// Forward Declarations
 template<class Type, class GeoMesh> class DimensionedField;
 
 template<class Type, class GeoMesh>
@@ -95,7 +95,7 @@ public:
 
 private:
 
-    // Private data
+    // Private Data
 
         //- Reference to mesh
         const Mesh& mesh_;
diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C
index bc3b9ef1862..21f0336b2ea 100644
--- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C
+++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C
@@ -422,9 +422,9 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::updateCoeffs()
     ///    InfoInFunction << nl;
     ///}
 
-    forAll(*this, patchi)
+    for (auto& pfld : *this)
     {
-        this->operator[](patchi).updateCoeffs();
+        pfld.updateCoeffs();
     }
 }
 
@@ -437,35 +437,37 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluate()
     ///    InfoInFunction << nl;
     ///}
 
+    const UPstream::commsTypes commsType(UPstream::defaultCommsType);
+
     if
     (
-        Pstream::defaultCommsType == Pstream::commsTypes::blocking
-     || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
+        commsType == UPstream::commsTypes::blocking
+     || commsType == UPstream::commsTypes::nonBlocking
     )
     {
-        const label nReq = Pstream::nRequests();
+        const label startOfRequests = UPstream::nRequests();
 
-        forAll(*this, patchi)
+        for (auto& pfld : *this)
         {
-            this->operator[](patchi).initEvaluate(Pstream::defaultCommsType);
+            pfld.initEvaluate(commsType);
         }
 
-        // Block for any outstanding requests
+        // Wait for outstanding requests
         if
         (
-            Pstream::parRun()
-         && Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
+            UPstream::parRun()
+         && commsType == Pstream::commsTypes::nonBlocking
         )
         {
-            Pstream::waitRequests(nReq);
+            UPstream::waitRequests(startOfRequests);
         }
 
-        forAll(*this, patchi)
+        for (auto& pfld : *this)
         {
-            this->operator[](patchi).evaluate(Pstream::defaultCommsType);
+            pfld.evaluate(commsType);
         }
     }
-    else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
+    else if (commsType == UPstream::commsTypes::scheduled)
     {
         const lduSchedule& patchSchedule =
             bmesh_.mesh().globalData().patchSchedule();
@@ -473,16 +475,99 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluate()
         for (const auto& schedEval : patchSchedule)
         {
             const label patchi = schedEval.patch;
+            auto& pfld = (*this)[patchi];
 
             if (schedEval.init)
             {
-                this->operator[](patchi)
-                    .initEvaluate(Pstream::commsTypes::scheduled);
+                pfld.initEvaluate(commsType);
             }
             else
             {
-                this->operator[](patchi)
-                    .evaluate(Pstream::commsTypes::scheduled);
+                pfld.evaluate(commsType);
+            }
+        }
+    }
+    else
+    {
+        FatalErrorInFunction
+            << "Unsupported communications type "
+            << UPstream::commsTypeNames[commsType]
+            << exit(FatalError);
+    }
+}
+
+
+template<class Type, template<class> class PatchField, class GeoMesh>
+template<class CoupledPatchType>
+void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluateCoupled()
+{
+    ///if (GeometricField<Type, PatchField, GeoMesh::debug)
+    ///{
+    ///    InfoInFunction << nl;
+    ///}
+
+    const UPstream::commsTypes commsType(UPstream::defaultCommsType);
+
+    if
+    (
+        commsType == UPstream::commsTypes::blocking
+     || commsType == UPstream::commsTypes::nonBlocking
+    )
+    {
+        const label startOfRequests = UPstream::nRequests();
+
+        for (auto& pfld : *this)
+        {
+            const auto* cpp = isA<CoupledPatchType>(pfld.patch());
+
+            if (cpp && cpp->coupled())
+            {
+                pfld.initEvaluate(commsType);
+            }
+        }
+
+        // Wait for outstanding requests
+        if
+        (
+            UPstream::parRun()
+         && commsType == UPstream::commsTypes::nonBlocking
+        )
+        {
+            UPstream::waitRequests(startOfRequests);
+        }
+
+        for (auto& pfld : *this)
+        {
+            const auto* cpp = isA<CoupledPatchType>(pfld.patch());
+
+            if (cpp && cpp->coupled())
+            {
+                pfld.evaluate(commsType);
+            }
+        }
+    }
+    else if (commsType == UPstream::commsTypes::scheduled)
+    {
+        const lduSchedule& patchSchedule =
+            bmesh_.mesh().globalData().patchSchedule();
+
+        for (const auto& schedEval : patchSchedule)
+        {
+            const label patchi = schedEval.patch;
+            auto& pfld = (*this)[patchi];
+
+            const auto* cpp = isA<CoupledPatchType>(pfld.patch());
+
+            if (cpp && cpp->coupled())
+            {
+                if (schedEval.init)
+                {
+                    pfld.initEvaluate(commsType);
+                }
+                else
+                {
+                    pfld.evaluate(commsType);
+                }
             }
         }
     }
@@ -490,7 +575,7 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::evaluate()
     {
         FatalErrorInFunction
             << "Unsupported communications type "
-            << Pstream::commsTypeNames[Pstream::defaultCommsType]
+            << UPstream::commsTypeNames[commsType]
             << exit(FatalError);
     }
 }
@@ -593,10 +678,10 @@ void Foam::GeometricBoundaryField<Type, PatchField, GeoMesh>::writeEntries
     Ostream& os
 ) const
 {
-    forAll(*this, patchi)
+    for (const auto& pfld : *this)
     {
-        os.beginBlock(this->operator[](patchi).patch().name());
-        os  << this->operator[](patchi);
+        os.beginBlock(pfld.patch().name());
+        os << pfld;
         os.endBlock();
     }
 }
diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.H
index c484a500c88..e2b52abb9e1 100644
--- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.H
+++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.H
@@ -114,22 +114,22 @@ public:
         );
 
         //- Construct from a BoundaryMesh, reference to the internal field
-        //- and a PtrList<PatchField<Type>>
+        //- and a PtrList<PatchField<Type>> (to be cloned)
         GeometricBoundaryField
         (
             const BoundaryMesh& bmesh,
             const DimensionedField<Type, GeoMesh>& field,
-            const PtrList<PatchField<Type>>&
+            const PtrList<PatchField<Type>>& ptfl
         );
 
-        //- Construct as copy setting the reference to the internal field
+        //- Construct as copy, setting the reference to the internal field
         GeometricBoundaryField
         (
             const DimensionedField<Type, GeoMesh>& field,
             const GeometricBoundaryField<Type, PatchField, GeoMesh>& btf
         );
 
-        //- Construct as copy setting the reference to the internal field
+        //- Construct as copy, setting the reference to the internal field
         //- and resetting type of field for given patch IDs
         GeometricBoundaryField
         (
@@ -170,10 +170,14 @@ public:
         //- Evaluate boundary conditions
         void evaluate();
 
+        //- Evaluate boundary conditions on a subset of coupled patches
+        template<class CoupledPatchType>
+        void evaluateCoupled();
+
         //- Return a list of the patch types
         wordList types() const;
 
-        //- Return boundary field of cell values neighbouring the boundary
+        //- Return boundary field of values neighbouring the boundary
         GeometricBoundaryField boundaryInternalField() const;
 
         //- Return a list of pointers for each patch field with only those
diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
index b93df0811cc..ec8b6626611 100644
--- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
+++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C
@@ -307,6 +307,88 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
 }
 
 
+template<class Type, template<class> class PatchField, class GeoMesh>
+Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
+(
+    const IOobject& io,
+    Internal&& diField,
+    const PtrList<PatchField<Type>>& ptfl
+)
+:
+    Internal(io, std::move(diField)),
+    timeIndex_(this->time().timeIndex()),
+    field0Ptr_(nullptr),
+    fieldPrevIterPtr_(nullptr),
+    boundaryField_(this->mesh().boundary(), *this, ptfl)
+{
+    DebugInFunction
+        << "Move construct from components" << nl << this->info() << endl;
+
+    readIfPresent();
+}
+
+
+template<class Type, template<class> class PatchField, class GeoMesh>
+Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
+(
+    const IOobject& io,
+    const tmp<Internal>& tfield,
+    const PtrList<PatchField<Type>>& ptfl
+)
+:
+    Internal(io, tfield),
+    timeIndex_(this->time().timeIndex()),
+    field0Ptr_(nullptr),
+    fieldPrevIterPtr_(nullptr),
+    boundaryField_(this->mesh().boundary(), *this, ptfl)
+{
+    DebugInFunction
+        << "Construct from tmp internalField" << nl << this->info() << endl;
+
+    readIfPresent();
+}
+
+
+template<class Type, template<class> class PatchField, class GeoMesh>
+Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
+(
+    const Internal& diField,
+    const PtrList<PatchField<Type>>& ptfl
+)
+:
+    Internal(diField),
+    timeIndex_(this->time().timeIndex()),
+    field0Ptr_(nullptr),
+    fieldPrevIterPtr_(nullptr),
+    boundaryField_(this->mesh().boundary(), *this, ptfl)
+{
+    DebugInFunction
+        << "Copy construct from components" << nl << this->info() << endl;
+
+    readIfPresent();
+}
+
+
+template<class Type, template<class> class PatchField, class GeoMesh>
+Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
+(
+    Internal&& diField,
+    const PtrList<PatchField<Type>>& ptfl
+)
+:
+    Internal(std::move(diField)),
+    timeIndex_(this->time().timeIndex()),
+    field0Ptr_(nullptr),
+    fieldPrevIterPtr_(nullptr),
+    boundaryField_(this->mesh().boundary(), *this, ptfl)
+{
+    DebugInFunction
+        << "Move construct from components" << nl << this->info() << endl;
+
+    readIfPresent();
+}
+
+
 template<class Type, template<class> class PatchField, class GeoMesh>
 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
 (
@@ -376,6 +458,52 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
 }
 
 
+template<class Type, template<class> class PatchField, class GeoMesh>
+Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
+(
+    const IOobject& io,
+    const Mesh& mesh,
+    const dimensionSet& ds,
+    Field<Type>&& iField,
+    const PtrList<PatchField<Type>>& ptfl
+)
+:
+    Internal(io, mesh, ds, std::move(iField)),
+    timeIndex_(this->time().timeIndex()),
+    field0Ptr_(nullptr),
+    fieldPrevIterPtr_(nullptr),
+    boundaryField_(mesh.boundary(), *this, ptfl)
+{
+    DebugInFunction
+        << "Move construct from components" << nl << this->info() << endl;
+
+    readIfPresent();
+}
+
+
+template<class Type, template<class> class PatchField, class GeoMesh>
+Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
+(
+    const IOobject& io,
+    const Mesh& mesh,
+    const dimensionSet& ds,
+    const tmp<Field<Type>>& tfield,
+    const PtrList<PatchField<Type>>& ptfl
+)
+:
+    Internal(io, mesh, ds, tfield),
+    timeIndex_(this->time().timeIndex()),
+    field0Ptr_(nullptr),
+    fieldPrevIterPtr_(nullptr),
+    boundaryField_(mesh.boundary(), *this, ptfl)
+{
+    DebugInFunction
+        << "Construct from tmp internalField" << nl << this->info() << endl;
+
+    readIfPresent();
+}
+
+
 template<class Type, template<class> class PatchField, class GeoMesh>
 Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
 (
diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H
index db89a752771..1fbf2ebe947 100644
--- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H
+++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H
@@ -174,7 +174,7 @@ public:
 
         //- Construct given IOobject, mesh, dimensioned<Type> and patch type.
         //  This assigns both dimensions and values.
-        //  The internal name for the dimensioned\<Type\> has no influence.
+        //  The name of the dimensioned\<Type\> has no influence.
         GeometricField
         (
             const IOobject& io,
@@ -185,7 +185,7 @@ public:
 
         //- Construct given IOobject, mesh, dimensioned<Type> and patch types.
         //  This assigns both dimensions and values.
-        //  The internal name for the dimensioned\<Type\> has no influence.
+        //  The name of the dimensioned\<Type\> has no influence.
         GeometricField
         (
             const IOobject& io,
@@ -195,7 +195,7 @@ public:
             const wordList& actualPatchTypes = wordList()
         );
 
-        //- Copy construct from components
+        //- Copy construct from internal field and a patch list to clone
         GeometricField
         (
             const IOobject& io,
@@ -203,6 +203,36 @@ public:
             const PtrList<PatchField<Type>>& ptfl
         );
 
+        //- Move construct from internal field and a patch list to clone
+        GeometricField
+        (
+            const IOobject& io,
+            Internal&& diField,
+            const PtrList<PatchField<Type>>& ptfl
+        );
+
+        //- Move construct from internal field and a patch list to clone
+        GeometricField
+        (
+            const IOobject& io,
+            const tmp<Internal>& tfield,
+            const PtrList<PatchField<Type>>& ptfl
+        );
+
+        //- Copy construct from internal field and a patch list to clone
+        GeometricField
+        (
+            const Internal& diField,
+            const PtrList<PatchField<Type>>& ptfl
+        );
+
+        //- Move construct from internal field and a patch list to clone
+        GeometricField
+        (
+            Internal&& diField,
+            const PtrList<PatchField<Type>>& ptfl
+        );
+
         //- Copy construct from internal field, with specified patch type
         GeometricField
         (
@@ -233,6 +263,26 @@ public:
             const PtrList<PatchField<Type>>& ptfl
         );
 
+        //- Move construct from internal field and a patch list to clone
+        GeometricField
+        (
+            const IOobject& io,
+            const Mesh& mesh,
+            const dimensionSet& ds,
+            Field<Type>&& iField,
+            const PtrList<PatchField<Type>>& ptfl
+        );
+
+        //- Copy construct from components
+        GeometricField
+        (
+            const IOobject& io,
+            const Mesh& mesh,
+            const dimensionSet& ds,
+            const tmp<Field<Type>>& tiField,
+            const PtrList<PatchField<Type>>& ptfl
+        );
+
         //- Construct and read given IOobject
         GeometricField
         (
@@ -268,7 +318,7 @@ public:
             const GeometricField<Type, PatchField, GeoMesh>& gf
         );
 
-        //- Construct as copy of tmp<GeometricField> resetting IO parameters
+        //- Construct from tmp\<GeometricField\> resetting IO parameters
         GeometricField
         (
             const IOobject& io,
diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H
index b6346620922..61dbe49d534 100644
--- a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H
+++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchField.H
@@ -95,8 +95,16 @@ class pointPatchField
 
 public:
 
+    //- The Field value_type
     typedef Type value_type;
+
+    //- The internal field type associated with the patch field
+    typedef DimensionedField<Type, pointMesh> Internal;
+
+    //- The patch type for the patch field
     typedef pointPatch Patch;
+
+    //- Type for a \em calculated patch
     typedef calculatedPointPatchField<Type> Calculated;
 
 
diff --git a/src/OpenFOAM/meshes/pointMesh/pointMesh.H b/src/OpenFOAM/meshes/pointMesh/pointMesh.H
index 4fb0831867e..16e9b923192 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointMesh.H
+++ b/src/OpenFOAM/meshes/pointMesh/pointMesh.H
@@ -32,8 +32,8 @@ Description
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef pointMesh_H
-#define pointMesh_H
+#ifndef Foam_pointMesh_H
+#define Foam_pointMesh_H
 
 #include "GeoMesh.H"
 #include "MeshObject.H"
@@ -74,12 +74,17 @@ class pointMesh
 
 public:
 
-    // Declare name of the class and its debug switch
-    ClassName("pointMesh");
+    // Public Typedefs
+
+        //- The mesh type
+        typedef pointMesh Mesh;
 
+        //- The boundary type associated with the mesh
+        typedef pointBoundaryMesh BoundaryMesh;
 
-    typedef pointMesh Mesh;
-    typedef pointBoundaryMesh BoundaryMesh;
+
+    // Declare name of the class and its debug switch
+    ClassName("pointMesh");
 
 
     // Constructors
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.C b/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.C
index 784572c414f..f00bb8cbb41 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.C
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.C
@@ -28,13 +28,11 @@ License
 #include "coupledPointPatch.H"
 #include "pointBoundaryMesh.H"
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
 
 namespace Foam
 {
-defineTypeNameAndDebug(coupledPointPatch, 0);
+    defineTypeNameAndDebug(coupledPointPatch, 0);
 }
 
 
@@ -44,10 +42,4 @@ Foam::coupledPointPatch::coupledPointPatch(const pointBoundaryMesh& bm)
 {}
 
 
-// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
-
-Foam::coupledPointPatch::~coupledPointPatch()
-{}
-
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.H
index 457062aa292..88a77c8f18d 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.H
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/basic/coupled/coupledPointPatch.H
@@ -35,8 +35,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef coupledPointPatch_H
-#define coupledPointPatch_H
+#ifndef Foam_coupledPointPatch_H
+#define Foam_coupledPointPatch_H
 
 #include "coupledPolyPatch.H"
 
@@ -45,6 +45,7 @@ SourceFiles
 namespace Foam
 {
 
+// Forward Declarations
 class pointBoundaryMesh;
 
 /*---------------------------------------------------------------------------*\
@@ -53,15 +54,6 @@ class pointBoundaryMesh;
 
 class coupledPointPatch
 {
-    // Private Member Functions
-
-        //- No copy construct
-        coupledPointPatch(const coupledPointPatch&) = delete;
-
-        //- No copy assignment
-        void operator=(const coupledPointPatch&) = delete;
-
-
 protected:
 
     // Protected Member Functions
@@ -85,6 +77,12 @@ protected:
         virtual void updateMesh(PstreamBuffers&) = 0;
 
 
+        //- No copy construct
+        coupledPointPatch(const coupledPointPatch&) = delete;
+
+        //- No copy assignment
+        void operator=(const coupledPointPatch&) = delete;
+
 public:
 
     //- Runtime type information
@@ -94,12 +92,11 @@ public:
     // Constructors
 
         //- Construct from components
-        coupledPointPatch(const pointBoundaryMesh& bm);
+        explicit coupledPointPatch(const pointBoundaryMesh& bm);
 
 
     //- Destructor
-    virtual ~coupledPointPatch();
-
+    virtual ~coupledPointPatch() = default;
 };
 
 
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclicSlip/cyclicSlipPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclicSlip/cyclicSlipPointPatch.H
index dbb531f3917..7b8d8ec754d 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclicSlip/cyclicSlipPointPatch.H
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/cyclicSlip/cyclicSlipPointPatch.H
@@ -74,9 +74,8 @@ public:
         {}
 
 
-    // Destructor
-
-        virtual ~cyclicSlipPointPatch() = default;
+    //- Destructor
+    virtual ~cyclicSlipPointPatch() = default;
 
 
     // Member Functions
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C
index 6a3018f31e6..4542912bb80 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C
@@ -52,7 +52,7 @@ namespace Foam
 void Foam::processorPointPatch::initGeometry(PstreamBuffers& pBufs)
 {
     // Algorithm:
-    // Depending on whether the patch is a master or a slave, get the primitive
+    // Depending on whether the patch is a owner or neighbour, get the primitive
     // patch points and filter away the points from the global patch.
 
     // Create the reversed patch and pick up its points
@@ -117,18 +117,4 @@ Foam::processorPointPatch::processorPointPatch
 {}
 
 
-// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
-
-Foam::processorPointPatch::~processorPointPatch()
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
-
-const Foam::labelList& Foam::processorPointPatch::reverseMeshPoints() const
-{
-    return reverseMeshPoints_;
-}
-
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H
index de76a27dd3c..df6a488b417 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.H
@@ -6,6 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2013 OpenFOAM Foundation
+    Copyright (C) 2022 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -34,7 +35,7 @@ Description
     patch they need to be identical on both sides with the normals pointing
     in opposite directions.  This is achieved by calling the reverseFace
     function in the decomposition.  It is therefore possible to re-create
-    the ordering of patch points on the slave side by reversing all the
+    the ordering of patch points on the neighbour side by reversing all the
     patch faces of the owner.
 
 SourceFiles
@@ -42,8 +43,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef processorPointPatch_H
-#define processorPointPatch_H
+#ifndef Foam_processorPointPatch_H
+#define Foam_processorPointPatch_H
 
 #include "coupledFacePointPatch.H"
 #include "processorPolyPatch.H"
@@ -61,7 +62,7 @@ class processorPointPatch
 :
     public coupledFacePointPatch
 {
-    // Private data
+    // Private Data
 
         const processorPolyPatch& procPolyPatch_;
 
@@ -112,10 +113,10 @@ public:
 
 
     //- Destructor
-    virtual ~processorPointPatch();
+    virtual ~processorPointPatch() = default;
 
 
-    // Member functions
+    // Member Functions
 
         //- Return message tag to use for communication
         virtual int tag() const
@@ -147,16 +148,16 @@ public:
             return procPolyPatch_.neighbProcNo();
         }
 
-        //- Is this a master patch
-        bool isMaster() const
+        //- Does the processor own the patch ?
+        bool owner() const
         {
-            return myProcNo() < neighbProcNo();
+            return procPolyPatch_.owner();
         }
 
-        //- Is this a slave patch
-        bool isSlave() const
+        //- Is the processor the patch neighbour ?
+        bool neighbour() const
         {
-            return !isMaster();
+            return !owner();
         }
 
         //- Return the underlying processorPolyPatch
@@ -166,8 +167,10 @@ public:
         }
 
         //- Return mesh points in the correct order for the receiving side
-        const labelList& reverseMeshPoints() const;
-
+        const labelList& reverseMeshPoints() const
+        {
+            return reverseMeshPoints_;
+        }
 };
 
 
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processorCyclic/processorCyclicPointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processorCyclic/processorCyclicPointPatch.H
index f943522bce7..c24d0324544 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processorCyclic/processorCyclicPointPatch.H
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processorCyclic/processorCyclicPointPatch.H
@@ -34,7 +34,7 @@ Description
     patch they need to be identical on both sides with the normals pointing
     in opposite directions.  This is achieved by calling the reverseFace
     function in the decomposition.  It is therefore possible to re-create
-    the ordering of patch points on the slave side by reversing all the
+    the ordering of patch points on the neighbour side by reversing all the
     patch faces of the owner.
 
 SourceFiles
@@ -42,8 +42,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef processorCyclicPointPatch_H
-#define processorCyclicPointPatch_H
+#ifndef Foam_processorCyclicPointPatch_H
+#define Foam_processorCyclicPointPatch_H
 
 #include "processorPointPatch.H"
 #include "processorCyclicPolyPatch.H"
@@ -61,10 +61,13 @@ class processorCyclicPointPatch
 :
     public processorPointPatch
 {
-    // Private data
+    // Private Data
 
         const processorCyclicPolyPatch& procCycPolyPatch_;
 
+
+    // Private Member Functions
+
         //- No copy construct
         processorCyclicPointPatch(const processorCyclicPointPatch&) = delete;
 
@@ -87,13 +90,11 @@ public:
         );
 
 
-    // Destructor
-
-        virtual ~processorCyclicPointPatch();
-
+    //- Destructor
+    virtual ~processorCyclicPointPatch();
 
-    // Member functions
 
+    // Member Functions
 
         //- Return message tag to use for communication
         virtual int tag() const
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.C b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.C
index f7992fdd721..40ab33cdd97 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.C
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.C
@@ -32,7 +32,7 @@ License
 
 namespace Foam
 {
-defineTypeNameAndDebug(coupledFacePointPatch, 0);
+    defineTypeNameAndDebug(coupledFacePointPatch, 0);
 }
 
 
@@ -50,10 +50,4 @@ Foam::coupledFacePointPatch::coupledFacePointPatch
 {}
 
 
-// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
-
-Foam::coupledFacePointPatch::~coupledFacePointPatch()
-{}
-
-
 // ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H
index 1cbd7345d13..e3701771b45 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/derived/coupled/coupledFacePointPatch.H
@@ -35,8 +35,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef coupledFacePointPatch_H
-#define coupledFacePointPatch_H
+#ifndef Foam_coupledFacePointPatch_H
+#define Foam_coupledFacePointPatch_H
 
 #include "coupledPointPatch.H"
 #include "facePointPatch.H"
@@ -47,8 +47,6 @@ SourceFiles
 namespace Foam
 {
 
-class pointBoundaryMesh;
-
 /*---------------------------------------------------------------------------*\
                       Class coupledFacePointPatch Declaration
 \*---------------------------------------------------------------------------*/
@@ -58,12 +56,18 @@ class coupledFacePointPatch
     public facePointPatch,
     public coupledPointPatch
 {
-    // Private data
+    // Private Data
 
         const coupledPolyPatch& coupledPolyPatch_;
 
 
-    // Private Member Functions
+protected:
+
+    // Protected Member Functions
+
+        //- Calculate mesh points
+        virtual void calcGeometry(PstreamBuffers&) = 0;
+
 
         //- No copy construct
         coupledFacePointPatch(const coupledFacePointPatch&) = delete;
@@ -72,14 +76,6 @@ class coupledFacePointPatch
         void operator=(const coupledFacePointPatch&) = delete;
 
 
-protected:
-
-        // Construction of demand-driven data
-
-            //- Calculate mesh points
-            virtual void calcGeometry(PstreamBuffers&) = 0;
-
-
 public:
 
     //- Runtime type information
@@ -97,7 +93,7 @@ public:
 
 
     //- Destructor
-    virtual ~coupledFacePointPatch();
+    virtual ~coupledFacePointPatch() = default;
 };
 
 
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.H
index 539f2901a02..efb6c478995 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.H
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/facePointPatch/facePointPatch.H
@@ -32,12 +32,12 @@ Description
 
 SourceFiles
     facePointPatch.C
-    newPointPatch.C
+    facePointPatchNew.C
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef facePointPatch_H
-#define facePointPatch_H
+#ifndef Foam_facePointPatch_H
+#define Foam_facePointPatch_H
 
 #include "pointPatch.H"
 #include "polyPatch.H"
@@ -61,7 +61,7 @@ class facePointPatch
 {
 protected:
 
-    // Protected data
+    // Protected Data
 
         //- Reference to the underlying polyPatch
         const polyPatch& polyPatch_;
diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H b/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H
index fdd5fb42d5f..22b6e194383 100644
--- a/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H
+++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/pointPatch/pointPatch.H
@@ -68,6 +68,7 @@ class pointPatch
         //- Reference to boundary mesh
         const pointBoundaryMesh& boundaryMesh_;
 
+
 protected:
 
     // Protected Member Functions
@@ -152,10 +153,10 @@ public:
         //- Return mesh points
         virtual const labelList& meshPoints() const = 0;
 
-        //- Return mesh points
+        //- Return pointField of points in patch
         virtual const vectorField& localPoints() const = 0;
 
-        //- Return  point normals
+        //- Return point unit normals
         virtual const vectorField& pointNormals() const = 0;
 
         //- Return the constraint type this pointPatch implements.
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H
index 4a631d55a7c..ac41ac96258 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H
+++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H
@@ -306,9 +306,12 @@ private:
 
 public:
 
-    // Public typedefs
+    // Public Typedefs
 
+        //- The mesh type
         typedef polyMesh Mesh;
+
+        //- The boundary type associated with the mesh
         typedef polyBoundaryMesh BoundaryMesh;
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
index 6b62c55f546..771d2f31701 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
@@ -484,8 +484,8 @@ void Foam::cyclicPolyPatch::getCentresAndAnchors
                         << endl;
                 }
 
-                // Note: getCentresAndAnchors gets called on the slave side
-                // so separationVector is owner-slave points.
+                // Note: getCentresAndAnchors gets called on the neighbour side
+                // so separationVector is owner-neighbour points.
 
                 half0Ctrs -= separationVector_;
                 anchors0 -= separationVector_;
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C
index 06bff44cf78..f3989dc66ad 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processorCyclic/processorCyclicPolyPatch.C
@@ -358,7 +358,7 @@ bool Foam::processorCyclicPolyPatch::order
 
     // (ab)use the cyclicPolyPatch ordering:
     //  - owner side stores geometry
-    //  - slave side does ordering according to owner side
+    //  - neighbour side does ordering according to owner side
     cycPatch.neighbPatch().initOrder(pBufs, masterPtr());
 
     return cycPatch.order(pBufs, pp, faceMap, rotation);
diff --git a/src/OpenFOAM/orientedType/orientedType.C b/src/OpenFOAM/orientedType/orientedType.C
index f22f9636ef7..0a04b1bfccc 100644
--- a/src/OpenFOAM/orientedType/orientedType.C
+++ b/src/OpenFOAM/orientedType/orientedType.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2017-2021 OpenCFD Ltd.
+    Copyright (C) 2017-2022 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -63,21 +63,21 @@ bool Foam::orientedType::checkType
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
-Foam::orientedType::orientedType()
+Foam::orientedType::orientedType() noexcept
 :
     oriented_(UNKNOWN)
 {}
 
 
-Foam::orientedType::orientedType(const orientedType& ot)
+Foam::orientedType::orientedType(const orientedType& ot) noexcept
 :
     oriented_(ot.oriented_)
 {}
 
 
-Foam::orientedType::orientedType(const bool oriented)
+Foam::orientedType::orientedType(const bool isOriented) noexcept
 :
-    oriented_(oriented ? ORIENTED : UNORIENTED)
+    oriented_(isOriented ? ORIENTED : UNORIENTED)
 {}
 
 
@@ -103,9 +103,9 @@ Foam::orientedType::orientedOption Foam::orientedType::oriented() const noexcept
 }
 
 
-void Foam::orientedType::setOriented(const bool oriented) noexcept
+void Foam::orientedType::setOriented(const bool on) noexcept
 {
-    oriented_ = oriented ? ORIENTED : UNORIENTED;
+    oriented_ = on ? ORIENTED : UNORIENTED;
 }
 
 
@@ -221,7 +221,7 @@ void Foam::orientedType::operator/=(const scalar s)
 }
 
 
-bool Foam::orientedType::operator()() const
+bool Foam::orientedType::operator()() const noexcept
 {
     return oriented_ == ORIENTED;
 }
diff --git a/src/OpenFOAM/orientedType/orientedType.H b/src/OpenFOAM/orientedType/orientedType.H
index 608c7656f7a..8cfebe96553 100644
--- a/src/OpenFOAM/orientedType/orientedType.H
+++ b/src/OpenFOAM/orientedType/orientedType.H
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2017-2021 OpenCFD Ltd.
+    Copyright (C) 2017-2022 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -34,8 +34,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef orientedType_H
-#define orientedType_H
+#ifndef Foam_orientedType_H
+#define Foam_orientedType_H
 
 #include "Enum.H"
 
@@ -61,7 +61,7 @@ public:
     // Public Data Types
 
         //- Enumeration defining oriented flags
-        enum orientedOption
+        enum orientedOption : unsigned char
         {
             UNKNOWN = 0,
             ORIENTED = 1,
@@ -84,14 +84,14 @@ public:
 
     // Constructors
 
-        //- Default construct as "UNKNOWN"
-        orientedType();
+        //- Default construct as \c UNKNOWN
+        orientedType() noexcept;
 
         //- Copy construct
-        orientedType(const orientedType& ot);
+        orientedType(const orientedType& ot) noexcept;
 
         //- Construct from bool
-        explicit orientedType(const bool oriented);
+        explicit orientedType(const bool isOriented) noexcept;
 
         //- Construct from Istream
         explicit orientedType(Istream& is);
@@ -112,19 +112,25 @@ public:
         //- Return the oriented flag
         orientedOption oriented() const noexcept;
 
-        //- Set the oriented flag
-        void setOriented(const bool oriented = true) noexcept;
+        //- Set the oriented flag: on/off
+        void setOriented(const bool on = true) noexcept;
 
         //- Read the "oriented" state from dictionary
         void read(const dictionary& dict);
 
-        //- Write the "oriented" flag entry (if ORIENTED)
+        //- Write the "oriented" flag entry (if \c ORIENTED)
         //  \return True if entry was written
         bool writeEntry(Ostream& os) const;
 
 
     // Member Operators
 
+        //- True if type is \c ORIENTED
+        explicit operator bool() const noexcept
+        {
+            return (oriented_ == orientedOption::ORIENTED);
+        }
+
         void operator=(const orientedType& ot);
 
         void operator+=(const orientedType& ot);
@@ -133,7 +139,9 @@ public:
         void operator/=(const orientedType& ot);
         void operator*=(const scalar s);
         void operator/=(const scalar s);
-        bool operator()() const;
+
+        //- True if type is \c ORIENTED. Same as bool operator
+        bool operator()() const noexcept;
 
 
     // IOstream Operators
diff --git a/src/finiteArea/faMesh/faMesh.H b/src/finiteArea/faMesh/faMesh.H
index 7d4bd4704d5..3cdcc6811f5 100644
--- a/src/finiteArea/faMesh/faMesh.H
+++ b/src/finiteArea/faMesh/faMesh.H
@@ -485,7 +485,10 @@ public:
 
     // Public Typedefs
 
+        //- The mesh type
         typedef faMesh Mesh;
+
+        //- The boundary type associated with the mesh
         typedef faBoundaryMesh BoundaryMesh;
 
 
diff --git a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H
index 35d19bd11ce..73b55bf598d 100644
--- a/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H
+++ b/src/finiteArea/faMesh/faPatches/faPatch/faPatch.H
@@ -146,8 +146,10 @@ protected:
 
 public:
 
+    //- The boundary type associated with the patch
     typedef faBoundaryMesh BoundaryMesh;
 
+
     //- Runtime type information
     TypeName("patch");
 
diff --git a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H
index 3ec4c8a26ce..a6cf3cb1701 100644
--- a/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H
+++ b/src/finiteArea/fields/faPatchFields/faPatchField/faPatchField.H
@@ -101,7 +101,13 @@ class faPatchField
 
 public:
 
+    //- The internal field type associated with the patch field
+    typedef DimensionedField<Type, areaMesh> Internal;
+
+    //- The patch type for the patch field
     typedef faPatch Patch;
+
+    //- Type for a \em calculated patch
     typedef calculatedFaPatchField<Type> Calculated;
 
 
diff --git a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H
index ab434bc0533..679bebca548 100644
--- a/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H
+++ b/src/finiteArea/fields/faePatchFields/faePatchField/faePatchField.H
@@ -45,8 +45,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef faePatchField_H
-#define faePatchField_H
+#ifndef Foam_faePatchField_H
+#define Foam_faePatchField_H
 
 #include "faPatch.H"
 #include "DimensionedField.H"
@@ -82,7 +82,7 @@ class faePatchField
 :
     public Field<Type>
 {
-    // Private data
+    // Private Data
 
         //- Reference to a patch
         const faPatch& patch_;
@@ -93,7 +93,13 @@ class faePatchField
 
 public:
 
+    //- The internal field type associated with the patch field
+    typedef DimensionedField<Type, edgeMesh> Internal;
+
+    //- The patch type for the patch field
     typedef faPatch Patch;
+
+    //- Type for a \em calculated patch
     typedef calculatedFaePatchField<Type> Calculated;
 
 
diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
index ce9c89d4fd3..4db51f93a4a 100644
--- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2017 OpenFOAM Foundation
-    Copyright (C) 2019-2021 OpenCFD Ltd.
+    Copyright (C) 2019-2022 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -44,8 +44,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef fvPatchField_H
-#define fvPatchField_H
+#ifndef Foam_fvPatchField_H
+#define Foam_fvPatchField_H
 
 #include "fvPatch.H"
 #include "DimensionedField.H"
@@ -108,7 +108,13 @@ class fvPatchField
 
 public:
 
+    //- The internal field type associated with the patch field
+    typedef DimensionedField<Type, volMesh> Internal;
+
+    //- The patch type for the patch field
     typedef fvPatch Patch;
+
+    //- Type for a \em calculated patch
     typedef calculatedFvPatchField<Type> Calculated;
 
 
diff --git a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H
index c65ee8877dc..0ac59521360 100644
--- a/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H
+++ b/src/finiteVolume/fields/fvsPatchFields/fvsPatchField/fvsPatchField.H
@@ -44,8 +44,8 @@ SourceFiles
 
 \*---------------------------------------------------------------------------*/
 
-#ifndef fvsPatchField_H
-#define fvsPatchField_H
+#ifndef Foam_fvsPatchField_H
+#define Foam_fvsPatchField_H
 
 #include "fvPatch.H"
 #include "DimensionedField.H"
@@ -78,7 +78,7 @@ class fvsPatchField
 :
     public Field<Type>
 {
-    // Private data
+    // Private Data
 
         //- Reference to patch
         const fvPatch& patch_;
@@ -89,7 +89,13 @@ class fvsPatchField
 
 public:
 
+    //- The internal field type associated with the patch field
+    typedef DimensionedField<Type, surfaceMesh> Internal;
+
+    //- The patch type for the patch field
     typedef fvPatch Patch;
+
+    //- Type for a \em calculated patch
     typedef calculatedFvsPatchField<Type> Calculated;
 
 
diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H
index 4415f5b9a97..a8a7d096311 100644
--- a/src/finiteVolume/fvMesh/fvMesh.H
+++ b/src/finiteVolume/fvMesh/fvMesh.H
@@ -174,9 +174,12 @@ protected:
 
 public:
 
-    // Public typedefs
+    // Public Typedefs
 
+        //- The mesh type
         typedef fvMesh Mesh;
+
+        //- The boundary type associated with the mesh
         typedef fvBoundaryMesh BoundaryMesh;
 
 
diff --git a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H
index 9f1a73a006a..b184dd0ec66 100644
--- a/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H
+++ b/src/finiteVolume/fvMesh/fvPatches/fvPatch/fvPatch.H
@@ -113,6 +113,7 @@ public:
 
 public:
 
+    //- The boundary type associated with the patch
     typedef fvBoundaryMesh BoundaryMesh;
 
     friend class fvBoundaryMesh;
diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C
index a92364d0ccb..43f77436c19 100644
--- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C
+++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C
@@ -89,13 +89,10 @@ void Foam::volPointInterpolation::addSeparated
         Pout<< "volPointInterpolation::addSeparated" << endl;
     }
 
-    typename GeometricField<Type, pointPatchField, pointMesh>::
-        Internal& pfi = pf.ref();
+    auto& pfi = pf.ref();
+    auto& pfbf = pf.boundaryFieldRef();
 
-    typename GeometricField<Type, pointPatchField, pointMesh>::
-        Boundary& pfbf = pf.boundaryFieldRef();
-
-    const label nReq = Pstream::nRequests();
+    const label startOfRequests = UPstream::nRequests();
 
     forAll(pfbf, patchi)
     {
@@ -110,8 +107,8 @@ void Foam::volPointInterpolation::addSeparated
         }
     }
 
-    // Block for any outstanding requests
-    Pstream::waitRequests(nReq);
+    // Wait for outstanding requests
+    UPstream::waitRequests(startOfRequests);
 
     forAll(pfbf, patchi)
     {
diff --git a/src/functionObjects/field/mapFields/mapFieldsTemplates.C b/src/functionObjects/field/mapFields/mapFieldsTemplates.C
index 54d268270e1..c5e6968d962 100644
--- a/src/functionObjects/field/mapFields/mapFieldsTemplates.C
+++ b/src/functionObjects/field/mapFields/mapFieldsTemplates.C
@@ -36,17 +36,17 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes
     GeometricField<Type, fvPatchField, volMesh>& fld
 ) const
 {
-    typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
+    auto& fldBf = fld.boundaryFieldRef();
 
-    typename VolFieldType::Boundary& fldBf = fld.boundaryFieldRef();
+    const UPstream::commsTypes commsType(UPstream::defaultCommsType);
 
     if
     (
-        Pstream::defaultCommsType == Pstream::commsTypes::blocking
-     || Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
+        commsType == UPstream::commsTypes::blocking
+     || commsType == UPstream::commsTypes::nonBlocking
     )
     {
-        const label nReq = Pstream::nRequests();
+        const label startOfRequests = UPstream::nRequests();
 
         forAll(fldBf, patchi)
         {
@@ -58,18 +58,18 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes
              && polyPatch::constraintType(tgtField.patch().patch().type())
             )
             {
-                tgtField.initEvaluate(Pstream::defaultCommsType);
+                tgtField.initEvaluate(commsType);
             }
         }
 
-        // Block for any outstanding requests
+        // Wait for outstanding requests
         if
         (
-            Pstream::parRun()
-         && Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
+            UPstream::parRun()
+         && commsType == UPstream::commsTypes::nonBlocking
         )
         {
-            Pstream::waitRequests(nReq);
+            UPstream::waitRequests(startOfRequests);
         }
 
         forAll(fldBf, patchi)
@@ -82,11 +82,11 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes
              && polyPatch::constraintType(tgtField.patch().patch().type())
             )
             {
-                tgtField.evaluate(Pstream::defaultCommsType);
+                tgtField.evaluate(commsType);
             }
         }
     }
-    else if (Pstream::defaultCommsType == Pstream::commsTypes::scheduled)
+    else if (commsType == UPstream::commsTypes::scheduled)
     {
         const lduSchedule& patchSchedule =
             fld.mesh().globalData().patchSchedule();
@@ -105,11 +105,11 @@ void Foam::functionObjects::mapFields::evaluateConstraintTypes
             {
                 if (schedEval.init)
                 {
-                    tgtField.initEvaluate(Pstream::commsTypes::scheduled);
+                    tgtField.initEvaluate(commsType);
                 }
                 else
                 {
-                    tgtField.evaluate(Pstream::commsTypes::scheduled);
+                    tgtField.evaluate(commsType);
                 }
             }
         }
diff --git a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C
index e8e889bd7c0..688913f5dd6 100644
--- a/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C
+++ b/src/overset/dynamicOversetFvMesh/dynamicOversetFvMeshTemplates.C
@@ -119,27 +119,31 @@ void Foam::dynamicOversetFvMesh::correctBoundaryConditions
     const bool typeOnly
 )
 {
-    const label nReq = Pstream::nRequests();
+    const label startOfRequests = UPstream::nRequests();
 
     forAll(bfld, patchi)
     {
         if (typeOnly == (isA<PatchType>(bfld[patchi]) != nullptr))
         {
-            bfld[patchi].initEvaluate(Pstream::defaultCommsType);
+            bfld[patchi].initEvaluate(UPstream::defaultCommsType);
         }
     }
 
-    // Block for any outstanding requests
-    if (Pstream::parRun())
+    // Wait for outstanding requests
+    if
+    (
+        UPstream::parRun()
+     && UPstream::defaultCommsType == UPstream::commsTypes::nonBlocking
+    )
     {
-        Pstream::waitRequests(nReq);
+        UPstream::waitRequests(startOfRequests);
     }
 
     forAll(bfld, patchi)
     {
         if (typeOnly == (isA<PatchType>(bfld[patchi]) != nullptr))
         {
-            bfld[patchi].evaluate(Pstream::defaultCommsType);
+            bfld[patchi].evaluate(UPstream::defaultCommsType);
         }
     }
 }
@@ -899,7 +903,7 @@ void Foam::dynamicOversetFvMesh::correctCoupledBoundaryConditions(GeoField& fld)
 {
     typename GeoField::Boundary& bfld = fld.boundaryFieldRef();
 
-    const label nReq = Pstream::nRequests();
+    const label startOfRequests = UPstream::nRequests();
 
     forAll(bfld, patchi)
     {
@@ -910,10 +914,14 @@ void Foam::dynamicOversetFvMesh::correctCoupledBoundaryConditions(GeoField& fld)
         }
     }
 
-    // Block for any outstanding requests
-    if (Pstream::parRun())
+    // Wait for outstanding requests
+    if
+    (
+        UPstream::parRun()
+     && UPstream::defaultCommsType == UPstream::commsTypes::nonBlocking
+    )
     {
-        Pstream::waitRequests(nReq);
+        UPstream::waitRequests(startOfRequests);
     }
 
     forAll(bfld, patchi)
-- 
GitLab