From 5e539b30a9c0c3e358aaf4df3f88fd4a865e3c83 Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin <kutalmis.bercin@esi-group.com> Date: Thu, 29 Oct 2020 14:13:03 +0000 Subject: [PATCH] INT: reactingParcelFoam: add dynamicMeshMotion capabilities --- .../reactingParcelFoam/Make/options | 4 ++ .../lagrangian/reactingParcelFoam/pEqn.H | 8 +++ .../Make/options | 4 ++ .../reactingParcelFoam/reactingParcelFoam.C | 69 +++++++++++++++++-- .../reactingParcelFoam/setRDeltaT.H | 2 +- 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/applications/solvers/lagrangian/reactingParcelFoam/Make/options b/applications/solvers/lagrangian/reactingParcelFoam/Make/options index 5a6dbd5a1df..d836d1aae02 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/Make/options +++ b/applications/solvers/lagrangian/reactingParcelFoam/Make/options @@ -2,6 +2,8 @@ EXE_INC = \ -I../reactingParcelFoam \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I${LIB_SRC}/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I${LIB_SRC}/sampling/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ @@ -27,6 +29,8 @@ EXE_LIBS = \ -lfiniteVolume \ -lfvOptions \ -lmeshTools \ + -ldynamicMesh \ + -ldynamicFvMesh \ -lsampling \ -lturbulenceModels \ -lcompressibleTurbulenceModels \ diff --git a/applications/solvers/lagrangian/reactingParcelFoam/pEqn.H b/applications/solvers/lagrangian/reactingParcelFoam/pEqn.H index b6854000777..0344f9b1a41 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/pEqn.H +++ b/applications/solvers/lagrangian/reactingParcelFoam/pEqn.H @@ -81,7 +81,15 @@ else if (pimple.SIMPLErho()) rho = thermo.rho(); } +// Correct rhoUf if the mesh is moving +fvc::correctRhoUf(rhoUf, rho, U, phi); + if (thermo.dpdt()) { dpdt = fvc::ddt(p); + + if (mesh.moving()) + { + dpdt -= fvc::div(fvc::meshPhi(rho, U), p); + } } diff --git a/applications/solvers/lagrangian/reactingParcelFoam/reactingHeterogenousParcelFoam/Make/options b/applications/solvers/lagrangian/reactingParcelFoam/reactingHeterogenousParcelFoam/Make/options index 1bbc23c2279..de0941c2da3 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/reactingHeterogenousParcelFoam/Make/options +++ b/applications/solvers/lagrangian/reactingParcelFoam/reactingHeterogenousParcelFoam/Make/options @@ -3,6 +3,8 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I${LIB_SRC}/sampling/lnInclude \ -I${LIB_SRC}/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ -I$(LIB_SRC)/lagrangian/distributionModels/lnInclude \ @@ -28,6 +30,8 @@ EXE_LIBS = \ -lfvOptions \ -lsampling \ -lmeshTools \ + -ldynamicMesh \ + -ldynamicFvMesh \ -lturbulenceModels \ -lcompressibleTurbulenceModels \ -lspecie \ diff --git a/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C index cdb809ae666..5f9e6899af0 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C +++ b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C @@ -5,8 +5,8 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2011-2020 OpenFOAM Foundation + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,8 +37,8 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" +#include "dynamicFvMesh.H" #include "turbulentFluidThermoModel.H" - #include "surfaceFilmModel.H" #include "rhoReactionThermo.H" #include "CombustionModel.H" @@ -47,6 +47,7 @@ Description #include "fvOptions.H" #include "pimpleControl.H" #include "pressureControl.H" +#include "CorrectPhi.H" #include "localEulerDdtScheme.H" #include "fvcSmooth.H" #include "cloudMacros.H" @@ -76,13 +77,13 @@ int main(int argc, char *argv[]) #include "addCheckCaseOptions.H" #include "setRootCaseLists.H" #include "createTime.H" - #include "createMesh.H" - #include "createControl.H" - #include "createTimeControls.H" + #include "createDynamicFvMesh.H" + #include "createDyMControls.H" #include "createFields.H" #include "createFieldRefs.H" #include "createRegionControls.H" #include "initContinuityErrs.H" + #include "createRhoUfIfPresent.H" turbulence->validate(); @@ -98,7 +99,23 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readTimeControls.H" + #include "readDyMControls.H" + + // Store divrhoU from the previous mesh + // so that it can be mapped and used in correctPhi + // to ensure the corrected phi has the same divergence + autoPtr<volScalarField> divrhoU; + if (solvePrimaryRegion && correctPhi) + { + divrhoU.reset + ( + new volScalarField + ( + "divrhoU", + fvc::div(fvc::absolute(phi, rho, U)) + ) + ); + } if (LTS) { @@ -114,6 +131,44 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; + // Store momentum to set rhoUf for introduced faces. + autoPtr<volVectorField> rhoU; + if (solvePrimaryRegion && rhoUf.valid()) + { + rhoU.reset(new volVectorField("rhoU", rho*U)); + } + + // Store the particle positions + parcels.storeGlobalPositions(); + + // Do any mesh changes + mesh.update(); + + if (solvePrimaryRegion && 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() & rhoUf(); + + #include "../../compressible/rhoPimpleFoam/correctPhi.H" + + // Make the fluxes relative to the mesh-motion + fvc::makeRelative(phi, rho, U); + } + + if (checkMeshCourantNo) + { + #include "meshCourantNo.H" + } + } + parcels.evolve(); surfaceFilm.evolve(); diff --git a/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H b/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H index fbb69464c2d..5977b18fe67 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H +++ b/applications/solvers/lagrangian/reactingParcelFoam/setRDeltaT.H @@ -103,7 +103,7 @@ License ); } - // Update tho boundary values of the reciprocal time-step + // Update the boundary values of the reciprocal time-step rDeltaT.correctBoundaryConditions(); // Spatially smooth the time scale field -- GitLab