diff --git a/src/dynamicMesh/attachDetach/attachDetach.C b/src/dynamicMesh/attachDetach/attachDetach.C index 1f0d9c6007..51e9143730 100644 --- a/src/dynamicMesh/attachDetach/attachDetach.C +++ b/src/dynamicMesh/attachDetach/attachDetach.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020,2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,6 +66,7 @@ void Foam::attachDetach::checkDefinition() } const polyMesh& mesh = topoChanger().mesh(); + const auto& bm = mesh.boundaryMesh(); if (debug) { @@ -76,11 +77,14 @@ void Foam::attachDetach::checkDefinition() } // Check the sizes and set up state - if - ( - mesh.boundaryMesh()[masterPatchID_.index()].empty() - && mesh.boundaryMesh()[slavePatchID_.index()].empty() - ) + const auto& mPatch = bm[masterPatchID_.index()]; + const label nMasterFaces = returnReduce(mPatch.size(), sumOp