From ff8cdfa7de9812fc49e5e24f794b255f8bcd2f1a Mon Sep 17 00:00:00 2001
From: Andrew Heather <>
Date: Tue, 25 Oct 2022 14:41:56 +0100
Subject: [PATCH] ENH: use local ref to map() to avoid excessive rebuilding
 during topo changes

---
 .../mappedPolyPatch/mappedPatchBaseTemplates.C   | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C
index 29894d48c55..5e5dd11d9ee 100644
--- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C
+++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseTemplates.C
@@ -70,14 +70,15 @@ void Foam::mappedPatchBase::distribute
         }
         default:
         {
+            const auto& map = this->map();
             mapDistributeBase::distribute
             (
                 Pstream::defaultCommsType,
-                map().schedule(),
-                map().constructSize(),
-                map().subMap(),
+                map.schedule(),
+                map.constructSize(),
+                map.subMap(),
                 false,
-                map().constructMap(),
+                map.constructMap(),
                 false,
                 lst,
                 Type(Zero),
@@ -139,14 +140,15 @@ void Foam::mappedPatchBase::reverseDistribute
         default:
         {
             label cSize = sampleSize();
+            const auto& map = this->map();
             mapDistributeBase::distribute
             (
                 Pstream::defaultCommsType,
-                map().schedule(),
+                map.schedule(),
                 cSize,
-                map().constructMap(),
+                map.constructMap(),
                 false,
-                map().subMap(),
+                map.subMap(),
                 false,
                 lst,
                 Type(Zero),
-- 
GitLab