From 1829f7db6e196158b3358ee0a0b23564a3314243 Mon Sep 17 00:00:00 2001
From: mattijs <mattijs>
Date: Wed, 24 Mar 2021 11:19:50 +0000
Subject: [PATCH] BUG: fvMesh: handle cyclicACMI inside e.g. checkMesh

fvMesh::readUpdate calls polyMesh::readUpdate which updates
the ACMI (including mesh areas etc). So we should not call
polyMesh::clearOut again inside fvMesh::readUpdate to avoid
having to re-do all the ACMI.
---
 src/finiteVolume/fvMesh/fvMesh.C | 12 +++++++++---
 src/finiteVolume/fvMesh/fvMesh.H |  9 ++++++---
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C
index 7a8de07dd3f..8d4bee062ea 100644
--- a/src/finiteVolume/fvMesh/fvMesh.C
+++ b/src/finiteVolume/fvMesh/fvMesh.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2017 OpenFOAM Foundation
-    Copyright (C) 2016-2020 OpenCFD Ltd.
+    Copyright (C) 2016-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -224,7 +224,7 @@ void Foam::fvMesh::storeOldVol(const scalarField& V)
 }
 
 
-void Foam::fvMesh::clearOut()
+void Foam::fvMesh::clearOutLocal()
 {
     clearGeom();
     surfaceInterpolation::clearOut();
@@ -233,7 +233,12 @@ void Foam::fvMesh::clearOut()
 
     // Clear mesh motion flux
     deleteDemandDrivenData(phiPtr_);
+}
+
 
+void Foam::fvMesh::clearOut()
+{
+    clearOutLocal();
     polyMesh::clearOut();
 }
 
@@ -659,7 +664,8 @@ Foam::polyMesh::readUpdateState Foam::fvMesh::readUpdate()
     {
         DebugInfo << "Topological update" << endl;
 
-        clearOut();
+        // fvMesh::clearOut() but without the polyMesh::clearOut
+        clearOutLocal();
     }
     else if (state == polyMesh::POINTS_MOVED)
     {
diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H
index b5b1abf3481..da3748cfe2a 100644
--- a/src/finiteVolume/fvMesh/fvMesh.H
+++ b/src/finiteVolume/fvMesh/fvMesh.H
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2017 OpenFOAM Foundation
-    Copyright (C) 2016-2020 OpenCFD Ltd.
+    Copyright (C) 2016-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -143,12 +143,15 @@ protected:
             //  geometric demand-driven data that was set
             void updateGeomNotOldVol();
 
-            //- Clear geometry
+            //- Clear local geometry
             void clearGeom();
 
-            //- Clear addressing
+            //- Clear local addressing
             void clearAddressing(const bool isMeshUpdate = false);
 
+            //- Clear local-only storage (geometry, addressing etc)
+            void clearOutLocal();
+
             //- Preserve old volume(s)
             void storeOldVol(const scalarField&);
 
-- 
GitLab