/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "CelikEtaIndex.H"
#include "resolutionIndexModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace resolutionIndexModels
{
defineTypeNameAndDebug(CelikEtaIndex, 0);
addToRunTimeSelectionTable(resolutionIndexModel, CelikEtaIndex, dictionary);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tmp
Foam::resolutionIndexModels::CelikEtaIndex::eta() const
{
const auto& nu = getOrReadField(nuName_);
tmp tepsilon = epsilon();
const dimensionedScalar epsilonMin(tepsilon.cref().dimensions(), SMALL);
// (CKJ:Eq. 23)
return pow025(pow3(nu)/max(epsilonMin, tepsilon));
}
Foam::tmp
Foam::resolutionIndexModels::CelikEtaIndex::epsilon() const
{
const auto& kSgs = getOrReadField(kName_);
const auto& Delta = getOrReadField(deltaName_);
tmp tnuEff = nuEff();
// (Derived based on CKJ:Eq. 25-26, p.031102-5)
return tnuEff*kSgs/(Ck_*sqr(Delta));
}
Foam::tmp
Foam::resolutionIndexModels::CelikEtaIndex::nuEff() const
{
const auto& nu = getOrReadField(nuName_);
const auto& nuSgs = getOrReadField(nutName_);
tmp tnuNum = nuNum();
// (CKJ:p. 031102-3)
return tnuNum + nuSgs + nu;
}
Foam::tmp
Foam::resolutionIndexModels::CelikEtaIndex::nuNum() const
{
const auto& Delta = getOrReadField(deltaName_);
tmp tkNum = kNum();
// (CKJ:Eq. 35)
return sign(tkNum.cref())*Cnu_*Delta*sqrt(mag(tkNum.cref()));
}
Foam::tmp
Foam::resolutionIndexModels::CelikEtaIndex::kNum() const
{
const auto& kSgs = getOrReadField(kName_);
const auto& Delta = getOrReadField(deltaName_);
tmp th = cbrt(V());
// (CKJ:Eq. 28)
return Cn_*sqr(th/Delta)*kSgs;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::resolutionIndexModels::CelikEtaIndex::CelikEtaIndex
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
)
:
resolutionIndexModel(name, mesh, dict),
alphaEta_(),
m_(),
Cnu_(),
Cn_(),
Ck_(),
kName_(),
deltaName_(),
nuName_(),
nutName_()
{
read(dict);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::resolutionIndexModels::CelikEtaIndex::read(const dictionary& dict)
{
if (!resolutionIndexModel::read(dict))
{
return false;
}
// (Default values from CKJ:p. 031102-3, 031102-5)
alphaEta_ = dict.getOrDefault("alphaEta", 0.05);
m_ = dict.getOrDefault("m", 0.5);
Cnu_ = dict.getOrDefault("Cnu", 0.1);
Cn_ = dict.getOrDefault("Cn", 1.0);
Ck_ = dict.getOrDefault("Ck", 0.0376);
kName_ = dict.getOrDefault("k", "k");
deltaName_ = dict.getOrDefault("delta", "delta");
nuName_ = dict.getOrDefault("nu", "nu");
nutName_ = dict.getOrDefault("nut", "nut");
return true;
}
bool Foam::resolutionIndexModels::CelikEtaIndex::execute()
{
// Calculate Kolmogorov and mesh length scales
tmp teta = eta();
tmp th = cbrt(V());
// Calculate index field
auto& index = getOrReadField(resultName());
// (CKJ:Eq. 9)
index = 1.0/(1.0 + alphaEta_*pow(th/teta, m_));
index.correctBoundaryConditions();
return true;
}
bool Foam::resolutionIndexModels::CelikEtaIndex::write()
{
const auto& index = getOrReadField(resultName());
Info<< tab << "writing field:" << index.name() << endl;
index.write();
return true;
}
// ************************************************************************* //