From 3666d90f31611dcf1e1078247d5689c61f07c20d Mon Sep 17 00:00:00 2001
From: Henry Weller <http://openfoam.org>
Date: Fri, 1 Dec 2017 14:19:54 +0000
Subject: [PATCH] ENH: interMixingFoam: Added support for mesh-motion and
 automatic refinement/unrefinement

---
 .../interFoam/interMixingFoam/Make/options    |  1 +
 .../interMixingFoam/interMixingFoam.C         | 42 +++++++++++++++++--
 2 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/applications/solvers/multiphase/interFoam/interMixingFoam/Make/options b/applications/solvers/multiphase/interFoam/interMixingFoam/Make/options
index 9fb8ee80bb8..f5dc7cc3280 100644
--- a/applications/solvers/multiphase/interFoam/interMixingFoam/Make/options
+++ b/applications/solvers/multiphase/interFoam/interMixingFoam/Make/options
@@ -23,6 +23,7 @@ EXE_LIBS = \
     -lturbulenceModels \
     -lincompressibleTurbulenceModels \
     -lfiniteVolume \
+    -ldynamicFvMesh \
     -lmeshTools \
     -lfvOptions \
     -lsampling \
diff --git a/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C b/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C
index b3924b1adb3..f6be50eb464 100644
--- a/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C
+++ b/applications/solvers/multiphase/interFoam/interMixingFoam/interMixingFoam.C
@@ -28,20 +28,22 @@ Group
     grpMultiphaseSolvers
 
 Description
-    Solver for 3 incompressible fluids, two of which are miscible,
-    using a VOF method to capture the interface.
+    Solver for 3 incompressible fluids, two of which are miscible, using a VOF
+    method to capture the interface, with optional mesh motion and mesh topology
+    changes including adaptive re-meshing.
 
 \*---------------------------------------------------------------------------*/
 
 #include "fvCFD.H"
+#include "dynamicFvMesh.H"
 #include "CMULES.H"
+#include "localEulerDdtScheme.H"
 #include "subCycle.H"
 #include "immiscibleIncompressibleThreePhaseMixture.H"
 #include "turbulentTransportModel.H"
 #include "pimpleControl.H"
 #include "fvOptions.H"
 #include "CorrectPhi.H"
-#include "localEulerDdtScheme.H"
 #include "fvcSmooth.H"
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -52,7 +54,7 @@ int main(int argc, char *argv[])
 
     #include "setRootCase.H"
     #include "createTime.H"
-    #include "createMesh.H"
+    #include "createDynamicFvMesh.H"
     #include "initContinuityErrs.H"
     #include "createDyMControls.H"
     #include "createFields.H"
@@ -94,6 +96,38 @@ int main(int argc, char *argv[])
         // --- Pressure-velocity PIMPLE corrector loop
         while (pimple.loop())
         {
+            if (pimple.firstIter() || moveMeshOuterCorrectors)
+            {
+                mesh.update();
+
+                if (mesh.changing())
+                {
+                    gh = (g & mesh.C()) - ghRef;
+                    ghf = (g & mesh.Cf()) - ghRef;
+
+                    MRF.update();
+
+                    if (correctPhi)
+                    {
+                        // Calculate absolute flux
+                        // from the mapped surface velocity
+                        phi = mesh.Sf() & Uf();
+
+                        #include "correctPhi.H"
+
+                        // Make the flux relative to the mesh motion
+                        fvc::makeRelative(phi, U);
+
+                        mixture.correct();
+                    }
+
+                    if (checkMeshCourantNo)
+                    {
+                        #include "meshCourantNo.H"
+                    }
+                }
+            }
+
             #include "alphaControls.H"
             #include "alphaEqnSubCycle.H"
 
-- 
GitLab