From e50af751a460d8161dc34ccf89f3307d38a7261c Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Thu, 30 Nov 2017 13:07:42 +0000 Subject: [PATCH] ENH: pimpleFoam, rhoPimpleFoam, interDyMFoam: Rationalized mesh-motion support Added support for mesh-motion update within PIMPLE loop in pimpleFoam and rhoPimpleFoam. --- .../compressible/rhoPimpleFoam/pcEqn.H | 2 - .../compressible/rhoPimpleFoam/readControls.H | 10 -- .../rhoPimpleFoam/rhoPimpleFoam.C | 131 +++++++++--------- .../sonicFoam/sonicDyMFoam/sonicDyMFoam.C | 5 +- .../pimpleFoam/createControls.H | 12 -- .../incompressible/pimpleFoam/pimpleFoam.C | 56 ++++---- .../incompressible/pimpleFoam/readControls.H | 5 - .../DPMFoam/DPMDyMFoam/DPMDyMFoam.C | 4 +- .../DPMFoam/DPMDyMFoam/createControls.H | 12 -- .../DPMFoam/DPMDyMFoam/readControls.H | 5 - .../sprayFoam/sprayDyMFoam/sprayDyMFoam.C | 5 +- .../cavitatingDyMFoam/cavitatingDyMFoam.C | 3 +- .../cavitatingDyMFoam/createControls.H | 7 +- .../cavitatingDyMFoam/readControls.H | 2 +- .../compressibleInterDyMFoam.C | 5 +- .../compressibleInterDyMFoam/readControls.H | 9 -- .../interFoam/interDyMFoam/correctPhi.H | 2 +- .../interDyMFoam/createDyMControls.H | 14 -- .../interFoam/interDyMFoam/interDyMFoam.C | 35 +++-- .../multiphase/interFoam/interDyMFoam/pEqn.H | 20 +-- .../interFoam/interDyMFoam/readControls.H | 9 -- .../interPhaseChangeDyMFoam.C | 6 +- .../multiphaseInterDyMFoam.C | 32 +++-- .../potentialFreeSurfaceDyMFoam.C | 4 +- src/OpenFOAM/meshes/polyMesh/polyMesh.H | 6 + .../dynamicFvMesh/dynamicFvMesh.H | 10 +- .../dynamicFvMesh/dynamicFvMeshNew.C | 2 +- .../dynamicFvMesh/include/createDyMControls.H | 3 +- src/dynamicFvMesh/include/readDyMControls.H | 19 +++ src/dynamicFvMesh/staticFvMesh/staticFvMesh.H | 8 +- .../compressible/createRhoUfIfPresent.H | 32 +++-- .../cfdTools/compressible/updateRhoUf.H | 24 +--- .../incompressible/createUfIfPresent.H | 32 +++-- .../cfdTools/incompressible/updateUf.H | 24 +--- src/finiteVolume/finiteVolume/fvc/fvcDdt.C | 4 +- .../finiteVolume/fvc/fvcMeshPhi.C | 4 +- .../constant/dynamicMeshDict | 2 +- 37 files changed, 240 insertions(+), 325 deletions(-) delete mode 100644 applications/solvers/compressible/rhoPimpleFoam/readControls.H delete mode 100644 applications/solvers/incompressible/pimpleFoam/createControls.H delete mode 100644 applications/solvers/incompressible/pimpleFoam/readControls.H delete mode 100644 applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/createControls.H delete mode 100644 applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/readControls.H delete mode 100644 applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/readControls.H delete mode 100644 applications/solvers/multiphase/interFoam/interDyMFoam/createDyMControls.H delete mode 100644 applications/solvers/multiphase/interFoam/interDyMFoam/readControls.H rename applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/createControls.H => src/dynamicFvMesh/include/createDyMControls.H (73%) create mode 100644 src/dynamicFvMesh/include/readDyMControls.H diff --git a/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H b/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H index 605dccd03e..7ac95a9c5b 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H +++ b/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H @@ -1,5 +1,3 @@ -InfoInFunction << "consistent" << endl; - if (!pimple.SIMPLErho()) { rho = thermo.rho(); diff --git a/applications/solvers/compressible/rhoPimpleFoam/readControls.H b/applications/solvers/compressible/rhoPimpleFoam/readControls.H deleted file mode 100644 index 8a127d2bd2..0000000000 --- a/applications/solvers/compressible/rhoPimpleFoam/readControls.H +++ /dev/null @@ -1,10 +0,0 @@ -#include "readTimeControls.H" - -bool correctPhi = pimple.dict().lookupOrDefault -( - "correctPhi", - !isA(mesh) -); - -bool checkMeshCourantNo = - pimple.dict().lookupOrDefault("checkMeshCourantNo", false); diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C index 7a9782a372..9d580abe2e 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleFoam.C @@ -57,12 +57,11 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createDynamicFvMesh.H" - #include "createControl.H" + #include "createDyMControls.H" #include "initContinuityErrs.H" #include "createFields.H" #include "createFieldRefs.H" #include "createRhoUfIfPresent.H" - #include "createTimeControls.H" turbulence->validate(); @@ -78,81 +77,81 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.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 divrhoU; + if (correctPhi) { - // 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 divrhoU; - if (correctPhi) - { - divrhoU.reset + divrhoU.reset + ( + new volScalarField ( - new volScalarField - ( - "divrhoU", - fvc::div(fvc::absolute(phi, rho, U)) - ) - ); - } - - if (LTS) - { - #include "setRDeltaT.H" - } - else - { - #include "compressibleCourantNo.H" - #include "setDeltaT.H" - } - - runTime++; - - Info<< "Time = " << runTime.timeName() << nl << endl; - - // Store momentum to set rhoUf for introduced faces. - autoPtr rhoU; - if (rhoUf.valid()) - { - rhoU.reset(new volVectorField("rhoU", rho*U)); - } - - // Do any mesh changes - mesh.update(); - - #include "updateRhoUf.H" - - if (mesh.changing()) - { - MRF.update(); - - if (correctPhi) - { - // Calculate absolute flux from the mapped surface velocity - phi = mesh.Sf() & rhoUf(); - - #include "correctPhi.H" - - // Make the fluxes relative to the mesh-motion - fvc::makeRelative(phi, rho, U); - } - - if (checkMeshCourantNo) - { - #include "meshCourantNo.H" - } - } + "divrhoU", + fvc::div(fvc::absolute(phi, rho, U)) + ) + ); } - if (pimple.nCorrPIMPLE() <= 1) + if (LTS) { - #include "rhoEqn.H" + #include "setRDeltaT.H" } + else + { + #include "compressibleCourantNo.H" + #include "setDeltaT.H" + } + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { + if (pimple.firstIter() || moveMeshOuterCorrectors) + { + // Store momentum to set rhoUf for introduced faces. + autoPtr rhoU; + if (rhoUf.valid()) + { + rhoU.reset(new volVectorField("rhoU", rho*U)); + } + + // Do any mesh changes + mesh.update(); + + if (mesh.changing()) + { + MRF.update(); + + if (correctPhi) + { + // Calculate absolute flux + // from the mapped surface velocity + phi = mesh.Sf() & rhoUf(); + + #include "correctPhi.H" + + // Make the fluxes relative to the mesh-motion + fvc::makeRelative(phi, rho, U); + } + + if (checkMeshCourantNo) + { + #include "meshCourantNo.H" + } + } + } + + if (pimple.nCorrPIMPLE() <= 1) + { + #include "rhoEqn.H" + } + #include "UEqn.H" #include "EEqn.H" diff --git a/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C b/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C index 899c5889f6..013dd4c3bb 100644 --- a/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C +++ b/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C @@ -50,8 +50,7 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createDynamicFvMesh.H" - #include "createControl.H" - #include "createTimeControls.H" + #include "createDyMControls.H" #include "createFields.H" #include "createFieldRefs.H" #include "createRhoUf.H" @@ -67,7 +66,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" { // Store divrhoU from the previous mesh so that it can be mapped diff --git a/applications/solvers/incompressible/pimpleFoam/createControls.H b/applications/solvers/incompressible/pimpleFoam/createControls.H deleted file mode 100644 index bee8bd4f39..0000000000 --- a/applications/solvers/incompressible/pimpleFoam/createControls.H +++ /dev/null @@ -1,12 +0,0 @@ -#include "createControl.H" -#include "createTimeControls.H" - -bool correctPhi -( - pimple.dict().lookupOrDefault("correctPhi", false) -); - -bool checkMeshCourantNo -( - pimple.dict().lookupOrDefault("checkMeshCourantNo", false) -); diff --git a/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C index dc5da155fe..51949bb545 100644 --- a/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C +++ b/applications/solvers/incompressible/pimpleFoam/pimpleFoam.C @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createDynamicFvMesh.H" #include "initContinuityErrs.H" - #include "createControls.H" + #include "createDyMControls.H" #include "createFields.H" #include "createUfIfPresent.H" #include "CourantNo.H" @@ -99,7 +99,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" #include "CourantNo.H" #include "setDeltaT.H" @@ -107,34 +107,36 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - mesh.update(); - - #include "updateUf.H" - - if (mesh.changing()) - { - 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); - } - - if (checkMeshCourantNo) - { - #include "meshCourantNo.H" - } - } - // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { + if (pimple.firstIter() || moveMeshOuterCorrectors) + { + mesh.update(); + + if (mesh.changing()) + { + 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); + } + + if (checkMeshCourantNo) + { + #include "meshCourantNo.H" + } + } + } + #include "UEqn.H" // --- Pressure corrector loop diff --git a/applications/solvers/incompressible/pimpleFoam/readControls.H b/applications/solvers/incompressible/pimpleFoam/readControls.H deleted file mode 100644 index 9f982e260b..0000000000 --- a/applications/solvers/incompressible/pimpleFoam/readControls.H +++ /dev/null @@ -1,5 +0,0 @@ -#include "readTimeControls.H" - -correctPhi = pimple.dict().lookupOrDefault("correctPhi", false); - -checkMeshCourantNo = pimple.dict().lookupOrDefault("checkMeshCourantNo", false); diff --git a/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/DPMDyMFoam.C b/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/DPMDyMFoam.C index 6f90b9c119..93a9154464 100644 --- a/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/DPMDyMFoam.C +++ b/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/DPMDyMFoam.C @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createDynamicFvMesh.H" - #include "createControls.H" + #include "createDyMControls.H" #include "createFields.H" #include "createUcf.H" #include "initContinuityErrs.H" @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" #include "CourantNo.H" #include "setDeltaT.H" diff --git a/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/createControls.H b/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/createControls.H deleted file mode 100644 index bee8bd4f39..0000000000 --- a/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/createControls.H +++ /dev/null @@ -1,12 +0,0 @@ -#include "createControl.H" -#include "createTimeControls.H" - -bool correctPhi -( - pimple.dict().lookupOrDefault("correctPhi", false) -); - -bool checkMeshCourantNo -( - pimple.dict().lookupOrDefault("checkMeshCourantNo", false) -); diff --git a/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/readControls.H b/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/readControls.H deleted file mode 100644 index 9f982e260b..0000000000 --- a/applications/solvers/lagrangian/DPMFoam/DPMDyMFoam/readControls.H +++ /dev/null @@ -1,5 +0,0 @@ -#include "readTimeControls.H" - -correctPhi = pimple.dict().lookupOrDefault("correctPhi", false); - -checkMeshCourantNo = pimple.dict().lookupOrDefault("checkMeshCourantNo", false); diff --git a/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/sprayDyMFoam.C b/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/sprayDyMFoam.C index 272b431d54..d047aa704b 100644 --- a/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/sprayDyMFoam.C +++ b/applications/solvers/lagrangian/sprayFoam/sprayDyMFoam/sprayDyMFoam.C @@ -53,8 +53,7 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createDynamicFvMesh.H" - #include "createControl.H" - #include "createTimeControls.H" + #include "createDyMControls.H" #include "createFields.H" #include "createFieldRefs.H" #include "createRhoUf.H" @@ -70,7 +69,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" { // Store divrhoU from the previous time-step/mesh for the correctPhi diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/cavitatingDyMFoam.C b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/cavitatingDyMFoam.C index 4ff3adb3c0..68e106b9f4 100644 --- a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/cavitatingDyMFoam.C +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/cavitatingDyMFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -53,7 +53,6 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createDynamicFvMesh.H" - #include "createControl.H" #include "createControls.H" #include "createFields.H" #include "createUf.H" diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/createControls.H b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/createControls.H index 9f3fba812c..d47cf78b5a 100644 --- a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/createControls.H +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/createControls.H @@ -1,9 +1,4 @@ -#include "createTimeControls.H" - -bool correctPhi -( - pimple.dict().lookupOrDefault("correctPhi", true) -); +#include "createDyMControls.H" scalar maxAcousticCo ( diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/readControls.H b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/readControls.H index ad5e574527..3e8a87d1a9 100644 --- a/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/readControls.H +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingDyMFoam/readControls.H @@ -1,4 +1,4 @@ -#include "readTimeControls.H" +#include "readDyMControls.H" correctPhi = pimple.dict().lookupOrDefault("correctPhi", true); maxAcousticCo = readScalar(runTime.controlDict().lookup("maxAcousticCo")); diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C index e4e1a2e975..8d3d5a2702 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C @@ -60,10 +60,9 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createDynamicFvMesh.H" #include "initContinuityErrs.H" - #include "createControl.H" + #include "createDyMControls.H" #include "createFields.H" #include "createUf.H" - #include "createControls.H" #include "CourantNo.H" #include "setInitialDeltaT.H" @@ -77,7 +76,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" // Store divU from the previous mesh so that it can be mapped // and used in correctPhi to ensure the corrected phi has the diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/readControls.H b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/readControls.H deleted file mode 100644 index 75e6cf6909..0000000000 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/readControls.H +++ /dev/null @@ -1,9 +0,0 @@ -#include "readTimeControls.H" - -correctPhi = pimple.dict().lookupOrDefault("correctPhi", true); - -checkMeshCourantNo = - pimple.dict().lookupOrDefault("checkMeshCourantNo", false); - -moveMeshOuterCorrectors = - pimple.dict().lookupOrDefault("moveMeshOuterCorrectors", false); diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H b/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H index 0c5ea13bbc..fcb5020587 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H @@ -3,7 +3,7 @@ CorrectPhi U, phi, p_rgh, - surfaceScalarField("rAUf", fvc::interpolate(rAU)), + surfaceScalarField("rAUf", fvc::interpolate(rAU())), geometricZeroField(), pimple ); diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/createDyMControls.H b/applications/solvers/multiphase/interFoam/interDyMFoam/createDyMControls.H deleted file mode 100644 index f2322bb143..0000000000 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/createDyMControls.H +++ /dev/null @@ -1,14 +0,0 @@ -bool correctPhi -( - pimple.dict().lookupOrDefault("correctPhi", true) -); - -bool checkMeshCourantNo -( - pimple.dict().lookupOrDefault("checkMeshCourantNo", false) -); - -bool moveMeshOuterCorrectors -( - pimple.dict().lookupOrDefault("moveMeshOuterCorrectors", false) -); diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C index 3a4e0c579c..b4af251ef4 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C @@ -59,28 +59,31 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createDynamicFvMesh.H" #include "initContinuityErrs.H" - #include "createControl.H" - #include "createTimeControls.H" #include "createDyMControls.H" #include "createFields.H" #include "createAlphaFluxes.H" - volScalarField rAU + tmp rAU; + + if (correctPhi) ( - IOobject + rAU = new volScalarField ( - "rAU", - runTime.timeName(), + IOobject + ( + "rAU", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), mesh, - IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE - ), - mesh, - dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0) + dimensionedScalar("rAU", dimTime/dimDensity, 1) + ) ); #include "correctPhi.H" - #include "createUf.H" + #include "createUfIfPresent.H" turbulence->validate(); @@ -95,7 +98,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" if (LTS) { @@ -117,16 +120,10 @@ int main(int argc, char *argv[]) { if (pimple.firstIter() || moveMeshOuterCorrectors) { - scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); - mesh.update(); if (mesh.changing()) { - Info<< "Execution time for mesh.update() = " - << runTime.elapsedCpuTime() - timeBeforeMeshUpdate - << " s" << endl; - // Do not apply previous time-step mesh compression flux // if the mesh topology changed if (mesh.topoChanging()) diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H b/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H index aafc10bcc4..8e60ede0dd 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H @@ -1,12 +1,12 @@ { rAU = 1.0/UEqn.A(); - surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); - volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh)); + surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU())); + volVectorField HbyA(constrainHbyA(rAU()*UEqn.H(), U, p_rgh)); surfaceScalarField phiHbyA ( "phiHbyA", fvc::flux(HbyA) - + fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, Uf) + + fvc::interpolate(rho*rAU())*fvc::ddtCorr(U, phi, Uf) ); MRF.makeRelative(phiHbyA); @@ -47,7 +47,7 @@ p_rgh.relax(); - U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); + U = HbyA + rAU()*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); U.correctBoundaryConditions(); fvOptions.correct(U); } @@ -55,11 +55,8 @@ #include "continuityErrs.H" - { - Uf = fvc::interpolate(U); - surfaceVectorField n(mesh.Sf()/mesh.magSf()); - Uf += n*(phi/mesh.magSf() - (n & Uf)); - } + // Correct Uf if the mesh is moving + fvc::correctUf(Uf, U, phi); // Make the fluxes relative to the mesh motion fvc::makeRelative(phi, U); @@ -76,4 +73,9 @@ ); p_rgh = p - rho*gh; } + + if (!correctPhi) + { + rAU.clear(); + } } diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/readControls.H b/applications/solvers/multiphase/interFoam/interDyMFoam/readControls.H deleted file mode 100644 index 75e6cf6909..0000000000 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/readControls.H +++ /dev/null @@ -1,9 +0,0 @@ -#include "readTimeControls.H" - -correctPhi = pimple.dict().lookupOrDefault("correctPhi", true); - -checkMeshCourantNo = - pimple.dict().lookupOrDefault("checkMeshCourantNo", false); - -moveMeshOuterCorrectors = - pimple.dict().lookupOrDefault("moveMeshOuterCorrectors", false); diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/interPhaseChangeDyMFoam.C b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/interPhaseChangeDyMFoam.C index 6ce57a501d..ccd301faac 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/interPhaseChangeDyMFoam.C +++ b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/interPhaseChangeDyMFoam.C @@ -64,9 +64,7 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" #include "createDynamicFvMesh.H" - #include "createControl.H" - #include "createTimeControls.H" - #include "../interFoam/interDyMFoam/createDyMControls.H" + #include "createDyMControls.H" #include "initContinuityErrs.H" #include "createFields.H" @@ -96,7 +94,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "../interFoam/interDyMFoam/readControls.H" + #include "readDyMControls.H" // Store divU from the previous mesh so that it can be mapped // and used in correctPhi to ensure the corrected phi has the diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterDyMFoam/multiphaseInterDyMFoam.C b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterDyMFoam/multiphaseInterDyMFoam.C index efceb9b056..8ccd221759 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterDyMFoam/multiphaseInterDyMFoam.C +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterDyMFoam/multiphaseInterDyMFoam.C @@ -54,27 +54,31 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createDynamicFvMesh.H" #include "initContinuityErrs.H" - #include "createControl.H" - #include "createTimeControls.H" #include "createDyMControls.H" #include "createFields.H" - volScalarField rAU + tmp rAU; + + if (correctPhi) ( - IOobject + rAU = new volScalarField ( - "rAU", - runTime.timeName(), + IOobject + ( + "rAU", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), mesh, - IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE - ), - mesh, - dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0) + dimensionedScalar("rAU", dimTime/dimDensity, 1) + ) ); #include "correctPhi.H" - #include "createUf.H" + #include "createUfIfPresent.H" + #include "CourantNo.H" #include "setInitialDeltaT.H" @@ -88,7 +92,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" #include "CourantNo.H" #include "alphaCourantNo.H" @@ -120,7 +124,7 @@ int main(int argc, char *argv[]) if (mesh.changing() && correctPhi) { // Calculate absolute flux from the mapped surface velocity - phi = mesh.Sf() & Uf; + phi = mesh.Sf() & Uf(); #include "correctPhi.H" diff --git a/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceDyMFoam/potentialFreeSurfaceDyMFoam.C b/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceDyMFoam/potentialFreeSurfaceDyMFoam.C index 13d2ff6b03..b1a920fdae 100644 --- a/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceDyMFoam/potentialFreeSurfaceDyMFoam.C +++ b/applications/solvers/multiphase/potentialFreeSurfaceFoam/potentialFreeSurfaceDyMFoam/potentialFreeSurfaceDyMFoam.C @@ -59,8 +59,6 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createDynamicFvMesh.H" #include "initContinuityErrs.H" - #include "createControl.H" - #include "createTimeControls.H" #include "createDyMControls.H" #include "createFields.H" @@ -89,7 +87,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { - #include "readControls.H" + #include "readDyMControls.H" #include "CourantNo.H" #include "setDeltaT.H" diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index da538b05f1..e3da087565 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -497,6 +497,12 @@ public: // Mesh motion + //- Is mesh dynamic + virtual bool dynamic() const + { + return false; + } + //- Is mesh moving bool moving() const { diff --git a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H index 7de66a472a..977ea14ff5 100644 --- a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H +++ b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMesh.H @@ -125,6 +125,12 @@ public: // Member Functions + //- Is mesh dynamic + virtual bool dynamic() const + { + return true; + } + //- Update the mesh for both mesh motion and topology change virtual bool update() = 0; }; @@ -135,10 +141,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "staticFvMesh.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C index 7163860049..a5ea250e1f 100644 --- a/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C +++ b/src/dynamicFvMesh/dynamicFvMesh/dynamicFvMeshNew.C @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "dynamicFvMesh.H" +#include "staticFvMesh.H" // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/createControls.H b/src/dynamicFvMesh/include/createDyMControls.H similarity index 73% rename from applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/createControls.H rename to src/dynamicFvMesh/include/createDyMControls.H index 1c2daf3427..193604f192 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/createControls.H +++ b/src/dynamicFvMesh/include/createDyMControls.H @@ -1,8 +1,9 @@ +#include "createControl.H" #include "createTimeControls.H" bool correctPhi ( - pimple.dict().lookupOrDefault("correctPhi", true) + pimple.dict().lookupOrDefault("correctPhi", mesh.dynamic()) ); bool checkMeshCourantNo diff --git a/src/dynamicFvMesh/include/readDyMControls.H b/src/dynamicFvMesh/include/readDyMControls.H new file mode 100644 index 0000000000..1f96bedb3a --- /dev/null +++ b/src/dynamicFvMesh/include/readDyMControls.H @@ -0,0 +1,19 @@ +#include "readTimeControls.H" + +correctPhi = pimple.dict().lookupOrDefault +( + "correctPhi", + correctPhi +); + +checkMeshCourantNo = pimple.dict().lookupOrDefault +( + "checkMeshCourantNo", + checkMeshCourantNo +); + +moveMeshOuterCorrectors = pimple.dict().lookupOrDefault +( + "moveMeshOuterCorrectors", + moveMeshOuterCorrectors +); diff --git a/src/dynamicFvMesh/staticFvMesh/staticFvMesh.H b/src/dynamicFvMesh/staticFvMesh/staticFvMesh.H index 88120aef5c..1c81d23f48 100644 --- a/src/dynamicFvMesh/staticFvMesh/staticFvMesh.H +++ b/src/dynamicFvMesh/staticFvMesh/staticFvMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -77,6 +77,12 @@ public: // Member Functions + //- Is mesh dynamic + virtual bool dynamic() const + { + return false; + } + //- Dummy update function which does not change the mesh virtual bool update(); }; diff --git a/src/finiteVolume/cfdTools/compressible/createRhoUfIfPresent.H b/src/finiteVolume/cfdTools/compressible/createRhoUfIfPresent.H index 6f9b78205d..42716f490d 100644 --- a/src/finiteVolume/cfdTools/compressible/createRhoUfIfPresent.H +++ b/src/finiteVolume/cfdTools/compressible/createRhoUfIfPresent.H @@ -25,7 +25,7 @@ Global createRhoUf Description - Creates and initialises the velocity field rhoUf if present. + Creates and initialises the velocity field rhoUf if required. \*---------------------------------------------------------------------------*/ @@ -33,19 +33,25 @@ Description autoPtr rhoUf; -IOobject rhoUfHeader -( - "rhoUf", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE -); - -if (rhoUfHeader.typeHeaderOk(true)) +if (mesh.dynamic()) { - Info<< "Reading face momentum rhoUf\n" << endl; - rhoUf.reset(new surfaceVectorField(rhoUfHeader, mesh)); + Info<< "Constructing face momentum rhoUf" << endl; + + rhoUf.reset + ( + new surfaceVectorField + ( + IOobject + ( + "rhoUf", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + fvc::interpolate(rho*U) + ) + ); } // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/compressible/updateRhoUf.H b/src/finiteVolume/cfdTools/compressible/updateRhoUf.H index 2356481618..8a340b1a4b 100644 --- a/src/finiteVolume/cfdTools/compressible/updateRhoUf.H +++ b/src/finiteVolume/cfdTools/compressible/updateRhoUf.H @@ -31,28 +31,6 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -if (mesh.changing()) -{ - if (!rhoUf.valid()) - { - Info<< "Constructing face momentum rhoUf" << endl; - - rhoUf.reset - ( - new surfaceVectorField - ( - IOobject - ( - "rhoUf", - runTime.timeName(), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE - ), - fvc::interpolate(rho*U) - ) - ); - } -} +#error Remove rhoUpdateUf.H // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/incompressible/createUfIfPresent.H b/src/finiteVolume/cfdTools/incompressible/createUfIfPresent.H index fa21a48dd0..3385e42fec 100644 --- a/src/finiteVolume/cfdTools/incompressible/createUfIfPresent.H +++ b/src/finiteVolume/cfdTools/incompressible/createUfIfPresent.H @@ -25,7 +25,7 @@ Global createUf Description - Creates and initialises the velocity field Uf if present. + Creates and initialises the velocity field Uf if required. \*---------------------------------------------------------------------------*/ @@ -33,19 +33,25 @@ Description autoPtr Uf; -IOobject UfHeader -( - "Uf", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE -); - -if (UfHeader.typeHeaderOk(true)) +if (mesh.dynamic()) { - Info<< "Reading face velocity Uf\n" << endl; - Uf.reset(new surfaceVectorField(UfHeader, mesh)); + Info<< "Constructing face velocity Uf\n" << endl; + + Uf.reset + ( + new surfaceVectorField + ( + IOobject + ( + "Uf", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + fvc::interpolate(U) + ) + ); } // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/incompressible/updateUf.H b/src/finiteVolume/cfdTools/incompressible/updateUf.H index be5cc269f3..373d6cd823 100644 --- a/src/finiteVolume/cfdTools/incompressible/updateUf.H +++ b/src/finiteVolume/cfdTools/incompressible/updateUf.H @@ -31,28 +31,6 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -if (mesh.changing()) -{ - if (!Uf.valid()) - { - Info<< "Constructing face velocity Uf" << endl; - - Uf.reset - ( - new surfaceVectorField - ( - IOobject - ( - "Uf", - runTime.timeName(), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE - ), - fvc::interpolate(U) - ) - ); - } -} +#error Remove updateUf.H // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/fvc/fvcDdt.C b/src/finiteVolume/finiteVolume/fvc/fvcDdt.C index b83ffbfe59..b85c6b9a10 100644 --- a/src/finiteVolume/finiteVolume/fvc/fvcDdt.C +++ b/src/finiteVolume/finiteVolume/fvc/fvcDdt.C @@ -215,7 +215,7 @@ ddtCorr const autoPtr>& Uf ) { - if (U.mesh().changing()) + if (U.mesh().dynamic()) { return ddtCorr(U, Uf()); } @@ -280,7 +280,7 @@ ddtCorr const autoPtr>& Uf ) { - if (U.mesh().changing()) + if (U.mesh().dynamic()) { return ddtCorr(rho, U, Uf()); } diff --git a/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C b/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C index c082e54ecf..287bbcfdb7 100644 --- a/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C +++ b/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C @@ -228,7 +228,7 @@ void Foam::fvc::correctUf { const fvMesh& mesh = U.mesh(); - if (mesh.changing()) + if (mesh.dynamic()) { Uf() = fvc::interpolate(U); surfaceVectorField n(mesh.Sf()/mesh.magSf()); @@ -247,7 +247,7 @@ void Foam::fvc::correctRhoUf { const fvMesh& mesh = U.mesh(); - if (mesh.changing()) + if (mesh.dynamic()) { rhoUf() = fvc::interpolate(rho*U); surfaceVectorField n(mesh.Sf()/mesh.magSf()); diff --git a/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/constant/dynamicMeshDict b/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/constant/dynamicMeshDict index 58b40f465f..90e16687b4 100644 --- a/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/constant/dynamicMeshDict +++ b/tutorials/multiphase/interDyMFoam/laminar/damBreakWithObstacle/constant/dynamicMeshDict @@ -47,7 +47,7 @@ correctFluxes (phi none) (nHatf none) (rhoPhi none) - (alphaPhi none) + (alphaPhi0.water none) (ghf none) );