Update on wall functions for Reynolds stress transport model, phase 1

This commit is contained in:
Hrvoje Jasak 2011-12-14 14:36:03 +00:00
parent 9b268cfd4c
commit c05b6cb62e
5 changed files with 408 additions and 38 deletions

View file

@ -345,6 +345,7 @@ void LaunderGibsonRSTM::correct()
}
volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_));
volSymmTensorField C = -fvc::div(phi_, R_);
volScalarField G("RASModel::G", 0.5*mag(tr(P)));
// Update epsilon and G at the wall
@ -403,7 +404,10 @@ void LaunderGibsonRSTM::correct()
==
P
+ (2.0/3.0*(Clg1_ - 1)*I)*epsilon_
- Clg2_*dev(P)
// Change for consistency with Fluent implementation.
// Emil Baric, NUMAP-FOAM 2011
// HJ, 13/Dec/2011
- Clg2_*(dev(P) - dev(C))
// wall reflection terms
+ symm
@ -441,42 +445,8 @@ void LaunderGibsonRSTM::correct()
nut_.correctBoundaryConditions();
// Correct wall shear stresses
forAll(patches, patchi)
{
const fvPatch& curPatch = patches[patchi];
if (curPatch.isWall())
{
symmTensorField& Rw = R_.boundaryField()[patchi];
const scalarField& nutw = nut_.boundaryField()[patchi];
vectorField snGradU = U_.boundaryField()[patchi].snGrad();
const vectorField& faceAreas
= mesh_.Sf().boundaryField()[patchi];
const scalarField& magFaceAreas
= mesh_.magSf().boundaryField()[patchi];
forAll(curPatch, facei)
{
// Calculate near-wall velocity gradient
tensor gradUw
= (faceAreas[facei]/magFaceAreas[facei])*snGradU[facei];
// Calculate near-wall shear-stress tensor
tensor tauw = -nutw[facei]*2*symm(gradUw);
// Reset the shear components of the stress tensor
Rw[facei].xy() = tauw.xy();
Rw[facei].xz() = tauw.xz();
Rw[facei].yz() = tauw.yz();
}
}
}
// Correct wall shear stresses. Moved to wall functions with anisotropy
// HJ, 14/Dec/2011
}

View file

@ -40,6 +40,9 @@ $(omegaWallFunctions)/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C
kqRWallFunctions = $(wallFunctions)/kqRWallFunctions
$(kqRWallFunctions)/kqRWallFunction/kqRWallFunctionFvPatchFields.C
RWallFunctions = $(wallFunctions)/RWallFunctions
$(RWallFunctions)/RWallFunction/RWallFunctionFvPatchSymmTensorField.C
/* Patch fields */
derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C

View file

@ -31,6 +31,7 @@ License
#include "nutLowReWallFunctionFvPatchScalarField.H"
#include "epsilonWallFunctionFvPatchScalarField.H"
#include "kqRWallFunctionFvPatchField.H"
#include "RWallFunctionFvPatchSymmTensorField.H"
#include "omegaWallFunctionFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -268,7 +269,8 @@ tmp<volSymmTensorField> autoCreateR
autoCreateWallFunctionField
<
symmTensor,
RASModels::kqRWallFunctionFvPatchField<symmTensor>
// New wall functions for R. HJ, 14/Dec/2011
RASModels::RWallFunctionFvPatchSymmTensorField
>
(
fieldName,

View file

@ -0,0 +1,218 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "RWallFunctionFvPatchSymmTensorField.H"
#include "RASModel.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void RWallFunctionFvPatchSymmTensorField::checkType()
{
if (!this->patch().isWall())
{
FatalErrorIn("RWallFunctionFvPatchSymmTensorField::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 RWallFunctionFvPatchSymmTensorField::setInInternalField
(
const symmTensorField& f
) const
{
symmTensorField& vf = const_cast<symmTensorField& >
(
this->internalField()
);
const labelList& faceCells = this->patch().faceCells();
// Apply the refValue into the cells next to the boundary
forAll (faceCells, faceI)
{
vf[faceCells[faceI]] = f[faceI];
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
RWallFunctionFvPatchSymmTensorField::RWallFunctionFvPatchSymmTensorField
(
const fvPatch& p,
const DimensionedField<symmTensor, volMesh>& iF
)
:
zeroGradientFvPatchField<symmTensor>(p, iF),
UName_("U"),
nutName_("nut")
{
checkType();
}
RWallFunctionFvPatchSymmTensorField::RWallFunctionFvPatchSymmTensorField
(
const RWallFunctionFvPatchSymmTensorField& ptf,
const fvPatch& p,
const DimensionedField<symmTensor, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
zeroGradientFvPatchField<symmTensor>(ptf, p, iF, mapper),
UName_(ptf.UName_),
nutName_(ptf.nutName_)
{
checkType();
}
RWallFunctionFvPatchSymmTensorField::RWallFunctionFvPatchSymmTensorField
(
const fvPatch& p,
const DimensionedField<symmTensor, volMesh>& iF,
const dictionary& dict
)
:
zeroGradientFvPatchField<symmTensor>(p, iF, dict),
UName_(dict.lookupOrDefault<word>("U", "U")),
nutName_(dict.lookupOrDefault<word>("nut", "nut"))
{
checkType();
}
RWallFunctionFvPatchSymmTensorField::RWallFunctionFvPatchSymmTensorField
(
const RWallFunctionFvPatchSymmTensorField& Rwfpsf
)
:
zeroGradientFvPatchField<symmTensor>(Rwfpsf),
UName_(Rwfpsf.UName_),
nutName_(Rwfpsf.nutName_)
{
checkType();
}
RWallFunctionFvPatchSymmTensorField::RWallFunctionFvPatchSymmTensorField
(
const RWallFunctionFvPatchSymmTensorField& Rwfpsf,
const DimensionedField<symmTensor, volMesh>& iF
)
:
zeroGradientFvPatchField<symmTensor>(Rwfpsf, iF),
UName_(Rwfpsf.UName_),
nutName_(Rwfpsf.nutName_)
{
checkType();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void RWallFunctionFvPatchSymmTensorField::evaluate
(
const Pstream::commsTypes commsType
)
{
const scalarField& nutw =
patch().lookupPatchField<volScalarField, scalar>(nutName_);
const fvPatchVectorField& Uw =
patch().lookupPatchField<volVectorField, vector>(UName_);
// Old treatment: anisotropy not enforced
vectorField snGradU = Uw.snGrad();
tensorField gradUw = patch().nf()*snGradU;
// Calculate near-wall shear-stress tensor
symmTensorField tauw = -nutw*2*symm(gradUw);
// // Normal coordinate
// vectorField n = patch().nf();
// // Tangential coordinate. Take care of mag(U) = 0;
// vectorField Utan = (I - sqr(n)) & Uw.patchInternalField();
// scalarField magUtan = mag(Utan);
// Utan /= magUtan + SMALL;
// vectorField t = pos(magUtan - SMALL)*Utan
// + neg(magUtan - SMALL)*vector(1, 0, 0);
// // Binormal coordinate
// vectorField l = n ^ t;
// Reset the shear components of the stress tensor
replace(symmTensor::XY, tauw.component(symmTensor::XY));
replace(symmTensor::XZ, tauw.component(symmTensor::XZ));
replace(symmTensor::YZ, tauw.component(symmTensor::YZ));
}
void RWallFunctionFvPatchSymmTensorField::write(Ostream& os) const
{
zeroGradientFvPatchSymmTensorField::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_);
writeEntryIfDifferent<word>(os, "nut", "nut", nutName_);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchSymmTensorField,
RWallFunctionFvPatchSymmTensorField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,177 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::incompressible::RASModels::RWallFunctionFvPatchSymmTensorField
Description
Boundary condition for R when using wall functions
- set and updated from the epsilon wall function
Author
Hrvoje Jasak, Wikki Ltd. All rights reserved
SourceFiles
RWallFunctionFvPatchSymmTensorField.C
\*---------------------------------------------------------------------------*/
#ifndef RWallFunctionFvPatchSymmTensorField_H
#define RWallFunctionFvPatchSymmTensorField_H
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
/*---------------------------------------------------------------------------*\
Class RWallFunctionFvPatchSymmTensorField Declaration
\*---------------------------------------------------------------------------*/
class RWallFunctionFvPatchSymmTensorField
:
public zeroGradientFvPatchSymmTensorField
{
// Private data
//- Name of velocity field
word UName_;
//- Name of turbulent viscosity field
word nutName_;
// Private member functions
//- Check the type of the patch
void checkType();
//- Set value in internal field
void setInInternalField(const symmTensorField& f) const;
public:
//- Runtime type information
TypeName("RWallFunction");
// Constructors
//- Construct from patch and internal field
RWallFunctionFvPatchSymmTensorField
(
const fvPatch&,
const DimensionedField<symmTensor, volMesh>&
);
//- Construct from patch, internal field and dictionary
RWallFunctionFvPatchSymmTensorField
(
const fvPatch&,
const DimensionedField<symmTensor, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// RWallFunctionFvPatchSymmTensorField
// onto a new patch
RWallFunctionFvPatchSymmTensorField
(
const RWallFunctionFvPatchSymmTensorField&,
const fvPatch&,
const DimensionedField<symmTensor, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
RWallFunctionFvPatchSymmTensorField
(
const RWallFunctionFvPatchSymmTensorField&
);
//- Construct and return a clone
virtual tmp<fvPatchSymmTensorField> clone() const
{
return tmp<fvPatchSymmTensorField>
(
new RWallFunctionFvPatchSymmTensorField(*this)
);
}
//- Construct as copy setting internal field reference
RWallFunctionFvPatchSymmTensorField
(
const RWallFunctionFvPatchSymmTensorField&,
const DimensionedField<symmTensor, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchSymmTensorField> clone
(
const DimensionedField<symmTensor, volMesh>& iF
) const
{
return tmp<fvPatchSymmTensorField>
(
new RWallFunctionFvPatchSymmTensorField(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Evaluate the patchField
virtual void evaluate
(
const Pstream::commsTypes commsType = Pstream::blocking
);
// I-O
//- Write
void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //