diff --git a/src/turbulenceModels/LES/LESdeltas/Make/files b/src/turbulenceModels/LES/LESdeltas/Make/files index a2513976396a8c8fb805ad035ee327ccb0f15edf..b7d627cb48ec3127b8261575f2e3818019e0b33a 100644 --- a/src/turbulenceModels/LES/LESdeltas/Make/files +++ b/src/turbulenceModels/LES/LESdeltas/Make/files @@ -2,5 +2,6 @@ LESdelta/LESdelta.C cubeRootVolDelta/cubeRootVolDelta.C PrandtlDelta/PrandtlDelta.C smoothDelta/smoothDelta.C +maxhxhyhzDelta/maxhxhyhzDelta.C LIB = $(FOAM_LIBBIN)/libLESdeltas diff --git a/src/turbulenceModels/LES/LESdeltas/maxhxhyhzDelta/maxhxhyhzDelta.C b/src/turbulenceModels/LES/LESdeltas/maxhxhyhzDelta/maxhxhyhzDelta.C new file mode 100644 index 0000000000000000000000000000000000000000..0ba1d63b1aa42642dcadf10a0e81f86d734096c5 --- /dev/null +++ b/src/turbulenceModels/LES/LESdeltas/maxhxhyhzDelta/maxhxhyhzDelta.C @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 "maxhxhyhzDelta.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(maxhxhyhzDelta, 0); +addToRunTimeSelectionTable(LESdelta, maxhxhyhzDelta, dictionary); + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void maxhxhyhzDelta::calcDelta() +{ + label nD = mesh().nGeometricD(); + + tmp<volScalarField> hmax + ( + new volScalarField + ( + IOobject + ( + "hmax", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh(), + dimensionedScalar("zrero", dimLength, 0.0) + ) + ); + + const cellList& cells = mesh().cells(); + + forAll(cells,cellI) + { + scalar deltaMaxTmp = 0.0; + const labelList& cFaces = mesh().cells()[cellI]; + const point& centrevector = mesh().cellCentres()[cellI]; + + forAll(cFaces, cFaceI) + { + label faceI = cFaces[cFaceI]; + const point& facevector = mesh().faceCentres()[faceI]; + scalar tmp = mag(facevector - centrevector); + if (tmp > deltaMaxTmp) + { + deltaMaxTmp = tmp; + } + } + hmax()[cellI] = deltaCoeff_*deltaMaxTmp; + } + + if (nD == 3) + { + delta_.internalField() = hmax(); + } + else if (nD == 2) + { + WarningIn("maxhxhyhzDelta::calcDelta()") + << "Case is 2D, LES is not strictly applicable\n" + << endl; + + delta_.internalField() = hmax(); + } + else + { + FatalErrorIn("maxhxhyhzDelta::calcDelta()") + << "Case is not 3D or 2D, LES is not applicable" + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +maxhxhyhzDelta::maxhxhyhzDelta +( + const word& name, + const fvMesh& mesh, + const dictionary& dd +) +: + LESdelta(name, mesh), + deltaCoeff_(readScalar(dd.subDict(type() + "Coeffs").lookup("deltaCoeff"))) +{ + calcDelta(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void maxhxhyhzDelta::read(const dictionary& dd) +{ + dd.subDict(type() + "Coeffs").lookup("deltaCoeff") >> deltaCoeff_; + calcDelta(); +} + + +void maxhxhyhzDelta::correct() +{ + if (mesh_.changing()) + { + calcDelta(); + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/LES/LESdeltas/maxhxhyhzDelta/maxhxhyhzDelta.H b/src/turbulenceModels/LES/LESdeltas/maxhxhyhzDelta/maxhxhyhzDelta.H new file mode 100644 index 0000000000000000000000000000000000000000..30f26e6bd09ef902fe2f9dbc2f12ee6b3e307d78 --- /dev/null +++ b/src/turbulenceModels/LES/LESdeltas/maxhxhyhzDelta/maxhxhyhzDelta.H @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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::maxhxhyhzDelta + +Description + maxhxhyhzDelta takes the maximum of the three dimensions per cell: + max(hx, hy, hz). Valid for structures hexahedral cells only. + + +SourceFiles + maxhxhyhzDelta.C + +\*---------------------------------------------------------------------------*/ + +#ifndef maxhxhyhzDeltaDelta_H +#define maxhxhyhzDeltaDelta_H + +#include "LESdelta.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class maxhxhyhzDelta Declaration +\*---------------------------------------------------------------------------*/ + +class maxhxhyhzDelta +: + public LESdelta +{ + // Private data + + scalar deltaCoeff_; // + + + // Private Member Functions + + //- Disallow default bitwise copy construct and assignment + maxhxhyhzDelta(const maxhxhyhzDelta&); + void operator=(const maxhxhyhzDelta&); + + // Calculate the delta values + void calcDelta(); + + +public: + + //- Runtime type information + TypeName("maxhxhyhzDelta"); + + + // Constructors + + //- Construct from name, mesh and IOdictionary + maxhxhyhzDelta + ( + const word& name, + const fvMesh& mesh, + const dictionary& + ); + + + //- Destructor + virtual ~maxhxhyhzDelta() + {} + + + // Member Functions + + //- Read the LESdelta dictionary + virtual void read(const dictionary&); + + // Correct values + virtual void correct(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/LES/LESModel/LESModel.H b/src/turbulenceModels/incompressible/LES/LESModel/LESModel.H index eafb352fb2c9b501d2cba7e6caa96068a1f20b1a..9e6c8845ec842d28b9cf41e39888c052fe53a019 100644 --- a/src/turbulenceModels/incompressible/LES/LESModel/LESModel.H +++ b/src/turbulenceModels/incompressible/LES/LESModel/LESModel.H @@ -182,7 +182,7 @@ public: } //- Access function to filter width - inline const volScalarField& delta() const + virtual const volScalarField& delta() const { return delta_(); } diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C index a7de909e459c6dbe3fa88a46329fa189928ab14e..f1e008eab1ff54db60503f2399274300ffa2e65f 100644 --- a/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.C @@ -25,6 +25,7 @@ License #include "IDDESDelta.H" #include "addToRunTimeSelectionTable.H" +#include "wallDistReflection.H" #include "wallDist.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -42,25 +43,50 @@ void Foam::IDDESDelta::calcDelta() { label nD = mesh().nGeometricD(); - volScalarField delta + const volScalarField& hmax = hmax_(); + + // initialise wallNorm + wallDistReflection wallNorm(mesh()); + + const volVectorField& n = wallNorm.n(); + + tmp<volScalarField> faceToFacenMax ( - IOobject + new volScalarField ( - "delta", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar("zero", dimLength, SMALL), - calculatedFvPatchScalarField::typeName + IOobject + ( + "faceToFaceMax", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh(), + dimensionedScalar("zrero", dimLength, 0.0) + ) ); - delta.internalField() = pow(mesh_.V(), 1.0/3.0); + const cellList& cells = mesh().cells(); - // initialise hwn as wall distance - volScalarField hwn = wallDist(mesh()).y(); + forAll(cells,cellI) + { + scalar deltaMaxTmp = 0.0; + const labelList& cFaces = mesh().cells()[cellI]; + const point& faceCentre = mesh().faceCentres()[cFaces[0]]; + const vector nCell = n[cellI]; + forAll(cFaces, cFaceI) + { + label faceI = cFaces[cFaceI]; + const point& faceCentreTwo = mesh().faceCentres()[faceI]; + scalar tmp = (faceCentre - faceCentreTwo) & nCell; + if (tmp > deltaMaxTmp) + { + deltaMaxTmp = tmp; + } + } + faceToFacenMax()[cellI] = deltaMaxTmp; + } if (nD == 3) { @@ -68,8 +94,12 @@ void Foam::IDDESDelta::calcDelta() deltaCoeff_ *min ( - max(max(cw_*wallDist(mesh()).y(), cw_*delta), hwn), - delta + max + ( + max(cw_*wallDist(mesh()).y(), cw_*hmax), + faceToFacenMax() + ), + hmax ); } else if (nD == 2) @@ -82,8 +112,8 @@ void Foam::IDDESDelta::calcDelta() deltaCoeff_ *min ( - max(max(cw_*wallDist(mesh()).y(), cw_*delta), hwn), - delta + max(max(cw_*wallDist(mesh()).y(), cw_*hmax), faceToFacenMax()), + hmax ); } else @@ -105,8 +135,12 @@ Foam::IDDESDelta::IDDESDelta ) : LESdelta(name, mesh), - deltaCoeff_(readScalar(dd.subDict(type() + "Coeffs").lookup("deltaCoeff"))), - cw_(0) + hmax_(LESdelta::New("hmax", mesh, dd.parent())), + deltaCoeff_ + ( + readScalar(dd.subDict(type()+"Coeffs").lookup("deltaCoeff")) + ), + cw_(0.15) { dd.subDict(type() + "Coeffs").readIfPresent("cw", cw_); calcDelta(); @@ -127,6 +161,7 @@ void Foam::IDDESDelta::correct() if (mesh_.changing()) { calcDelta(); + hmax_().correct(); } } diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.H b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.H index e738f6740cbcccb2e59f5e87d04b71a93362d6fc..8f74dbacc937824adab27b5024444366b3c4884a 100644 --- a/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.H +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/IDDESDelta/IDDESDelta.H @@ -54,6 +54,7 @@ class IDDESDelta { // Private data + autoPtr<LESdelta> hmax_; scalar deltaCoeff_; scalar cw_; @@ -85,9 +86,10 @@ public: ); - //- Destructor - ~IDDESDelta() - {} + // Destructor + + ~IDDESDelta() + {} // Member Functions diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C index 50ea893c03b7d0695b9d933542929327f9bbf67c..e06b1d2615a36dbb7aa6b307079844cb7f2c65d6 100644 --- a/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.C @@ -44,26 +44,9 @@ addToRunTimeSelectionTable(LESModel, SpalartAllmarasIDDES, dictionary); tmp<volScalarField> SpalartAllmarasIDDES::alpha() const { - volScalarField delta - ( - IOobject - ( - "delta", - mesh_.time().timeName(), - mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh_, - dimensionedScalar("zero", dimLength, SMALL), - calculatedFvPatchScalarField::typeName - ); - - delta.internalField() = pow(mesh_.V(), 1.0/3.0); - return max ( - 0.25 - y_/delta, + 0.25 - y_/static_cast<const volScalarField&>(hmax_()), scalar(-5) ); } @@ -166,7 +149,24 @@ SpalartAllmarasIDDES::SpalartAllmarasIDDES ) : SpalartAllmaras(U, phi, transport, turbulenceModelName, modelName), - + hmax_ + ( + LESdelta::New + ( + "hmax", + mesh_, + *this + ) + ), + IDDESDelta_ + ( + LESdelta::New + ( + "IDDESDelta", + mesh_, + this->subDict(typeName + "Coeffs") + ) + ), fwStar_ ( dimensioned<scalar>::lookupOrAddToDict diff --git a/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H index 832b4947c5504d05460fb8a5ae34cd5290434f38..80b13e1ec087852e42155788a861b2e0d0b9f41b 100644 --- a/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H +++ b/src/turbulenceModels/incompressible/LES/SpalartAllmarasIDDES/SpalartAllmarasIDDES.H @@ -58,6 +58,8 @@ class SpalartAllmarasIDDES // Model constants + autoPtr<LESdelta> hmax_; + autoPtr<LESdelta> IDDESDelta_; dimensionedScalar fwStar_; dimensionedScalar cl_; dimensionedScalar ct_; @@ -117,6 +119,12 @@ public: // Member Functions + //- Access function to filter width + virtual const volScalarField& delta() const + { + return IDDESDelta_(); + } + //- Read LESProperties dictionary virtual bool read(); };