From 3bc8ab2839abe06d6ec646903ade1f23c72ad06b Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 10 May 2021 13:38:02 +0200 Subject: [PATCH] ENH: improve PrimitivePatch access for edges - return internalEdges() and boundaryEdges() sub lists directly - calculate and return boundaryFaces() to identify faces attached to boundary edges. - minor code cleanup, and add PrimitivePatchBase class for non-templated code. STYLE: mark unused parameter in globalMeshData mergePoints --- .../test/primitivePatch/Test-PrimitivePatch.C | 25 +++- src/OpenFOAM/Make/files | 2 +- .../polyMesh/globalMeshData/globalMeshData.C | 2 +- .../polyMesh/globalMeshData/globalMeshData.H | 20 +-- .../PrimitivePatch/PrimitivePatch.C | 39 ++++-- .../PrimitivePatch/PrimitivePatch.H | 51 ++++--- .../PrimitivePatch/PrimitivePatchAddressing.C | 37 ++--- ...mitivePatchName.C => PrimitivePatchBase.C} | 5 +- .../PrimitivePatch/PrimitivePatchBase.H | 72 ++++++++++ .../PrimitivePatch/PrimitivePatchBdryFaces.C | 53 ++++++++ .../PrimitivePatch/PrimitivePatchBdryPoints.C | 14 +- .../PrimitivePatch/PrimitivePatchEdgeLoops.C | 16 +-- .../PrimitivePatchLocalPointOrder.C | 16 +-- .../PrimitivePatch/PrimitivePatchMeshData.C | 128 +++--------------- .../PrimitivePatch/PrimitivePatchMeshEdges.C | 77 +++++------ .../PrimitivePatchPointAddressing.C | 10 +- .../PrimitivePatchProjectPoints.C | 51 +++---- 17 files changed, 322 insertions(+), 296 deletions(-) rename src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/{PrimitivePatchName.C => PrimitivePatchBase.C} (92%) create mode 100644 src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchBase.H create mode 100644 src/OpenFOAM/meshes/primitiveMesh/PrimitivePatch/PrimitivePatchBdryFaces.C diff --git a/applications/test/primitivePatch/Test-PrimitivePatch.C b/applications/test/primitivePatch/Test-PrimitivePatch.C index a74deb4bdf..e53f81b409 100644 --- a/applications/test/primitivePatch/Test-PrimitivePatch.C +++ b/applications/test/primitivePatch/Test-PrimitivePatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,6 +34,7 @@ Description #include "polyMesh.H" #include "primitiveFacePatch.H" #include "primitivePatch.H" +#include "IndirectList.H" #include "Fstream.H" using namespace Foam; @@ -242,6 +243,28 @@ int main(int argc, char *argv[]) writeEdgeFaces(localPoints, localFaces, edges, edgeFaces); writeFaceFaces(localPoints, localFaces, faceFaces); + + const labelList bndFaceIds(pp.boundaryFaces()); + + Info<< "Have: " << bndFaceIds.size() << " boundary faces" << nl; + + // Can calculate by hand + if (!pp.hasFaceCentres()) + { + pointField boundaryCentres(bndFaceIds.size()); + + forAll(bndFaceIds, facei) + { + boundaryCentres[facei] = + pp[bndFaceIds[facei]].centre(pp.points()); + } + Info << "calc faceCentres:" + << boundaryCentres << nl; + } + + // But will often use the cached information + Info<< "faceCentres:" + << UIndirectList(pp.faceCentres(), bndFaceIds) << nl; } // Move construct diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 4ca6562acf..e7b0357b08 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -655,7 +655,7 @@ $(mapPolyMesh)/mapDistribute/IOmapDistribute.C $(mapPolyMesh)/mapAddedPolyMesh.C PrimitivePatch = $(primitiveMesh)/PrimitivePatch -$(PrimitivePatch)/PrimitivePatchName.C +$(PrimitivePatch)/PrimitivePatchBase.C pointMesh = meshes/pointMesh $(pointMesh)/pointMesh.C diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 3b98b0c996..9ff449fde5 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -2507,7 +2507,7 @@ Foam::autoPtr Foam::globalMeshData::mergePoints Foam::autoPtr Foam::globalMeshData::mergePoints ( const labelList& meshPoints, - const Map