diff --git a/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C index 90591979a..db178fa2d 100644 --- a/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/incompressible/RAS/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -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 } diff --git a/src/turbulenceModels/incompressible/RAS/Make/files b/src/turbulenceModels/incompressible/RAS/Make/files index 18f52c82a..230ca1f68 100644 --- a/src/turbulenceModels/incompressible/RAS/Make/files +++ b/src/turbulenceModels/incompressible/RAS/Make/files @@ -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 diff --git a/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C index b0e3796fa..d1b804c65 100644 --- a/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C +++ b/src/turbulenceModels/incompressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C @@ -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 autoCreateR autoCreateWallFunctionField < symmTensor, - RASModels::kqRWallFunctionFvPatchField + // New wall functions for R. HJ, 14/Dec/2011 + RASModels::RWallFunctionFvPatchSymmTensorField > ( fieldName, diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/RWallFunctions/RWallFunction/RWallFunctionFvPatchSymmTensorField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/RWallFunctions/RWallFunction/RWallFunctionFvPatchSymmTensorField.C new file mode 100644 index 000000000..b781b2392 --- /dev/null +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/RWallFunctions/RWallFunction/RWallFunctionFvPatchSymmTensorField.C @@ -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 + ( + 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& iF +) +: + zeroGradientFvPatchField(p, iF), + UName_("U"), + nutName_("nut") +{ + checkType(); +} + + +RWallFunctionFvPatchSymmTensorField::RWallFunctionFvPatchSymmTensorField +( + const RWallFunctionFvPatchSymmTensorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + zeroGradientFvPatchField(ptf, p, iF, mapper), + UName_(ptf.UName_), + nutName_(ptf.nutName_) +{ + checkType(); +} + + +RWallFunctionFvPatchSymmTensorField::RWallFunctionFvPatchSymmTensorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + zeroGradientFvPatchField(p, iF, dict), + UName_(dict.lookupOrDefault("U", "U")), + nutName_(dict.lookupOrDefault("nut", "nut")) +{ + checkType(); +} + + +RWallFunctionFvPatchSymmTensorField::RWallFunctionFvPatchSymmTensorField +( + const RWallFunctionFvPatchSymmTensorField& Rwfpsf +) +: + zeroGradientFvPatchField(Rwfpsf), + UName_(Rwfpsf.UName_), + nutName_(Rwfpsf.nutName_) +{ + checkType(); +} + + +RWallFunctionFvPatchSymmTensorField::RWallFunctionFvPatchSymmTensorField +( + const RWallFunctionFvPatchSymmTensorField& Rwfpsf, + const DimensionedField& iF +) +: + zeroGradientFvPatchField(Rwfpsf, iF), + UName_(Rwfpsf.UName_), + nutName_(Rwfpsf.nutName_) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void RWallFunctionFvPatchSymmTensorField::evaluate +( + const Pstream::commsTypes commsType +) +{ + const scalarField& nutw = + patch().lookupPatchField(nutName_); + + const fvPatchVectorField& Uw = + patch().lookupPatchField(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(os, "U", "U", UName_); + writeEntryIfDifferent(os, "nut", "nut", nutName_); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchSymmTensorField, + RWallFunctionFvPatchSymmTensorField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/RWallFunctions/RWallFunction/RWallFunctionFvPatchSymmTensorField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/RWallFunctions/RWallFunction/RWallFunctionFvPatchSymmTensorField.H new file mode 100644 index 000000000..b3e80232c --- /dev/null +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/RWallFunctions/RWallFunction/RWallFunctionFvPatchSymmTensorField.H @@ -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& + ); + + //- Construct from patch, internal field and dictionary + RWallFunctionFvPatchSymmTensorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // RWallFunctionFvPatchSymmTensorField + // onto a new patch + RWallFunctionFvPatchSymmTensorField + ( + const RWallFunctionFvPatchSymmTensorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + RWallFunctionFvPatchSymmTensorField + ( + const RWallFunctionFvPatchSymmTensorField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new RWallFunctionFvPatchSymmTensorField(*this) + ); + } + + //- Construct as copy setting internal field reference + RWallFunctionFvPatchSymmTensorField + ( + const RWallFunctionFvPatchSymmTensorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + 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 + +// ************************************************************************* //