Refactored mutkRoughWallFunction according to the new interface
This commit is contained in:
parent
3d7f902f82
commit
671ad26638
3 changed files with 454 additions and 0 deletions
|
@ -20,6 +20,7 @@ mutWallFunctions = $(wallFunctions)/mutWallFunctions
|
||||||
$(mutWallFunctions)/mutWallFunction/mutWallFunctionFvPatchScalarField.C
|
$(mutWallFunctions)/mutWallFunction/mutWallFunctionFvPatchScalarField.C
|
||||||
$(mutWallFunctions)/mutLowReWallFunction/mutLowReWallFunctionFvPatchScalarField.C
|
$(mutWallFunctions)/mutLowReWallFunction/mutLowReWallFunctionFvPatchScalarField.C
|
||||||
$(mutWallFunctions)/mutkWallFunction/mutkWallFunctionFvPatchScalarField.C
|
$(mutWallFunctions)/mutkWallFunction/mutkWallFunctionFvPatchScalarField.C
|
||||||
|
$(mutWallFunctions)/mutkRoughWallFunction/mutkRoughWallFunctionFvPatchScalarField.C
|
||||||
|
|
||||||
|
|
||||||
epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions
|
epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions
|
||||||
|
|
|
@ -0,0 +1,236 @@
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | foam-extend: Open Source CFD
|
||||||
|
\\ / O peration | Version: 4.1
|
||||||
|
\\ / 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 "mutkRoughWallFunctionFvPatchScalarField.H"
|
||||||
|
#include "RASModel.H"
|
||||||
|
#include "fvPatchFieldMapper.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace compressible
|
||||||
|
{
|
||||||
|
namespace RASModels
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
scalar mutkRoughWallFunctionFvPatchScalarField::fnRough
|
||||||
|
(
|
||||||
|
const scalar KsPlus,
|
||||||
|
const scalar Cs
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Return fn based on non-dimensional roughness height
|
||||||
|
|
||||||
|
if (KsPlus < 90.0)
|
||||||
|
{
|
||||||
|
return pow
|
||||||
|
(
|
||||||
|
(KsPlus - 2.25)/87.75 + Cs*KsPlus,
|
||||||
|
sin(0.4258*(log(KsPlus) - 0.811))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (1.0 + Cs*KsPlus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
tmp<scalarField> mutkRoughWallFunctionFvPatchScalarField::calcMut() const
|
||||||
|
{
|
||||||
|
const label patchI = patch().index();
|
||||||
|
|
||||||
|
const turbulenceModel& turbModel =
|
||||||
|
db().lookupObject<turbulenceModel>("turbulenceModel");
|
||||||
|
|
||||||
|
const scalarField& y = turbModel.y()[patchI];
|
||||||
|
const scalarField& rhow = turbModel.rho().boundaryField()[patchI];
|
||||||
|
const tmp<volScalarField> tk = turbModel.k();
|
||||||
|
const volScalarField& k = tk();
|
||||||
|
const scalarField& muw = turbModel.mu().boundaryField()[patchI];
|
||||||
|
|
||||||
|
const scalar Cmu25 = pow025(Cmu_);
|
||||||
|
|
||||||
|
tmp<scalarField> tmutw(new scalarField(*this));
|
||||||
|
scalarField& mutw = tmutw();
|
||||||
|
|
||||||
|
const unallocLabelList& fc = patch().faceCells();
|
||||||
|
|
||||||
|
forAll(mutw, faceI)
|
||||||
|
{
|
||||||
|
const label faceCellI = fc[faceI];
|
||||||
|
|
||||||
|
const scalar uStar = Cmu25*sqrt(k[faceCellI]);
|
||||||
|
const scalar yPlus = uStar*y[faceI]/(muw[faceI]/rhow[faceI]);
|
||||||
|
const scalar KsPlus = uStar*Ks_[faceI]/(muw[faceI]/rhow[faceI]);
|
||||||
|
|
||||||
|
scalar Edash = E_;
|
||||||
|
scalar yPlusLamNew = yPlusLam_;
|
||||||
|
if (KsPlus > 2.25)
|
||||||
|
{
|
||||||
|
Edash /= fnRough(KsPlus, Cs_[faceI]);
|
||||||
|
yPlusLamNew = turbModel.yPlusLam(kappa_, Edash);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (yPlus > yPlusLamNew)
|
||||||
|
{
|
||||||
|
mutw[faceI] =
|
||||||
|
muw[faceI]*(yPlus*kappa_/log(max(Edash*yPlus, 1 + 1e-4)) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "yPlus = " << yPlus
|
||||||
|
<< ", KsPlus = " << KsPlus
|
||||||
|
<< ", Edash = " << Edash
|
||||||
|
<< ", yPlusLam = " << yPlusLam_
|
||||||
|
<< ", mutw = " << mutw[faceI]
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmutw;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
mutkRoughWallFunctionFvPatchScalarField::mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<scalar, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mutkWallFunctionFvPatchScalarField(p, iF),
|
||||||
|
Ks_(p.size(), 0.0),
|
||||||
|
Cs_(p.size(), 0.0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
mutkRoughWallFunctionFvPatchScalarField::mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const mutkRoughWallFunctionFvPatchScalarField& ptf,
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<scalar, volMesh>& iF,
|
||||||
|
const fvPatchFieldMapper& mapper
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
|
||||||
|
Ks_(ptf.Ks_, mapper),
|
||||||
|
Cs_(ptf.Cs_, mapper)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
mutkRoughWallFunctionFvPatchScalarField::mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<scalar, volMesh>& iF,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mutkWallFunctionFvPatchScalarField(p, iF, dict),
|
||||||
|
Ks_("Ks", dict, p.size()),
|
||||||
|
Cs_("Cs", dict, p.size())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
mutkRoughWallFunctionFvPatchScalarField::mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const mutkRoughWallFunctionFvPatchScalarField& rwfpsf
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mutkWallFunctionFvPatchScalarField(rwfpsf),
|
||||||
|
Ks_(rwfpsf.Ks_),
|
||||||
|
Cs_(rwfpsf.Cs_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
mutkRoughWallFunctionFvPatchScalarField::mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const mutkRoughWallFunctionFvPatchScalarField& rwfpsf,
|
||||||
|
const DimensionedField<scalar, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
mutkWallFunctionFvPatchScalarField(rwfpsf, iF),
|
||||||
|
Ks_(rwfpsf.Ks_),
|
||||||
|
Cs_(rwfpsf.Cs_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void mutkRoughWallFunctionFvPatchScalarField::autoMap
|
||||||
|
(
|
||||||
|
const fvPatchFieldMapper& m
|
||||||
|
)
|
||||||
|
{
|
||||||
|
mutkWallFunctionFvPatchScalarField::autoMap(m);
|
||||||
|
Ks_.autoMap(m);
|
||||||
|
Cs_.autoMap(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mutkRoughWallFunctionFvPatchScalarField::rmap
|
||||||
|
(
|
||||||
|
const fvPatchScalarField& ptf,
|
||||||
|
const labelList& addr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
mutkWallFunctionFvPatchScalarField::rmap(ptf, addr);
|
||||||
|
|
||||||
|
const mutkRoughWallFunctionFvPatchScalarField& nrwfpsf =
|
||||||
|
refCast<const mutkRoughWallFunctionFvPatchScalarField>(ptf);
|
||||||
|
|
||||||
|
Ks_.rmap(nrwfpsf.Ks_, addr);
|
||||||
|
Cs_.rmap(nrwfpsf.Cs_, addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void mutkRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
fvPatchField<scalar>::write(os);
|
||||||
|
writeLocalEntries(os);
|
||||||
|
Cs_.writeEntry("Cs", os);
|
||||||
|
Ks_.writeEntry("Ks", os);
|
||||||
|
writeEntry("value", os);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
makePatchTypeField(fvPatchScalarField, mutkRoughWallFunctionFvPatchScalarField);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace RASModels
|
||||||
|
} // End namespace compressible
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
|
@ -0,0 +1,217 @@
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | foam-extend: Open Source CFD
|
||||||
|
\\ / O peration | Version: 4.1
|
||||||
|
\\ / 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::compressible::RASModels::mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
|
||||||
|
Description
|
||||||
|
Boundary condition for turbulent (dynamic) viscosity when using wall
|
||||||
|
functions for rough walls.
|
||||||
|
|
||||||
|
Manipulates the E parameter to account for roughness effects, based on
|
||||||
|
KsPlus.
|
||||||
|
|
||||||
|
- roughness height = sand-grain roughness (0 for smooth walls)
|
||||||
|
- roughness constant = 0.5-1.0 (0.5 default)
|
||||||
|
|
||||||
|
Usage
|
||||||
|
\table
|
||||||
|
Property | Description | Required | Default value
|
||||||
|
Ks | sand-grain roughness height | yes |
|
||||||
|
Cs | roughness constant | yes |
|
||||||
|
\endtable
|
||||||
|
|
||||||
|
Example of the boundary condition specification:
|
||||||
|
\verbatim
|
||||||
|
<patchName>
|
||||||
|
{
|
||||||
|
type mutkRoughWallFunction;
|
||||||
|
Ks uniform 0;
|
||||||
|
Cs uniform 0.5;
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
mutkRoughWallFunctionFvPatchScalarField.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef compressibleMutRoughWallFunctionFvPatchScalarField_H
|
||||||
|
#define compressibleMutRoughWallFunctionFvPatchScalarField_H
|
||||||
|
|
||||||
|
#include "mutkWallFunctionFvPatchScalarField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace compressible
|
||||||
|
{
|
||||||
|
namespace RASModels
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class mutkRoughWallFunctionFvPatchScalarField Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
:
|
||||||
|
public mutkWallFunctionFvPatchScalarField
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected data
|
||||||
|
|
||||||
|
//- Roughness height
|
||||||
|
scalarField Ks_;
|
||||||
|
|
||||||
|
//- Roughness constant
|
||||||
|
scalarField Cs_;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Compute the roughness function
|
||||||
|
virtual scalar fnRough(const scalar KsPlus, const scalar Cs) const;
|
||||||
|
|
||||||
|
//- Calculate the turbulence viscosity
|
||||||
|
virtual tmp<scalarField> calcMut() const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("mutkRoughWallFunction");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from patch and internal field
|
||||||
|
mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<scalar, volMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from patch, internal field and dictionary
|
||||||
|
mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<scalar, volMesh>&,
|
||||||
|
const dictionary&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct by mapping given
|
||||||
|
// mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
// onto a new patch
|
||||||
|
mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const mutkRoughWallFunctionFvPatchScalarField&,
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<scalar, volMesh>&,
|
||||||
|
const fvPatchFieldMapper&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct as copy
|
||||||
|
mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const mutkRoughWallFunctionFvPatchScalarField&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct and return a clone
|
||||||
|
virtual tmp<fvPatchScalarField> clone() const
|
||||||
|
{
|
||||||
|
return tmp<fvPatchScalarField>
|
||||||
|
(
|
||||||
|
new mutkRoughWallFunctionFvPatchScalarField(*this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Construct as copy setting internal field reference
|
||||||
|
mutkRoughWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const mutkRoughWallFunctionFvPatchScalarField&,
|
||||||
|
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 mutkRoughWallFunctionFvPatchScalarField(*this, iF)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Member functions
|
||||||
|
|
||||||
|
// Acces functions
|
||||||
|
|
||||||
|
// Return Ks
|
||||||
|
scalarField& Ks()
|
||||||
|
{
|
||||||
|
return Ks_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return Cs
|
||||||
|
scalarField& Cs()
|
||||||
|
{
|
||||||
|
return Cs_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Mapping functions
|
||||||
|
|
||||||
|
//- Map (and resize as needed) from self given a mapping object
|
||||||
|
virtual void autoMap(const fvPatchFieldMapper&);
|
||||||
|
|
||||||
|
//- Reverse map the given fvPatchField onto this fvPatchField
|
||||||
|
virtual void rmap
|
||||||
|
(
|
||||||
|
const fvPatchScalarField&,
|
||||||
|
const labelList&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// I-O
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
virtual void write(Ostream&) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace RASModels
|
||||||
|
} // End namespace compressible
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
Reference in a new issue