driftFluxFoam: Updated in preparation for conversion into a solver module

This commit is contained in:
Henry Weller
2023-04-18 16:28:19 +01:00
parent 050c617d3b
commit 060690b6fa
12 changed files with 76 additions and 156 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,7 +37,7 @@ scalar meanCoNum = 0.0;
( (
fvc::surfaceSum fvc::surfaceSum
( (
mag(phi) + mag(fvc::flux(mixture.Udm())) mag(phi) + mag(fvc::flux(relativeVelocity->Udm()))
)().primitiveField() )().primitiveField()
); );

View File

@ -3,8 +3,8 @@
fvVectorMatrix UEqn fvVectorMatrix UEqn
( (
fvm::ddt(rho, U) + fvm::div(rhoPhi, U) fvm::ddt(rho, U) + fvm::div(rhoPhi, U)
+ mixture.MRF().DDt(rho, U) + MRF.DDt(rho, U)
+ mixture.divTauDm() + relativeVelocity->divDevTau()
+ turbulence->divDevTau(U) + turbulence->divDevTau(U)
== ==
fvModels.source(rho, U) fvModels.source(rho, U)

View File

@ -13,7 +13,7 @@
dimensionedScalar(phi.dimensions(), 0) dimensionedScalar(phi.dimensions(), 0)
); );
surfaceScalarField phir(fvc::flux(mixture.Udm())); surfaceScalarField phir(fvc::flux(relativeVelocity->Udm()));
if (nAlphaSubCycles > 1) if (nAlphaSubCycles > 1)
{ {

View File

@ -35,7 +35,7 @@ volVectorField U
Info<< "Reading incompressibleTwoPhaseInteractingMixture\n" << endl; Info<< "Reading incompressibleTwoPhaseInteractingMixture\n" << endl;
incompressibleTwoPhaseInteractingMixture mixture(U, phi, g); incompressibleTwoPhaseInteractingMixture mixture(U, phi);
volScalarField& alpha1(mixture.alpha1()); volScalarField& alpha1(mixture.alpha1());
const volScalarField& rho(mixture.rho()); const volScalarField& rho(mixture.rho());
@ -55,6 +55,13 @@ surfaceScalarField rhoPhi
); );
// Dispersed phase relative velocity model
autoPtr<relativeVelocityModel> relativeVelocity
(
relativeVelocityModel::New(mixture, mixture, g)
);
// Construct compressible turbulence model // Construct compressible turbulence model
autoPtr<compressible::momentumTransportModel> turbulence autoPtr<compressible::momentumTransportModel> turbulence
( (
@ -95,6 +102,7 @@ mesh.schemes().setFluxRequired(alpha1.name());
// MULES Correction // MULES Correction
tmp<surfaceScalarField> talphaPhiCorr0; tmp<surfaceScalarField> talphaPhiCorr0;
#include "createMRF.H"
#include "createFvModels.H" #include "createFvModels.H"
#include "createFvConstraints.H" #include "createFvConstraints.H"
@ -102,7 +110,7 @@ tmp<surfaceScalarField> talphaPhiCorr0;
// used for ddtCorr with MRF // used for ddtCorr with MRF
autoPtr<surfaceVectorField> Uf; autoPtr<surfaceVectorField> Uf;
if (mixture.MRF().size()) if (MRF.size())
{ {
Info<< "Constructing face momentum Uf" << endl; Info<< "Constructing face momentum Uf" << endl;

View File

@ -38,6 +38,7 @@ Description
#include "CMULES.H" #include "CMULES.H"
#include "subCycle.H" #include "subCycle.H"
#include "incompressibleTwoPhaseInteractingMixture.H" #include "incompressibleTwoPhaseInteractingMixture.H"
#include "relativeVelocityModel.H"
#include "momentumTransportModel.H" #include "momentumTransportModel.H"
#include "compressibleMomentumTransportModels.H" #include "compressibleMomentumTransportModels.H"
#include "pimpleControl.H" #include "pimpleControl.H"
@ -105,7 +106,7 @@ int main(int argc, char *argv[])
#include "alphaEqnSubCycle.H" #include "alphaEqnSubCycle.H"
mixture.correct(); relativeVelocity->correct();
if (pimple.predictTransport()) if (pimple.predictTransport())
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2014-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,8 +25,6 @@ License
#include "incompressibleTwoPhaseInteractingMixture.H" #include "incompressibleTwoPhaseInteractingMixture.H"
#include "mixtureViscosityModel.H" #include "mixtureViscosityModel.H"
#include "relativeVelocityModel.H"
#include "fvcDiv.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -43,25 +41,19 @@ Foam::incompressibleTwoPhaseInteractingMixture::
incompressibleTwoPhaseInteractingMixture incompressibleTwoPhaseInteractingMixture
( (
volVectorField& U, volVectorField& U,
const surfaceScalarField& phi, const surfaceScalarField& phi
const uniformDimensionedVectorField& g
) )
: :
twoPhaseMixture(U.mesh()), twoPhaseMixture(U.mesh()),
U_(U), U_(U),
muModel_(mixtureViscosityModel::New(*this)),
nucModel_(viscosityModel::New(U.mesh(), phase2Name())), nucModel_(viscosityModel::New(U.mesh(), phase2Name())),
muModel_(mixtureViscosityModel::New(*this)),
rhod_("rho", dimDensity, muModel_()),
rhoc_("rho", dimDensity, nucModel_()), rhoc_("rho", dimDensity, nucModel_()),
dd_ rhod_("rho", dimDensity, muModel_()),
(
"d",
dimLength,
muModel_->lookupOrDefault("d", 0.0)
),
alphaMax_(lookupOrDefault("alphaMax", 1.0)), alphaMax_(lookupOrDefault("alphaMax", 1.0)),
rho_ rho_
@ -78,22 +70,18 @@ incompressibleTwoPhaseInteractingMixture
dimensionedScalar("rho", dimDensity, 0) dimensionedScalar("rho", dimDensity, 0)
), ),
mu_ nu_
( (
IOobject IOobject
( (
"mu", "nu",
U_.time().name(), U_.time().name(),
U_.db() U_.db()
), ),
U_.mesh(), U_.mesh(),
dimensionedScalar(dimensionSet(1, -1, -1, 0, 0), 0), dimensionedScalar(dimViscosity, 0),
calculatedFvPatchScalarField::typeName calculatedFvPatchScalarField::typeName
), )
MRF_(U.mesh()),
UdmModel_(relativeVelocityModel::New(*this, *this, g))
{ {
correct(); correct();
} }
@ -108,13 +96,6 @@ Foam::incompressibleTwoPhaseInteractingMixture::
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::volScalarField&
Foam::incompressibleTwoPhaseInteractingMixture::alphad() const
{
return alpha1();
}
const Foam::volScalarField& const Foam::volScalarField&
Foam::incompressibleTwoPhaseInteractingMixture::alphac() const Foam::incompressibleTwoPhaseInteractingMixture::alphac() const
{ {
@ -122,24 +103,10 @@ Foam::incompressibleTwoPhaseInteractingMixture::alphac() const
} }
const Foam::mixtureViscosityModel& const Foam::volScalarField&
Foam::incompressibleTwoPhaseInteractingMixture::muModel() const Foam::incompressibleTwoPhaseInteractingMixture::alphad() const
{ {
return muModel_(); return alpha1();
}
const Foam::viscosityModel&
Foam::incompressibleTwoPhaseInteractingMixture::nucModel() const
{
return nucModel_();
}
const Foam::dimensionedScalar&
Foam::incompressibleTwoPhaseInteractingMixture::rhod() const
{
return rhod_;
} }
@ -151,9 +118,9 @@ Foam::incompressibleTwoPhaseInteractingMixture::rhoc() const
const Foam::dimensionedScalar& const Foam::dimensionedScalar&
Foam::incompressibleTwoPhaseInteractingMixture::dd() const Foam::incompressibleTwoPhaseInteractingMixture::rhod() const
{ {
return dd_; return rhod_;
} }
@ -177,60 +144,24 @@ Foam::incompressibleTwoPhaseInteractingMixture::rho() const
} }
Foam::tmp<Foam::volScalarField>
Foam::incompressibleTwoPhaseInteractingMixture::mu() const
{
return mu_;
}
Foam::tmp<Foam::scalarField>
Foam::incompressibleTwoPhaseInteractingMixture::mu(const label patchi) const
{
return mu_.boundaryField()[patchi];
}
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::incompressibleTwoPhaseInteractingMixture::nu() const Foam::incompressibleTwoPhaseInteractingMixture::nu() const
{ {
return mu_/rho_; return nu_;
} }
Foam::tmp<Foam::scalarField> Foam::tmp<Foam::scalarField>
Foam::incompressibleTwoPhaseInteractingMixture::nu(const label patchi) const Foam::incompressibleTwoPhaseInteractingMixture::nu(const label patchi) const
{ {
return mu_.boundaryField()[patchi]/rho_.boundaryField()[patchi]; return nu_.boundaryField()[patchi];
}
const Foam::IOMRFZoneList&
Foam::incompressibleTwoPhaseInteractingMixture::MRF() const
{
return MRF_;
}
const Foam::volVectorField&
Foam::incompressibleTwoPhaseInteractingMixture::Udm() const
{
return UdmModel_->Udm();
}
Foam::tmp<Foam::volVectorField>
Foam::incompressibleTwoPhaseInteractingMixture::divTauDm() const
{
return fvc::div(UdmModel_->tauDm());
} }
void Foam::incompressibleTwoPhaseInteractingMixture::correct() void Foam::incompressibleTwoPhaseInteractingMixture::correct()
{ {
rho_ = alpha1()*rhod_ + alpha2()*rhoc_; rho_ = alpha1()*rhod_ + alpha2()*rhoc_;
mu_ = muModel_->mu(rhoc_*nucModel_->nu(), U_); nu_ = muModel_->mu(rhoc_*nucModel_->nu(), U_)/rho_;
UdmModel_->correct();
} }
@ -240,17 +171,10 @@ bool Foam::incompressibleTwoPhaseInteractingMixture::read()
{ {
if (muModel_->read() || nucModel_->read()) if (muModel_->read() || nucModel_->read())
{ {
muModel_->lookup("rho") >> rhod_;
nucModel_->lookup("rho") >> rhoc_; nucModel_->lookup("rho") >> rhoc_;
muModel_->lookup("rho") >> rhod_;
dd_ = dimensionedScalar alphaMax_ = muModel_->lookupOrDefault("alphaMax", 1.0);
(
"d",
dimLength,
muModel_->lookupOrDefault("d", 0)
);
alphaMax_ = muModel_->lookupOrDefault( "alphaMax", 1.0);
return true; return true;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2014-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -39,8 +39,6 @@ SourceFiles
#include "twoPhaseMixture.H" #include "twoPhaseMixture.H"
#include "viscosityModel.H" #include "viscosityModel.H"
#include "uniformDimensionedFields.H"
#include "IOMRFZoneList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,7 +46,6 @@ namespace Foam
{ {
class mixtureViscosityModel; class mixtureViscosityModel;
class relativeVelocityModel;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class incompressibleTwoPhaseInteractingMixture Declaration Class incompressibleTwoPhaseInteractingMixture Declaration
@ -63,27 +60,26 @@ class incompressibleTwoPhaseInteractingMixture
volVectorField& U_; volVectorField& U_;
autoPtr<mixtureViscosityModel> muModel_; //- Continuous phase viscosity model
autoPtr<viscosityModel> nucModel_; autoPtr<viscosityModel> nucModel_;
dimensionedScalar rhod_; //- Mixture viscosity model
autoPtr<mixtureViscosityModel> muModel_;
//- Continuous phase density
dimensionedScalar rhoc_; dimensionedScalar rhoc_;
//- Optional diameter of the dispersed phase particles //- Dispersed phase density
dimensionedScalar dd_; dimensionedScalar rhod_;
//- Optional maximum dispersed phase-fraction (e.g. packing limit) //- Optional maximum dispersed phase-fraction (e.g. packing limit)
scalar alphaMax_; scalar alphaMax_;
//- Mixture density
volScalarField rho_; volScalarField rho_;
volScalarField mu_; //- Mixture kinematic viscosity
volScalarField nu_;
//- Optional MRF zones
IOMRFZoneList MRF_;
//- Dispersed phase relative velocity model
autoPtr<relativeVelocityModel> UdmModel_;
public: public:
@ -97,8 +93,7 @@ public:
incompressibleTwoPhaseInteractingMixture incompressibleTwoPhaseInteractingMixture
( (
volVectorField& U, volVectorField& U,
const surfaceScalarField& phi, const surfaceScalarField& phi
const uniformDimensionedVectorField& g
); );
@ -114,20 +109,11 @@ public:
//- Return const-access to the dispersed phase-fraction //- Return const-access to the dispersed phase-fraction
const volScalarField& alphad() const; const volScalarField& alphad() const;
//- Return const-access to the mixture viscosityModel
const mixtureViscosityModel& muModel() const;
//- Return const-access to the continuous-phase viscosityModel
const viscosityModel& nucModel() const;
//- Return const-access to the dispersed-phase density
const dimensionedScalar& rhod() const;
//- Return const-access to continuous-phase density //- Return const-access to continuous-phase density
const dimensionedScalar& rhoc() const; const dimensionedScalar& rhoc() const;
//- Return the diameter of the dispersed-phase particles //- Return const-access to the dispersed-phase density
const dimensionedScalar& dd() const; const dimensionedScalar& rhod() const;
//- Optional maximum phase-fraction (e.g. packing limit) //- Optional maximum phase-fraction (e.g. packing limit)
// Defaults to 1 // Defaults to 1
@ -139,27 +125,12 @@ public:
//- Return the mixture density //- Return the mixture density
virtual const volScalarField& rho() const; virtual const volScalarField& rho() const;
//- Return the dynamic mixture viscosity
tmp<volScalarField> mu() const;
//- Return the dynamic mixture viscosity for patch
virtual tmp<scalarField> mu(const label patchi) const;
//- Return the mixture viscosity //- Return the mixture viscosity
virtual tmp<volScalarField> nu() const; virtual tmp<volScalarField> nu() const;
//- Return the mixture viscosity for patch //- Return the mixture viscosity for patch
virtual tmp<scalarField> nu(const label patchi) const; virtual tmp<scalarField> nu(const label patchi) const;
//- Return MRF zones
const IOMRFZoneList& MRF() const;
//- Return the diffusion velocity of the dispersed phase
const volVectorField& Udm() const;
//- Return the div stress tensor due to the phase transport
tmp<volVectorField> divTauDm() const;
//- Correct the laminar viscosity //- Correct the laminar viscosity
virtual void correct(); virtual void correct();

View File

@ -8,7 +8,7 @@
fvc::flux(HbyA) fvc::flux(HbyA)
+ fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi, Uf) + fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, phi, Uf)
); );
mixture.MRF().makeRelative(phiHbyA); MRF.makeRelative(phiHbyA);
adjustPhi(phiHbyA, U, p_rgh); adjustPhi(phiHbyA, U, p_rgh);
surfaceScalarField phig surfaceScalarField phig
@ -21,7 +21,7 @@
phiHbyA += phig; phiHbyA += phig;
// Update the pressure BCs to ensure flux consistency // Update the pressure BCs to ensure flux consistency
constrainPressure(p_rgh, U, phiHbyA, rAUf, mixture.MRF()); constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF);
while (pimple.correctNonOrthogonal()) while (pimple.correctNonOrthogonal())
{ {
@ -67,5 +67,5 @@
} }
// Correct Uf for MRF // Correct Uf for MRF
fvc::correctUf(Uf, U, phi, mixture.MRF()); fvc::correctUf(Uf, U, phi, MRF);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2014-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -28,6 +28,7 @@ License
#include "slipFvPatchFields.H" #include "slipFvPatchFields.H"
#include "partialSlipFvPatchFields.H" #include "partialSlipFvPatchFields.H"
#include "fvcGrad.H" #include "fvcGrad.H"
#include "fvcDiv.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -177,4 +178,10 @@ Foam::tmp<Foam::volSymmTensorField> Foam::relativeVelocityModel::tauDm() const
} }
Foam::tmp<Foam::volVectorField> Foam::relativeVelocityModel::divDevTau() const
{
return fvc::div(tauDm());
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2014-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2014-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -137,6 +137,9 @@ public:
//- Return the stress tensor due to the phase transport //- Return the stress tensor due to the phase transport
tmp<volSymmTensorField> tauDm() const; tmp<volSymmTensorField> tauDm() const;
//- Return the div stress tensor due to the phase transport
tmp<volVectorField> divDevTau() const;
//- Update the diffusion velocity //- Update the diffusion velocity
virtual void correct() = 0; virtual void correct() = 0;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -361,8 +361,16 @@ void Foam::MULES::limiterCorr
} }
} }
if (extremaCoeff > 0)
{
psiMaxn = min(psiMaxn + extremaCoeff*(psiMax - psiMin), psiMax); psiMaxn = min(psiMaxn + extremaCoeff*(psiMax - psiMin), psiMax);
psiMinn = max(psiMinn - extremaCoeff*(psiMax - psiMin), psiMin); psiMinn = max(psiMinn - extremaCoeff*(psiMax - psiMin), psiMin);
}
else
{
psiMaxn = min(psiMaxn, psiMax);
psiMinn = max(psiMinn, psiMin);
}
if (smoothLimiter > small) if (smoothLimiter > small)
{ {

View File

@ -25,8 +25,6 @@ solvers
nLimiterIter 3; nLimiterIter 3;
alphaApplyPrevCorr yes; alphaApplyPrevCorr yes;
boundaryExtremaCoeff 1;
solver smoothSolver; solver smoothSolver;
smoother symGaussSeidel; smoother symGaussSeidel;
tolerance 1e-6; tolerance 1e-6;