diff --git a/.gitignore b/.gitignore index a148a68efe..4d6083623e 100644 --- a/.gitignore +++ b/.gitignore @@ -82,5 +82,8 @@ doc/Doxygen/DTAGS /.dir-locals.el /.ycm* -# Ignore the test directory +# Ignore the tutorials/log file +/tutorials/log + +# Ignore the tutorialsTest directory /tutorialsTest diff --git a/applications/solvers/modules/Allwmake b/applications/solvers/modules/Allwmake index d8a9c60a06..640eaccf22 100755 --- a/applications/solvers/modules/Allwmake +++ b/applications/solvers/modules/Allwmake @@ -11,6 +11,7 @@ wmake $targetType fluid wmake $targetType multicomponentFluid wmake $targetType XiFluid wmake $targetType VoFSolver +wmake $targetType twoPhaseVoFSolver incompressibleVoF/Allwmake $targetType $* compressibleVoF/Allwmake $targetType $* multiphaseEuler/Allwmake $targetType $* diff --git a/applications/solvers/modules/VoFSolver/Make/files b/applications/solvers/modules/VoFSolver/Make/files index 3f151b257e..e76628212e 100644 --- a/applications/solvers/modules/VoFSolver/Make/files +++ b/applications/solvers/modules/VoFSolver/Make/files @@ -1,6 +1,6 @@ +VoFMixture/VoFMixture.C setRDeltaT.C moveMesh.C -alphaPredictor.C momentumPredictor.C VoFSolver.C diff --git a/applications/solvers/modules/VoFSolver/VoFMixture/VoFMixture.C b/applications/solvers/modules/VoFSolver/VoFMixture/VoFMixture.C new file mode 100644 index 0000000000..d9aa7ab860 --- /dev/null +++ b/applications/solvers/modules/VoFSolver/VoFMixture/VoFMixture.C @@ -0,0 +1,41 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "VoFMixture.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(VoFMixture, 0); +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::VoFMixture::VoFMixture(const fvMesh& mesh) +{} + + +// ************************************************************************* // diff --git a/applications/solvers/modules/VoFSolver/VoFMixture/VoFMixture.H b/applications/solvers/modules/VoFSolver/VoFMixture/VoFMixture.H new file mode 100644 index 0000000000..c00ec1e455 --- /dev/null +++ b/applications/solvers/modules/VoFSolver/VoFMixture/VoFMixture.H @@ -0,0 +1,92 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +Class + Foam::VoFMixture + +Description + Class to represent a VoF mixture + +SourceFiles + VoFMixture.C + +\*---------------------------------------------------------------------------*/ + +#ifndef VoFMixture_H +#define VoFMixture_H + +#include "volFieldsFwd.H" +#include "surfaceFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class fvMesh; + +/*---------------------------------------------------------------------------*\ + Class VoFMixture Declaration +\*---------------------------------------------------------------------------*/ + +class VoFMixture +{ + +public: + + TypeName("VoFMixture"); + + + // Constructors + + //- Construct from components + VoFMixture(const fvMesh& mesh); + + + //- Destructor + virtual ~VoFMixture() + {} + + + // Member Functions + + //- Return the mixture density + virtual const volScalarField& rho() const = 0; + + //- Correct the mixture properties + virtual void correct() = 0; + + //- Read base phaseProperties dictionary + virtual bool read() = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/modules/VoFSolver/VoFSolver.C b/applications/solvers/modules/VoFSolver/VoFSolver.C index 61f42bed6d..b5c07f13db 100644 --- a/applications/solvers/modules/VoFSolver/VoFSolver.C +++ b/applications/solvers/modules/VoFSolver/VoFSolver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,38 +41,26 @@ namespace solvers // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::solvers::VoFSolver::correctCoNum() -{ - fluidSolver::correctCoNum(phi); - - const scalarField sumPhi - ( - interface.nearInterface()().primitiveField() - *fvc::surfaceSum(mag(phi))().primitiveField() - ); - - alphaCoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue(); - - const scalar meanAlphaCoNum = - 0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue(); - - Info<< "Interface Courant Number mean: " << meanAlphaCoNum - << " max: " << alphaCoNum << endl; -} - - void Foam::solvers::VoFSolver::continuityErrors() { fluidSolver::continuityErrors(phi); } +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void Foam::solvers::VoFSolver::correctCoNum() +{ + fluidSolver::correctCoNum(phi); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::solvers::VoFSolver::VoFSolver ( fvMesh& mesh, - autoPtr mixturePtr + autoPtr mixturePtr ) : fluidSolver(mesh), @@ -80,21 +68,6 @@ Foam::solvers::VoFSolver::VoFSolver mixture_(mixturePtr), mixture(mixture_()), - alpha1(mixture.alpha1()), - alpha2(mixture.alpha2()), - - alphaRestart - ( - typeIOobject - ( - IOobject::groupName("alphaPhi", alpha1.group()), - runTime.name(), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE - ).headerOk() - ), - divAlphaName("div(phi,alpha)"), U @@ -123,8 +96,6 @@ Foam::solvers::VoFSolver::VoFSolver linearInterpolate(U) & mesh.Sf() ), - interface(mixture, alpha1, alpha2, U), - buoyancy(mesh), p_rgh(buoyancy.p_rgh), @@ -144,31 +115,9 @@ Foam::solvers::VoFSolver::VoFSolver fvc::interpolate(rho)*phi ), - alphaPhi1 - ( - IOobject - ( - IOobject::groupName("alphaPhi", alpha1.group()), - runTime.name(), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE - ), - phi*fvc::interpolate(alpha1) - ), - MRF(mesh) { - // Read the controls - read(); - mesh.schemes().setFluxRequired(p_rgh.name()); - mesh.schemes().setFluxRequired(alpha1.name()); - - if (alphaRestart) - { - Info << "Restarting alpha" << endl; - } if (mesh.dynamic()) { @@ -188,11 +137,7 @@ Foam::solvers::VoFSolver::VoFSolver ); } - if (transient()) - { - correctCoNum(); - } - else if (LTS) + if (LTS) { Info<< "Using LTS" << endl; @@ -268,11 +213,7 @@ void Foam::solvers::VoFSolver::preSolve() // Store divU from the previous mesh so that it can be mapped // and used in correctPhi to ensure the corrected phi has the // same divergence - if - ( - correctPhi - && divergent() - && mesh.topoChanged()) + if (correctPhi && divergent()) { // Construct and register divU for mapping divU = new volScalarField @@ -283,21 +224,13 @@ void Foam::solvers::VoFSolver::preSolve() } // Update the mesh for topology change, mesh to mesh mapping - const bool topoChanged = mesh.update(); - - // Do not apply previous time-step mesh compression flux - // if the mesh topology changed - if (topoChanged) - { - talphaPhi1Corr0.clear(); - } + mesh.update(); } void Foam::solvers::VoFSolver::prePredictor() { fvModels().correct(); - alphaPredictor(); } diff --git a/applications/solvers/modules/VoFSolver/VoFSolver.H b/applications/solvers/modules/VoFSolver/VoFSolver.H index 5aaeaebd07..20d0eac41f 100644 --- a/applications/solvers/modules/VoFSolver/VoFSolver.H +++ b/applications/solvers/modules/VoFSolver/VoFSolver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -56,7 +56,7 @@ See also #define VoFSolver_H #include "fluidSolver.H" -#include "twoPhaseMixture.H" +#include "VoFMixture.H" #include "interfaceProperties.H" #include "buoyancy.H" #include "pressureReference.H" @@ -83,18 +83,9 @@ protected: // Phase properties //- The compressible two-phase mixture - autoPtr mixture_; + autoPtr mixture_; - twoPhaseMixture& mixture; - - //- Reference to the phase1-fraction - volScalarField& alpha1; - - //- Reference to the phase2-fraction - volScalarField& alpha2; - - //- Switch indicating if this is a restart - bool alphaRestart; + VoFMixture& mixture; //- Name of the alpha convection scheme const word divAlphaName; @@ -112,11 +103,6 @@ protected: surfaceScalarField phi; - // Interface properties - - interfaceProperties interface; - - // Thermophysical properties //- Buoyancy force @@ -135,9 +121,6 @@ protected: //- Mass flux field surfaceScalarField rhoPhi; - // Phase-1 volumetric flux - surfaceScalarField alphaPhi1; - // Optional models @@ -149,9 +132,6 @@ protected: tmp rAU; - //- MULES Correction - tmp talphaPhi1Corr0; - //- Pointer to the surface momentum field // used to recreate the flux after mesh-change autoPtr Uf; @@ -175,22 +155,19 @@ private: // Private Member Functions //- Set rDeltaT for LTS - virtual void setRDeltaT(); - - //- Correct the cached Courant numbers - void correctCoNum(); - - //- Solve for the phase-fractions - void alphaSolve(const dictionary& alphaControls); - - //- Solve for the phase-fractions - void alphaPredictor(); + void setRDeltaT(); protected: // Protected Member Functions + //- Correct the cached Courant numbers + virtual void correctCoNum() = 0; + + //- Adjust the rDeltaT in the vicinity of the interface + virtual void setInterfaceRDeltaT(volScalarField& rDeltaT) = 0; + //- Calculate and print the continuity errors void continuityErrors(); @@ -201,16 +178,16 @@ protected: // i.e. compressible or include phase-fraction sources virtual bool divergent() = 0; - //- Calculate the alpha equation sources - virtual void alphaSuSp - ( - tmp& Su, - tmp& Sp - ) = 0; - //- Return the momentum equation stress term virtual tmp divDevTau(volVectorField& U) = 0; + //- Correct the interface properties following mesh-change + // and phase-fraction update + virtual void correctInterface() = 0; + + //- Return the interface surface tension force for the momentum equation + virtual tmp surfaceTensionForce() const = 0; + public: @@ -221,7 +198,7 @@ public: // Constructors //- Construct from region mesh - VoFSolver(fvMesh& mesh, autoPtr); + VoFSolver(fvMesh& mesh, autoPtr); //- Disallow default bitwise copy construction VoFSolver(const VoFSolver&) = delete; diff --git a/applications/solvers/modules/VoFSolver/alphaSuSp.H b/applications/solvers/modules/VoFSolver/alphaSuSp.H deleted file mode 100644 index 2cee24cfb2..0000000000 --- a/applications/solvers/modules/VoFSolver/alphaSuSp.H +++ /dev/null @@ -1,19 +0,0 @@ -tmp divU; -tmp Su; -tmp Sp; - -if (divergent()) -{ - // Phase change alpha1 source - const fvScalarMatrix alphaSup(fvModels().source(alpha1)); - - Su = alphaSup.Su(); - Sp = alphaSup.Sp(); - - divU = - ( - mesh.moving() - ? fvc::div(phiCN() + mesh.phi()) - : fvc::div(phiCN()) - ); -} diff --git a/applications/solvers/modules/VoFSolver/momentumPredictor.C b/applications/solvers/modules/VoFSolver/momentumPredictor.C index 093b774479..b869031d9a 100644 --- a/applications/solvers/modules/VoFSolver/momentumPredictor.C +++ b/applications/solvers/modules/VoFSolver/momentumPredictor.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,7 +55,7 @@ void Foam::solvers::VoFSolver::momentumPredictor() fvc::reconstruct ( ( - interface.surfaceTensionForce() + surfaceTensionForce() - buoyancy.ghf*fvc::snGrad(rho) - fvc::snGrad(p_rgh) ) * mesh.magSf() diff --git a/applications/solvers/modules/VoFSolver/moveMesh.C b/applications/solvers/modules/VoFSolver/moveMesh.C index 7be29fbab7..638308133e 100644 --- a/applications/solvers/modules/VoFSolver/moveMesh.C +++ b/applications/solvers/modules/VoFSolver/moveMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -101,7 +101,7 @@ bool Foam::solvers::VoFSolver::moveMesh() meshCourantNo(); - interface.correct(); + correctInterface(); divU.clear(); diff --git a/applications/solvers/modules/VoFSolver/setRDeltaT.C b/applications/solvers/modules/VoFSolver/setRDeltaT.C index b27ae2ca8c..fb87416236 100644 --- a/applications/solvers/modules/VoFSolver/setRDeltaT.C +++ b/applications/solvers/modules/VoFSolver/setRDeltaT.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,9 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "VoFSolver.H" -#include "fvcSmooth.H" #include "fvcSurfaceIntegrate.H" -#include "fvcAverage.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -41,41 +39,6 @@ void Foam::solvers::VoFSolver::setRDeltaT() pimpleDict.lookupOrDefault("maxCo", 0.9) ); - const scalar maxAlphaCo - ( - pimpleDict.lookupOrDefault("maxAlphaCo", 0.2) - ); - - const scalar rDeltaTSmoothingCoeff - ( - pimpleDict.lookupOrDefault("rDeltaTSmoothingCoeff", 0.1) - ); - - const label nAlphaSpreadIter - ( - pimpleDict.lookupOrDefault