diff --git a/src/meshTools/patchIntersection/FacePatchIntersection.C b/src/meshTools/patchIntersection/FacePatchIntersection.C index 1e1d7869d8..d6c28514b4 100644 --- a/src/meshTools/patchIntersection/FacePatchIntersection.C +++ b/src/meshTools/patchIntersection/FacePatchIntersection.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -71,6 +71,28 @@ void inplaceRemove(ListType& lst, const T& value, const T&) lst.resize(iNew); } +template +ListType reorder +( + const label size, + const typename ListType::value_type& defaultValue, + const labelUList& oldToNew, + const ListType& lst +) +{ + ListType newLst(size, defaultValue); + + forAll(lst, elemI) + { + if (oldToNew[elemI] >= 0) + { + newLst[oldToNew[elemI]] = lst[elemI]; + } + } + + return newLst; +} + } @@ -248,9 +270,21 @@ Foam::FacePatchIntersection::FacePatchIntersection // Point-point connectivity this->srcPointPoints_ = - reorder(srcTriPatchPointSrcPatchPoints, tpi.srcPointPoints()); + reorder + ( + this->srcPatch().nPoints(), + -1, + srcTriPatchPointSrcPatchPoints, + tpi.srcPointPoints() + ); this->tgtPointPoints_ = - reorder(tgtTriPatchPointTgtPatchPoints, tpi.tgtPointPoints()); + reorder + ( + this->tgtPatch().nPoints(), + -1, + tgtTriPatchPointTgtPatchPoints, + tpi.tgtPointPoints() + ); this->pointSrcPoints_ = tpi.pointSrcPoints(); inplaceRenumber(srcTriPatchPointSrcPatchPoints, this->pointSrcPoints_); this->pointTgtPoints_ = tpi.pointTgtPoints(); @@ -258,10 +292,22 @@ Foam::FacePatchIntersection::FacePatchIntersection // Point-edge connectivity this->srcEdgePoints_ = - reorder(srcTriPatchEdgeSrcPatchEdges, tpi.srcEdgePoints()); + reorder + ( + this->srcPatch_.nEdges(), + DynamicList