Commit 30e91088 authored by Henry's avatar Henry
Browse files

TurbulenceModels: Added templated v2f for incompressible and compressible flow

parent a3d70945
......@@ -3,7 +3,6 @@ incompressibleTurbulenceModel.C
turbulentTransportModels/turbulentTransportModels.C
turbulentTransportModels/RAS/kOmega/kOmega.C
turbulentTransportModels/RAS/RNGkEpsilon/RNGkEpsilon.C
turbulentTransportModels/RAS/v2f/v2f.C
turbulentTransportModels/RAS/qZeta/qZeta.C
turbulentTransportModels/RAS/kkLOmega/kkLOmega.C
turbulentTransportModels/RAS/LamBremhorstKE/LamBremhorstKE.C
......@@ -13,8 +12,10 @@ turbulentTransportModels/RAS/LienLeschzinerLowRe/LienLeschzinerLowRe.C
turbulentTransportModels/RAS/nonlinearKEShih/nonlinearKEShih.C
BCs = turbulentTransportModels/RAS/derivedFvPatchFields
/*
$(BCs)/wallFunctions/v2WallFunction/v2WallFunctionFvPatchScalarField.C
$(BCs)/wallFunctions/fWallFunction/fWallFunctionFvPatchScalarField.C
*/
turbulentTransportModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatJayatillekeWallFunction/alphatJayatillekeWallFunctionFvPatchScalarField.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 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 "fWallFunctionFvPatchScalarField.H"
#include "v2f.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "wallFvPatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void fWallFunctionFvPatchScalarField::checkType()
{
if (!isA<wallFvPatch>(patch()))
{
FatalErrorIn("fWallFunctionFvPatchScalarField::checkType()")
<< "Invalid wall function specification" << nl
<< " Patch type for patch " << patch().name()
<< " must be wall" << nl
<< " Current patch type is " << patch().type() << nl << endl
<< abort(FatalError);
}
}
void fWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const
{
os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("E") << E_ << token::END_STATEMENT << nl;
}
scalar fWallFunctionFvPatchScalarField::yPlusLam
(
const scalar kappa,
const scalar E
)
{
scalar ypl = 11.0;
for (int i=0; i<10; i++)
{
ypl = log(max(E*ypl, 1))/kappa;
}
return ypl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
fWallFunctionFvPatchScalarField::fWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchField<scalar>(p, iF),
Cmu_(0.09),
kappa_(0.41),
E_(9.8),
yPlusLam_(yPlusLam(kappa_, E_))
{
checkType();
}
fWallFunctionFvPatchScalarField::fWallFunctionFvPatchScalarField
(
const fWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchField<scalar>(ptf, p, iF, mapper),
Cmu_(ptf.Cmu_),
kappa_(ptf.kappa_),
E_(ptf.E_),
yPlusLam_(ptf.yPlusLam_)
{
checkType();
}
fWallFunctionFvPatchScalarField::fWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchField<scalar>(p, iF, dict),
Cmu_(dict.lookupOrDefault<scalar>("Cmu", 0.09)),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
E_(dict.lookupOrDefault<scalar>("E", 9.8)),
yPlusLam_(yPlusLam(kappa_, E_))
{
checkType();
}
fWallFunctionFvPatchScalarField::fWallFunctionFvPatchScalarField
(
const fWallFunctionFvPatchScalarField& v2wfpsf
)
:
fixedValueFvPatchField<scalar>(v2wfpsf),
Cmu_(v2wfpsf.Cmu_),
kappa_(v2wfpsf.kappa_),
E_(v2wfpsf.E_),
yPlusLam_(v2wfpsf.yPlusLam_)
{
checkType();
}
fWallFunctionFvPatchScalarField::fWallFunctionFvPatchScalarField
(
const fWallFunctionFvPatchScalarField& v2wfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchField<scalar>(v2wfpsf, iF),
Cmu_(v2wfpsf.Cmu_),
kappa_(v2wfpsf.kappa_),
E_(v2wfpsf.E_),
yPlusLam_(v2wfpsf.yPlusLam_)
{
checkType();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void fWallFunctionFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
const label patchi = patch().index();
const turbulenceModel& turbulence = db().lookupObject<turbulenceModel>
(
IOobject::groupName
(
turbulenceModel::propertiesName,
dimensionedInternalField().group()
)
);
const v2f& v2fModel = refCast<const v2f>(turbulence);
const scalarField& y = v2fModel.y()[patchi];
const tmp<volScalarField> tk = v2fModel.k();
const volScalarField& k = tk();
const tmp<volScalarField> tepsilon = v2fModel.epsilon();
const volScalarField& epsilon = tepsilon();
const tmp<volScalarField> tv2 = v2fModel.v2();
const volScalarField& v2 = tv2();
const tmp<scalarField> tnuw = turbulence.nu(patchi);
const scalarField& nuw = tnuw();
const scalar Cmu25 = pow025(Cmu_);
scalarField& f = *this;
// Set f wall values
forAll(f, faceI)
{
label faceCellI = patch().faceCells()[faceI];
scalar uTau = Cmu25*sqrt(k[faceCellI]);
scalar yPlus = uTau*y[faceI]/nuw[faceI];
if (yPlus > yPlusLam_)
{
scalar N = 6.0;
scalar v2c = v2[faceCellI];
scalar epsc = epsilon[faceCellI];
scalar kc = k[faceCellI];
f[faceI] = N*v2c*epsc/(sqr(kc) + ROOTVSMALL);
f[faceI] /= sqr(uTau) + ROOTVSMALL;
}
else
{
f[faceI] = 0.0;
}
}
fixedValueFvPatchField<scalar>::updateCoeffs();
// TODO: perform averaging for cells sharing more than one boundary face
}
void fWallFunctionFvPatchScalarField::evaluate
(
const Pstream::commsTypes commsType
)
{
fixedValueFvPatchField<scalar>::evaluate(commsType);
}
void fWallFunctionFvPatchScalarField::write(Ostream& os) const
{
writeLocalEntries(os);
fixedValueFvPatchField<scalar>::write(os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchScalarField,
fWallFunctionFvPatchScalarField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 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::RASModels::fWallFunctionFvPatchScalarField
Group
grpWallFunctions
Description
This boundary condition provides a turbulence damping function, f, wall
function condition for low- and high Reynolds number, turbulent flow cases
The model operates in two modes, based on the computed laminar-to-turbulent
switch-over y+ value derived from kappa and E.
\heading Patch usage
\table
Property | Description | Required | Default value
Cmu | model coefficient | no | 0.09
kappa | Von Karman constant | no | 0.41
E | model coefficient | no | 9.8
\endtable
Example of the boundary condition specification:
\verbatim
myPatch
{
type fWallFunction;
}
\endverbatim
SeeAlso
Foam::fixedValueFvPatchField
SourceFiles
fWallFunctionFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef fWallFunctionFvPatchScalarField_H
#define fWallFunctionFvPatchScalarField_H
#include "fixedValueFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
/*---------------------------------------------------------------------------*\
Class fWallFunctionFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class fWallFunctionFvPatchScalarField
:
public fixedValueFvPatchField<scalar>
{
protected:
// Protected data
//- Cmu coefficient
scalar Cmu_;
//- Von Karman constant
scalar kappa_;
//- E coefficient
scalar E_;
//- Y+ at the edge of the laminar sublayer
scalar yPlusLam_;
// Protected Member Functions
//- Check the type of the patch
virtual void checkType();
//- Write local wall function variables
virtual void writeLocalEntries(Ostream&) const;
//- Calculate the Y+ at the edge of the laminar sublayer
scalar yPlusLam(const scalar kappa, const scalar E);
public:
//- Runtime type information
TypeName("fWallFunction");
// Constructors
//- Construct from patch and internal field
fWallFunctionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
fWallFunctionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given fWallFunctionFvPatchScalarField
// onto a new patch
fWallFunctionFvPatchScalarField
(
const fWallFunctionFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
fWallFunctionFvPatchScalarField
(
const fWallFunctionFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new fWallFunctionFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
fWallFunctionFvPatchScalarField
(
const fWallFunctionFvPatchScalarField&,
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 fWallFunctionFvPatchScalarField(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Evaluate the patchField
virtual void evaluate(const Pstream::commsTypes);
// I-O
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 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 "v2WallFunctionFvPatchScalarField.H"
#include "turbulenceModel.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
#include "wallFvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void v2WallFunctionFvPatchScalarField::checkType()
{
if (!isA<wallFvPatch>(patch()))
{
FatalErrorIn("v2WallFunctionFvPatchScalarField::checkType()")
<< "Invalid wall function specification" << nl
<< " Patch type for patch " << patch().name()