Skip to content
Snippets Groups Projects
Commit d6c5d294 authored by mattijs's avatar mattijs
Browse files

ENH: added patchID access function

parent d981028d
Branches
Tags
No related merge requests found
......@@ -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<labelPairList>(size());
List<labelPairList>& neighbourEdges = *neighbourEdgesPtr_;
neighbourEdgesPtr_.reset(new List<labelPairList>(size()));
List<labelPairList>& 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);
......
......@@ -67,8 +67,10 @@ class polyBoundaryMesh
//- Reference to mesh
const polyMesh& mesh_;
mutable autoPtr<labelList> patchIDPtr_;
//- Edges of neighbouring patches
mutable List<labelPairList>* neighbourEdgesPtr_;
mutable autoPtr<List<labelPairList> > 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;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment