diff --git a/applications/solvers/lagrangian/denseParticleFoam/correctPhic.H b/applications/solvers/lagrangian/denseParticleFoam/correctPhic.H index 43d24572dd..bdbed32ae8 100644 --- a/applications/solvers/lagrangian/denseParticleFoam/correctPhic.H +++ b/applications/solvers/lagrangian/denseParticleFoam/correctPhic.H @@ -3,12 +3,12 @@ phic = mesh.Sf() & Ucf(); correctUphiBCs(Uc, phic, true); -CorrectPhi +fv::correctPhi ( phic, Uc, p, - dimensionedScalar("rAUf", dimTime, 1), + autoPtr(), autoPtr(), pressureReference, pimple diff --git a/applications/solvers/lagrangian/denseParticleFoam/denseParticleFoam.C b/applications/solvers/lagrangian/denseParticleFoam/denseParticleFoam.C index 656660efd0..06af8ecac8 100644 --- a/applications/solvers/lagrangian/denseParticleFoam/denseParticleFoam.C +++ b/applications/solvers/lagrangian/denseParticleFoam/denseParticleFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,7 +80,7 @@ namespace Foam #include "phaseIncompressibleMomentumTransportModel.H" #include "pimpleControl.H" #include "pressureReference.H" -#include "CorrectPhi.H" +#include "fvCorrectPhi.H" #include "fvModels.H" #include "fvConstraints.H" #include "parcelClouds.H" diff --git a/applications/solvers/modules/VoFSolver/VoFSolver.C b/applications/solvers/modules/VoFSolver/VoFSolver.C index 9b2052928c..fcdf95f9f8 100644 --- a/applications/solvers/modules/VoFSolver/VoFSolver.C +++ b/applications/solvers/modules/VoFSolver/VoFSolver.C @@ -50,6 +50,28 @@ void Foam::solvers::VoFSolver::continuityErrors() // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // +void Foam::solvers::VoFSolver::setrAU(const fvVectorMatrix& UEqn) +{ + if (rAU.valid()) + { + rAU() = 1.0/UEqn.A(); + } + else + { + rAU = (1.0/UEqn.A()).ptr(); + } +} + + +void Foam::solvers::VoFSolver::clearrAU() +{ + if (!(correctPhi || mesh.topoChanging())) + { + rAU.clear(); + } +} + + void Foam::solvers::VoFSolver::correctCoNum() { fluidSolver::correctCoNum(phi); diff --git a/applications/solvers/modules/VoFSolver/VoFSolver.H b/applications/solvers/modules/VoFSolver/VoFSolver.H index 80b8317301..8bad78daf8 100644 --- a/applications/solvers/modules/VoFSolver/VoFSolver.H +++ b/applications/solvers/modules/VoFSolver/VoFSolver.H @@ -125,7 +125,9 @@ protected: // Cached temporary fields - tmp rAU; + //- Inverse momentum equation diagonal + // Used to correct phi following mesh changes + autoPtr rAU; //- Pointer to the surface momentum field // used to recreate the flux after mesh-change @@ -157,6 +159,12 @@ protected: // Protected Member Functions + //- Set or update the cached rAU + void setrAU(const fvVectorMatrix& UEqn); + + //- Clear the cached rAU is no longer needed + void clearrAU(); + //- Correct the cached Courant numbers virtual void correctCoNum() = 0; diff --git a/applications/solvers/modules/VoFSolver/moveMesh.C b/applications/solvers/modules/VoFSolver/moveMesh.C index 2076f55182..0d3e7beb8e 100644 --- a/applications/solvers/modules/VoFSolver/moveMesh.C +++ b/applications/solvers/modules/VoFSolver/moveMesh.C @@ -24,8 +24,9 @@ License \*---------------------------------------------------------------------------*/ #include "VoFSolver.H" -#include "CorrectPhi.H" -#include "geometricZeroField.H" +#include "fvCorrectPhi.H" +#include "fvcMeshPhi.H" +#include "fvcDiv.H" // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // @@ -67,12 +68,12 @@ void Foam::solvers::VoFSolver::moveMesh() if (incompressible()) { - CorrectPhi + fv::correctPhi ( phi, U, p_rgh, - surfaceScalarField("rAUf", fvc::interpolate(rAU())), + rAU, divU, pressureReference(), pimple @@ -80,12 +81,12 @@ void Foam::solvers::VoFSolver::moveMesh() } else { - CorrectPhi + fv::correctPhi ( phi, p_rgh, psiByRho(), - surfaceScalarField("rAUf", fvc::interpolate(rAU())), + rAU, divU(), pimple ); diff --git a/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C b/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C index cbc9005f2c..6c58ce6a00 100644 --- a/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C +++ b/applications/solvers/modules/compressibleMultiphaseVoF/pressureCorrector.C @@ -44,15 +44,7 @@ void Foam::solvers::compressibleMultiphaseVoF::pressureCorrector() volVectorField& U = U_; fvVectorMatrix& UEqn = tUEqn.ref(); - - if (rAU.valid()) - { - rAU.ref() = 1.0/UEqn.A(); - } - else - { - rAU = 1.0/UEqn.A(); - } + setrAU(UEqn); const surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU())); @@ -173,6 +165,7 @@ void Foam::solvers::compressibleMultiphaseVoF::pressureCorrector() K = 0.5*magSqr(U); + clearrAU(); tUEqn.clear(); } diff --git a/applications/solvers/modules/compressibleVoF/pressureCorrector.C b/applications/solvers/modules/compressibleVoF/pressureCorrector.C index ba7e95b407..476384d17c 100644 --- a/applications/solvers/modules/compressibleVoF/pressureCorrector.C +++ b/applications/solvers/modules/compressibleVoF/pressureCorrector.C @@ -49,15 +49,7 @@ void Foam::solvers::compressibleVoF::pressureCorrector() const volScalarField& psi2 = mixture.thermo2().psi(); fvVectorMatrix& UEqn = tUEqn.ref(); - - if (rAU.valid()) - { - rAU.ref() = 1.0/UEqn.A(); - } - else - { - rAU = 1.0/UEqn.A(); - } + setrAU(UEqn); const surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU())); @@ -233,6 +225,7 @@ void Foam::solvers::compressibleVoF::pressureCorrector() K = 0.5*magSqr(U); + clearrAU(); tUEqn.clear(); } diff --git a/applications/solvers/modules/incompressibleFluid/moveMesh.C b/applications/solvers/modules/incompressibleFluid/moveMesh.C index b80a9c2053..54232f5d5a 100644 --- a/applications/solvers/modules/incompressibleFluid/moveMesh.C +++ b/applications/solvers/modules/incompressibleFluid/moveMesh.C @@ -24,7 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "incompressibleFluid.H" -#include "CorrectPhi.H" +#include "fvCorrectPhi.H" +#include "fvcMeshPhi.H" #include "geometricZeroField.H" // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // @@ -48,12 +49,12 @@ void Foam::solvers::incompressibleFluid::moveMesh() correctUphiBCs(U, phi, true); - CorrectPhi + fv::correctPhi ( phi, U, p, - dimensionedScalar("rAUf", dimTime, 1), + autoPtr(), autoPtr(), pressureReference, pimple diff --git a/applications/solvers/modules/incompressibleMultiphaseVoF/incompressibleMultiphaseVoF.C b/applications/solvers/modules/incompressibleMultiphaseVoF/incompressibleMultiphaseVoF.C index 4abf5d8958..90de88f01e 100644 --- a/applications/solvers/modules/incompressibleMultiphaseVoF/incompressibleMultiphaseVoF.C +++ b/applications/solvers/modules/incompressibleMultiphaseVoF/incompressibleMultiphaseVoF.C @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "incompressibleMultiphaseVoF.H" -#include "CorrectPhi.H" +#include "fvCorrectPhi.H" #include "geometricZeroField.H" #include "addToRunTimeSelectionTable.H" @@ -123,32 +123,16 @@ Foam::solvers::incompressibleMultiphaseVoF::incompressibleMultiphaseVoF { correctUphiBCs(U_, phi, true); - if (correctPhi) - { - CorrectPhi - ( - phi, - U, - p_rgh, - surfaceScalarField("rAUf", fvc::interpolate(rAU())), - autoPtr(), - pressureReference(), - pimple - ); - } - else - { - CorrectPhi - ( - phi, - U, - p_rgh, - dimensionedScalar(dimTime/rho.dimensions(), 1), - autoPtr(), - pressureReference(), - pimple - ); - } + fv::correctPhi + ( + phi, + U, + p_rgh, + rAU, + autoPtr(), + pressureReference(), + pimple + ); } } diff --git a/applications/solvers/modules/incompressibleMultiphaseVoF/pressureCorrector.C b/applications/solvers/modules/incompressibleMultiphaseVoF/pressureCorrector.C index e2b9d4937d..d8bfc27227 100644 --- a/applications/solvers/modules/incompressibleMultiphaseVoF/pressureCorrector.C +++ b/applications/solvers/modules/incompressibleMultiphaseVoF/pressureCorrector.C @@ -43,17 +43,9 @@ void Foam::solvers::incompressibleMultiphaseVoF::pressureCorrector() volVectorField& U = U_; fvVectorMatrix& UEqn = tUEqn.ref(); + setrAU(UEqn); - if (rAU.valid()) - { - rAU.ref() = 1.0/UEqn.A(); - } - else - { - rAU = 1.0/UEqn.A(); - } - - surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU())); + const surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU())); while (pimple.correct()) { @@ -154,11 +146,7 @@ void Foam::solvers::incompressibleMultiphaseVoF::pressureCorrector() } } - if (!correctPhi) - { - rAU.clear(); - } - + clearrAU(); tUEqn.clear(); } diff --git a/applications/solvers/modules/incompressibleVoF/incompressibleVoF.C b/applications/solvers/modules/incompressibleVoF/incompressibleVoF.C index 5ce3910ca6..ee64ee2091 100644 --- a/applications/solvers/modules/incompressibleVoF/incompressibleVoF.C +++ b/applications/solvers/modules/incompressibleVoF/incompressibleVoF.C @@ -25,7 +25,7 @@ License #include "incompressibleVoF.H" #include "localEulerDdtScheme.H" -#include "CorrectPhi.H" +#include "fvCorrectPhi.H" #include "geometricZeroField.H" #include "addToRunTimeSelectionTable.H" @@ -108,32 +108,16 @@ Foam::solvers::incompressibleVoF::incompressibleVoF(fvMesh& mesh) { correctUphiBCs(U_, phi, true); - if (correctPhi) - { - CorrectPhi - ( - phi, - U, - p_rgh, - surfaceScalarField("rAUf", fvc::interpolate(rAU())), - autoPtr(), - pressureReference(), - pimple - ); - } - else - { - CorrectPhi - ( - phi, - U, - p_rgh, - dimensionedScalar(dimTime/rho.dimensions(), 1), - autoPtr(), - pressureReference(), - pimple - ); - } + fv::correctPhi + ( + phi, + U, + p_rgh, + rAU, + autoPtr(), + pressureReference(), + pimple + ); } } diff --git a/applications/solvers/modules/incompressibleVoF/pressureCorrector.C b/applications/solvers/modules/incompressibleVoF/pressureCorrector.C index 7058a13345..29f0c3bbe6 100644 --- a/applications/solvers/modules/incompressibleVoF/pressureCorrector.C +++ b/applications/solvers/modules/incompressibleVoF/pressureCorrector.C @@ -43,17 +43,9 @@ void Foam::solvers::incompressibleVoF::pressureCorrector() volVectorField& U = U_; fvVectorMatrix& UEqn = tUEqn.ref(); + setrAU(UEqn); - if (rAU.valid()) - { - rAU.ref() = 1.0/UEqn.A(); - } - else - { - rAU = 1.0/UEqn.A(); - } - - surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU())); + const surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU())); while (pimple.correct()) { @@ -154,11 +146,7 @@ void Foam::solvers::incompressibleVoF::pressureCorrector() } } - if (!correctPhi) - { - rAU.clear(); - } - + clearrAU(); tUEqn.clear(); } diff --git a/applications/solvers/modules/isothermalFluid/moveMesh.C b/applications/solvers/modules/isothermalFluid/moveMesh.C index 1907420a73..09af637daa 100644 --- a/applications/solvers/modules/isothermalFluid/moveMesh.C +++ b/applications/solvers/modules/isothermalFluid/moveMesh.C @@ -24,7 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "isothermalFluid.H" -#include "CorrectPhi.H" +#include "fvCorrectPhi.H" +#include "fvcMeshPhi.H" // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // @@ -57,12 +58,12 @@ void Foam::solvers::isothermalFluid::moveMesh() correctUphiBCs(rho, U, phi, true); - CorrectPhi + fv::correctPhi ( phi, buoyancy.valid() ? p_rgh : p, thermo.psi(), - dimensionedScalar("rAUf", dimTime, 1), + autoPtr(), divrhoU(), pimple ); diff --git a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.C b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.C index 591f09336a..80bafef5b2 100644 --- a/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.C +++ b/applications/solvers/modules/multiphaseEuler/phaseSystems/phaseSystem/phaseSystem.C @@ -31,7 +31,7 @@ License #include "fvcDiv.H" #include "fvcGrad.H" #include "fvcSnGrad.H" -#include "CorrectPhi.H" +#include "fvCorrectPhi.H" #include "fvcMeshPhi.H" #include "correctContactAngle.H" #include "dragModel.H" @@ -778,12 +778,12 @@ void Foam::phaseSystem::correctPhi if (incompressible()) { - CorrectPhi + fv::correctPhi ( phi_, movingPhases()[0].U(), p_rgh, - dimensionedScalar(dimTime/dimDensity, 1), + autoPtr(), divU, pressureReference, pimple @@ -809,12 +809,12 @@ void Foam::phaseSystem::correctPhi psi += alpha*phase.thermo().psi()/phase.thermo().rho(); } - CorrectPhi + fv::correctPhi ( phi_, p_rgh, psi, - dimensionedScalar(dimTime/dimDensity, 1), + autoPtr(), divU(), pimple ); diff --git a/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C b/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C index 1aca3a0f7a..64580b6cc6 100644 --- a/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C +++ b/applications/solvers/multiphase/cavitatingFoam/cavitatingFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,7 +36,7 @@ Description #include "fvCFD.H" #include "cavitatingTwoPhaseMixture.H" #include "incompressibleMomentumTransportModels.H" -#include "CorrectPhi.H" +#include "fvCorrectPhi.H" #include "pimpleControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 849f4d7170..a0c0c18460 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -452,7 +452,8 @@ $(general)/findRefCell/findRefCell.C $(general)/constrainHbyA/constrainHbyA.C $(general)/adjustPhi/adjustPhi.C $(general)/bound/bound.C -$(general)/CorrectPhi/correctUphiBCs.C +$(general)/correctPhi/fvCorrectPhi.C +$(general)/correctPhi/correctUphiBCs.C $(general)/pressureReference/pressureReference.C $(general)/levelSet/levelSet.C $(general)/surfaceToVolVelocity/surfaceToVolVelocity.C diff --git a/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.C b/src/finiteVolume/cfdTools/general/correctPhi/CorrectPhi.C similarity index 96% rename from src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.C rename to src/finiteVolume/cfdTools/general/correctPhi/CorrectPhi.C index 953c43f420..5eadfe35ff 100644 --- a/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.C +++ b/src/finiteVolume/cfdTools/general/correctPhi/CorrectPhi.C @@ -26,7 +26,6 @@ License #include "CorrectPhi.H" #include "volFields.H" #include "surfaceFields.H" -#include "fvScalarMatrix.H" #include "fvmDdt.H" #include "fvmLaplacian.H" #include "fvcDiv.H" @@ -40,12 +39,12 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -void Foam::CorrectPhi +void Foam::fv::CorrectPhi ( surfaceScalarField& phi, const volVectorField& U, const volScalarField& p, - const RAUfType& rAUf, + const RAUfType& rAU, const autoPtr& divU, const pressureReference& pressureReference, nonOrthogonalSolutionControl& pcorrControl @@ -98,7 +97,7 @@ void Foam::CorrectPhi // matches the divU provided (from previous iteration, time-step...) fvScalarMatrix pcorrEqn ( - fvm::laplacian(rAUf, pcorr) + fvm::laplacian(rAU, pcorr) == ( divU.valid() @@ -120,12 +119,12 @@ void Foam::CorrectPhi template -void Foam::CorrectPhi +void Foam::fv::CorrectPhi ( surfaceScalarField& phi, const volScalarField& p, const volScalarField& psi, - const RAUfType& rAUf, + const RAUfType& rAU, const volScalarField& divRhoU, nonOrthogonalSolutionControl& pcorrControl ) @@ -172,7 +171,7 @@ void Foam::CorrectPhi ( fvm::ddt(psi, pcorr) + fvc::div(phi) - - fvm::laplacian(rAUf, pcorr) + - fvm::laplacian(rAU, pcorr) == divRhoU ); diff --git a/src/finiteVolume/cfdTools/general/correctPhi/CorrectPhi.H b/src/finiteVolume/cfdTools/general/correctPhi/CorrectPhi.H new file mode 100644 index 0000000000..e3ba824eb6 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/correctPhi/CorrectPhi.H @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Function + Foam::fv::CorrectPhi + +Description + Flux correction functions to ensure continuity. + + Required during start-up, restart, mesh-motion etc. when non-conservative + fluxes may adversely affect the prediction-part of the solution algorithm + (the part before the first pressure solution which would ensure continuity). + This is particularly important for VoF and other multi-phase solver in + which non-conservative fluxes cause unboundedness of the phase-fraction. + +SourceFiles + CorrectPhi.C + +\*---------------------------------------------------------------------------*/ + +#ifndef CorrectPhi_H +#define CorrectPhi_H + +#include "volFieldsFwd.H" +#include "surfaceFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + class pressureReference; + class nonOrthogonalSolutionControl; + + namespace fv + { + template + void CorrectPhi + ( + surfaceScalarField& phi, + const volVectorField& U, + const volScalarField& p, + const RAUfType& rAU, + const autoPtr& divU, + const pressureReference& pressureReference, + nonOrthogonalSolutionControl& pcorrControl + ); + + template + void CorrectPhi + ( + surfaceScalarField& phi, + const volScalarField& p, + const volScalarField& psi, + const RAUfType& rAU, + const volScalarField& divRhoU, + nonOrthogonalSolutionControl& pcorrControl + ); + } +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "CorrectPhi.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/CorrectPhi/correctUphiBCs.C b/src/finiteVolume/cfdTools/general/correctPhi/correctUphiBCs.C similarity index 95% rename from src/finiteVolume/cfdTools/general/CorrectPhi/correctUphiBCs.C rename to src/finiteVolume/cfdTools/general/correctPhi/correctUphiBCs.C index 1b7dee43b6..e0791e8ca5 100644 --- a/src/finiteVolume/cfdTools/general/CorrectPhi/correctUphiBCs.C +++ b/src/finiteVolume/cfdTools/general/correctPhi/correctUphiBCs.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,7 +23,9 @@ License \*---------------------------------------------------------------------------*/ -#include "CorrectPhi.H" +#include "fvCorrectPhi.H" +#include "volFields.H" +#include "surfaceFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/cfdTools/general/correctPhi/fvCorrectPhi.C b/src/finiteVolume/cfdTools/general/correctPhi/fvCorrectPhi.C new file mode 100644 index 0000000000..147c76a422 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/correctPhi/fvCorrectPhi.C @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2023 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "fvCorrectPhi.H" +#include "CorrectPhi.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +void Foam::fv::correctPhi +( + surfaceScalarField& phi, + const volVectorField& U, + const volScalarField& p, + const autoPtr& rAU, + const autoPtr& divU, + const pressureReference& pressureReference, + nonOrthogonalSolutionControl& pcorrControl +) +{ + if (rAU.valid()) + { + CorrectPhi + ( + phi, + U, + p, + rAU(), + divU, + pressureReference, + pcorrControl + ); + } + else + { + CorrectPhi + ( + phi, + U, + p, + dimensionedScalar + ( + "rAU", + phi.dimensions()/p.dimensions()/dimLength, + 1 + ), + divU, + pressureReference, + pcorrControl + ); + } +} + + +void Foam::fv::correctPhi +( + surfaceScalarField& phi, + const volScalarField& p, + const volScalarField& psi, + const autoPtr& rAU, + const volScalarField& divRhoU, + nonOrthogonalSolutionControl& pcorrControl +) +{ + if (rAU.valid()) + { + CorrectPhi + ( + phi, + p, + psi, + rAU(), + divRhoU, + pcorrControl + ); + } + else + { + CorrectPhi + ( + phi, + p, + psi, + dimensionedScalar + ( + "rAU", + phi.dimensions()/p.dimensions()/dimLength, + 1 + ), + divRhoU, + pcorrControl + ); + } +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.H b/src/finiteVolume/cfdTools/general/correctPhi/fvCorrectPhi.H similarity index 75% rename from src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.H rename to src/finiteVolume/cfdTools/general/correctPhi/fvCorrectPhi.H index bd853766c4..dfcf880806 100644 --- a/src/finiteVolume/cfdTools/general/CorrectPhi/CorrectPhi.H +++ b/src/finiteVolume/cfdTools/general/correctPhi/fvCorrectPhi.H @@ -21,8 +21,8 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Class - Foam::CorrectPhi +Function + Foam::fv::correctPhi Description Flux correction functions to ensure continuity. @@ -34,12 +34,13 @@ Description which non-conservative fluxes cause unboundedness of the phase-fraction. SourceFiles - CorrectPhi.C + fvCorrectPhi.C + correctUphiBCs.C \*---------------------------------------------------------------------------*/ -#ifndef CorrectPhi_H -#define CorrectPhi_H +#ifndef fvCorrectPhi_H +#define fvCorrectPhi_H #include "volFieldsFwd.H" #include "surfaceFieldsFwd.H" @@ -70,35 +71,31 @@ namespace Foam const bool evaluateUBCs ); - template - void CorrectPhi - ( - surfaceScalarField& phi, - const volVectorField& U, - const volScalarField& p, - const RAUfType& rAUf, - const autoPtr& divU, - const pressureReference& pressureReference, - nonOrthogonalSolutionControl& pcorrControl - ); + namespace fv + { + void correctPhi + ( + surfaceScalarField& phi, + const volVectorField& U, + const volScalarField& p, + const autoPtr& rAU, + const autoPtr& divU, + const pressureReference& pressureReference, + nonOrthogonalSolutionControl& pcorrControl + ); - template - void CorrectPhi - ( - surfaceScalarField& phi, - const volScalarField& p, - const volScalarField& psi, - const RAUfType& rAUf, - const volScalarField& divRhoU, - nonOrthogonalSolutionControl& pcorrControl - ); + void correctPhi + ( + surfaceScalarField& phi, + const volScalarField& p, + const volScalarField& psi, + const autoPtr& rAU, + const volScalarField& divRhoU, + nonOrthogonalSolutionControl& pcorrControl + ); + } } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository - #include "CorrectPhi.C" -#endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/modules/isothermalFluid/potentialFreeSurfaceMovingOscillatingBox/system/controlDict b/tutorials/modules/isothermalFluid/potentialFreeSurfaceMovingOscillatingBox/system/controlDict index 69f91c987b..5c8210cc42 100644 --- a/tutorials/modules/isothermalFluid/potentialFreeSurfaceMovingOscillatingBox/system/controlDict +++ b/tutorials/modules/isothermalFluid/potentialFreeSurfaceMovingOscillatingBox/system/controlDict @@ -30,7 +30,7 @@ deltaT 0.001; writeControl adjustableRunTime; -writeInterval 0.02; +writeInterval 0.1; purgeWrite 0;