From 64c3e484bb2134d1865cbccf6fe923bfafeb769a Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Thu, 27 Sep 2018 10:17:30 +0200
Subject: [PATCH] STYLE: add nBoundaryFaces() method to primitiveMesh

- nBoundaryFaces() is often used and is identical to
  (nFaces() - nInternalFaces()).

- forward the mesh nInternalFaces() and nBoundaryFaces() to
  polyBoundaryMesh as nFaces() and start() respectively,
  for use when operating on a polyBoundaryMesh.

STYLE:

- use identity() function with starting offset when creating boundary maps.

     labelList map
     (
         identity(mesh.nBoundaryFaces(), mesh.nInternalFaces())
     );

  vs.

     labelList map(mesh.nBoundaryFaces());
     forAll(map, i)
     {
         map[i] = mesh.nInternalFaces() + i;
     }
---
 .../test/globalMeshData/Test-globalMeshData.C |  2 +-
 applications/test/syncTools/Test-syncTools.C  |  2 +-
 .../mesh/advanced/modifyMesh/modifyMesh.C     |  2 +-
 .../fluentMeshToFoam/fluentMeshToFoam.L       |  2 +-
 .../backgroundMeshDecomposition.C             |  4 +-
 .../conformalVoronoiMeshZones.C               |  8 +-
 .../foamyHexMeshBackgroundMesh.C              |  2 +-
 .../mesh/manipulation/checkMesh/checkTools.C  |  2 +-
 .../mergeOrSplitBaffles/mergeOrSplitBaffles.C |  2 +-
 .../orientFaceZone/orientFaceZone.C           |  6 +-
 .../polyDualMesh/polyDualMeshApp.C            |  4 +-
 .../splitMeshRegions/splitMeshRegions.C       | 12 +--
 .../redistributePar/redistributePar.C         |  2 +-
 .../miscellaneous/postChannel/channelIndex.C  |  2 +-
 .../faceAgglomerate/faceAgglomerate.C         |  2 +-
 .../preProcessing/setFields/setFields.C       |  4 +-
 .../viewFactorsGen/viewFactorsGen.C           |  5 +-
 .../polyMesh/globalMeshData/globalMeshData.C  |  2 +-
 .../polyBoundaryMesh/polyBoundaryMesh.C       | 23 +++---
 .../polyBoundaryMesh/polyBoundaryMesh.H       | 14 +++-
 .../polyMeshTetDecomposition.C                |  2 +-
 .../polyPatches/polyPatch/polyPatch.C         |  8 +-
 .../polyPatches/polyPatch/polyPatch.H         | 11 +--
 .../meshes/polyMesh/syncTools/syncTools.C     |  2 +-
 .../meshes/polyMesh/syncTools/syncTools.H     |  6 +-
 .../polyMesh/syncTools/syncToolsTemplates.C   |  4 +-
 .../meshes/polyMesh/zones/faceZone/faceZone.C |  4 +-
 .../meshes/primitiveMesh/primitiveMesh.H      | 41 ++++++----
 .../meshes/primitiveMesh/primitiveMeshI.H     | 75 +++++++++----------
 .../ensight/output/ensightOutputTemplates.C   |  2 +-
 src/conversion/polyDualMesh/polyDualMesh.C    |  6 +-
 .../dynamicRefineFvMesh/dynamicRefineFvMesh.C |  2 +-
 src/dynamicMesh/boundaryMesh/boundaryMesh.C   | 10 +--
 .../fvMeshDistribute/fvMeshDistribute.C       | 18 ++---
 src/dynamicMesh/meshCut/cellCuts/cellCuts.C   |  2 +-
 .../polyMeshGeometry/polyMeshGeometry.C       | 10 +--
 .../polyMeshAdder/faceCoupleInfo.C            | 17 ++---
 .../polyTopoChange/combineFaces.C             |  2 +-
 .../polyTopoChange/edgeCollapser.C            |  2 +-
 .../polyTopoChange/hexRef8/hexRef8.C          | 26 +++----
 .../polyTopoChange/removeCells.C              |  2 +-
 .../polyTopoChange/removePoints.C             |  2 +-
 .../polyTopoChange/tetDecomposer.C            |  2 +-
 .../faMesh/faMeshMapper/faAreaMapper.C        | 12 +--
 .../isoAdvection/isoAdvection/isoAdvection.C  |  2 +-
 .../CFCCellToCellStencil.C                    |  4 +-
 .../globalIndexStencils/cellToCellStencil.C   |  4 +-
 .../extendedUpwindCellToFaceStencil.C         |  2 +-
 .../FECCellToFaceStencil.C                    |  2 +-
 .../globalIndexStencils/cellToFaceStencil.C   |  6 +-
 .../CFCFaceToCellStencil.C                    |  6 +-
 .../singleCellFvMesh/singleCellFvMesh.C       |  2 +-
 .../volPointInterpolate.C                     |  2 +-
 .../volPointInterpolation.C                   |  2 +-
 .../meshRefinement/meshRefinement.C           | 31 +++-----
 .../meshRefinement/meshRefinementBaffles.C    | 26 +++----
 .../meshRefinement/meshRefinementGapRefine.C  |  2 +-
 .../meshRefinement/meshRefinementMerge.C      | 24 ++----
 .../meshRefinementProblemCells.C              |  4 +-
 .../meshRefinement/meshRefinementRefine.C     |  8 +-
 .../meshRefinement/meshRefinementTemplates.C  |  2 +-
 .../snappyHexMeshDriver/snappyLayerDriver.C   | 10 +--
 .../mappedPolyPatch/mappedPatchBaseI.H        |  2 +-
 src/meshTools/meshSearch/meshSearch.C         | 11 ++-
 src/meshTools/regionSplit/localPointRegion.C  |  6 +-
 src/meshTools/regionSplit/regionSplit.C       |  2 +-
 .../sets/cellSources/nbrToCell/nbrToCell.C    |  2 +-
 src/meshTools/sets/topoSets/faceZoneSet.C     |  2 +-
 .../triSurfaceTools/triSurfaceTools.C         | 15 +---
 .../preserveFaceZonesConstraint.C             |  2 +-
 .../preservePatchesConstraint.C               |  2 +-
 .../decompositionMethod/decompositionMethod.C |  4 +-
 src/renumber/SloanRenumber/SloanRenumber.C    |  2 +-
 src/sampling/meshToMesh/meshToMesh.C          |  2 +-
 .../sampledSet/shortestPath/shortestPathSet.C |  2 +-
 .../sampledTriSurfaceMesh.C                   |  2 +-
 .../sampledTriSurfaceMeshTemplates.C          |  2 +-
 src/sampling/surface/isoSurface/isoSurface.C  |  2 +-
 .../surface/isoSurface/isoSurfaceTemplates.C  |  2 +-
 .../surface/triSurfaceMesh/discreteSurface.C  |  2 +-
 .../triSurfaceMesh/discreteSurfaceTemplates.C |  2 +-
 src/surfMesh/MeshedSurface/MeshedSurface.C    |  2 +-
 .../solarLoad/faceShading/faceShading.C       |  5 +-
 83 files changed, 279 insertions(+), 303 deletions(-)

diff --git a/applications/test/globalMeshData/Test-globalMeshData.C b/applications/test/globalMeshData/Test-globalMeshData.C
index 56a285ae026..8d3f2c24e6a 100644
--- a/applications/test/globalMeshData/Test-globalMeshData.C
+++ b/applications/test/globalMeshData/Test-globalMeshData.C
@@ -180,7 +180,7 @@ int main(int argc, char *argv[])
         const labelListList& transformedSlaves =
             globalData.globalPointTransformedBoundaryFaces();
 
-        label nBnd = mesh.nFaces()-mesh.nInternalFaces();
+        const label nBnd = mesh.nBoundaryFaces();
 
         pointField fc(globalPointBoundaryFacesMap.constructSize());
         SubList<point>(fc, nBnd) =
diff --git a/applications/test/syncTools/Test-syncTools.C b/applications/test/syncTools/Test-syncTools.C
index 5dfef2fcf2d..5fca906370b 100644
--- a/applications/test/syncTools/Test-syncTools.C
+++ b/applications/test/syncTools/Test-syncTools.C
@@ -195,7 +195,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
         SubList<face>
         (
             mesh.faces(),
-            mesh.nFaces()-mesh.nInternalFaces(),
+            mesh.nBoundaryFaces(),
             mesh.nInternalFaces()
         ),
         mesh.points()
diff --git a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C
index ce2ee164f20..c522d8f48ab 100644
--- a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C
+++ b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C
@@ -413,7 +413,7 @@ int main(int argc, char *argv[])
     const SubList<face> outsideFaces
     (
         mesh.faces(),
-        mesh.nFaces() - mesh.nInternalFaces(),
+        mesh.nBoundaryFaces(),
         mesh.nInternalFaces()
     );
 
diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
index 064395df05a..e029457d425 100644
--- a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
+++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L
@@ -1386,7 +1386,7 @@ int main(int argc, char *argv[])
     DynamicList<polyPatch*> newPatches(nPatches);
 
     // For every boundary face the old patch.
-    labelList facePatchID(pShapeMesh.nFaces()-pShapeMesh.nInternalFaces(), -1);
+    labelList facePatchID(pShapeMesh.nBoundaryFaces(), -1);
     label cMeshFace = pShapeMesh.nInternalFaces();
     label nBoundaries = 0;
 
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C
index ce5f0bc1916..3ab96dd6b05 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C
@@ -468,7 +468,7 @@ void Foam::backgroundMeshDecomposition::printMeshData
 
     // // Print stats
 
-    // globalIndex globalBoundaryFaces(mesh.nFaces()-mesh.nInternalFaces());
+    // globalIndex globalBoundaryFaces(mesh.nBoundaryFaces());
 
     for (label proci = 0; proci < Pstream::nProcs(); proci++)
     {
@@ -671,7 +671,7 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree()
         SubList<face>
         (
             mesh_.faces(),
-            mesh_.nFaces() - mesh_.nInternalFaces(),
+            mesh_.nBoundaryFaces(),
             mesh_.nInternalFaces()
         ),
         mesh_.points()
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C
index 2a370493889..7f2ecf8c81e 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshZones.C
@@ -39,7 +39,7 @@ void Foam::conformalVoronoiMesh::calcNeighbourCellCentres
     pointField& neiCc
 ) const
 {
-    label nBoundaryFaces = mesh.nFaces() - mesh.nInternalFaces();
+    const label nBoundaryFaces = mesh.nBoundaryFaces();
 
     if (neiCc.size() != nBoundaryFaces)
     {
@@ -319,7 +319,7 @@ void Foam::conformalVoronoiMesh::calcFaceZones
     const labelList& faceOwner = mesh.faceOwner();
     const labelList& faceNeighbour = mesh.faceNeighbour();
 
-    labelList neiFaceOwner(mesh.nFaces() - mesh.nInternalFaces(), label(-1));
+    labelList neiFaceOwner(mesh.nBoundaryFaces(), label(-1));
 
     const polyBoundaryMesh& patches = mesh.boundaryMesh();
 
@@ -421,7 +421,7 @@ void Foam::conformalVoronoiMesh::calcFaceZones
         )
     );
 
-    pointField neiCc(mesh.nFaces() - mesh.nInternalFaces());
+    pointField neiCc(mesh.nBoundaryFaces());
     calcNeighbourCellCentres
     (
         mesh,
@@ -498,7 +498,7 @@ void Foam::conformalVoronoiMesh::calcFaceZones
     }
 
 
-//    labelList neiCellSurface(mesh.nFaces()-mesh.nInternalFaces());
+//    labelList neiCellSurface(mesh.nBoundaryFaces());
 //
 //    forAll(patches, patchi)
 //    {
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C
index 578731132f9..0364c177749 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C
@@ -119,7 +119,7 @@ void printMeshData(const polyMesh& mesh)
 
     // Print stats
 
-    globalIndex globalBoundaryFaces(mesh.nFaces()-mesh.nInternalFaces());
+    globalIndex globalBoundaryFaces(mesh.nBoundaryFaces());
 
     label maxProcCells = 0;
     label totProcFaces = 0;
diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C
index d3d78534361..e230e03990e 100644
--- a/applications/utilities/mesh/manipulation/checkMesh/checkTools.C
+++ b/applications/utilities/mesh/manipulation/checkMesh/checkTools.C
@@ -314,7 +314,7 @@ void Foam::mergeAndWrite
     }
 
 
-    boolList bndInSet(mesh.nFaces()-mesh.nInternalFaces());
+    boolList bndInSet(mesh.nBoundaryFaces());
     forAll(pbm, patchi)
     {
         const polyPatch& pp = pbm[patchi];
diff --git a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C
index 5422183a3f3..d6c7160f5d5 100644
--- a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C
+++ b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C
@@ -249,7 +249,7 @@ labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces)
         (
             mesh,
             "duplicateFaces",
-            (mesh.nFaces() - mesh.nInternalFaces())/256
+            mesh.nBoundaryFaces()/256
         );
 
         forAll(duplicates, bFacei)
diff --git a/applications/utilities/mesh/manipulation/orientFaceZone/orientFaceZone.C b/applications/utilities/mesh/manipulation/orientFaceZone/orientFaceZone.C
index 2a05649e771..972503c9ec8 100644
--- a/applications/utilities/mesh/manipulation/orientFaceZone/orientFaceZone.C
+++ b/applications/utilities/mesh/manipulation/orientFaceZone/orientFaceZone.C
@@ -295,11 +295,7 @@ int main(int argc, char *argv[])
     {
         const polyBoundaryMesh& bm = mesh.boundaryMesh();
 
-        labelList neiStatus
-        (
-            mesh.nFaces()-mesh.nInternalFaces(),
-            orientedSurface::UNVISITED
-        );
+        labelList neiStatus(mesh.nBoundaryFaces(), orientedSurface::UNVISITED);
 
         forAll(faceLabels, i)
         {
diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMeshApp.C b/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMeshApp.C
index 88f949782d3..a1cbb287f6b 100644
--- a/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMeshApp.C
+++ b/applications/utilities/mesh/manipulation/polyDualMesh/polyDualMeshApp.C
@@ -140,7 +140,7 @@ void simpleMarkFeatures
         SubList<face>
         (
             mesh.faces(),
-            mesh.nFaces()-mesh.nInternalFaces(),
+            mesh.nBoundaryFaces(),
             mesh.nInternalFaces()
         ),
         mesh.points()
@@ -238,7 +238,7 @@ void simpleMarkFeatures
     // ~~~~~~~~~~~~~~~~~~~~~~~~~
 
     // Face centres that need inclusion in the dual mesh
-    labelHashSet featureFaceSet(mesh.nFaces()-mesh.nInternalFaces());
+    labelHashSet featureFaceSet(mesh.nBoundaryFaces());
     // A. boundary faces.
     for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
     {
diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
index fe0a60070fb..2b9ff9c3b85 100644
--- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
+++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C
@@ -353,7 +353,7 @@ void getInterfaceSizes
     // ~~~~~~~~~~~~~~
 
     // Neighbour cellRegion.
-    labelList coupledRegion(mesh.nFaces()-mesh.nInternalFaces());
+    labelList coupledRegion(mesh.nBoundaryFaces());
 
     forAll(coupledRegion, i)
     {
@@ -641,7 +641,7 @@ autoPtr<mapPolyMesh> createRegionMesh
 
 
     // Neighbour cellRegion.
-    labelList coupledRegion(mesh.nFaces()-mesh.nInternalFaces());
+    labelList coupledRegion(mesh.nBoundaryFaces());
 
     forAll(coupledRegion, i)
     {
@@ -1232,7 +1232,7 @@ void getZoneID
     }
 
     // Neighbour zoneID.
-    neiZoneID.setSize(mesh.nFaces()-mesh.nInternalFaces());
+    neiZoneID.setSize(mesh.nBoundaryFaces());
 
     forAll(neiZoneID, i)
     {
@@ -1263,7 +1263,7 @@ void matchRegions
 
     // Get current per cell zoneID
     labelList zoneID(mesh.nCells(), -1);
-    labelList neiZoneID(mesh.nFaces()-mesh.nInternalFaces());
+    labelList neiZoneID(mesh.nBoundaryFaces());
     getZoneID(mesh, cellZones, zoneID, neiZoneID);
 
     // Sizes per cellzone
@@ -1552,7 +1552,7 @@ int main(int argc, char *argv[])
     // Existing zoneID
     labelList zoneID(mesh.nCells(), -1);
     // Neighbour zoneID.
-    labelList neiZoneID(mesh.nFaces()-mesh.nInternalFaces());
+    labelList neiZoneID(mesh.nBoundaryFaces());
     getZoneID(mesh, cellZones, zoneID, neiZoneID);
 
 
@@ -1622,7 +1622,7 @@ int main(int argc, char *argv[])
         );
 
         labelList newZoneID(mesh.nCells(), -1);
-        labelList newNeiZoneID(mesh.nFaces()-mesh.nInternalFaces());
+        labelList newNeiZoneID(mesh.nBoundaryFaces());
         getZoneID(mesh, newCellZones, newZoneID, newNeiZoneID);
 
         label unzonedCelli = newZoneID.find(-1);
diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
index 133161fcc7a..e01205428b3 100644
--- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
+++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C
@@ -172,7 +172,7 @@ void printMeshData(const polyMesh& mesh)
 
     // Print stats
 
-    globalIndex globalBoundaryFaces(mesh.nFaces()-mesh.nInternalFaces());
+    globalIndex globalBoundaryFaces(mesh.nBoundaryFaces());
 
     label maxProcCells = 0;
     label totProcFaces = 0;
diff --git a/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C b/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C
index b90e4cefea2..ddefd7f7ee4 100644
--- a/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C
+++ b/applications/utilities/postProcessing/miscellaneous/postChannel/channelIndex.C
@@ -55,7 +55,7 @@ void Foam::channelIndex::walkOppositeFaces
 {
     const cellList& cells = mesh.cells();
     const faceList& faces = mesh.faces();
-    label nBnd = mesh.nFaces() - mesh.nInternalFaces();
+    const label nBnd = mesh.nBoundaryFaces();
 
     DynamicList<label> frontFaces(startFaces);
     forAll(frontFaces, i)
diff --git a/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C b/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C
index e48f7b48e34..ff77af6bb62 100644
--- a/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C
+++ b/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C
@@ -128,7 +128,7 @@ int main(int argc, char *argv[])
     }
 
     // Sync agglomeration across coupled patches
-    labelList nbrAgglom(mesh.nFaces() - mesh.nInternalFaces(), -1);
+    labelList nbrAgglom(mesh.nBoundaryFaces(), -1);
 
     forAll(boundary, patchi)
     {
diff --git a/applications/utilities/preProcessing/setFields/setFields.C b/applications/utilities/preProcessing/setFields/setFields.C
index f7578ee9de0..554f8e1ac9c 100644
--- a/applications/utilities/preProcessing/setFields/setFields.C
+++ b/applications/utilities/preProcessing/setFields/setFields.C
@@ -239,7 +239,7 @@ bool setFaceFieldType
         const Type& value = pTraits<Type>(fieldValueStream);
 
         // Create flat list of selected faces and their value.
-        Field<Type> allBoundaryValues(mesh.nFaces()-mesh.nInternalFaces());
+        Field<Type> allBoundaryValues(mesh.nBoundaryFaces());
         forAll(field.boundaryField(), patchi)
         {
             SubField<Type>
@@ -447,7 +447,7 @@ int main(int argc, char *argv[])
             (
                 mesh,
                 "faceSet",
-                (mesh.nFaces()-mesh.nInternalFaces())/10+1
+                mesh.nBoundaryFaces()/10+1
             );
 
             source->applyToSet
diff --git a/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C b/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C
index 7d575efa820..3670eceab11 100644
--- a/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C
+++ b/applications/utilities/preProcessing/viewFactorsGen/viewFactorsGen.C
@@ -82,10 +82,7 @@ triSurface triangulate
     const polyMesh& mesh = bMesh.mesh();
 
     // Storage for surfaceMesh. Size estimate.
-    DynamicList<labelledTri> triangles
-    (
-        mesh.nFaces() - mesh.nInternalFaces()
-    );
+    DynamicList<labelledTri> triangles(mesh.nBoundaryFaces());
 
     label newPatchI = 0;
     label localTriFaceI = 0;
diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C
index ae6d7f28a2f..feb7781a196 100644
--- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C
+++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C
@@ -1325,7 +1325,7 @@ void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const
     // Global indices for boundary faces
     globalBoundaryFaceNumberingPtr_.reset
     (
-        new globalIndex(mesh_.nFaces()-mesh_.nInternalFaces())
+        new globalIndex(mesh_.nBoundaryFaces())
     );
     globalIndex& globalIndices = globalBoundaryFaceNumberingPtr_();
 
diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C
index 9182fb5a907..741aeef3e81 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C
@@ -450,10 +450,7 @@ const Foam::labelList& Foam::polyBoundaryMesh::patchID() const
 {
     if (!patchIDPtr_.valid())
     {
-        patchIDPtr_.reset
-        (
-            new labelList(mesh_.nFaces() - mesh_.nInternalFaces())
-        );
+        patchIDPtr_.reset(new labelList(mesh_.nBoundaryFaces()));
         labelList& list = *patchIDPtr_;
 
         const polyPatchList& patches = *this;
@@ -613,13 +610,21 @@ Foam::wordList Foam::polyBoundaryMesh::physicalTypes() const
 }
 
 
+Foam::label Foam::polyBoundaryMesh::start() const
+{
+    return mesh_.nInternalFaces();
+}
+
+
+Foam::label Foam::polyBoundaryMesh::nFaces() const
+{
+    return mesh_.nBoundaryFaces();
+}
+
+
 Foam::labelRange Foam::polyBoundaryMesh::range() const
 {
-    return labelRange
-    (
-        mesh_.nInternalFaces(),
-        mesh_.nFaces() - mesh_.nInternalFaces()
-    );
+    return labelRange(mesh_.nInternalFaces(), mesh_.nBoundaryFaces());
 }
 
 
diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H
index 0947df807d6..c97da3db7bc 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H
+++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H
@@ -153,7 +153,7 @@ public:
         //  polyBoundaryMesh and not parallel
         const List<labelPairList>& neighbourEdges() const;
 
-        //- Return the number of non-processor patches
+        //- The number of patches before the first processor patch.
         label nNonProcessor() const;
 
         //- Return a list of patch names
@@ -165,8 +165,16 @@ public:
         //- Return a list of physical types
         wordList physicalTypes() const;
 
-        //- Return the range used for all boundary faces
-        //  Spans [nInternalFaces, nFaces)
+        //- The start label of the boundary faces in the polyMesh face list
+        //  Same as mesh.nInternalFaces()
+        label start() const;
+
+        //- The number of boundary faces in the underlying mesh
+        //  Same as mesh.nBoundaryFaces()
+        label nFaces() const;
+
+        //- The face range for all boundary faces
+        //  Spans [nInternalFaces, nFaces) of the underlying mesh
         labelRange range() const;
 
         //- Return the range used for boundary faces on patchi.
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C b/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C
index f2389857d98..a84f56d5d7d 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C
@@ -377,7 +377,7 @@ bool Foam::polyMeshTetDecomposition::checkFaceTets
     const vectorField& fc = mesh.faceCentres();
 
     // Calculate coupled cell centre
-    pointField neiCc(mesh.nFaces() - mesh.nInternalFaces());
+    pointField neiCc(mesh.nBoundaryFaces());
 
     for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); ++facei)
     {
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C
index d48d7e30caa..24bc155db03 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2018 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -293,6 +293,12 @@ Foam::wordList Foam::polyPatch::constraintTypes()
 }
 
 
+Foam::label Foam::polyPatch::offset() const
+{
+    return start_ - boundaryMesh().start();
+}
+
+
 const Foam::polyBoundaryMesh& Foam::polyPatch::boundaryMesh() const
 {
     return boundaryMesh_;
diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H
index a43c9e9844b..9de2d07b6ad 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H
+++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/polyPatch/polyPatch.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2015 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2018 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -49,10 +49,7 @@ SourceFiles
 namespace Foam
 {
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-// Forward declaration of friend functions and operators
-
+// Forward declarations
 class polyBoundaryMesh;
 class polyPatch;
 class PstreamBuffers;
@@ -304,6 +301,10 @@ public:
 
     // Member Functions
 
+        //- The offset where this patch starts in the boundary face list
+        //  The value is the same as  patch.start() - mesh.nInternalFaces()
+        label offset() const;
+
         //- Return start label of this patch in the polyMesh face list
         label start() const
         {
diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C
index 99bf41e4c35..1437834a46e 100644
--- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C
+++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C
@@ -44,7 +44,7 @@ void Foam::syncTools::swapBoundaryCellPositions
 
     const polyBoundaryMesh& patches = mesh.boundaryMesh();
 
-    neighbourCellData.resize(mesh.nFaces()-mesh.nInternalFaces());
+    neighbourCellData.resize(mesh.nBoundaryFaces());
 
     for (const polyPatch& pp : patches)
     {
diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H
index 68f47b1494e..7f32972586e 100644
--- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H
+++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H
@@ -395,7 +395,7 @@ public:
                 SubList<T> bndValues
                 (
                     faceValues,
-                    mesh.nFaces()-mesh.nInternalFaces(),
+                    mesh.nBoundaryFaces(),
                     mesh.nInternalFaces()
                 );
 
@@ -420,7 +420,7 @@ public:
                 SubList<point> bndValues
                 (
                     positions,
-                    mesh.nFaces()-mesh.nInternalFaces(),
+                    mesh.nBoundaryFaces(),
                     mesh.nInternalFaces()
                 );
                 syncBoundaryFaceList
@@ -476,7 +476,7 @@ public:
                 SubList<T> bndValues
                 (
                     faceValues,
-                    mesh.nFaces()-mesh.nInternalFaces(),
+                    mesh.nBoundaryFaces(),
                     mesh.nInternalFaces()
                 );
                 syncBoundaryFaceList
diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C
index e96be7fe10d..c0b15c78dae 100644
--- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C
+++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C
@@ -929,7 +929,7 @@ void Foam::syncTools::syncBoundaryFaceList
     const bool parRun
 )
 {
-    const label nBFaces = mesh.nFaces() - mesh.nInternalFaces();
+    const label nBFaces = mesh.nBoundaryFaces();
 
     if (faceValues.size() != nBFaces)
     {
@@ -1160,7 +1160,7 @@ void Foam::syncTools::swapBoundaryCellList
 
     const polyBoundaryMesh& patches = mesh.boundaryMesh();
 
-    neighbourCellData.resize(mesh.nFaces()-mesh.nInternalFaces());
+    neighbourCellData.resize(mesh.nBoundaryFaces());
 
     for (const polyPatch& pp : patches)
     {
diff --git a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C
index 8bf7480557c..d7543f4fd52 100644
--- a/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C
+++ b/src/OpenFOAM/meshes/polyMesh/zones/faceZone/faceZone.C
@@ -537,8 +537,8 @@ bool Foam::faceZone::checkParallelSync(const bool report) const
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
     {
-        boolList neiZoneFace(mesh.nFaces()-mesh.nInternalFaces(), false);
-        boolList neiZoneFlip(mesh.nFaces()-mesh.nInternalFaces(), false);
+        boolList neiZoneFace(mesh.nBoundaryFaces(), false);
+        boolList neiZoneFlip(mesh.nBoundaryFaces(), false);
         forAll(*this, i)
         {
             const label facei = operator[](i);
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H
index 5e1f71275aa..cbd7df5f902 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2018 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -91,7 +91,7 @@ class primitiveMesh
             //- Number of internal edges using 0 or 1 boundary points
             mutable label nInternal1Edges_;
 
-            //- Number of internal edges using 0,1 or 2boundary points
+            //- Number of internal edges using 0,1 or 2 boundary points
             mutable label nInternalEdges_;
 
             //- Number of edges
@@ -478,24 +478,39 @@ public:
 
             // Mesh size parameters
 
+                //- Number of mesh points
                 inline label nPoints() const;
+
+                //- Number of mesh edges
                 inline label nEdges() const;
-                inline label nInternalFaces() const;
+
+                //- Number of mesh faces
                 inline label nFaces() const;
+
+                //- Number of mesh cells
                 inline label nCells() const;
 
-                // If points are ordered (nInternalPoints != -1):
+                //- Number of internal faces
+                inline label nInternalFaces() const;
+
+                //- Number of boundary faces (== nFaces - nInternalFaces)
+                inline label nBoundaryFaces() const;
+
+
+            // If points are ordered (nInternalPoints != -1):
+
+                //- Points not on boundary
+                inline label nInternalPoints() const;
+
+                //- Internal edges (i.e. not on boundary face) using
+                //- no boundary point
+                inline label nInternal0Edges() const;
 
-                    //- Points not on boundary
-                    inline label nInternalPoints() const;
+                //- Internal edges using 0 or 1 boundary point
+                inline label nInternal1Edges() const;
 
-                    //- Internal edges (i.e. not on boundary face) using
-                    //  no boundary point
-                    inline label nInternal0Edges() const;
-                    //- Internal edges using 0 or 1 boundary point
-                    inline label nInternal1Edges() const;
-                    //- Internal edges using 0,1 or 2 boundary points
-                    inline label nInternalEdges() const;
+                //- Internal edges using 0,1 or 2 boundary points
+                inline label nInternalEdges() const;
 
 
             // Primitive mesh data
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshI.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshI.H
index 42ad4c26870..df14e3c3624 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshI.H
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshI.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
-     \\/     M anipulation  |
+     \\/     M anipulation  | Copyright (C) 2018 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -21,30 +21,23 @@ License
     You should have received a copy of the GNU General Public License
     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
 
-Description
-
 \*---------------------------------------------------------------------------*/
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
-inline label primitiveMesh::nInternalPoints() const
+inline Foam::label Foam::primitiveMesh::nInternalPoints() const
 {
     return nInternalPoints_;
 }
 
 
-inline label primitiveMesh::nPoints() const
+inline Foam::label Foam::primitiveMesh::nPoints() const
 {
     return nPoints_;
 }
 
 
-inline label primitiveMesh::nInternal0Edges() const
+inline Foam::label Foam::primitiveMesh::nInternal0Edges() const
 {
     // Force edge calculation
     (void)nEdges();
@@ -52,7 +45,7 @@ inline label primitiveMesh::nInternal0Edges() const
 }
 
 
-inline label primitiveMesh::nInternal1Edges() const
+inline Foam::label Foam::primitiveMesh::nInternal1Edges() const
 {
     // Force edge calculation
     (void)nEdges();
@@ -60,7 +53,7 @@ inline label primitiveMesh::nInternal1Edges() const
 }
 
 
-inline label primitiveMesh::nInternalEdges() const
+inline Foam::label Foam::primitiveMesh::nInternalEdges() const
 {
     // Force edge calculation
     (void)nEdges();
@@ -68,7 +61,7 @@ inline label primitiveMesh::nInternalEdges() const
 }
 
 
-inline label primitiveMesh::nEdges() const
+inline Foam::label Foam::primitiveMesh::nEdges() const
 {
     if (nEdges_ < 0)
     {
@@ -79,134 +72,136 @@ inline label primitiveMesh::nEdges() const
 }
 
 
-inline label primitiveMesh::nInternalFaces() const
+inline Foam::label Foam::primitiveMesh::nInternalFaces() const
 {
     return nInternalFaces_;
 }
 
 
-inline label primitiveMesh::nFaces() const
+inline Foam::label Foam::primitiveMesh::nBoundaryFaces() const
+{
+    return (nFaces_ - nInternalFaces_);
+}
+
+
+inline Foam::label Foam::primitiveMesh::nFaces() const
 {
     return nFaces_;
 }
 
 
-inline label primitiveMesh::nCells() const
+inline Foam::label Foam::primitiveMesh::nCells() const
 {
     return nCells_;
 }
 
 
-inline bool primitiveMesh::isInternalFace(const label faceIndex) const
+inline bool Foam::primitiveMesh::isInternalFace(const label faceIndex) const
 {
-    return faceIndex < nInternalFaces();
+    return faceIndex < nInternalFaces_;
 }
 
 
-inline bool primitiveMesh::hasCellShapes() const
+inline bool Foam::primitiveMesh::hasCellShapes() const
 {
     return cellShapesPtr_;
 }
 
 
-inline bool primitiveMesh::hasEdges() const
+inline bool Foam::primitiveMesh::hasEdges() const
 {
     return edgesPtr_;
 }
 
 
-inline bool primitiveMesh::hasCellCells() const
+inline bool Foam::primitiveMesh::hasCellCells() const
 {
     return ccPtr_;
 }
 
 
-inline bool primitiveMesh::hasEdgeCells() const
+inline bool Foam::primitiveMesh::hasEdgeCells() const
 {
     return ecPtr_;
 }
 
 
-inline bool primitiveMesh::hasPointCells() const
+inline bool Foam::primitiveMesh::hasPointCells() const
 {
     return pcPtr_;
 }
 
 
-inline bool primitiveMesh::hasCells() const
+inline bool Foam::primitiveMesh::hasCells() const
 {
     return cfPtr_;
 }
 
 
-inline bool primitiveMesh::hasEdgeFaces() const
+inline bool Foam::primitiveMesh::hasEdgeFaces() const
 {
     return efPtr_;
 }
 
 
-inline bool primitiveMesh::hasPointFaces() const
+inline bool Foam::primitiveMesh::hasPointFaces() const
 {
     return pfPtr_;
 }
 
 
-inline bool primitiveMesh::hasCellEdges() const
+inline bool Foam::primitiveMesh::hasCellEdges() const
 {
     return cePtr_;
 }
 
 
-inline bool primitiveMesh::hasFaceEdges() const
+inline bool Foam::primitiveMesh::hasFaceEdges() const
 {
     return fePtr_;
 }
 
 
-inline bool primitiveMesh::hasPointEdges() const
+inline bool Foam::primitiveMesh::hasPointEdges() const
 {
     return pePtr_;
 }
 
 
-inline bool primitiveMesh::hasPointPoints() const
+inline bool Foam::primitiveMesh::hasPointPoints() const
 {
     return ppPtr_;
 }
 
 
-inline bool primitiveMesh::hasCellPoints() const
+inline bool Foam::primitiveMesh::hasCellPoints() const
 {
     return cpPtr_;
 }
 
 
-inline bool primitiveMesh::hasCellCentres() const
+inline bool Foam::primitiveMesh::hasCellCentres() const
 {
     return cellCentresPtr_;
 }
 
 
-inline bool primitiveMesh::hasFaceCentres() const
+inline bool Foam::primitiveMesh::hasFaceCentres() const
 {
     return faceCentresPtr_;
 }
 
 
-inline bool primitiveMesh::hasCellVolumes() const
+inline bool Foam::primitiveMesh::hasCellVolumes() const
 {
     return cellVolumesPtr_;
 }
 
 
-inline bool primitiveMesh::hasFaceAreas() const
+inline bool Foam::primitiveMesh::hasFaceAreas() const
 {
     return faceAreasPtr_;
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
diff --git a/src/conversion/ensight/output/ensightOutputTemplates.C b/src/conversion/ensight/output/ensightOutputTemplates.C
index a29fa3ea584..3ffb0661498 100644
--- a/src/conversion/ensight/output/ensightOutputTemplates.C
+++ b/src/conversion/ensight/output/ensightOutputTemplates.C
@@ -261,7 +261,7 @@ bool Foam::ensightOutput::writeField
         // flat boundary field
         // as per volPointInterpolation::flatBoundaryField()
 
-        Field<Type> flat(mesh.nFaces() - mesh.nInternalFaces());
+        Field<Type> flat(mesh.nBoundaryFaces());
 
         const fvBoundaryMesh& bm = mesh.boundary();
         forAll(vf.boundaryField(), patchI)
diff --git a/src/conversion/polyDualMesh/polyDualMesh.C b/src/conversion/polyDualMesh/polyDualMesh.C
index 9b325c94157..382ae4d4451 100644
--- a/src/conversion/polyDualMesh/polyDualMesh.C
+++ b/src/conversion/polyDualMesh/polyDualMesh.C
@@ -1407,7 +1407,7 @@ Foam::polyDualMesh::polyDualMesh
             IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        labelList(mesh.nFaces() - mesh.nInternalFaces())
+        labelList(mesh.nBoundaryFaces(), -1)
     )
 {
     calcDual(mesh, featureEdges, featurePoints);
@@ -1446,7 +1446,7 @@ Foam::polyDualMesh::polyDualMesh
             IOobject::NO_READ,
             IOobject::AUTO_WRITE
         ),
-        labelList(mesh.nFaces() - mesh.nInternalFaces(), -1)
+        labelList(mesh.nBoundaryFaces(), -1)
     )
 {
     labelList featureEdges, featurePoints;
@@ -1470,7 +1470,7 @@ void Foam::polyDualMesh::calcFeatures
         SubList<face>
         (
             mesh.faces(),
-            mesh.nFaces() - mesh.nInternalFaces(),
+            mesh.nBoundaryFaces(),
             mesh.nInternalFaces()
         ),
         mesh.points()
diff --git a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C
index 25dc0c9687f..266d2c3dbff 100644
--- a/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C
+++ b/src/dynamicFvMesh/dynamicRefineFvMesh/dynamicRefineFvMesh.C
@@ -86,7 +86,7 @@ void Foam::dynamicRefineFvMesh::calculateProtectedCells
     unrefineableCell = protectedCell_;
 
     // Get neighbouring cell level
-    labelList neiLevel(nFaces()-nInternalFaces());
+    labelList neiLevel(nBoundaryFaces());
 
     for (label facei = nInternalFaces(); facei < nFaces(); facei++)
     {
diff --git a/src/dynamicMesh/boundaryMesh/boundaryMesh.C b/src/dynamicMesh/boundaryMesh/boundaryMesh.C
index a26a4313300..1d3a1ec3805 100644
--- a/src/dynamicMesh/boundaryMesh/boundaryMesh.C
+++ b/src/dynamicMesh/boundaryMesh/boundaryMesh.C
@@ -476,7 +476,7 @@ void Foam::boundaryMesh::read(const polyMesh& mesh)
     patches_.setSize(mesh.boundaryMesh().size());
 
     // Number of boundary faces
-    label nBFaces = mesh.nFaces() - mesh.nInternalFaces();
+    const label nBFaces = mesh.nBoundaryFaces();
 
     faceList bFaces(nBFaces);
 
@@ -976,7 +976,7 @@ Foam::labelList Foam::boundaryMesh::getNearest
     // Search nearest triangle centre for every polyMesh boundary face
     //
 
-    labelList nearestBFacei(pMesh.nFaces() - pMesh.nInternalFaces());
+    labelList nearestBFacei(pMesh.nBoundaryFaces());
 
     treeBoundBox tightest;
 
@@ -1168,7 +1168,7 @@ void Foam::boundaryMesh::patchify
     label meshFacei = newMesh.nInternalFaces();
 
     // First patch gets all non-coupled faces
-    label facesToBeDone = newMesh.nFaces() - newMesh.nInternalFaces();
+    label facesToBeDone = newMesh.nBoundaryFaces();
 
     forAll(patches_, bPatchi)
     {
@@ -1262,9 +1262,7 @@ void Foam::boundaryMesh::patchify
         List<DynamicList<label>> patchFaces(nNewPatches);
 
         // Give reasonable estimate for size of patches
-        label nAvgFaces =
-            (newMesh.nFaces() - newMesh.nInternalFaces())
-          / nNewPatches;
+        label nAvgFaces = newMesh.nBoundaryFaces() / nNewPatches;
 
         forAll(patchFaces, newPatchi)
         {
diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C
index d6c18d1cb89..02ef7638ea8 100644
--- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C
+++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C
@@ -500,7 +500,7 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::deleteProcPatches
 
     // New patchID per boundary faces to be repatched. Is -1 (no change)
     // or new patchID
-    labelList newPatchID(mesh_.nFaces() - mesh_.nInternalFaces(), -1);
+    labelList newPatchID(mesh_.nBoundaryFaces(), -1);
 
     label nProcPatches = 0;
 
@@ -791,7 +791,7 @@ void Foam::fvMeshDistribute::getCouplingData
     // Construct the coupling information for all (boundary) faces and
     // points
 
-    label nBnd = mesh_.nFaces() - mesh_.nInternalFaces();
+    const label nBnd = mesh_.nBoundaryFaces();
     sourceFace.setSize(nBnd);
     sourceProc.setSize(nBnd);
     sourcePatch.setSize(nBnd);
@@ -998,10 +998,10 @@ void Foam::fvMeshDistribute::subsetCouplingData
     labelList& subPointMaster
 )
 {
-    subFace.setSize(mesh.nFaces() - mesh.nInternalFaces());
-    subProc.setSize(mesh.nFaces() - mesh.nInternalFaces());
-    subPatch.setSize(mesh.nFaces() - mesh.nInternalFaces());
-    subNewNbrProc.setSize(mesh.nFaces() - mesh.nInternalFaces());
+    subFace.setSize(mesh.nBoundaryFaces());
+    subProc.setSize(mesh.nBoundaryFaces());
+    subPatch.setSize(mesh.nBoundaryFaces());
+    subNewNbrProc.setSize(mesh.nBoundaryFaces());
 
     forAll(subFace, newBFacei)
     {
@@ -1132,7 +1132,7 @@ Foam::labelList Foam::fvMeshDistribute::mapBoundaryData
     const labelList& boundaryData1  // on added mesh
 )
 {
-    labelList newBoundaryData(mesh.nFaces() - mesh.nInternalFaces());
+    labelList newBoundaryData(mesh.nBoundaryFaces());
 
     forAll(boundaryData0, oldBFacei)
     {
@@ -1932,7 +1932,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
             SubList<label>
             (
                 repatchMap().reverseFaceMap(),
-                mesh_.nFaces() - mesh_.nInternalFaces(),
+                mesh_.nBoundaryFaces(),
                 mesh_.nInternalFaces()
             )
           - mesh_.nInternalFaces()
@@ -2685,7 +2685,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::fvMeshDistribute::distribute
             {
                 // Find out if any faces of domain mesh were flipped (boundary
                 // faces becoming internal)
-                label nBnd = domainMesh.nFaces()-domainMesh.nInternalFaces();
+                const label nBnd = domainMesh.nBoundaryFaces();
                 flippedAddedFaces.resize(nBnd/4);
 
                 for
diff --git a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C
index edb8209d6f5..97b23b8bf79 100644
--- a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C
+++ b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C
@@ -139,7 +139,7 @@ void Foam::cellCuts::syncProc()
     syncTools::syncEdgeList(mesh(), edgeWeight_, maxEqOp<scalar>(), -GREAT);
 
     {
-        const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
+        const label nBnd = mesh().nBoundaryFaces();
 
         // Convert faceSplitCut into face-local data: vertex and edge w.r.t.
         // vertex 0: (since this is same on both sides)
diff --git a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C
index 2a0b294eba0..46500f13999 100644
--- a/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C
+++ b/src/dynamicMesh/motionSmoother/polyMeshGeometry/polyMeshGeometry.C
@@ -385,7 +385,7 @@ bool Foam::polyMeshGeometry::checkFaceDotProduct
     const scalar severeNonorthogonalityThreshold = ::cos(degToRad(orthWarn));
 
     // Calculate coupled cell centre
-    pointField neiCc(mesh.nFaces() - mesh.nInternalFaces());
+    pointField neiCc(mesh.nBoundaryFaces());
 
     for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
     {
@@ -745,7 +745,7 @@ bool Foam::polyMeshGeometry::checkFaceTets
     const polyBoundaryMesh& patches = mesh.boundaryMesh();
 
     // Calculate coupled cell centre
-    pointField neiCc(mesh.nFaces() - mesh.nInternalFaces());
+    pointField neiCc(mesh.nBoundaryFaces());
 
     for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
     {
@@ -1187,7 +1187,7 @@ bool Foam::polyMeshGeometry::checkFaceWeights
     const polyBoundaryMesh& patches = mesh.boundaryMesh();
 
     // Calculate coupled cell centre
-    pointField neiCc(mesh.nFaces()-mesh.nInternalFaces());
+    pointField neiCc(mesh.nBoundaryFaces());
 
     for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
     {
@@ -1340,7 +1340,7 @@ bool Foam::polyMeshGeometry::checkVolRatio
     const polyBoundaryMesh& patches = mesh.boundaryMesh();
 
     // Calculate coupled cell vol
-    scalarField neiVols(mesh.nFaces()-mesh.nInternalFaces());
+    scalarField neiVols(mesh.nBoundaryFaces());
 
     for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
     {
@@ -1671,7 +1671,7 @@ bool Foam::polyMeshGeometry::checkFaceTwist
     const polyBoundaryMesh& patches = mesh.boundaryMesh();
 
     // Calculate coupled cell centre
-    pointField neiCc(mesh.nFaces()-mesh.nInternalFaces());
+    pointField neiCc(mesh.nBoundaryFaces());
 
     for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
     {
diff --git a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C
index be4b283afd7..a7135b9f4f9 100644
--- a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C
+++ b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C
@@ -908,7 +908,7 @@ void Foam::faceCoupleInfo::findPerfectMatchingFaces
             mesh0.faces(),
             mesh0.points(),
             mesh0.nInternalFaces(),
-            mesh0.nFaces() - mesh0.nInternalFaces()
+            mesh0.nBoundaryFaces()
         )
     );
 
@@ -919,7 +919,7 @@ void Foam::faceCoupleInfo::findPerfectMatchingFaces
             mesh1.faces(),
             mesh1.points(),
             mesh1.nInternalFaces(),
-            mesh1.nFaces() - mesh1.nInternalFaces()
+            mesh1.nBoundaryFaces()
         )
     );
 
@@ -984,11 +984,10 @@ void Foam::faceCoupleInfo::findSlavesCoveringMaster
 )
 {
     // Construct octree from all mesh0 boundary faces
-    labelList bndFaces(mesh0.nFaces()-mesh0.nInternalFaces());
-    forAll(bndFaces, i)
-    {
-        bndFaces[i] = mesh0.nInternalFaces() + i;
-    }
+    labelList bndFaces
+    (
+        identity(mesh0.nBoundaryFaces(), mesh0.nInternalFaces())
+    );
 
     treeBoundBox overallBb(mesh0.points());
 
@@ -1016,8 +1015,8 @@ void Foam::faceCoupleInfo::findSlavesCoveringMaster
 
     // Search nearest face for every mesh1 boundary face.
 
-    labelHashSet mesh0Set(mesh0.nFaces() - mesh0.nInternalFaces());
-    labelHashSet mesh1Set(mesh1.nFaces() - mesh1.nInternalFaces());
+    labelHashSet mesh0Set(mesh0.nBoundaryFaces());
+    labelHashSet mesh1Set(mesh1.nBoundaryFaces());
 
     for
     (
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
index 44c3ca0afce..34ad10fde8e 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/combineFaces.C
@@ -384,7 +384,7 @@ Foam::labelListList Foam::combineFaces::getMergeSets
     const polyBoundaryMesh& patches = mesh_.boundaryMesh();
 
     // Pick up all cells on boundary
-    labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelHashSet boundaryCells(mesh_.nBoundaryFaces());
 
     forAll(patches, patchi)
     {
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C
index 0608d45f7b3..dae24bc0677 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/edgeCollapser.C
@@ -462,7 +462,7 @@ Foam::scalarField Foam::edgeCollapser::calcTargetFaceSizes() const
     const labelList& cellOwner = mesh_.faceOwner();
     const labelList& cellNeighbour = mesh_.faceNeighbour();
 
-    const label nBoundaryFaces = mesh_.nFaces() - mesh_.nInternalFaces();
+    const label nBoundaryFaces = mesh_.nBoundaryFaces();
 
     // Calculate face size from cell volumes for internal faces
     for (label intFacei = 0; intFacei < mesh_.nInternalFaces(); ++intFacei)
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C
index 8d1b96c3184..fa3797e2f7d 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8.C
@@ -1608,7 +1608,7 @@ Foam::label Foam::hexRef8::faceConsistentRefinement
 
     // Coupled faces. Swap owner level to get neighbouring cell level.
     // (only boundary faces of neiLevel used)
-    labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelList neiLevel(mesh_.nBoundaryFaces());
 
     forAll(neiLevel, i)
     {
@@ -1685,7 +1685,7 @@ void Foam::hexRef8::checkWantedRefinementLevels
 
     // Coupled faces. Swap owner level to get neighbouring cell level.
     // (only boundary faces of neiLevel used)
-    labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelList neiLevel(mesh_.nBoundaryFaces());
 
     forAll(neiLevel, i)
     {
@@ -2696,9 +2696,9 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement
         // Coupled faces. Swap owner level to get neighbouring cell level.
         // (only boundary faces of neiLevel used)
 
-        labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
-        labelList neiCount(mesh_.nFaces()-mesh_.nInternalFaces());
-        labelList neiRefCount(mesh_.nFaces()-mesh_.nInternalFaces());
+        labelList neiLevel(mesh_.nBoundaryFaces());
+        labelList neiCount(mesh_.nBoundaryFaces());
+        labelList neiRefCount(mesh_.nBoundaryFaces());
 
         forAll(neiLevel, i)
         {
@@ -3471,7 +3471,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
     //  refinining and subsetting)
 
     {
-        labelList newNeiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
+        labelList newNeiLevel(mesh_.nBoundaryFaces());
 
         forAll(newNeiLevel, i)
         {
@@ -3528,7 +3528,7 @@ Foam::labelListList Foam::hexRef8::setRefinement
         // above
         pointField bFaceMids
         (
-            mesh_.nFaces()-mesh_.nInternalFaces(),
+            mesh_.nBoundaryFaces(),
             point(-GREAT, -GREAT, -GREAT)
         );
 
@@ -4562,7 +4562,7 @@ void Foam::hexRef8::checkMesh() const
     // otherwise mesh redistribution might cause multiple faces between two
     // cells
     {
-        labelList nei(mesh_.nFaces()-mesh_.nInternalFaces());
+        labelList nei(mesh_.nBoundaryFaces());
         forAll(nei, i)
         {
             nei[i] = mesh_.faceOwner()[i+mesh_.nInternalFaces()];
@@ -4616,7 +4616,7 @@ void Foam::hexRef8::checkMesh() const
     // ~~~~~~~~~~~~~~~~~
 
     {
-        scalarField neiFaceAreas(mesh_.nFaces()-mesh_.nInternalFaces());
+        scalarField neiFaceAreas(mesh_.nBoundaryFaces());
         forAll(neiFaceAreas, i)
         {
             neiFaceAreas[i] = mag(mesh_.faceAreas()[i+mesh_.nInternalFaces()]);
@@ -4658,7 +4658,7 @@ void Foam::hexRef8::checkMesh() const
     // Check number of points on faces.
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     {
-        labelList nVerts(mesh_.nFaces()-mesh_.nInternalFaces());
+        labelList nVerts(mesh_.nBoundaryFaces());
 
         forAll(nVerts, i)
         {
@@ -4700,7 +4700,7 @@ void Foam::hexRef8::checkMesh() const
     // ~~~~~~~~~~~~~~~~~~~~
     {
         // Anchor points.
-        pointField anchorPoints(mesh_.nFaces()-mesh_.nInternalFaces());
+        pointField anchorPoints(mesh_.nBoundaryFaces());
 
         forAll(anchorPoints, i)
         {
@@ -4808,7 +4808,7 @@ void Foam::hexRef8::checkRefinementLevels
         }
 
         // Coupled faces. Get neighbouring value
-        labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
+        labelList neiLevel(mesh_.nBoundaryFaces());
 
         forAll(neiLevel, i)
         {
@@ -5379,7 +5379,7 @@ Foam::labelList Foam::hexRef8::consistentUnrefinement
 
 
         // Coupled faces. Swap owner level to get neighbouring cell level.
-        labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
+        labelList neiLevel(mesh_.nBoundaryFaces());
 
         forAll(neiLevel, i)
         {
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.C
index 38269d63a66..2e6244fe371 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removeCells.C
@@ -133,7 +133,7 @@ Foam::labelList Foam::removeCells::getExposedFaces
         SubList<label> bndValues
         (
             nCellsUsingFace,
-            mesh_.nFaces()-mesh_.nInternalFaces(),
+            mesh_.nBoundaryFaces(),
             mesh_.nInternalFaces()
         );
 
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/removePoints.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/removePoints.C
index 4cd0f0e0ae7..30c1382e82f 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/removePoints.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/removePoints.C
@@ -638,7 +638,7 @@ void Foam::removePoints::getUnrefimentSet
         // restoring. Note that this is over all saved faces, not just over
         // the ones in undoFaces.
 
-        boolListList faceVertexRestore(mesh_.nFaces()-mesh_.nInternalFaces());
+        boolListList faceVertexRestore(mesh_.nBoundaryFaces());
 
         // Populate with my local points-to-restore.
         forAll(savedFaces_, saveI)
diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C
index dea8299a49f..dde8008349d 100644
--- a/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C
+++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C
@@ -222,7 +222,7 @@ void Foam::tetDecomposer::setRefinement
             }
         }
 
-        boolList neiDecomposeCell(mesh_.nFaces()-mesh_.nInternalFaces());
+        boolList neiDecomposeCell(mesh_.nBoundaryFaces());
         forAll(neiDecomposeCell, bFacei)
         {
             label facei = mesh_.nInternalFaces()+bFacei;
diff --git a/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.C b/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.C
index de29f2e4a09..0b772daad9b 100644
--- a/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.C
+++ b/src/finiteArea/faMesh/faMeshMapper/faAreaMapper.C
@@ -63,18 +63,10 @@ void Foam::faAreaMapper::calcAddressing() const
 
     // Prepare a list of new face labels and (preliminary) addressing
     // Note: dimensioned to number of boundary faces of polyMesh
-    newFaceLabelsPtr_ = new labelList
-    (
-        mesh_().nFaces() - mesh_().nInternalFaces(),
-        -1
-    );
+    newFaceLabelsPtr_ = new labelList(mesh_().nBoundaryFaces(), -1);
     labelList& newFaceLabels = *newFaceLabelsPtr_;
 
-    newFaceLabelsMapPtr_ = new labelList
-    (
-        mesh_().nFaces() - mesh_().nInternalFaces(),
-        -1
-    );
+    newFaceLabelsMapPtr_ = new labelList(mesh_().nBoundaryFaces(), -1);
     labelList& newFaceLabelsMap = *newFaceLabelsMapPtr_;
     label nNewFaces = 0;
 
diff --git a/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoAdvection/isoAdvection.C b/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoAdvection/isoAdvection.C
index deb3b89bd18..f722a5578e1 100644
--- a/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoAdvection/isoAdvection.C
+++ b/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoAdvection/isoAdvection.C
@@ -92,7 +92,7 @@ Foam::isoAdvection::isoAdvection
     isoCutFace_(mesh_, ap_),
     cellIsBounded_(mesh_.nCells(), false),
     checkBounding_(mesh_.nCells(), false),
-    bsFaces_(label(0.2*(mesh_.nFaces() - mesh_.nInternalFaces()))),
+    bsFaces_(label(0.2*mesh_.nBoundaryFaces())),
     bsx0_(bsFaces_.size()),
     bsn0_(bsFaces_.size()),
     bsUn0_(bsFaces_.size()),
diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToCell/globalIndexStencils/CFCCellToCellStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/globalIndexStencils/CFCCellToCellStencil.C
index f7ed9ce24bd..853842ee9c1 100644
--- a/src/finiteVolume/fvMesh/extendedStencil/cellToCell/globalIndexStencils/CFCCellToCellStencil.C
+++ b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/globalIndexStencils/CFCCellToCellStencil.C
@@ -36,7 +36,7 @@ void Foam::CFCCellToCellStencil::calcFaceBoundaryData
 ) const
 {
     const polyBoundaryMesh& patches = mesh().boundaryMesh();
-    const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
+    const label nBnd = mesh().nBoundaryFaces();
     const labelList& own = mesh().faceOwner();
 
     neiGlobal.setSize(nBnd);
@@ -86,7 +86,7 @@ void Foam::CFCCellToCellStencil::calcCellStencil
     labelListList& globalCellCells
 ) const
 {
-    const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
+    const label nBnd = mesh().nBoundaryFaces();
     const labelList& own = mesh().faceOwner();
     const labelList& nei = mesh().faceNeighbour();
 
diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToCell/globalIndexStencils/cellToCellStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/globalIndexStencils/cellToCellStencil.C
index d4b051c8454..e79969b6f0c 100644
--- a/src/finiteVolume/fvMesh/extendedStencil/cellToCell/globalIndexStencils/cellToCellStencil.C
+++ b/src/finiteVolume/fvMesh/extendedStencil/cellToCell/globalIndexStencils/cellToCellStencil.C
@@ -169,7 +169,7 @@ void Foam::cellToCellStencil::validBoundaryFaces(boolList& isValidBFace) const
 {
     const polyBoundaryMesh& patches = mesh().boundaryMesh();
 
-    isValidBFace.setSize(mesh().nFaces()-mesh().nInternalFaces(), true);
+    isValidBFace.setSize(mesh().nBoundaryFaces(), true);
 
     for (const polyPatch& pp : patches)
     {
@@ -328,7 +328,7 @@ Foam::labelList Foam::cellToCellStencil::calcFaceCells
 Foam::cellToCellStencil::cellToCellStencil(const polyMesh& mesh)
 :
     mesh_(mesh),
-    globalNumbering_(mesh_.nCells()+mesh_.nFaces()-mesh_.nInternalFaces())
+    globalNumbering_(mesh_.nCells()+mesh_.nBoundaryFaces())
 {}
 
 
diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedUpwindCellToFaceStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedUpwindCellToFaceStencil.C
index edd4da2e1e0..eb724d3fe36 100644
--- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedUpwindCellToFaceStencil.C
+++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedUpwindCellToFaceStencil.C
@@ -205,7 +205,7 @@ void Foam::extendedUpwindCellToFaceStencil::transportStencils
 )
 {
     const polyBoundaryMesh& patches = mesh_.boundaryMesh();
-    const label nBnd = mesh_.nFaces()-mesh_.nInternalFaces();
+    const label nBnd = mesh_.nBoundaryFaces();
     const labelList& own = mesh_.faceOwner();
     const labelList& nei = mesh_.faceNeighbour();
 
diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/globalIndexStencils/FECCellToFaceStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/globalIndexStencils/FECCellToFaceStencil.C
index 80124852443..ea303e30471 100644
--- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/globalIndexStencils/FECCellToFaceStencil.C
+++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/globalIndexStencils/FECCellToFaceStencil.C
@@ -65,7 +65,7 @@ void Foam::FECCellToFaceStencil::calcFaceStencil
 ) const
 {
     const polyBoundaryMesh& patches = mesh().boundaryMesh();
-    const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
+    const label nBnd = mesh().nBoundaryFaces();
     const labelList& own = mesh().faceOwner();
     const labelList& nei = mesh().faceNeighbour();
 
diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/globalIndexStencils/cellToFaceStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/globalIndexStencils/cellToFaceStencil.C
index 7106ebfae5a..270047bfaa3 100644
--- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/globalIndexStencils/cellToFaceStencil.C
+++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/globalIndexStencils/cellToFaceStencil.C
@@ -164,7 +164,7 @@ void Foam::cellToFaceStencil::validBoundaryFaces(boolList& isValidBFace) const
 {
     const polyBoundaryMesh& patches = mesh().boundaryMesh();
 
-    isValidBFace.setSize(mesh().nFaces()-mesh().nInternalFaces(), true);
+    isValidBFace.setSize(mesh().nBoundaryFaces(), true);
 
     forAll(patches, patchi)
     {
@@ -333,7 +333,7 @@ void Foam::cellToFaceStencil::calcFaceStencil
     // Calculates per face a list of global cell/face indices.
 
     const polyBoundaryMesh& patches = mesh_.boundaryMesh();
-    const label nBnd = mesh_.nFaces()-mesh_.nInternalFaces();
+    const label nBnd = mesh_.nBoundaryFaces();
     const labelList& own = mesh_.faceOwner();
     const labelList& nei = mesh_.faceNeighbour();
 
@@ -482,7 +482,7 @@ void Foam::cellToFaceStencil::calcFaceStencil
 Foam::cellToFaceStencil::cellToFaceStencil(const polyMesh& mesh)
 :
     mesh_(mesh),
-    globalNumbering_(mesh_.nCells()+mesh_.nFaces()-mesh_.nInternalFaces())
+    globalNumbering_(mesh_.nCells()+mesh_.nBoundaryFaces())
 {}
 
 
diff --git a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C
index 78b2b90247e..efdaaaac149 100644
--- a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C
+++ b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/globalIndexStencils/CFCFaceToCellStencil.C
@@ -36,7 +36,7 @@ void Foam::CFCFaceToCellStencil::calcFaceBoundaryData
 ) const
 {
     const polyBoundaryMesh& patches = mesh().boundaryMesh();
-    const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
+    const label nBnd = mesh().nBoundaryFaces();
     const labelList& own = mesh().faceOwner();
 
     neiGlobal.setSize(nBnd);
@@ -93,7 +93,7 @@ void Foam::CFCFaceToCellStencil::calcCellStencil
     labelListList& globalCellFaces
 ) const
 {
-    const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
+    const label nBnd = mesh().nBoundaryFaces();
     const labelList& own = mesh().faceOwner();
     const labelList& nei = mesh().faceNeighbour();
 
@@ -107,7 +107,7 @@ void Foam::CFCFaceToCellStencil::calcCellStencil
 
 
     // Non-empty boundary faces
-    boolList validBFace(mesh().nFaces()-mesh().nInternalFaces(), true);
+    boolList validBFace(mesh().nBoundaryFaces(), true);
 
     const polyBoundaryMesh& patches = mesh().boundaryMesh();
     forAll(patches, patchi)
diff --git a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C
index 1fadf245ef2..d8d5b72fa56 100644
--- a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C
+++ b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C
@@ -68,7 +68,7 @@ void Foam::singleCellFvMesh::agglomerateMesh
     // Check agglomeration is sync
     {
         // Get neighbouring agglomeration
-        labelList nbrAgglom(mesh.nFaces()-mesh.nInternalFaces());
+        labelList nbrAgglom(mesh.nBoundaryFaces());
         forAll(oldPatches, patchi)
         {
             const polyPatch& pp = oldPatches[patchi];
diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C
index a278005fda8..3a2c6e12a62 100644
--- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C
+++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C
@@ -231,7 +231,7 @@ Foam::tmp<Foam::Field<Type>> Foam::volPointInterpolation::flatBoundaryField
 
     tmp<Field<Type>> tboundaryVals
     (
-        new Field<Type>(mesh.nFaces()-mesh.nInternalFaces())
+        new Field<Type>(mesh.nBoundaryFaces())
     );
     Field<Type>& boundaryVals = tboundaryVals.ref();
 
diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolation.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolation.C
index 7b0ea37758e..a36399f0757 100644
--- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolation.C
+++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolation.C
@@ -57,7 +57,7 @@ void Foam::volPointInterpolation::calcBoundaryAddressing()
             SubList<face>
             (
                 mesh().faces(),
-                mesh().nFaces()-mesh().nInternalFaces(),
+                mesh().nBoundaryFaces(),
                 mesh().nInternalFaces()
             ),
             mesh().points()
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C
index da0ea0bee73..a54f1e4fa20 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinement.C
@@ -130,7 +130,7 @@ void Foam::meshRefinement::calcNeighbourData
     const labelList& cellLevel = meshCutter_.cellLevel();
     const pointField& cellCentres = mesh_.cellCentres();
 
-    label nBoundaryFaces = mesh_.nFaces() - mesh_.nInternalFaces();
+    const label nBoundaryFaces = mesh_.nBoundaryFaces();
 
     if (neiLevel.size() != nBoundaryFaces || neiCc.size() != nBoundaryFaces)
     {
@@ -297,8 +297,8 @@ void Foam::meshRefinement::updateIntersections(const labelList& changedFaces)
 
 
     // Get boundary face centre and level. Coupled aware.
-    labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
-    pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelList neiLevel(mesh_.nBoundaryFaces());
+    pointField neiCc(mesh_.nBoundaryFaces());
     calcNeighbourData(neiLevel, neiCc);
 
     // Collect segments we want to test for
@@ -458,7 +458,7 @@ void Foam::meshRefinement::checkData()
     meshCutter_.checkRefinementLevels(1, labelList(0));
 
 
-    label nBnd = mesh_.nFaces()-mesh_.nInternalFaces();
+    const label nBnd = mesh_.nBoundaryFaces();
 
     Pout<< "meshRefinement::checkData() : Checking synchronization."
         << endl;
@@ -597,7 +597,7 @@ void Foam::meshRefinement::checkData()
         labelList::subList boundarySurface
         (
             surfaceIndex_,
-            mesh_.nFaces()-mesh_.nInternalFaces(),
+            mesh_.nBoundaryFaces(),
             mesh_.nInternalFaces()
         );
 
@@ -628,11 +628,7 @@ void Foam::meshRefinement::checkData()
         localPointRegion::findDuplicateFaces
         (
             mesh_,
-            identity
-            (
-                mesh_.nFaces() - mesh_.nInternalFaces(),
-                mesh_.nInternalFaces()
-            )
+            identity(mesh_.nBoundaryFaces(), mesh_.nInternalFaces())
         )
     );
 
@@ -998,12 +994,7 @@ Foam::label Foam::meshRefinement::splitFacesUndo
         // Check mesh for errors
         // ~~~~~~~~~~~~~~~~~~~~~
 
-        faceSet errorFaces
-        (
-            mesh_,
-            "errorFaces",
-            mesh_.nFaces()-mesh_.nInternalFaces()
-        );
+        faceSet errorFaces(mesh_, "errorFaces", mesh_.nBoundaryFaces());
         bool hasErrors = motionSmoother::checkMesh
         (
             false,  // report
@@ -1405,7 +1396,7 @@ Foam::autoPtr<Foam::mapDistributePolyMesh> Foam::meshRefinement::balance
 
             if (keepBaffles)
             {
-                label nBnd = mesh_.nFaces()-mesh_.nInternalFaces();
+                const label nBnd = mesh_.nBoundaryFaces();
 
                 labelList coupledFace(mesh_.nFaces(), -1);
                 {
@@ -1752,7 +1743,7 @@ void Foam::meshRefinement::checkCoupledFaceZones(const polyMesh& mesh)
 
     // Check that coupled faces are present on both sides.
 
-    labelList faceToZone(mesh.nFaces()-mesh.nInternalFaces(), -1);
+    labelList faceToZone(mesh.nBoundaryFaces(), -1);
 
     forAll(fZones, zonei)
     {
@@ -2891,8 +2882,8 @@ void Foam::meshRefinement::dumpIntersections(const fileName& prefix) const
         // ~~~~~~~~~~~~~~~~~~~~~~
 
         // Get boundary face centre and level. Coupled aware.
-        labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
-        pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
+        labelList neiLevel(mesh_.nBoundaryFaces());
+        pointField neiCc(mesh_.nBoundaryFaces());
         calcNeighbourData(neiLevel, neiCc);
 
         labelList intersectionFaces(intersectedFaces());
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C
index 5ca36811c73..2fe2cbdd7a7 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementBaffles.C
@@ -2413,8 +2413,8 @@ void Foam::meshRefinement::zonify
     const PtrList<surfaceZonesInfo>& surfZones = surfaces_.surfZones();
 
     // Swap neighbouring cell centres and cell level
-    labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
-    pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelList neiLevel(mesh_.nBoundaryFaces());
+    pointField neiCc(mesh_.nBoundaryFaces());
     calcNeighbourData(neiLevel, neiCc);
 
 
@@ -3268,7 +3268,7 @@ void Foam::meshRefinement::consistentOrientation
     {
         labelList neiStatus
         (
-            mesh_.nFaces()-mesh_.nInternalFaces(),
+            mesh_.nBoundaryFaces(),
             orientedSurface::UNVISITED
         );
 
@@ -3575,8 +3575,8 @@ void Foam::meshRefinement::baffleAndSplitMesh
         << " faces that are intersected by the surface." << nl << endl;
 
     // Swap neighbouring cell centres and cell level
-    labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
-    pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelList neiLevel(mesh_.nBoundaryFaces());
+    pointField neiCc(mesh_.nBoundaryFaces());
     calcNeighbourData(neiLevel, neiCc);
 
     labelList ownPatch, neiPatch;
@@ -3646,8 +3646,8 @@ void Foam::meshRefinement::baffleAndSplitMesh
         // so re-do the surface intersections
         {
             // Swap neighbouring cell centres and cell level
-            neiLevel.setSize(mesh_.nFaces()-mesh_.nInternalFaces());
-            neiCc.setSize(mesh_.nFaces()-mesh_.nInternalFaces());
+            neiLevel.setSize(mesh_.nBoundaryFaces());
+            neiCc.setSize(mesh_.nBoundaryFaces());
             calcNeighbourData(neiLevel, neiCc);
 
             labelList ownPatch, neiPatch;
@@ -3834,8 +3834,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::splitMesh
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
     // Swap neighbouring cell centres and cell level
-    labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
-    pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelList neiLevel(mesh_.nBoundaryFaces());
+    pointField neiCc(mesh_.nBoundaryFaces());
     calcNeighbourData(neiLevel, neiCc);
 
     // Find intersections with all unnamed(!) surfaces
@@ -4133,8 +4133,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::removeLimitShells
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
     // Swap neighbouring cell centres and cell level
-    labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
-    pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelList neiLevel(mesh_.nBoundaryFaces());
+    pointField neiCc(mesh_.nBoundaryFaces());
     calcNeighbourData(neiLevel, neiCc);
 
     // Find intersections with all unnamed(!) surfaces
@@ -4459,8 +4459,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
 
 
     // Swap neighbouring cell centres and cell level
-    labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
-    pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelList neiLevel(mesh_.nBoundaryFaces());
+    pointField neiCc(mesh_.nBoundaryFaces());
     calcNeighbourData(neiLevel, neiCc);
 
 
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementGapRefine.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementGapRefine.C
index cda200b52b3..5e76cd63cc5 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementGapRefine.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementGapRefine.C
@@ -90,7 +90,7 @@ Foam::label Foam::meshRefinement::markSurfaceGapRefinement
 
         // Collect cells to test for inside/outside in shell
         labelList cellToCompact(mesh_.nCells(), -1);
-        labelList bFaceToCompact(mesh_.nFaces()-mesh_.nInternalFaces(), -1);
+        labelList bFaceToCompact(mesh_.nBoundaryFaces(), -1);
         List<FixedList<label, 3>> shellGapInfo;
         List<volumeType> shellGapMode;
         {
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementMerge.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementMerge.C
index 739bff247f5..a7cc9e377e1 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementMerge.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementMerge.C
@@ -49,7 +49,7 @@ Foam::label Foam::meshRefinement::mergePatchFaces
     const polyBoundaryMesh& patches = mesh_.boundaryMesh();
 
     // Pick up all candidate cells on boundary
-    labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelHashSet boundaryCells(mesh_.nBoundaryFaces());
 
     for (const label patchi : patchIDs)
     {
@@ -254,16 +254,14 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
     combineFaces faceCombiner(mesh_, true);
 
     // Pick up all candidate cells on boundary
-    labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelHashSet boundaryCells(mesh_.nBoundaryFaces());
 
     {
         const polyBoundaryMesh& patches = mesh_.boundaryMesh();
 
-        forAll(patchIDs, i)
+        for (const label patchi : patchIDs)
         {
-            label patchI = patchIDs[i];
-
-            const polyPatch& patch = patches[patchI];
+            const polyPatch& patch = patches[patchi];
 
             if (!patch.coupled())
             {
@@ -410,12 +408,7 @@ Foam::label Foam::meshRefinement::mergePatchFacesUndo
             // Check mesh for errors
             // ~~~~~~~~~~~~~~~~~~~~~
 
-            faceSet errorFaces
-            (
-                mesh_,
-                "errorFaces",
-                mesh_.nFaces()-mesh_.nInternalFaces()
-            );
+            faceSet errorFaces(mesh_, "errorFaces", mesh_.nBoundaryFaces());
             bool hasErrors = motionSmoother::checkMesh
             (
                 false,  // report
@@ -899,12 +892,7 @@ Foam::label Foam::meshRefinement::mergeEdgesUndo
             // Check mesh for errors
             // ~~~~~~~~~~~~~~~~~~~~~
 
-            faceSet errorFaces
-            (
-                mesh_,
-                "errorFaces",
-                mesh_.nFaces()-mesh_.nInternalFaces()
-            );
+            faceSet errorFaces(mesh_, "errorFaces", mesh_.nBoundaryFaces());
             bool hasErrors = motionSmoother::checkMesh
             (
                 false,  // report
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C
index 8b147255b82..1bd63cc13c2 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementProblemCells.C
@@ -520,8 +520,8 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
     labelList facePatch(mesh_.nFaces(), -1);
 
     // Swap neighbouring cell centres and cell level
-    labelList neiLevel(mesh_.nFaces()-mesh_.nInternalFaces());
-    pointField neiCc(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelList neiLevel(mesh_.nBoundaryFaces());
+    pointField neiCc(mesh_.nBoundaryFaces());
     calcNeighbourData(neiLevel, neiCc);
 
 
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C
index 7643ab1822c..182be2ee222 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementRefine.C
@@ -176,7 +176,7 @@ Foam::labelList Foam::meshRefinement::getChangedFaces
 
         // 2. Boundary faces
 
-        boolList refinedBoundaryFace(mesh.nFaces()-nInternalFaces, false);
+        boolList refinedBoundaryFace(mesh.nBoundaryFaces(), false);
 
         forAll(mesh.boundaryMesh(), patchI)
         {
@@ -1871,9 +1871,9 @@ Foam::label Foam::meshRefinement::markProximityRefinement
     // 2. Find out a measure of surface curvature and region edges.
     // Send over surface region and surface normal to neighbour cell.
 
-    labelList neiBndMaxLevel(mesh_.nFaces()-mesh_.nInternalFaces());
-    pointField neiBndMaxLocation(mesh_.nFaces()-mesh_.nInternalFaces());
-    vectorField neiBndMaxNormal(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelList neiBndMaxLevel(mesh_.nBoundaryFaces());
+    pointField neiBndMaxLocation(mesh_.nBoundaryFaces());
+    vectorField neiBndMaxNormal(mesh_.nBoundaryFaces());
 
     for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++)
     {
diff --git a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementTemplates.C b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementTemplates.C
index f28db75b4a5..9cba909231d 100644
--- a/src/mesh/snappyHexMesh/meshRefinement/meshRefinementTemplates.C
+++ b/src/mesh/snappyHexMesh/meshRefinement/meshRefinementTemplates.C
@@ -106,7 +106,7 @@ void Foam::meshRefinement::testSyncBoundaryFaceList
     const UList<T>& syncedFaceData
 ) const
 {
-    label nBFaces = mesh_.nFaces() - mesh_.nInternalFaces();
+    const label nBFaces = mesh_.nBoundaryFaces();
 
     if (faceData.size() != nBFaces || syncedFaceData.size() != nBFaces)
     {
diff --git a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
index 53b66abd604..87bb6389d4c 100644
--- a/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
+++ b/src/mesh/snappyHexMesh/snappyHexMeshDriver/snappyLayerDriver.C
@@ -165,12 +165,10 @@ void Foam::snappyLayerDriver::checkMeshManifold() const
     Info<< nl << "Checking mesh manifoldness ..." << endl;
 
     // Get all outside faces
-    labelList outsideFaces(mesh.nFaces() - mesh.nInternalFaces());
-
-    for (label facei = mesh.nInternalFaces(); facei < mesh.nFaces(); facei++)
-    {
-         outsideFaces[facei - mesh.nInternalFaces()] = facei;
-    }
+    labelList outsideFaces
+    (
+        identity(mesh.nBoundaryFaces(), mesh.nInternalFaces())
+    );
 
     pointSet nonManifoldPoints
     (
diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H
index 9a42db9dfa3..0fbdbd5e638 100644
--- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H
+++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H
@@ -111,7 +111,7 @@ inline Foam::label Foam::mappedPatchBase::sampleSize() const
         case NEARESTFACE:
         {
             const polyMesh& mesh = sampleMesh();
-            return mesh.nFaces() - mesh.nInternalFaces();
+            return mesh.nBoundaryFaces();
         }
         default:
         {
diff --git a/src/meshTools/meshSearch/meshSearch.C b/src/meshTools/meshSearch/meshSearch.C
index 9a9c7a2fd10..a14b3e841ab 100644
--- a/src/meshTools/meshSearch/meshSearch.C
+++ b/src/meshTools/meshSearch/meshSearch.C
@@ -566,12 +566,11 @@ Foam::meshSearch::boundaryTree() const
             overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
         }
 
-        // all boundary faces (not just walls)
-        labelList bndFaces(mesh_.nFaces()-mesh_.nInternalFaces());
-        forAll(bndFaces, i)
-        {
-            bndFaces[i] = mesh_.nInternalFaces() + i;
-        }
+        // All boundary faces (not just walls)
+        labelList bndFaces
+        (
+            identity(mesh_.nBoundaryFaces(), mesh_.nInternalFaces())
+        );
 
         boundaryTreePtr_.reset
         (
diff --git a/src/meshTools/regionSplit/localPointRegion.C b/src/meshTools/regionSplit/localPointRegion.C
index 7672813d0c5..5f1e0da9b2c 100644
--- a/src/meshTools/regionSplit/localPointRegion.C
+++ b/src/meshTools/regionSplit/localPointRegion.C
@@ -251,7 +251,7 @@ void Foam::localPointRegion::calcPointRegions
     boolList& candidatePoint
 )
 {
-    label nBnd = mesh.nFaces()-mesh.nInternalFaces();
+    const label nBnd = mesh.nBoundaryFaces();
     const labelList& faceOwner = mesh.faceOwner();
     const labelList& faceNeighbour = mesh.faceNeighbour();
 
@@ -419,7 +419,7 @@ void Foam::localPointRegion::calcPointRegions
         SubList<face> l
         (
             minRegion,
-            mesh.nFaces()-mesh.nInternalFaces(),
+            mesh.nBoundaryFaces(),
             mesh.nInternalFaces()
         );
         syncTools::syncBoundaryFaceList
@@ -628,7 +628,7 @@ Foam::List<Foam::labelPair> Foam::localPointRegion::findDuplicateFacePairs
     // Faces to test: all boundary faces
     labelList testFaces
     (
-        identity(mesh.nFaces()-mesh.nInternalFaces(), mesh.nInternalFaces())
+        identity(mesh.nBoundaryFaces(), mesh.nInternalFaces())
     );
 
     // Find corresponding baffle face (or -1)
diff --git a/src/meshTools/regionSplit/regionSplit.C b/src/meshTools/regionSplit/regionSplit.C
index b89a64001bc..47056b2092a 100644
--- a/src/meshTools/regionSplit/regionSplit.C
+++ b/src/meshTools/regionSplit/regionSplit.C
@@ -530,7 +530,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::regionSplit::reduceRegions
     const polyBoundaryMesh& patches = mesh().boundaryMesh();
 
     // Buffer for swapping boundary information
-    labelList nbrRegion(mesh().nFaces()-mesh().nInternalFaces());
+    labelList nbrRegion(mesh().nBoundaryFaces());
 
     do
     {
diff --git a/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C b/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C
index 7aca426d575..e4c55b966b7 100644
--- a/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C
+++ b/src/meshTools/sets/cellSources/nbrToCell/nbrToCell.C
@@ -52,7 +52,7 @@ void Foam::nbrToCell::combine(topoSet& set, const bool add) const
     const cellList& cells = mesh().cells();
     const polyBoundaryMesh& patches = mesh_.boundaryMesh();
 
-    boolList isCoupled(mesh_.nFaces()-mesh_.nInternalFaces(), false);
+    boolList isCoupled(mesh_.nBoundaryFaces(), false);
 
     for (const polyPatch& pp : patches)
     {
diff --git a/src/meshTools/sets/topoSets/faceZoneSet.C b/src/meshTools/sets/topoSets/faceZoneSet.C
index e0716e858a2..674beddc35d 100644
--- a/src/meshTools/sets/topoSets/faceZoneSet.C
+++ b/src/meshTools/sets/topoSets/faceZoneSet.C
@@ -351,7 +351,7 @@ void Foam::faceZoneSet::sync(const polyMesh& mesh)
     //-1 : in faceZone and flipped
     const label UNFLIPPED = 1;
     const label FLIPPED = -1;
-    labelList myZoneFace(mesh.nFaces()-mesh.nInternalFaces(), 0);
+    labelList myZoneFace(mesh.nBoundaryFaces(), Zero);
 
     forAll(addressing_, i)
     {
diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C
index 46c36f7deb3..2ac294e46ab 100644
--- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C
+++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C
@@ -2283,10 +2283,7 @@ Foam::triSurface Foam::triSurfaceTools::triangulate
     const polyMesh& mesh = bMesh.mesh();
 
     // Storage for surfaceMesh. Size estimate.
-    DynamicList<labelledTri> triangles
-    (
-        mesh.nFaces() - mesh.nInternalFaces()
-    );
+    DynamicList<labelledTri> triangles(mesh.nBoundaryFaces());
 
     label newPatchi = 0;
 
@@ -2364,10 +2361,7 @@ Foam::triSurface Foam::triSurfaceTools::triangulate
     const polyMesh& mesh = bMesh.mesh();
 
     // Storage for surfaceMesh. Size estimate.
-    DynamicList<labelledTri> triangles
-    (
-        mesh.nFaces() - mesh.nInternalFaces()
-    );
+    DynamicList<labelledTri> triangles(mesh.nBoundaryFaces());
 
     label newPatchi = 0;
 
@@ -2472,10 +2466,7 @@ Foam::triSurface Foam::triSurfaceTools::triangulateFaceCentre
 
 
     // Count number of faces.
-    DynamicList<labelledTri> triangles
-    (
-        mesh.nFaces() - mesh.nInternalFaces()
-    );
+    DynamicList<labelledTri> triangles(mesh.nBoundaryFaces());
 
     label newPatchi = 0;
 
diff --git a/src/parallel/decompose/decompositionMethods/decompositionConstraints/preserveFaceZones/preserveFaceZonesConstraint.C b/src/parallel/decompose/decompositionMethods/decompositionConstraints/preserveFaceZones/preserveFaceZonesConstraint.C
index e481aef6044..79c2400658b 100644
--- a/src/parallel/decompose/decompositionMethods/decompositionConstraints/preserveFaceZones/preserveFaceZonesConstraint.C
+++ b/src/parallel/decompose/decompositionMethods/decompositionConstraints/preserveFaceZones/preserveFaceZonesConstraint.C
@@ -146,7 +146,7 @@ void Foam::decompositionConstraints::preserveFaceZonesConstraint::apply
 
     const polyBoundaryMesh& pbm = mesh.boundaryMesh();
 
-    labelList destProc(mesh.nFaces()-mesh.nInternalFaces(), labelMax);
+    labelList destProc(mesh.nBoundaryFaces(), labelMax);
 
     for (const polyPatch& pp : pbm)
     {
diff --git a/src/parallel/decompose/decompositionMethods/decompositionConstraints/preservePatches/preservePatchesConstraint.C b/src/parallel/decompose/decompositionMethods/decompositionConstraints/preservePatches/preservePatchesConstraint.C
index 8333cbfd7db..35130948488 100644
--- a/src/parallel/decompose/decompositionMethods/decompositionConstraints/preservePatches/preservePatchesConstraint.C
+++ b/src/parallel/decompose/decompositionMethods/decompositionConstraints/preservePatches/preservePatchesConstraint.C
@@ -146,7 +146,7 @@ void Foam::decompositionConstraints::preservePatchesConstraint::apply
 
     const polyBoundaryMesh& pbm = mesh.boundaryMesh();
 
-    labelList destProc(mesh.nFaces()-mesh.nInternalFaces(), labelMax);
+    labelList destProc(mesh.nBoundaryFaces(), labelMax);
 
     for (const polyPatch& pp : pbm)
     {
diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C
index deaa397e034..73bb15f9a18 100644
--- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C
+++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C
@@ -535,7 +535,7 @@ void Foam::decompositionMethod::calcCellCells
     // Get agglomerate owner on other side of coupled faces
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-    labelList globalNeighbour(mesh.nFaces()-mesh.nInternalFaces());
+    labelList globalNeighbour(mesh.nBoundaryFaces());
 
     for (const polyPatch& pp : patches)
     {
@@ -734,7 +734,7 @@ void Foam::decompositionMethod::calcCellCells
     // Get agglomerate owner on other side of coupled faces
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-    labelList globalNeighbour(mesh.nFaces()-mesh.nInternalFaces());
+    labelList globalNeighbour(mesh.nBoundaryFaces());
 
     for (const polyPatch& pp : patches)
     {
diff --git a/src/renumber/SloanRenumber/SloanRenumber.C b/src/renumber/SloanRenumber/SloanRenumber.C
index c967dd7956a..075d81a89bb 100644
--- a/src/renumber/SloanRenumber/SloanRenumber.C
+++ b/src/renumber/SloanRenumber/SloanRenumber.C
@@ -113,7 +113,7 @@ Foam::labelList Foam::SloanRenumber::renumber
     // Construct graph : faceOwner + connections across cyclics.
 
     // Determine neighbour cell
-    labelList nbr(mesh.nFaces()-mesh.nInternalFaces(), -1);
+    labelList nbr(mesh.nBoundaryFaces(), -1);
     forAll(pbm, patchi)
     {
         if (pbm[patchi].coupled() && !isA<processorPolyPatch>(pbm[patchi]))
diff --git a/src/sampling/meshToMesh/meshToMesh.C b/src/sampling/meshToMesh/meshToMesh.C
index 2c6a5e8ab65..f904480f00e 100644
--- a/src/sampling/meshToMesh/meshToMesh.C
+++ b/src/sampling/meshToMesh/meshToMesh.C
@@ -492,7 +492,7 @@ void Foam::meshToMesh::calculate(const word& methodName, const bool normalise)
         patches[0] = new polyPatch
         (
             "defaultFaces",
-            newTgt.nFaces() - newTgt.nInternalFaces(),
+            newTgt.nBoundaryFaces(),
             newTgt.nInternalFaces(),
             0,
             newTgt.boundaryMesh(),
diff --git a/src/sampling/sampledSet/shortestPath/shortestPathSet.C b/src/sampling/sampledSet/shortestPath/shortestPathSet.C
index 2cf4276fdf4..ba80d903ffa 100644
--- a/src/sampling/sampledSet/shortestPath/shortestPathSet.C
+++ b/src/sampling/sampledSet/shortestPath/shortestPathSet.C
@@ -238,7 +238,7 @@ void Foam::shortestPathSet::genSamples(const polyMesh& mesh)
 
             // Situation 2: we're on a coupled patch and might need to
             //              switch processor/cell
-            boolList isFront(mesh.nFaces()-mesh.nInternalFaces(), false);
+            boolList isFront(mesh.nBoundaryFaces(), false);
 
             if (frontFaceI != -1)
             {
diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C
index 2a666f29ccb..83db3ec3252 100644
--- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C
+++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C
@@ -116,7 +116,7 @@ Foam::sampledTriSurfaceMesh::nonCoupledboundaryTree() const
         // all non-coupled boundary faces (not just walls)
         const polyBoundaryMesh& patches = mesh().boundaryMesh();
 
-        labelList bndFaces(mesh().nFaces()-mesh().nInternalFaces());
+        labelList bndFaces(patches.nFaces());
         label bndI = 0;
         for (const polyPatch& pp : patches)
         {
diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMeshTemplates.C b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMeshTemplates.C
index b4f83b37362..7988cfcb033 100644
--- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMeshTemplates.C
+++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMeshTemplates.C
@@ -58,7 +58,7 @@ Foam::sampledTriSurfaceMesh::sampleOnFaces
     auto& values = tvalues.ref();
 
     const polyBoundaryMesh& pbm = mesh().boundaryMesh();
-    const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
+    const label nBnd = mesh().nBoundaryFaces();
 
     // Create flat boundary field
 
diff --git a/src/sampling/surface/isoSurface/isoSurface.C b/src/sampling/surface/isoSurface/isoSurface.C
index bc2a3b3c4ce..1efeaec9c18 100644
--- a/src/sampling/surface/isoSurface/isoSurface.C
+++ b/src/sampling/surface/isoSurface/isoSurface.C
@@ -1453,7 +1453,7 @@ Foam::isoSurface::isoSurface
 
 
     // Pre-calculate patch-per-face to avoid whichPatch call.
-    labelList boundaryRegion(mesh_.nFaces()-mesh_.nInternalFaces());
+    labelList boundaryRegion(mesh_.nBoundaryFaces());
 
     forAll(patches, patchi)
     {
diff --git a/src/sampling/surface/isoSurface/isoSurfaceTemplates.C b/src/sampling/surface/isoSurface/isoSurfaceTemplates.C
index 542bd28f249..c03a97de507 100644
--- a/src/sampling/surface/isoSurface/isoSurfaceTemplates.C
+++ b/src/sampling/surface/isoSurface/isoSurfaceTemplates.C
@@ -606,7 +606,7 @@ void Foam::isoSurface::generateTriPoints
 
 
     // Determine neighbouring snap status
-    boolList neiSnapped(mesh_.nFaces()-mesh_.nInternalFaces(), false);
+    boolList neiSnapped(mesh_.nBoundaryFaces(), false);
     List<Type> neiSnappedPoint(neiSnapped.size(), Type(Zero));
     for (const polyPatch& pp : patches)
     {
diff --git a/src/sampling/surface/triSurfaceMesh/discreteSurface.C b/src/sampling/surface/triSurfaceMesh/discreteSurface.C
index 79bfa6ddf03..5df8594ae74 100644
--- a/src/sampling/surface/triSurfaceMesh/discreteSurface.C
+++ b/src/sampling/surface/triSurfaceMesh/discreteSurface.C
@@ -110,7 +110,7 @@ Foam::discreteSurface::nonCoupledboundaryTree() const
         // all non-coupled boundary faces (not just walls)
         const polyBoundaryMesh& patches = mesh().boundaryMesh();
 
-        labelList bndFaces(mesh().nFaces()-mesh().nInternalFaces());
+        labelList bndFaces(patches.nFaces());
         label bndI = 0;
         for (const polyPatch& pp : patches)
         {
diff --git a/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C b/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C
index 74256346f42..3fce29d212a 100644
--- a/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C
+++ b/src/sampling/surface/triSurfaceMesh/discreteSurfaceTemplates.C
@@ -169,7 +169,7 @@ Foam::discreteSurface::sampleOnFaces
         // Sample boundary faces
 
         const polyBoundaryMesh& pbm = mesh().boundaryMesh();
-        const label nBnd = mesh().nFaces()-mesh().nInternalFaces();
+        const label nBnd = mesh().nBoundaryFaces();
 
         // Create flat boundary field
 
diff --git a/src/surfMesh/MeshedSurface/MeshedSurface.C b/src/surfMesh/MeshedSurface/MeshedSurface.C
index 2be602bf469..c241d13623f 100644
--- a/src/surfMesh/MeshedSurface/MeshedSurface.C
+++ b/src/surfMesh/MeshedSurface/MeshedSurface.C
@@ -337,7 +337,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
         SubList<face>
         (
             mesh.faces(),
-            mesh.nFaces() - mesh.nInternalFaces(),
+            mesh.nBoundaryFaces(),
             mesh.nInternalFaces()
         ),
         mesh.points()
diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C
index 2c76eeeedf4..4c0785eb118 100644
--- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C
+++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/faceShading/faceShading.C
@@ -80,10 +80,7 @@ Foam::triSurface Foam::faceShading::triangulate
     const polyBoundaryMesh& bMesh = mesh_.boundaryMesh();
 
     // Storage for surfaceMesh. Size estimate.
-    DynamicList<labelledTri> triangles
-    (
-        mesh_.nFaces() - mesh_.nInternalFaces()
-    );
+    DynamicList<labelledTri> triangles(mesh_.nBoundaryFaces());
 
     label newPatchI = 0;
 
-- 
GitLab