From f421e29c2e6a9384577c9d4f16c6fb7027e9309c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 27 May 2021 15:35:52 +0200 Subject: [PATCH] ENH: improved handling of dangling finiteArea edges (#2084) - restrict searching to patch quantities to avoid triggering mesh edge calculations --- src/finiteArea/faMesh/faMesh.H | 6 +- src/finiteArea/faMesh/faMeshPatches.C | 570 ++++++++++++++++---------- 2 files changed, 364 insertions(+), 212 deletions(-) diff --git a/src/finiteArea/faMesh/faMesh.H b/src/finiteArea/faMesh/faMesh.H index 9498c7ade3..8a9b165011 100644 --- a/src/finiteArea/faMesh/faMesh.H +++ b/src/finiteArea/faMesh/faMesh.H @@ -269,10 +269,7 @@ class faMesh // Helpers //- Get the polyPatch pairs for the boundary edges (natural order) - List> getBoundaryEdgePatchPairs - ( - const labelUList& meshEdges - ) const; + List> getBoundaryEdgePatchPairs() const; //- Create a single patch PtrList createOnePatch @@ -294,7 +291,6 @@ class faMesh void reorderProcEdges ( faPatchData& patchDef, - const labelUList& meshEdges, const List>& bndEdgePatchPairs ) const; diff --git a/src/finiteArea/faMesh/faMeshPatches.C b/src/finiteArea/faMesh/faMeshPatches.C index 966f582994..889bdd7826 100644 --- a/src/finiteArea/faMesh/faMeshPatches.C +++ b/src/finiteArea/faMesh/faMeshPatches.C @@ -52,53 +52,125 @@ typedef List patchPairInfoList; typedef UIndirectList patchPairInfoUIndList; -// Synchronize edge patch pairs. -// - only propagate real (non-processor) patch ids - -struct syncEdgePatchPairs +// Handling of dangling coupled edges. +// Tag values to "push" with special -(patchId+2) +struct combineDanglingEdge { const label upperLimit; - explicit syncEdgePatchPairs(const label nNonProcessor) + // Set dangling patchId from real patchId + static void setDangling(patchPairInfo& pairing, const label patchId) + { + pairing.first() = pairing.second() = -(patchId + 2); + pairing.setIndex(-1); // Invalidate + } + + // Convert dangling patchId to real patchId + static void correct(patchPairInfo& pairing) + { + if (pairing.first() < -1) + { + pairing.first() = -(pairing.first() + 2); + } + if (pairing.second() < -1) + { + pairing.second() = -(pairing.second() + 2); + } + } + + //- Construct with upper limit (the number of non-processor patches) + explicit combineDanglingEdge(const label nNonProcessor) : upperLimit(nNonProcessor) {} - void insert(edge& e, const label i) const - { - // This could probably be simpler - if (i >= 0 && i < upperLimit && !e.found(i)) - { - if (e.first() == -1) - { - e.first() = i; - } - else if (e.second() == -1) - { - e.second() = i; - } - else if (upperLimit < e.first()) - { - e.first() = i; - } - else if (upperLimit < e.second()) - { - e.second() = i; - } - } - } - void operator()(edge& x, const edge& y) const + // Combine operation: overwrite unused or processor patches with + // 'dangling' patch information only + void operator()(patchPairInfo& x, const patchPairInfo& y) const { - if (edge::compare(x, y) == 0) + if (y.first() < -1 && edge::compare(x, y) == 0) { - insert(x, y.first()); - insert(x, y.second()); + if (x.first() == -1 || x.first() >= upperLimit) + { + x.first() = y.first(); + } + if (x.second() == -1 || x.second() >= upperLimit) + { + x.second() = y.first(); + x.index() = y.index(); + } } } }; +// Populate patch pairings according to the boundary edges +void findEdgePatchPairing +( + const polyBoundaryMesh& pbm, + const EdgeMap