From 08a9b038916f3afea1e4144ba6cfda1f0f7e35fa Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 6 Nov 2023 13:58:00 +0100 Subject: [PATCH] ENH: polyBoundaryMesh additional faces() and faceOwner() slice methods - return a subList view of the mesh faces, owners --- .../test/foamMeshToTet-vtk/writeVTKtetMesh.C | 4 +-- .../polyBoundaryMesh/polyBoundaryMesh.C | 28 +++++++++++++++++++ .../polyBoundaryMesh/polyBoundaryMesh.H | 6 ++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/applications/test/foamMeshToTet-vtk/writeVTKtetMesh.C b/applications/test/foamMeshToTet-vtk/writeVTKtetMesh.C index ea7157fac0..2679174fcf 100644 --- a/applications/test/foamMeshToTet-vtk/writeVTKtetMesh.C +++ b/applications/test/foamMeshToTet-vtk/writeVTKtetMesh.C @@ -52,9 +52,9 @@ void writeVTKtetMesh(const fileName& output, const polyMesh& mesh_) { nTets += 2 * faces[facei].nTriangles(); } - for (label facei = mesh_.nInternalFaces(); facei < mesh_.nFaces(); ++facei) + for (const face& f : mesh_.boundaryMesh().faces()) { - nTets += faces[facei].nTriangles(); + nTets += f.nTriangles(); } const label nPoints = (mesh_.nPoints() + mesh_.nCells()); diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index 531500637f..29c9b93eda 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -300,6 +300,34 @@ void Foam::polyBoundaryMesh::calcGeometry() } +const Foam::faceList::subList Foam::polyBoundaryMesh::faces() const +{ + return faceList::subList + ( + mesh_.faces(), + mesh_.nBoundaryFaces(), + mesh_.nInternalFaces() + ); +} + + +const Foam::labelList::subList Foam::polyBoundaryMesh::faceOwner() const +{ + return labelList::subList + ( + mesh_.faceOwner(), + mesh_.nBoundaryFaces(), + mesh_.nInternalFaces() + ); +} + +// Potentially useful to simplify logic elsewhere? +// const Foam::labelList::subList Foam::polyBoundaryMesh::faceNeighbour() const +// { +// return labelList::subList(); +// } + + Foam::UPtrList Foam::polyBoundaryMesh::faceCells() const { diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H index 625b2d7a3e..3227472a11 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H @@ -171,6 +171,12 @@ public: return mesh_; } + //- Return mesh faces for the entire boundary + const faceList::subList faces() const; + + //- Return face owner for the entire boundary + const labelList::subList faceOwner() const; + //- Return a list of faceCells for each patch UPtrList faceCells() const;