From d6c5d294b43936bf813f39b6447ebfc2a3be4fc5 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 26 Mar 2010 13:36:24 +0000 Subject: [PATCH] ENH: added patchID access function --- .../polyBoundaryMesh/polyBoundaryMesh.C | 53 ++++++++++++++----- .../polyBoundaryMesh/polyBoundaryMesh.H | 7 ++- 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index 07bb357ff3..1820c43ef0 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -61,8 +61,7 @@ Foam::polyBoundaryMesh::polyBoundaryMesh : polyPatchList(), regIOobject(io), - mesh_(mesh), - neighbourEdgesPtr_(NULL) + mesh_(mesh) { if (readOpt() == IOobject::MUST_READ) { @@ -110,17 +109,14 @@ Foam::polyBoundaryMesh::polyBoundaryMesh : polyPatchList(size), regIOobject(io), - mesh_(pm), - neighbourEdgesPtr_(NULL) + mesh_(pm) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::polyBoundaryMesh::~polyBoundaryMesh() -{ - deleteDemandDrivenData(neighbourEdgesPtr_); -} +{} void Foam::polyBoundaryMesh::clearGeom() @@ -134,7 +130,8 @@ void Foam::polyBoundaryMesh::clearGeom() void Foam::polyBoundaryMesh::clearAddressing() { - deleteDemandDrivenData(neighbourEdgesPtr_); + neighbourEdgesPtr_.clear(); + patchIDPtr_.clear(); forAll (*this, patchi) { @@ -201,10 +198,10 @@ Foam::polyBoundaryMesh::neighbourEdges() const << " boundaries." << endl; } - if (!neighbourEdgesPtr_) + if (!neighbourEdgesPtr_.valid()) { - neighbourEdgesPtr_ = new List(size()); - List& neighbourEdges = *neighbourEdgesPtr_; + neighbourEdgesPtr_.reset(new List(size())); + List& neighbourEdges = neighbourEdgesPtr_(); // Initialize. label nEdgePairs = 0; @@ -320,7 +317,36 @@ Foam::polyBoundaryMesh::neighbourEdges() const } } - return *neighbourEdgesPtr_; + return neighbourEdgesPtr_(); +} + + +const Foam::labelList& Foam::polyBoundaryMesh::patchID() const +{ + if (!patchIDPtr_.valid()) + { + patchIDPtr_.reset + ( + new labelList + ( + mesh_.nFaces() + - mesh_.nInternalFaces() + ) + ); + labelList& patchID = patchIDPtr_(); + + const polyBoundaryMesh& bm = *this; + + forAll(bm, patchI) + { + label bFaceI = bm[patchI].start() - mesh_.nInternalFaces(); + forAll(bm[patchI], i) + { + patchID[bFaceI++] = patchI; + } + } + } + return patchIDPtr_(); } @@ -654,7 +680,8 @@ void Foam::polyBoundaryMesh::movePoints(const pointField& p) void Foam::polyBoundaryMesh::updateMesh() { - deleteDemandDrivenData(neighbourEdgesPtr_); + neighbourEdgesPtr_.clear(); + patchIDPtr_.clear(); PstreamBuffers pBufs(Pstream::defaultCommsType); diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H index fdea473ed3..76981ef2bc 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H @@ -67,8 +67,10 @@ class polyBoundaryMesh //- Reference to mesh const polyMesh& mesh_; + mutable autoPtr patchIDPtr_; + //- Edges of neighbouring patches - mutable List* neighbourEdgesPtr_; + mutable autoPtr > neighbourEdgesPtr_; // Private Member Functions @@ -157,6 +159,9 @@ public: //- Return patch index for a given face label label whichPatch(const label faceIndex) const; + //- Per boundary face label the patch index + const labelList& patchID() const; + //- Return the set of patch IDs corresponding to the given list of names // Wild cards are expanded. labelHashSet patchSet(const wordList&) const;