ENH: kOmegaSST - code refactoring and clean-up

This commit is contained in:
Andrew Heather
2022-05-11 09:10:13 +01:00
parent b92fbd8f73
commit d2f2ab6d25
8 changed files with 89 additions and 134 deletions

View File

@ -132,6 +132,17 @@ void kOmegaSSTBase<BasicEddyViscosityModel>::correctNut()
}
template<class BasicEddyViscosityModel>
Foam::tmp<Foam::volScalarField> kOmegaSSTBase<BasicEddyViscosityModel>::S2
(
const volScalarField& F1,
const volTensorField& gradU
) const
{
return 2*magSqr(symm(gradU));
}
template<class BasicEddyViscosityModel>
tmp<volScalarField::Internal> kOmegaSSTBase<BasicEddyViscosityModel>::Pk
(
@ -143,11 +154,10 @@ tmp<volScalarField::Internal> kOmegaSSTBase<BasicEddyViscosityModel>::Pk
template<class BasicEddyViscosityModel>
tmp<volScalarField::Internal>
kOmegaSSTBase<BasicEddyViscosityModel>::epsilonByk
tmp<volScalarField::Internal> kOmegaSSTBase<BasicEddyViscosityModel>::epsilonByk
(
const volScalarField& F1,
const volTensorField& gradU
const volScalarField& /* F1 not used */,
const volTensorField& /* gradU not used */
) const
{
return betaStar_*omega_();
@ -165,8 +175,7 @@ tmp<volScalarField::Internal> kOmegaSSTBase<BasicEddyViscosityModel>::GbyNu
return min
(
GbyNu0,
(c1_/a1_)*betaStar_*omega_()
*max(a1_*omega_(), b1_*F2*sqrt(S2))
(c1_/a1_)*betaStar_*omega_()*max(a1_*omega_(), b1_*F2*sqrt(S2))
);
}
@ -174,13 +183,10 @@ tmp<volScalarField::Internal> kOmegaSSTBase<BasicEddyViscosityModel>::GbyNu
template<class BasicEddyViscosityModel>
tmp<fvScalarMatrix> kOmegaSSTBase<BasicEddyViscosityModel>::kSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime
)
k_,
dimVolume*this->rho_.dimensions()*k_.dimensions()/dimTime
);
}
@ -188,13 +194,10 @@ tmp<fvScalarMatrix> kOmegaSSTBase<BasicEddyViscosityModel>::kSource() const
template<class BasicEddyViscosityModel>
tmp<fvScalarMatrix> kOmegaSSTBase<BasicEddyViscosityModel>::omegaSource() const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
omega_,
dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime
)
omega_,
dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime
);
}
@ -207,13 +210,10 @@ tmp<fvScalarMatrix> kOmegaSSTBase<BasicEddyViscosityModel>::Qsas
const volScalarField::Internal& beta
) const
{
return tmp<fvScalarMatrix>
return tmp<fvScalarMatrix>::New
(
new fvScalarMatrix
(
omega_,
dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime
)
omega_,
dimVolume*this->rho_.dimensions()*omega_.dimensions()/dimTime
);
}
@ -500,18 +500,6 @@ void kOmegaSSTBase<BasicEddyViscosityModel>::correct()
volScalarField::Internal divU(fvc::div(fvc::absolute(this->phi(), U)));
tmp<volTensorField> tgradU = fvc::grad(U);
volScalarField S2(2*magSqr(symm(tgradU())));
volScalarField::Internal GbyNu0
(
this->type() + ":GbyNu",
(tgradU() && dev(twoSymm(tgradU())))
);
volScalarField::Internal G(this->GName(), nut*GbyNu0);
// Update omega and G at the wall
omega_.boundaryFieldRef().updateCoeffs();
volScalarField CDkOmega
(
(2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_
@ -520,6 +508,19 @@ void kOmegaSSTBase<BasicEddyViscosityModel>::correct()
volScalarField F1(this->F1(CDkOmega));
volScalarField F23(this->F23());
tmp<volTensorField> tgradU = fvc::grad(U);
volScalarField S2(this->S2(F1, tgradU()));
volScalarField::Internal GbyNu0
(
this->type() + ":GbyNu",
(tgradU() && dev(twoSymm(tgradU())))
);
volScalarField::Internal G(this->GName(), nut*GbyNu0);
tgradU.clear();
// Update omega and G at the wall
omega_.boundaryFieldRef().updateCoeffs();
{
volScalarField::Internal gamma(this->gamma(F1));
volScalarField::Internal beta(this->beta(F1));

View File

@ -253,6 +253,13 @@ protected:
virtual void correctNut();
//- Return square of strain rate
virtual tmp<volScalarField> S2
(
const volScalarField& F1,
const volTensorField& gradU
) const;
//- Return k production rate
virtual tmp<volScalarField::Internal> Pk
(
@ -321,22 +328,20 @@ public:
//- Return the effective diffusivity for k
tmp<volScalarField> DkEff(const volScalarField& F1) const
{
return tmp<volScalarField>
return tmp<volScalarField>::New
(
new volScalarField("DkEff", alphaK(F1)*this->nut_ + this->nu())
"DkEff",
alphaK(F1)*this->nut_ + this->nu()
);
}
//- Return the effective diffusivity for omega
tmp<volScalarField> DomegaEff(const volScalarField& F1) const
{
return tmp<volScalarField>
return tmp<volScalarField>::New
(
new volScalarField
(
"DomegaEff",
alphaOmega(F1)*this->nut_ + this->nu()
)
"DomegaEff",
alphaOmega(F1)*this->nut_ + this->nu()
);
}

View File

@ -37,41 +37,13 @@ namespace LESModels
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template<class BasicTurbulenceModel>
tmp<volScalarField> kOmegaSSTDDES<BasicTurbulenceModel>::rd
(
const volScalarField& magGradU
) const
{
tmp<volScalarField> tr
(
min
(
this->nuEff()
/(
max
(
magGradU,
dimensionedScalar("SMALL", magGradU.dimensions(), SMALL)
)
*sqr(this->kappa_*this->y_)
),
scalar(10)
)
);
tr.ref().boundaryFieldRef() == 0.0;
return tr;
}
template<class BasicTurbulenceModel>
tmp<volScalarField> kOmegaSSTDDES<BasicTurbulenceModel>::fd
(
const volScalarField& magGradU
) const
{
return 1 - tanh(pow(Cd1_*rd(magGradU), Cd2_));
return 1 - tanh(pow(Cd1_*this->r(this->nuEff(), magGradU), Cd2_));
}

View File

@ -71,8 +71,6 @@ class kOmegaSSTDDES
tmp<volScalarField> fd(const volScalarField& magGradU) const;
tmp<volScalarField> rd(const volScalarField& magGradU) const;
//- No copy construct
kOmegaSSTDDES(const kOmegaSSTDDES&) = delete;

View File

@ -55,6 +55,25 @@ void kOmegaSSTDES<BasicTurbulenceModel>::correctNut()
}
template<class BasicTurbulenceModel>
tmp<volScalarField> kOmegaSSTDES<BasicTurbulenceModel>::r
(
const volScalarField& nur,
const volScalarField& magGradU
) const
{
const dimensionedScalar eps("SMALL", magGradU.dimensions(), SMALL);
tmp<volScalarField> tr =
min(nur/(max(magGradU, eps)*sqr(this->kappa_*this->y_)), scalar(10));
tr.ref().boundaryFieldRef() == 0;
return tr;
}
template<class BasicTurbulenceModel>
tmp<volScalarField> kOmegaSSTDES<BasicTurbulenceModel>::dTilda
(
@ -187,31 +206,19 @@ tmp<volScalarField> kOmegaSSTDES<BasicTurbulenceModel>::LESRegion() const
const volScalarField F1(this->F1(CDkOmega));
tmp<volScalarField> tLESRegion
return tmp<volScalarField>::New
(
new volScalarField
IOobject::scopedName("DES", "LESRegion"),
neg
(
IOobject
dTilda
(
"DES::LESRegion",
this->mesh_.time().timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
neg
(
dTilda
(
mag(fvc::grad(U)),
F1*CDESkom_ + (1 - F1)*CDESkeps_
)
- sqrt(k)/(this->betaStar_*omega)
mag(fvc::grad(U)),
F1*CDESkom_ + (1 - F1)*CDESkeps_
)
- sqrt(k)/(this->betaStar_*omega)
)
);
return tLESRegion;
}

View File

@ -104,6 +104,12 @@ protected:
virtual void correctNut(const volScalarField& S2);
virtual void correctNut();
tmp<volScalarField> r
(
const volScalarField& nur,
const volScalarField& magGradU
) const;
//- Length scale
virtual tmp<volScalarField> dTilda
(

View File

@ -64,7 +64,7 @@ tmp<volScalarField> kOmegaSSTIDDES<BasicTurbulenceModel>::ft
const volScalarField& magGradU
) const
{
return tanh(pow3(sqr(Ct_)*rd(this->nut_, magGradU)));
return tanh(pow3(sqr(Ct_)*this->r(this->nut_, magGradU)));
}
@ -74,36 +74,7 @@ tmp<volScalarField> kOmegaSSTIDDES<BasicTurbulenceModel>::fl
const volScalarField& magGradU
) const
{
return tanh(pow(sqr(Cl_)*rd(this->nu(), magGradU), 10));
}
template<class BasicTurbulenceModel>
tmp<volScalarField> kOmegaSSTIDDES<BasicTurbulenceModel>::rd
(
const volScalarField& nur,
const volScalarField& magGradU
) const
{
tmp<volScalarField> tr
(
min
(
nur
/(
max
(
magGradU,
dimensionedScalar("SMALL", magGradU.dimensions(), SMALL)
)
*sqr(this->kappa_*this->y_)
),
scalar(10)
)
);
tr.ref().boundaryFieldRef() == 0.0;
return tr;
return tanh(pow(sqr(Cl_)*this->r(this->nu(), magGradU), 10));
}
@ -113,7 +84,7 @@ tmp<volScalarField> kOmegaSSTIDDES<BasicTurbulenceModel>::fdt
const volScalarField& magGradU
) const
{
return 1 - tanh(pow(Cdt1_*rd(this->nut_, magGradU), Cdt2_));
return 1 - tanh(pow(Cdt1_*this->r(this->nut_, magGradU), Cdt2_));
}

View File

@ -77,12 +77,6 @@ class kOmegaSSTIDDES
tmp<volScalarField> ft(const volScalarField& magGradU) const;
tmp<volScalarField> fl(const volScalarField& magGradU) const;
tmp<volScalarField> rd
(
const volScalarField& nur,
const volScalarField& magGradU
) const;
//- Delay function
tmp<volScalarField> fdt(const volScalarField& magGradU) const;
@ -104,9 +98,10 @@ protected:
dimensionedScalar Cl_;
dimensionedScalar Ct_;
// Fields
const IDDESDelta& IDDESDelta_;
//- IDDES delta
const IDDESDelta& IDDESDelta_;
// Protected Member Functions