TurbulenceModels: Added validate function
Moved correctNut call from constructors to the new validate function to avoid problems with construction order and field availability for the calculation of nut. To ensure nut is physical and consistent with the turbulence fields the validate function should be called after the construction of the turbulence model, fvOptions and any other fields that the calculation of nut might depend on.
This commit is contained in:
@ -74,7 +74,6 @@ buoyantKEpsilon<BasicTurbulenceModel>::buoyantKEpsilon
|
||||
{
|
||||
if (type == typeName)
|
||||
{
|
||||
kEpsilon<BasicTurbulenceModel>::correctNut();
|
||||
this->printCoeffs(type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,14 +181,6 @@ LamBremhorstKE::LamBremhorstKE
|
||||
if (type == typeName)
|
||||
{
|
||||
printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -331,14 +331,6 @@ LienCubicKE::LienCubicKE
|
||||
if (type == typeName)
|
||||
{
|
||||
printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -225,14 +225,6 @@ LienLeschziner::LienLeschziner
|
||||
if (type == typeName)
|
||||
{
|
||||
printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -223,14 +223,6 @@ ShihQuadraticKE::ShihQuadraticKE
|
||||
if (type == typeName)
|
||||
{
|
||||
printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -593,6 +593,10 @@ bool kkLOmega::read()
|
||||
}
|
||||
|
||||
|
||||
void kkLOmega::validate()
|
||||
{}
|
||||
|
||||
|
||||
void kkLOmega::correct()
|
||||
{
|
||||
eddyViscosity<incompressible::RASModel>::correct();
|
||||
|
||||
@ -301,6 +301,10 @@ public:
|
||||
return epsilon_;
|
||||
}
|
||||
|
||||
//- Validate the turbulence fields after construction
|
||||
// Update turbulence viscosity and other derived fields as requires
|
||||
virtual void validate();
|
||||
|
||||
//- Solve the turbulence equations and correct the turbulence viscosity
|
||||
virtual void correct();
|
||||
};
|
||||
|
||||
@ -208,14 +208,6 @@ qZeta::qZeta
|
||||
if (type == typeName)
|
||||
{
|
||||
printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -96,9 +96,6 @@ NicenoKEqn<BasicTurbulenceModel>::NicenoKEqn
|
||||
{
|
||||
if (type == typeName)
|
||||
{
|
||||
// Cannot correct nut yet: construction of the phases is not complete
|
||||
// correctNut();
|
||||
|
||||
this->printCoeffs(type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,9 +73,6 @@ SmagorinskyZhang<BasicTurbulenceModel>::SmagorinskyZhang
|
||||
{
|
||||
if (type == typeName)
|
||||
{
|
||||
// Cannot correct nut yet: construction of the phases is not complete
|
||||
// correctNut();
|
||||
|
||||
this->printCoeffs(type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,6 @@ continuousGasKEqn<BasicTurbulenceModel>::continuousGasKEqn
|
||||
{
|
||||
if (type == typeName)
|
||||
{
|
||||
kEqn<BasicTurbulenceModel>::correctNut();
|
||||
this->printCoeffs(type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,9 +107,6 @@ LaheyKEpsilon<BasicTurbulenceModel>::LaheyKEpsilon
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Cannot correct nut yet: construction of the phases is not complete
|
||||
// correctNut();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -89,8 +89,6 @@ continuousGasKEpsilon<BasicTurbulenceModel>::continuousGasKEpsilon
|
||||
{
|
||||
if (type == typeName)
|
||||
{
|
||||
// Cannot correct nut yet: construction of the phases is not complete
|
||||
// kEpsilon<BasicTurbulenceModel>::correctNut();
|
||||
this->printCoeffs(type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,8 +76,6 @@ kOmegaSSTSato<BasicTurbulenceModel>::kOmegaSSTSato
|
||||
{
|
||||
if (type == typeName)
|
||||
{
|
||||
// Cannot correct nut yet: construction of the phases is not complete
|
||||
// correctNut();
|
||||
this->printCoeffs(type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,14 +112,6 @@ DeardorffDiffStress<BasicTurbulenceModel>::DeardorffDiffStress
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
this->boundNormalStress(this->R_);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -114,14 +114,6 @@ Smagorinsky<BasicTurbulenceModel>::Smagorinsky
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -319,14 +319,6 @@ SpalartAllmarasDES<BasicTurbulenceModel>::SpalartAllmarasDES
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -144,14 +144,6 @@ WALE<BasicTurbulenceModel>::WALE
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -186,14 +186,6 @@ dynamicKEqn<BasicTurbulenceModel>::dynamicKEqn
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -123,14 +123,6 @@ dynamicLagrangian<BasicTurbulenceModel>::dynamicLagrangian
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -114,14 +114,6 @@ kEqn<BasicTurbulenceModel>::kEqn
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -205,14 +205,6 @@ LRR<BasicTurbulenceModel>::LRR
|
||||
this->boundNormalStress(this->R_);
|
||||
bound(epsilon_, this->epsilonMin_);
|
||||
k_ = 0.5*tr(this->R_);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -205,14 +205,6 @@ LaunderSharmaKE<BasicTurbulenceModel>::LaunderSharmaKE
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -206,14 +206,6 @@ RNGkEpsilon<BasicTurbulenceModel>::RNGkEpsilon
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -214,14 +214,6 @@ SSG<BasicTurbulenceModel>::SSG
|
||||
this->boundNormalStress(this->R_);
|
||||
bound(epsilon_, this->epsilonMin_);
|
||||
k_ = 0.5*tr(this->R_);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -256,14 +256,6 @@ SpalartAllmaras<BasicTurbulenceModel>::SpalartAllmaras
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -42,6 +42,16 @@ void kEpsilon<BasicTurbulenceModel>::correctNut()
|
||||
this->nut_ = Cmu_*sqr(k_)/epsilon_;
|
||||
this->nut_.correctBoundaryConditions();
|
||||
|
||||
// const_cast needed because the operators and functions of fvOptions
|
||||
// are currently non-const.
|
||||
fv::optionList& fvOptions = const_cast<fv::optionList&>
|
||||
(
|
||||
this->mesh_.objectRegistry::template
|
||||
lookupObject<fv::optionList>("fvOptions")
|
||||
);
|
||||
|
||||
fvOptions.correct(this->nut_);
|
||||
|
||||
BasicTurbulenceModel::correctNut();
|
||||
}
|
||||
|
||||
@ -189,14 +199,6 @@ kEpsilon<BasicTurbulenceModel>::kEpsilon
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,7 +302,6 @@ void kEpsilon<BasicTurbulenceModel>::correct()
|
||||
bound(k_, this->kMin_);
|
||||
|
||||
correctNut();
|
||||
fvOptions.correct(nut);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -148,14 +148,6 @@ kOmega<BasicTurbulenceModel>::kOmega
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -351,14 +351,6 @@ kOmegaSST<BasicTurbulenceModel>::kOmegaSST
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -227,14 +227,6 @@ realizableKE<BasicTurbulenceModel>::realizableKE
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -239,14 +239,6 @@ v2f<BasicTurbulenceModel>::v2f
|
||||
if (type == typeName)
|
||||
{
|
||||
this->printCoeffs(type);
|
||||
|
||||
// Correct nut for single-phase solvers only.
|
||||
// For multiphase solvers the phase construction is not complete
|
||||
// at this point.
|
||||
if (isType<geometricOneField>(alpha))
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -295,6 +295,13 @@ Foam::ReynoldsStress<BasicTurbulenceModel>::divDevRhoReff
|
||||
}
|
||||
|
||||
|
||||
template<class BasicTurbulenceModel>
|
||||
void Foam::ReynoldsStress<BasicTurbulenceModel>::validate()
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
|
||||
|
||||
template<class BasicTurbulenceModel>
|
||||
void Foam::ReynoldsStress<BasicTurbulenceModel>::correct()
|
||||
{
|
||||
|
||||
@ -140,6 +140,10 @@ public:
|
||||
volVectorField& U
|
||||
) const;
|
||||
|
||||
//- Validate the turbulence fields after construction
|
||||
// Update turbulence viscosity and other derived fields as requires
|
||||
virtual void validate();
|
||||
|
||||
//- Solve the turbulence equations and correct the turbulence viscosity
|
||||
virtual void correct() = 0;
|
||||
};
|
||||
|
||||
@ -121,6 +121,13 @@ Foam::eddyViscosity<BasicTurbulenceModel>::R() const
|
||||
}
|
||||
|
||||
|
||||
template<class BasicTurbulenceModel>
|
||||
void Foam::eddyViscosity<BasicTurbulenceModel>::validate()
|
||||
{
|
||||
correctNut();
|
||||
}
|
||||
|
||||
|
||||
template<class BasicTurbulenceModel>
|
||||
void Foam::eddyViscosity<BasicTurbulenceModel>::correct()
|
||||
{
|
||||
|
||||
@ -127,6 +127,10 @@ public:
|
||||
//- Return the Reynolds stress tensor
|
||||
virtual tmp<volSymmTensorField> R() const;
|
||||
|
||||
//- Validate the turbulence fields after construction
|
||||
// Update turbulence viscosity and other derived fields as requires
|
||||
virtual void validate();
|
||||
|
||||
//- Solve the turbulence equations and correct the turbulence viscosity
|
||||
virtual void correct() = 0;
|
||||
};
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -84,6 +84,10 @@ bool Foam::turbulenceModel::read()
|
||||
}
|
||||
|
||||
|
||||
void Foam::turbulenceModel::validate()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::turbulenceModel::correct()
|
||||
{
|
||||
if (mesh_.changing())
|
||||
|
||||
@ -205,6 +205,10 @@ public:
|
||||
//- Return the Reynolds stress tensor
|
||||
virtual tmp<volSymmTensorField> R() const = 0;
|
||||
|
||||
//- Validate the turbulence fields after construction
|
||||
// Update derived fields as required
|
||||
virtual void validate();
|
||||
|
||||
//- Solve the turbulence equations and correct the turbulence viscosity
|
||||
virtual void correct() = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user