谢谢李老师,我参考您链接里的方法改了WALE.C和.H文件,编译过程都很顺利,但是还是没有输出的Ksgs。想请您帮我看一下,我改动的在图片中,也附上了全部的WALE.C和.H文件。fb6aa985-d914-4113-a866-b6466dea71ce-图片.png 0a7c6741-e37a-475f-99f8-4bef8b726e18-图片.png 4112bd23-202d-439a-8cc4-daf15f9d19af-图片.png ```
WALE.C
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2018 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "WALE.H"
#include "fvOptions.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace LESModels
{
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class BasicTurbulenceModel>
tmp<volSymmTensorField> WALE<BasicTurbulenceModel>::Sd
(
const volTensorField& gradU
) const
{
return dev(symm(gradU & gradU));
}
template<class BasicTurbulenceModel>
tmp<volScalarField> WALE<BasicTurbulenceModel>::k
(
const volTensorField& gradU
) const
{
volScalarField magSqrSd(magSqr(Sd(gradU)));
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
IOobject::groupName("k", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_
),
sqr(sqr(Cw_)*this->delta()/Ck_)*
(
pow3(magSqrSd)
/(
sqr
(
pow(magSqr(symm(gradU)), 5.0/2.0)
+ pow(magSqrSd, 5.0/4.0)
)
+ dimensionedScalar
(
"small",
dimensionSet(0, 0, -10, 0, 0),
small
)
)
)
)
);
}
template<class BasicTurbulenceModel>
void WALE<BasicTurbulenceModel>::correctNut()
{
k_ = (this->k(fvc::grad(this->U_)));
this->nut_ = Ck_*this->delta()*sqrt(k_);
this->nut_.correctBoundaryConditions();
fv::options::New(this->mesh_).correct(this->nut_);
BasicTurbulenceModel::correctNut();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class BasicTurbulenceModel>
WALE<BasicTurbulenceModel>::WALE
(
const alphaField& alpha,
const rhoField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName,
const word& type
)
:
LESeddyViscosity<BasicTurbulenceModel>
(
type,
alpha,
rho,
U,
alphaRhoPhi,
phi,
transport,
propertiesName
),
Ck_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Ck",
this->coeffDict_,
0.094
)
),
k_
(
IOobject
(
IOobject::groupName("k", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
this->mesh_
),
Sd_
(
IOobject
(
Cw_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cw",
this->coeffDict_,
0.325
)
)
{
if (type == typeName)
{
this->printCoeffs(type);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class BasicTurbulenceModel>
bool WALE<BasicTurbulenceModel>::read()
{
if (LESeddyViscosity<BasicTurbulenceModel>::read())
{
Ck_.readIfPresent(this->coeffDict());
Cw_.readIfPresent(this->coeffDict());
return true;
}
else
{
return false;
}
}
template<class BasicTurbulenceModel>
tmp<volScalarField> WALE<BasicTurbulenceModel>::epsilon() const
{
volScalarField k(this->k(fvc::grad(this->U_)));
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
IOobject::groupName("epsilon", this->alphaRhoPhi_.group()),
this->runTime_.timeName(),
this->mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
this->Ce_*k*sqrt(k)/this->delta()
)
);
}
template<class BasicTurbulenceModel>
void WALE<BasicTurbulenceModel>::correct()
{
LESeddyViscosity<BasicTurbulenceModel>::correct();
correctNut();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace Foam
// ************************************************************************* //
WALE.H
/---------------------------------------------------------------------------\
\ / F ield
OpenFOAM: The Open Source CFD Toolbox
\ / O peration
Website: https://openfoam.org
\ / A nd
Copyright (C) 2015-2018 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 <http://www.gnu.org/licenses/>.
Class
Foam::LESModels::WALE
Description
The Wall-adapting local eddy-viscosity (WALE) SGS model.
Reference:
\verbatim
Nicoud, F., & Ducros, F. (1999).
Subgrid-scale stress modelling based on the square of the velocity
gradient tensor.
Flow, Turbulence and Combustion, 62(3), 183-200.
\endverbatim
The default model coefficients are
\verbatim
WALECoeffs
{
Ck 0.094;
Ce 1.048;e
Cw 0.325;
}
\endverbatim
See also
Foam::LESModels::Smagorinsky
SourceFiles
WALE.C
*---------------------------------------------------------------------------*/
#ifndef WALE_H
#define WALE_H
#include "LESModel.H"
#include "LESeddyViscosity.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace LESModels
{
/---------------------------------------------------------------------------
Class WALE Declaration
*---------------------------------------------------------------------------*/
template<class BasicTurbulenceModel>
class WALE
:
public LESeddyViscosity<BasicTurbulenceModel>
{
// Private Member Functions
// Disallow default bitwise copy construct and assignment
WALE(const WALE&);
void operator=(const WALE&);
protected:
// Protected data
dimensionedScalar Ck_;
dimensionedScalar Cw_;
volScalarField k_;
// Protected Member Functions
//- Return the deviatoric symmetric part of the square of the given
// velocity gradient field
tmp<volSymmTensorField> Sd(const volTensorField& gradU) const;
//- Return SGS kinetic energy
// calculated from the given velocity gradient
tmp<volScalarField> k(const volTensorField& gradU) const;
//- Update the SGS eddy-viscosity
virtual void correctNut();
public:
typedef typename BasicTurbulenceModel::alphaField alphaField;
typedef typename BasicTurbulenceModel::rhoField rhoField;
typedef typename BasicTurbulenceModel::transportModel transportModel;
//- Runtime type information
TypeName("WALE");
// Constructors
//- Construct from components
WALE
(
const alphaField& alpha,
const rhoField& rho,
const volVectorField& U,
const surfaceScalarField& alphaRhoPhi,
const surfaceScalarField& phi,
const transportModel& transport,
const word& propertiesName = turbulenceModel::propertiesName,
const word& type = typeName
);
//- Destructor
virtual ~WALE()
{}
// Member Functions
//- Read model coefficients if they have changed
virtual bool read();
//- Return SGS kinetic energy
virtual tmp<volScalarField> k() const
{
return k(fvc::grad(this->U_));
}
//- Return sub-grid disipation rate
virtual tmp<volScalarField> epsilon() const;
//- Correct Eddy-Viscosity and related properties
virtual void correct();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "WALE.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //