nuRatio boundary conditions for epsilon and omega

Given a desired nuRatio, the boundary conditions automatically calculate
epsilon/omega from k.
This commit is contained in:
Vuko Vukcevic 2017-06-29 08:56:04 +02:00 committed by Hrvoje Jasak
parent bee6a2228a
commit ec8b2eb97b
5 changed files with 752 additions and 0 deletions

View file

@ -59,6 +59,8 @@ $(wallFunctionFunctionObjects)/velocityConvection/velocityConvectionFunctionObje
derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C
derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C
derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C
derivedFvPatchFields/nuRatioEpsilon/nuRatioEpsilonFvPatchScalarField.C
derivedFvPatchFields/nuRatioOmega/nuRatioOmegaFvPatchScalarField.C
backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C

View file

@ -0,0 +1,205 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "nuRatioEpsilonFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "RASModel.H"
#include "fvPatchFieldMapper.H"
#include "surfaceFields.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::nuRatioEpsilonFvPatchScalarField::nuRatioEpsilonFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
inletOutletFvPatchScalarField(p, iF),
nuRatio_(1),
Cmu_(0.09),
kName_("undefined-k"),
phiName_("undefined-phi")
{
this->refValue() = 0.0;
this->refGrad() = 0.0;
this->valueFraction() = 0.0;
}
Foam::nuRatioEpsilonFvPatchScalarField::nuRatioEpsilonFvPatchScalarField
(
const nuRatioEpsilonFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
inletOutletFvPatchScalarField(ptf, p, iF, mapper),
nuRatio_(ptf.nuRatio_),
Cmu_(ptf.Cmu_),
kName_(ptf.kName_),
phiName_(ptf.phiName_)
{}
Foam::nuRatioEpsilonFvPatchScalarField::nuRatioEpsilonFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
inletOutletFvPatchScalarField(p, iF),
nuRatio_(readScalar(dict.lookup("nuRatio"))),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
kName_(dict.lookupOrDefault<word>("kName", "k")),
phiName_(dict.lookupOrDefault<word>("phiName", "phi"))
{
if (nuRatio_< SMALL)
{
FatalErrorIn
(
"nuRatioEpsilonFvPatchScalarField::nuRatioEpsilonFvPatchScalarField"
"(const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, "
"const dictionary& dict)"
) << "Invalid eddy viscosity ratio (nuRatio) specified: " << nuRatio_
<< "\n on patch " << this->patch().name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< exit(FatalError);
}
if (Cmu_ < SMALL)
{
FatalErrorIn
(
"nuRatioEpsilonFvPatchScalarField::nuRatioEpsilonFvPatchScalarField"
"(const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, "
"const dictionary& dict)"
) << "Invalid Cmu_ constant specified: " << Cmu_
<< "\n on patch " << this->patch().name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< exit(FatalError);
}
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
this->refValue() = 0.0;
this->refGrad() = 0.0;
this->valueFraction() = 0.0;
}
Foam::nuRatioEpsilonFvPatchScalarField::nuRatioEpsilonFvPatchScalarField
(
const nuRatioEpsilonFvPatchScalarField& ptf
)
:
inletOutletFvPatchScalarField(ptf),
nuRatio_(ptf.nuRatio_),
Cmu_(ptf.Cmu_),
kName_(ptf.kName_),
phiName_(ptf.phiName_)
{}
Foam::nuRatioEpsilonFvPatchScalarField::nuRatioEpsilonFvPatchScalarField
(
const nuRatioEpsilonFvPatchScalarField& ptf,
const DimensionedField<scalar, volMesh>& iF
)
:
inletOutletFvPatchScalarField(ptf, iF),
nuRatio_(ptf.nuRatio_),
Cmu_(ptf.Cmu_),
kName_(ptf.kName_),
phiName_(ptf.phiName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::nuRatioEpsilonFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
// Get turbulent kinetic energy field for this patch
const fvPatchScalarField& kp =
lookupPatchField<volScalarField, vector>(kName_);
// Get flux field for this patch
const fvsPatchScalarField& phip =
lookupPatchField<surfaceScalarField, scalar>(phiName_);
// Get RASModel
const incompressible::RASModel& rasModel =
this->dimensionedInternalField().mesh().lookupObject
<
incompressible::RASModel
>("RASProperties");
// Get laminar viscosity for this patch
const fvPatchScalarField& nup =
rasModel.nu().boundaryField()[this->patch().index()];
this->refValue() = Cmu_*sqrt(kp)/nuRatio_/nup;
this->valueFraction() = neg(phip);
inletOutletFvPatchScalarField::updateCoeffs();
}
void Foam::nuRatioEpsilonFvPatchScalarField::write
(
Ostream& os
) const
{
fvPatchScalarField::write(os);
os.writeKeyword("nuRatio") << nuRatio_ << token::END_STATEMENT << nl;
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
os.writeKeyword("kName") << kName_ << token::END_STATEMENT << nl;
os.writeKeyword("phiName") << phiName_ << token::END_STATEMENT << nl;
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
nuRatioEpsilonFvPatchScalarField
);
}
// ************************************************************************* //

View file

@ -0,0 +1,182 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::nuRatioEpsilonFvPatchScalarField
Description
Calculate turbulent dissipation rate (epsilon) from the provided eddy
viscosity ratio. Note: derived from inletOutlet so it can readily be used
for both inlets and outlets.
Example of the boundary condition specification:
\verbatim
inlet
{
type nuRatioEpsilon;
nuRatio 10; // Eddy viscosity ratio
Cmu 0.09; // Default value 0.09
kName k; // Name of the turbulent energy field
// (k by default)
phiName phi; // Name of the flux field
// (phi by default)
value uniform 1; // placeholder
}
\endverbatim
SourceFiles
nuRatioEpsilonFvPatchScalarField.C
Author
Vuko Vukcevic, Wikki Ltd. All rights reserved.
\*---------------------------------------------------------------------------*/
#ifndef nuRatioEpsilonFvPatchScalarField_H
#define nuRatioEpsilonFvPatchScalarField_H
#include "inletOutletFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class eddyViscosityRatioTurbulenceDissipationRateFvPatch Declaration
\*---------------------------------------------------------------------------*/
class nuRatioEpsilonFvPatchScalarField
:
public inletOutletFvPatchScalarField
{
// Private data
//- Target viscosity ratio
scalar nuRatio_;
//- Cmu constant
scalar Cmu_;
//- Name of the turbulent energy field
word kName_;
//- Name of the flux field
word phiName_;
public:
//- Runtime type information
TypeName("nuRatioEpsilon");
// Constructors
//- Construct from patch and internal field
nuRatioEpsilonFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
nuRatioEpsilonFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// nuRatioEpsilonFvPatchScalarField
// onto a new patch
nuRatioEpsilonFvPatchScalarField
(
const nuRatioEpsilonFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
nuRatioEpsilonFvPatchScalarField
(
const nuRatioEpsilonFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new nuRatioEpsilonFvPatchScalarField
(
*this
)
);
}
//- Construct as copy setting internal field reference
nuRatioEpsilonFvPatchScalarField
(
const nuRatioEpsilonFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new nuRatioEpsilonFvPatchScalarField
(
*this,
iF
)
);
}
// Member functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,185 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "nuRatioOmegaFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "RASModel.H"
#include "fvPatchFieldMapper.H"
#include "surfaceFields.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::nuRatioOmegaFvPatchScalarField::nuRatioOmegaFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
inletOutletFvPatchScalarField(p, iF),
nuRatio_(1),
kName_("undefined-k"),
phiName_("undefined-phi")
{
this->refValue() = 0.0;
this->refGrad() = 0.0;
this->valueFraction() = 0.0;
}
Foam::nuRatioOmegaFvPatchScalarField::nuRatioOmegaFvPatchScalarField
(
const nuRatioOmegaFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
inletOutletFvPatchScalarField(ptf, p, iF, mapper),
nuRatio_(ptf.nuRatio_),
kName_(ptf.kName_),
phiName_(ptf.phiName_)
{}
Foam::nuRatioOmegaFvPatchScalarField::nuRatioOmegaFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
inletOutletFvPatchScalarField(p, iF),
nuRatio_(readScalar(dict.lookup("nuRatio"))),
kName_(dict.lookupOrDefault<word>("kName", "k")),
phiName_(dict.lookupOrDefault<word>("phiName", "phi"))
{
if (nuRatio_< SMALL)
{
FatalErrorIn
(
"nuRatioOmegaFvPatchScalarField::nuRatioOmegaFvPatchScalarField"
"(const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, "
"const dictionary& dict)"
) << "Invalid eddy viscosity ratio (nuRatio) specified: " << nuRatio_
<< "\n on patch " << this->patch().name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< exit(FatalError);
}
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
this->refValue() = 0.0;
this->refGrad() = 0.0;
this->valueFraction() = 0.0;
}
Foam::nuRatioOmegaFvPatchScalarField::nuRatioOmegaFvPatchScalarField
(
const nuRatioOmegaFvPatchScalarField& ptf
)
:
inletOutletFvPatchScalarField(ptf),
nuRatio_(ptf.nuRatio_),
kName_(ptf.kName_),
phiName_(ptf.phiName_)
{}
Foam::nuRatioOmegaFvPatchScalarField::nuRatioOmegaFvPatchScalarField
(
const nuRatioOmegaFvPatchScalarField& ptf,
const DimensionedField<scalar, volMesh>& iF
)
:
inletOutletFvPatchScalarField(ptf, iF),
nuRatio_(ptf.nuRatio_),
kName_(ptf.kName_),
phiName_(ptf.phiName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::nuRatioOmegaFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
// Get turbulent kinetic energy field for this patch
const fvPatchScalarField& kp =
lookupPatchField<volScalarField, vector>(kName_);
// Get flux field for this patch
const fvsPatchScalarField& phip =
lookupPatchField<surfaceScalarField, scalar>(phiName_);
// Get RASModel
const incompressible::RASModel& rasModel =
this->dimensionedInternalField().mesh().lookupObject
<
incompressible::RASModel
>("RASProperties");
// Get laminar viscosity for this patch
const fvPatchScalarField& nup =
rasModel.nu().boundaryField()[this->patch().index()];
this->refValue() = kp/(nuRatio_*nup);
this->valueFraction() = neg(phip);
inletOutletFvPatchScalarField::updateCoeffs();
}
void Foam::nuRatioOmegaFvPatchScalarField::write
(
Ostream& os
) const
{
fvPatchScalarField::write(os);
os.writeKeyword("nuRatio") << nuRatio_ << token::END_STATEMENT << nl;
os.writeKeyword("kName") << kName_ << token::END_STATEMENT << nl;
os.writeKeyword("phiName") << phiName_ << token::END_STATEMENT << nl;
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
nuRatioOmegaFvPatchScalarField
);
}
// ************************************************************************* //

View file

@ -0,0 +1,178 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::nuRatioOmegaFvPatchScalarField
Description
Calculate turbulent dissipation rate (epsilon) from the provided eddy
viscosity ratio. Note: derived from inletOutlet so it can readily be used
for both inlets and outlets.
Example of the boundary condition specification:
\verbatim
inlet
{
type nuRatioOmega;
nuRatio 10; // Eddy viscosity ratio
kName k; // Name of the turbulent energy field
// (k by default)
phiName phi; // Name of the flux field
// (phi by default)
value uniform 1; // placeholder
}
\endverbatim
SourceFiles
nuRatioOmegaFvPatchScalarField.C
Author
Vuko Vukcevic, Wikki Ltd. All rights reserved.
\*---------------------------------------------------------------------------*/
#ifndef nuRatioOmegaFvPatchScalarField_H
#define nuRatioOmegaFvPatchScalarField_H
#include "inletOutletFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class eddyViscosityRatioTurbulenceDissipationRateFvPatch Declaration
\*---------------------------------------------------------------------------*/
class nuRatioOmegaFvPatchScalarField
:
public inletOutletFvPatchScalarField
{
// Private data
//- Target viscosity ratio
scalar nuRatio_;
//- Name of the turbulent energy field
word kName_;
//- Name of the flux field
word phiName_;
public:
//- Runtime type information
TypeName("nuRatioOmega");
// Constructors
//- Construct from patch and internal field
nuRatioOmegaFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
nuRatioOmegaFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// nuRatioOmegaFvPatchScalarField
// onto a new patch
nuRatioOmegaFvPatchScalarField
(
const nuRatioOmegaFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
nuRatioOmegaFvPatchScalarField
(
const nuRatioOmegaFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new nuRatioOmegaFvPatchScalarField
(
*this
)
);
}
//- Construct as copy setting internal field reference
nuRatioOmegaFvPatchScalarField
(
const nuRatioOmegaFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new nuRatioOmegaFvPatchScalarField
(
*this,
iF
)
);
}
// Member functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //