From 5c64455a115d7d974cd1156244e50b83055597ae Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Fri, 8 Sep 2017 15:07:53 +0200 Subject: [PATCH] Generalisation of polyRef::getAnchorLevel The function now returns the correct anchor level for arbitrary polygonal faces, i.e. there is no assumption that the face comes from possibly spit hex cell. --- .../directTopoChange/directActions/polyRef.C | 133 ++++++++++++------ .../directTopoChange/directActions/polyRef.H | 4 +- 2 files changed, 95 insertions(+), 42 deletions(-) diff --git a/src/dynamicMesh/dynamicMesh/directTopoChange/directTopoChange/directActions/polyRef.C b/src/dynamicMesh/dynamicMesh/directTopoChange/directTopoChange/directActions/polyRef.C index 6da24963c..ec1b91fce 100644 --- a/src/dynamicMesh/dynamicMesh/directTopoChange/directTopoChange/directActions/polyRef.C +++ b/src/dynamicMesh/dynamicMesh/directTopoChange/directTopoChange/directActions/polyRef.C @@ -753,41 +753,78 @@ Foam::label Foam::polyRef::findLevel } -// Gets cell level such that the face has four points <= level. +// Get cell level such that the face has the most points that are <= level (at +// least three points) Foam::label Foam::polyRef::getAnchorLevel(const label faceI) const { const face& f = mesh_.faces()[faceI]; - if (f.size() <= 4) + // Get number of points in this face + const label nPoints = f.size(); + + // Get unique levels that can be found in this face + labelHashSet uniqueLevels(nPoints); + forAll(f, fp) { - return pointLevel_[f[findMaxLevel(f)]]; + uniqueLevels.insert(pointLevel_[f[fp]]); } - else + + // Get sorted levels (in increasing order) + const labelList allLevels = uniqueLevels.sortedToc(); + + // Count number of points per level + labelList nPointsPerLevel(allLevels.size(), 0); + + // Loop through all points + forAll(f, fp) { - label ownLevel = cellLevel_[mesh_.faceOwner()[faceI]]; + const label curPointLevel = pointLevel_[f[fp]]; - if (countAnchors(f, ownLevel) == 4) + // Loop through all levels + forAll(allLevels, levelI) { - return ownLevel; - } - else if (countAnchors(f, ownLevel+1) == 4) - { - return ownLevel+1; - } - else - { - //FatalErrorIn("polyRef::getAnchorLevel(const label) const") - // << "face:" << faceI - // << " centre:" << mesh_.faceCentres()[faceI] - // << " verts:" << f - // << " point levels:" << IndirectList