From f87496b35dd722e3fa6694cccfb1fd69d8ee301f Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Tue, 30 Oct 2018 12:10:28 +0000
Subject: [PATCH] ENH: mappedPatchBase: short circuit when sampling own mesh.
 Fixed when doing #1046.

---
 .../mappedPatches/mappedPolyPatch/mappedPatchBase.C    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C
index 894a730f60f..405e1106066 100644
--- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C
+++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2018 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -1206,9 +1206,13 @@ void Foam::mappedPatchBase::clearOut()
 
 const Foam::polyMesh& Foam::mappedPatchBase::sampleMesh() const
 {
-    return patch_.boundaryMesh().mesh().time().lookupObject<polyMesh>
+    const polyMesh& thisMesh = patch_.boundaryMesh().mesh();
+
+    return
     (
-        sampleRegion()
+        sameRegion_
+      ? thisMesh
+      : thisMesh.time().lookupObject<polyMesh>(sampleRegion())
     );
 }
 
-- 
GitLab