From 333c815d8fbb0a0b57250be9f8f4d47120245f1d Mon Sep 17 00:00:00 2001 From: Pascal Beckstein Date: Mon, 24 Oct 2016 19:22:50 +0200 Subject: [PATCH] Make all axis point labels available in wedgeFaPatch (idea from Zeljko) --- .../faPatches/constraint/wedge/wedgeFaPatch.C | 43 +++++++++---------- .../faPatches/constraint/wedge/wedgeFaPatch.H | 38 +++++++++++----- 2 files changed, 48 insertions(+), 33 deletions(-) diff --git a/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.C b/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.C index 97b97d3f9..2f4fe0a7f 100644 --- a/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.C +++ b/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.C @@ -36,48 +36,49 @@ Description namespace Foam { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -defineTypeNameAndDebug(wedgeFaPatch, 0); -addToRunTimeSelectionTable(faPatch, wedgeFaPatch, dictionary); + defineTypeNameAndDebug(Foam::wedgeFaPatch, 0); + addToRunTimeSelectionTable(faPatch, wedgeFaPatch, dictionary); +} // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // -void wedgeFaPatch::findAxisPoint() const +void Foam::wedgeFaPatch::findAxisPoints() const { // Find axis point - labelList ptLabels = pointLabels(); + const labelList& ptLabels = pointLabels(); - labelListList ptEdges = pointEdges(); + const labelListList& ptEdges = pointEdges(); const vectorField& points = boundaryMesh().mesh().points(); const scalarField& magL = magEdgeLengths(); - forAll(ptEdges, pointI) + labelHashSet axisPointsSet; + + forAll (ptEdges, pointI) { - if( ptEdges[pointI].size() == 1 ) + if (ptEdges[pointI].size() == 1 ) { scalar r = mag((I-axis()*axis())&points[ptLabels[pointI]]); if( r < magL[ptEdges[pointI][0]] ) { - axisPoint_ = ptLabels[pointI]; - break; + axisPointsSet.insert(ptLabels[pointI]); } } } - axisPointChecked_ = true; + axisPoints_ = axisPointsSet.toc(); + + axisPointsChecked_ = true; } // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * // //- Construct from polyPatch -wedgeFaPatch::wedgeFaPatch +Foam::wedgeFaPatch::wedgeFaPatch ( const word& name, const dictionary& dict, @@ -87,14 +88,14 @@ wedgeFaPatch::wedgeFaPatch : faPatch(name, dict, index, bm), wedgePolyPatchPtr_(NULL), - axisPoint_(-1), - axisPointChecked_(false) + axisPointsChecked_(false) { if(ngbPolyPatchIndex() == -1) { FatalErrorIn ( - "wedgeFaPatch::wedgeFaPatch(const word&, const dictionary&, const label, const faBoundaryMesh&)" + "wedgeFaPatch::wedgeFaPatch(const word&, const dictionary&," + " const label, const faBoundaryMesh&)" ) << "Neighbour polyPatch index is not specified for faPatch " << this->name() << exit(FatalError); } @@ -117,16 +118,12 @@ wedgeFaPatch::wedgeFaPatch { FatalErrorIn ( - "wedgeFaPatch::wedgeFaPatch(const word&, const dictionary&, const label, const faBoundaryMesh&)" + "wedgeFaPatch::wedgeFaPatch(const word&, const dictionary&," + "const label, const faBoundaryMesh&)" ) << "Neighbour polyPatch is not of type " << wedgePolyPatch::typeName << exit(FatalError); } } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.H b/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.H index df4e179cf..26ba6ed03 100644 --- a/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.H +++ b/src/finiteArea/faMesh/faPatches/constraint/wedge/wedgeFaPatch.H @@ -55,14 +55,14 @@ class wedgeFaPatch const wedgePolyPatch* wedgePolyPatchPtr_; - //- Axis point label - mutable label axisPoint_; + //- Axis point labels + mutable labelList axisPoints_; - //- Is it axis point looked for? - mutable bool axisPointChecked_; + //- Have axis points already been checked? + mutable bool axisPointsChecked_; - //- Finde axis point - void findAxisPoint() const; + //- Find axis points + void findAxisPoints() const; public: @@ -116,15 +116,33 @@ public: return wedgePolyPatchPtr_->cellT(); } - //- Return axis point label + //- Return first axis point label label axisPoint() const { - if(axisPoint_ == -1 && !axisPointChecked_) + if (!axisPointsChecked_) { - findAxisPoint(); + findAxisPoints(); } - return axisPoint_; + if (axisPoints_.size() > 0) + { + return axisPoints_[0]; + } + else + { + return -1; + } + } + + //- Return all axis point labels + const labelList& axisPoints() const + { + if (!axisPointsChecked_) + { + findAxisPoints(); + } + + return axisPoints_; } };