From d9535b4b35baf3481fa137ca9512e0916411d1f6 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 27 Aug 2008 11:12:57 +0100 Subject: [PATCH 01/44] removing old lock file --- .../checkIncompressibleTurbulenceModelsLock.C | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 src/turbulenceModels/RAS/incompressible/RASModel/checkIncompressibleTurbulenceModelsLock.C diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/checkIncompressibleTurbulenceModelsLock.C b/src/turbulenceModels/RAS/incompressible/RASModel/checkIncompressibleTurbulenceModelsLock.C deleted file mode 100644 index 60909d1891..0000000000 --- a/src/turbulenceModels/RAS/incompressible/RASModel/checkIncompressibleTurbulenceModelsLock.C +++ /dev/null @@ -1,39 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 "checkLock.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - globalCheckLock incompressibleTurbulenceModelsLock - ( - "incompressibleTurbulenceModels" - ); -} - -// ************************************************************************* // From 1dc35beb58cae7e6d75cb54ac7b40377ab3e3a7b Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 27 Aug 2008 11:13:57 +0100 Subject: [PATCH 02/44] added manipulateMatrix function --- .../fields/fvPatchFields/fvPatchField/fvPatchField.C | 8 ++++++++ .../fields/fvPatchFields/fvPatchField/fvPatchField.H | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C index 188e950b6d..90741d5843 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C @@ -28,6 +28,7 @@ License #include "dictionary.H" #include "fvMesh.H" #include "fvPatchFieldMapper.H" +//#include "fvMatrices.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -223,6 +224,13 @@ void Foam::fvPatchField::evaluate(const Pstream::commsTypes) } +template +void Foam::fvPatchField::manipulateMatrix(fvMatrix& matrix) +{ + // do nothing +} + + template void Foam::fvPatchField::write(Ostream& os) const { diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H index 90cdb04a20..40fd3ff818 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H @@ -27,12 +27,12 @@ Class Description Abstract base class with a fat-interface to all derived classes - covering all possible ways in which they might be used. + covering all possible ways in which they might be used. The first level of derivation is to basic patchFields which cover zero-gradient, fixed-gradient, fixed-value and mixed conditions. - The next level of derivation covers all the specialised typed with + The next level of derivation covers all the specialised types with specific evaluation proceedures, particularly with respect to specific fields. @@ -66,6 +66,9 @@ class volMesh; template class fvPatchField; +template +class fvMatrix; + template Ostream& operator<<(Ostream&, const fvPatchField&); @@ -407,6 +410,10 @@ public: } + //- Manipulate matrix + virtual void manipulateMatrix(fvMatrix& matrix); + + //- Write virtual void write(Ostream&) const; From 2b614594ed9f2e5e117121e58c1888c46ff848a7 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 27 Aug 2008 11:14:21 +0100 Subject: [PATCH 03/44] added boundaryManipulate function --- .../fvMatrices/fvMatrix/fvMatrix.C | 24 +++++++++++++++---- .../fvMatrices/fvMatrix/fvMatrix.H | 9 ++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index f78213e1d9..86783eae2d 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -456,10 +456,10 @@ void Foam::fvMatrix::setValues if (internalCoeffs_[patchi].size()) { - label patchFacei = + label patchFacei = mesh.boundaryMesh()[patchi].whichFace(facei); - internalCoeffs_[patchi][patchFacei] = + internalCoeffs_[patchi][patchFacei] = pTraits::zero; boundaryCoeffs_[patchi][patchFacei] = @@ -591,6 +591,20 @@ void Foam::fvMatrix::relax() } +template +void Foam::fvMatrix::boundaryManipulate +( + typename GeometricField:: + GeometricBoundaryField& bFields +) +{ + forAll(bFields, patchI) + { + bFields[patchI].manipulateMatrix(*this); + } +} + + template Foam::tmp Foam::fvMatrix::D() const { @@ -653,7 +667,7 @@ Foam::tmp Foam::fvMatrix::A() const template -Foam::tmp > +Foam::tmp > Foam::fvMatrix::H() const { tmp > tHphi @@ -838,7 +852,7 @@ flux() const forAll(fieldFlux.boundaryField(), patchI) { - fieldFlux.boundaryField()[patchI] = + fieldFlux.boundaryField()[patchI] = InternalContrib[patchI] - NeighbourContrib[patchI]; } @@ -1255,7 +1269,7 @@ Foam::lduMatrix::solverPerformance Foam::solve Istream& solverControls ) { - lduMatrix::solverPerformance solverPerf = + lduMatrix::solverPerformance solverPerf = const_cast&>(tfvm()).solve(solverControls); tfvm.clear(); diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index f9c82a2d58..c40fa4b47e 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -350,6 +350,13 @@ public: // alpha is read from controlDict void relax(); + //- Manipulate based on a boundary field + void boundaryManipulate + ( + typename GeometricField:: + GeometricBoundaryField& values + ); + //- Construct and return the solver // Solver controls read from Istream autoPtr solver(Istream&); @@ -386,7 +393,7 @@ public: //- Return the face-flux field from the matrix tmp > - flux() const; + flux() const; // Member operators From 4e9ad300a7a46ed54276fff7ed704dc5c8de745e Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 27 Aug 2008 11:20:13 +0100 Subject: [PATCH 04/44] moving old nut wall functions --- ...ndardRoughWallFunctionFvPatchScalarField.C | 300 ------------------ ...ndardRoughWallFunctionFvPatchScalarField.H | 200 ------------ ...utStandardWallFunctionFvPatchScalarField.C | 169 ---------- ...utStandardWallFunctionFvPatchScalarField.H | 151 --------- .../nutWallFunctionFvPatchScalarField.C | 173 ---------- .../nutWallFunctionFvPatchScalarField.H | 151 --------- 6 files changed, 1144 deletions(-) delete mode 100644 src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.C delete mode 100644 src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.H delete mode 100644 src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.C delete mode 100644 src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.H delete mode 100644 src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C delete mode 100644 src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.C deleted file mode 100644 index cf74e31813..0000000000 --- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.C +++ /dev/null @@ -1,300 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 "nutStandardRoughWallFunctionFvPatchScalarField.H" -#include "RASModel.H" -#include "fvPatchFieldMapper.H" -#include "volFields.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace incompressible -{ -namespace RASModels -{ - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -nutStandardRoughWallFunctionFvPatchScalarField:: -nutStandardRoughWallFunctionFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(p, iF), - roughnessHeight_(pTraits::zero), - roughnessConstant_(pTraits::zero), - roughnessFudgeFactor_(pTraits::zero) -{} - - -nutStandardRoughWallFunctionFvPatchScalarField:: -nutStandardRoughWallFunctionFvPatchScalarField -( - const nutStandardRoughWallFunctionFvPatchScalarField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedValueFvPatchScalarField(ptf, p, iF, mapper), - roughnessHeight_(ptf.roughnessHeight_), - roughnessConstant_(ptf.roughnessConstant_), - roughnessFudgeFactor_(ptf.roughnessFudgeFactor_) -{} - - -nutStandardRoughWallFunctionFvPatchScalarField:: -nutStandardRoughWallFunctionFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedValueFvPatchScalarField(p, iF, dict), - roughnessHeight_(readScalar(dict.lookup("roughnessHeight"))), - roughnessConstant_(readScalar(dict.lookup("roughnessConstant"))), - roughnessFudgeFactor_(readScalar(dict.lookup("roughnessFudgeFactor"))) -{} - - -nutStandardRoughWallFunctionFvPatchScalarField:: -nutStandardRoughWallFunctionFvPatchScalarField -( - const nutStandardRoughWallFunctionFvPatchScalarField& tppsf -) -: - fixedValueFvPatchScalarField(tppsf), - roughnessHeight_(tppsf.roughnessHeight_), - roughnessConstant_(tppsf.roughnessConstant_), - roughnessFudgeFactor_(tppsf.roughnessFudgeFactor_) -{} - - -nutStandardRoughWallFunctionFvPatchScalarField:: -nutStandardRoughWallFunctionFvPatchScalarField -( - const nutStandardRoughWallFunctionFvPatchScalarField& tppsf, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(tppsf, iF), - roughnessHeight_(tppsf.roughnessHeight_), - roughnessConstant_(tppsf.roughnessConstant_), - roughnessFudgeFactor_(tppsf.roughnessFudgeFactor_) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void nutStandardRoughWallFunctionFvPatchScalarField::evaluate -( - const Pstream::commsTypes -) -{ - const RASModel& rasModel - = db().lookupObject("RASProperties"); - - const scalar kappa = rasModel.kappa().value(); - const scalar E = rasModel.E().value(); - const scalar yPlusLam = 11.225; - - // The reciprical of the distance to the adjacent cell centre. - const scalarField& ry = patch().deltaCoeffs(); - - const fvPatchVectorField& U = - patch().lookupPatchField("U"); - - // The flow velocity at the adjacent cell centre. - scalarField magUp = mag(U.patchInternalField() - U); - - const scalarField& nuw = - patch().lookupPatchField("nu"); - scalarField& nutw = *this; - - scalarField magFaceGradU = mag(U.snGrad()); - - if(roughnessHeight_ > 0.0) - { - // Rough Walls. - const scalar c_1 = 1/(90 - 2.25) + roughnessConstant_; - static const scalar c_2 = 2.25/(90 - 2.25); - static const scalar c_3 = 2.0*atan(1.0)/log(90/2.25); - static const scalar c_4 = c_3*log(2.25); - - //if (KsPlusBasedOnYPlus_) - { - // If KsPlus is based on YPlus the extra term added to the law - // of the wall will depend on yPlus. - forAll(nutw, facei) - { - const scalar magUpara = magUp[facei]; - const scalar Re = magUpara/(nuw[facei]*ry[facei]); - const scalar kappaRe = kappa*Re; - - scalar yPlus = yPlusLam; - const scalar ryPlusLam = 1.0/yPlus; - - int iter = 0; - scalar yPlusLast = 0.0; - scalar dKsPlusdYPlus = roughnessHeight_*ry[facei]; - - // Enforce the roughnessHeight to be less than the distance to - // the first cell centre. - if(dKsPlusdYPlus > 1) - { - dKsPlusdYPlus = 1; - } - - // Fudge factor to get results to be similar to fluent - // (at least difference between rough and smooth). - dKsPlusdYPlus *= roughnessFudgeFactor_; - - do - { - yPlusLast = yPlus; - - // The non-dimensional roughness height. - scalar KsPlus = yPlus*dKsPlusdYPlus; - - // The extra term in the law-of-the-wall. - scalar G = 0.0; - - scalar yPlusGPrime = 0.0; - - if (KsPlus >= 90) - { - const scalar t_1 = 1 + roughnessConstant_*KsPlus; - G = log(t_1); - yPlusGPrime = roughnessConstant_*KsPlus/t_1; - } - else if (KsPlus > 2.25) - { - const scalar t_1 = c_1*KsPlus - c_2; - const scalar t_2 = c_3*log(KsPlus) - c_4; - const scalar sint_2 = sin(t_2); - const scalar logt_1 = log(t_1); - G = logt_1*sint_2; - yPlusGPrime = - (c_1*sint_2*KsPlus/t_1) + (c_3*logt_1*cos(t_2)); - } - - scalar denom = 1.0 + log(E* yPlus) - G - yPlusGPrime; - if(mag(denom) > VSMALL) - { - yPlus = (kappaRe + yPlus*(1 - yPlusGPrime))/denom; - } - else - { - // Ensure immediate end and nutw = 0. - yPlus = 0; - } - - } while - ( - mag(ryPlusLam*(yPlus - yPlusLast)) > 0.0001 - && ++iter < 10 - && yPlus > VSMALL - ); - - if (yPlus > yPlusLam) - { - nutw[facei] = nuw[facei]*(yPlus*yPlus/Re - 1); - } - else - { - nutw[facei] = 0.0; - } - } - } - } - else - { - // Smooth Walls. - forAll(nutw, facei) - { - const scalar magUpara = magUp[facei]; - const scalar Re = magUpara/(nuw[facei]*ry[facei]); - const scalar kappaRe = kappa*Re; - - scalar yPlus = yPlusLam; - const scalar ryPlusLam = 1.0/yPlus; - - int iter = 0; - scalar yPlusLast = 0.0; - - do - { - yPlusLast = yPlus; - yPlus = (kappaRe + yPlus)/(1.0 + log(E*yPlus)); - - } while(mag(ryPlusLam*(yPlus - yPlusLast)) > 0.0001 && ++iter < 10); - - if (yPlus > yPlusLam) - { - nutw[facei] = nuw[facei]*(yPlus*yPlus/Re - 1); - } - else - { - nutw[facei] = 0.0; - } - } - } -} - - -void nutStandardRoughWallFunctionFvPatchScalarField::write(Ostream& os) const -{ - fixedValueFvPatchScalarField::write(os); - os.writeKeyword("roughnessHeight") - << roughnessHeight_ << token::END_STATEMENT << nl; - os.writeKeyword("roughnessConstant") - << roughnessConstant_ << token::END_STATEMENT << nl; - os.writeKeyword("roughnessFudgeFactor") - << roughnessFudgeFactor_ << token::END_STATEMENT << nl; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makePatchTypeField -( - fvPatchScalarField, - nutStandardRoughWallFunctionFvPatchScalarField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace RASModels -} // End namespace incompressible -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.H deleted file mode 100644 index df3007b10f..0000000000 --- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.H +++ /dev/null @@ -1,200 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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::nutStandardRoughWallFunctionFvPatchScalarField - -Description - Wall function boundary condition for rough walls - -SourceFiles - nutStandardWallFunctionFvPatchScalarField.C - -\*---------------------------------------------------------------------------*/ - -#ifndef nutStandardRoughWallFunctionFvPatchScalarField_H -#define nutStandardRoughWallFunctionFvPatchScalarField_H - -#include "fixedValueFvPatchFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace incompressible -{ -namespace RASModels -{ - -/*---------------------------------------------------------------------------*\ - Class nutWallFunctionFvPatch Declaration -\*---------------------------------------------------------------------------*/ - -class nutStandardRoughWallFunctionFvPatchScalarField -: - public fixedValueFvPatchScalarField -{ - // Private data - - scalar roughnessHeight_; - scalar roughnessConstant_; - scalar roughnessFudgeFactor_; - - -public: - - //- Runtime type information - TypeName("nutStandardRoughWallFunction"); - - - // Constructors - - //- Construct from patch and internal field - nutStandardRoughWallFunctionFvPatchScalarField - ( - const fvPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - nutStandardRoughWallFunctionFvPatchScalarField - ( - const fvPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given - // nutStandardRoughWallFunctionFvPatchScalarField - // onto a new patch - nutStandardRoughWallFunctionFvPatchScalarField - ( - const nutStandardRoughWallFunctionFvPatchScalarField&, - const fvPatch&, - const DimensionedField&, - const fvPatchFieldMapper& - ); - - //- Construct as copy - nutStandardRoughWallFunctionFvPatchScalarField - ( - const nutStandardRoughWallFunctionFvPatchScalarField& - ); - - //- Construct and return a clone - virtual tmp clone() const - { - return tmp - ( - new nutStandardRoughWallFunctionFvPatchScalarField(*this) - ); - } - - //- Construct as copy setting internal field reference - nutStandardRoughWallFunctionFvPatchScalarField - ( - const nutStandardRoughWallFunctionFvPatchScalarField&, - const DimensionedField& - ); - - //- Construct and return a clone setting internal field reference - virtual tmp clone - ( - const DimensionedField& iF - ) const - { - return tmp - ( - new nutStandardRoughWallFunctionFvPatchScalarField(*this, iF) - ); - } - - - // Member functions - - // Access - - //- Return the fluctuation scale - const scalar& roughnessHeight() const - { - return roughnessHeight_; - } - - //- Return reference to the fluctuation scale to allow adjustment - scalar& roughnessHeight() - { - return roughnessHeight_; - } - - - //- Return the fluctuation scale - const scalar& roughnessConstant() const - { - return roughnessConstant_; - } - - //- Return reference to the fluctuation scale to allow adjustment - scalar& roughnessConstant() - { - return roughnessConstant_; - } - - //- Return the fluctuation scale - const scalar& roughnessFudgeFactor() const - { - return roughnessFudgeFactor_; - } - - //- Return reference to the fluctuation scale to allow adjustment - scalar& roughnessFudgeFactor() - { - return roughnessFudgeFactor_; - } - - - // Evaluation functions - - //- Evaluate the patchField - virtual void evaluate - ( - const Pstream::commsTypes commsType=Pstream::blocking - ); - - - //- Write - virtual void write(Ostream& os) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace RASModels -} // End namespace incompressible -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.C deleted file mode 100644 index ddbb424255..0000000000 --- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.C +++ /dev/null @@ -1,169 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 "nutStandardWallFunctionFvPatchScalarField.H" -#include "RASModel.H" -#include "fvPatchFieldMapper.H" -#include "volFields.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace incompressible -{ -namespace RASModels -{ - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -nutStandardWallFunctionFvPatchScalarField:: -nutStandardWallFunctionFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(p, iF) -{} - - -nutStandardWallFunctionFvPatchScalarField:: -nutStandardWallFunctionFvPatchScalarField -( - const nutStandardWallFunctionFvPatchScalarField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedValueFvPatchScalarField(ptf, p, iF, mapper) -{} - - -nutStandardWallFunctionFvPatchScalarField:: -nutStandardWallFunctionFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedValueFvPatchScalarField(p, iF, dict) -{} - - -nutStandardWallFunctionFvPatchScalarField:: -nutStandardWallFunctionFvPatchScalarField -( - const nutStandardWallFunctionFvPatchScalarField& tppsf -) -: - fixedValueFvPatchScalarField(tppsf) -{} - - -nutStandardWallFunctionFvPatchScalarField:: -nutStandardWallFunctionFvPatchScalarField -( - const nutStandardWallFunctionFvPatchScalarField& tppsf, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(tppsf, iF) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void nutStandardWallFunctionFvPatchScalarField::evaluate -( - const Pstream::commsTypes -) -{ - const RASModel& rasModel - = db().lookupObject("RASProperties"); - - scalar kappa = rasModel.kappa().value(); - scalar E = rasModel.E().value(); - scalar yPlusLam = rasModel.yPlusLam(); - - const scalarField& ry = patch().deltaCoeffs(); - - const fvPatchVectorField& U = - patch().lookupPatchField("U"); - - scalarField magUp = mag(U.patchInternalField() - U); - - const scalarField& nuw = - patch().lookupPatchField("nu"); - scalarField& nutw = *this; - - scalarField magFaceGradU = mag(U.snGrad()); - - forAll(nutw, facei) - { - scalar magUpara = magUp[facei]; - - scalar kappaRe = kappa*magUpara/(nuw[facei]*ry[facei]); - - scalar yPlus = yPlusLam; - scalar ryPlusLam = 1.0/yPlus; - - int iter = 0; - scalar yPlusLast = 0.0; - - do - { - yPlusLast = yPlus; - yPlus = (kappaRe + yPlus)/(1.0 + log(E*yPlus)); - - } while(mag(ryPlusLam*(yPlus - yPlusLast)) > 0.01 && ++iter < 10 ); - - if (yPlus > yPlusLam) - { - nutw[facei] = nuw[facei]*(yPlus*kappa/log(E*yPlus) - 1); - } - else - { - nutw[facei] = 0.0; - } - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makePatchTypeField(fvPatchScalarField, nutStandardWallFunctionFvPatchScalarField); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace RASModels -} // End namespace incompressible -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.H deleted file mode 100644 index f4042e7f5f..0000000000 --- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.H +++ /dev/null @@ -1,151 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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::nutStandardWallFunctionFvPatchScalarField - -Description - Wall function boundary condition for walls - -SourceFiles - nutStandardWallFunctionFvPatchScalarField.C - -\*---------------------------------------------------------------------------*/ - -#ifndef nutStandardWallFunctionFvPatchScalarField_H -#define nutStandardWallFunctionFvPatchScalarField_H - -#include "fixedValueFvPatchFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace incompressible -{ -namespace RASModels -{ - -/*---------------------------------------------------------------------------*\ - Class nutWallFunctionFvPatch Declaration -\*---------------------------------------------------------------------------*/ - -class nutStandardWallFunctionFvPatchScalarField -: - public fixedValueFvPatchScalarField -{ - // Private data - - -public: - - //- Runtime type information - TypeName("nutStandardWallFunction"); - - - // Constructors - - //- Construct from patch and internal field - nutStandardWallFunctionFvPatchScalarField - ( - const fvPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - nutStandardWallFunctionFvPatchScalarField - ( - const fvPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given nutStandardWallFunctionFvPatchScalarField - // onto a new patch - nutStandardWallFunctionFvPatchScalarField - ( - const nutStandardWallFunctionFvPatchScalarField&, - const fvPatch&, - const DimensionedField&, - const fvPatchFieldMapper& - ); - - //- Construct as copy - nutStandardWallFunctionFvPatchScalarField - ( - const nutStandardWallFunctionFvPatchScalarField& - ); - - //- Construct and return a clone - virtual tmp clone() const - { - return tmp - ( - new nutStandardWallFunctionFvPatchScalarField(*this) - ); - } - - //- Construct as copy setting internal field reference - nutStandardWallFunctionFvPatchScalarField - ( - const nutStandardWallFunctionFvPatchScalarField&, - const DimensionedField& - ); - - //- Construct and return a clone setting internal field reference - virtual tmp clone - ( - const DimensionedField& iF - ) const - { - return tmp - ( - new nutStandardWallFunctionFvPatchScalarField(*this, iF) - ); - } - - - // Member functions - - // Evaluation functions - - //- Evaluate the patchField - virtual void evaluate - ( - const Pstream::commsTypes commsType=Pstream::blocking - ); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace RASModels -} // End namespace incompressible -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C deleted file mode 100644 index 2fab6a7429..0000000000 --- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C +++ /dev/null @@ -1,173 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 "nutWallFunctionFvPatchScalarField.H" -#include "RASModel.H" -#include "fvPatchFieldMapper.H" -#include "volFields.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace incompressible -{ -namespace RASModels -{ - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(p, iF) -{} - - -nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField -( - const nutWallFunctionFvPatchScalarField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedValueFvPatchScalarField(ptf, p, iF, mapper) -{} - - -nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedValueFvPatchScalarField(p, iF, dict) -{} - - -nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField -( - const nutWallFunctionFvPatchScalarField& tppsf -) -: - fixedValueFvPatchScalarField(tppsf) -{} - - -nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField -( - const nutWallFunctionFvPatchScalarField& tppsf, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(tppsf, iF) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void nutWallFunctionFvPatchScalarField::evaluate(const Pstream::commsTypes) -{ - const RASModel& rasModel - = db().lookupObject("RASProperties"); - - scalar kappa = rasModel.kappa().value(); - scalar E = rasModel.E().value(); - - const scalarField& ry = patch().deltaCoeffs(); - - const fvPatchVectorField& U = - patch().lookupPatchField("U"); - - scalarField magUp = mag(U.patchInternalField() - U); - - const scalarField& nuw = - patch().lookupPatchField("nu"); - - scalarField& nutw = *this; - - scalarField magFaceGradU = mag(U.snGrad()); - - forAll(nutw, facei) - { - scalar magUpara = magUp[facei]; - - scalar utau = sqrt((nutw[facei] + nuw[facei])*magFaceGradU[facei]); - - if (utau > VSMALL) - { - int iter = 0; - scalar err = GREAT; - - do - { - scalar kUu = min(kappa*magUpara/utau, 50); - scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu); - - scalar f = - - utau/(ry[facei]*nuw[facei]) - + magUpara/utau - + 1/E*(fkUu - 1.0/6.0*kUu*sqr(kUu)); - - scalar df = - 1.0/(ry[facei]*nuw[facei]) - + magUpara/sqr(utau) - + 1/E*kUu*fkUu/utau; - - scalar utauNew = utau + f/df; - err = mag((utau - utauNew)/utau); - utau = utauNew; - - } while (utau > VSMALL && err > 0.01 && ++iter < 10); - - nutw[facei] = - max(sqr(max(utau, 0))/magFaceGradU[facei] - nuw[facei], 0.0); - } - else - { - nutw[facei] = 0; - } - } -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makePatchTypeField(fvPatchScalarField, nutWallFunctionFvPatchScalarField); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace RASModels -} // End namespace incompressible -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H deleted file mode 100644 index 218599b59c..0000000000 --- a/src/turbulenceModels/RAS/incompressible/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H +++ /dev/null @@ -1,151 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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::nutWallFunctionFvPatchScalarField - -Description - Wall function boundary condition for walls - -SourceFiles - nutWallFunctionFvPatchScalarField.C - -\*---------------------------------------------------------------------------*/ - -#ifndef nutWallFunctionFvPatchScalarField_H -#define nutWallFunctionFvPatchScalarField_H - -#include "fixedValueFvPatchFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace incompressible -{ -namespace RASModels -{ - -/*---------------------------------------------------------------------------*\ - Class nutWallFunctionFvPatch Declaration -\*---------------------------------------------------------------------------*/ - -class nutWallFunctionFvPatchScalarField -: - public fixedValueFvPatchScalarField -{ - // Private data - - -public: - - //- Runtime type information - TypeName("nutWallFunction"); - - - // Constructors - - //- Construct from patch and internal field - nutWallFunctionFvPatchScalarField - ( - const fvPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - nutWallFunctionFvPatchScalarField - ( - const fvPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given nutWallFunctionFvPatchScalarField - // onto a new patch - nutWallFunctionFvPatchScalarField - ( - const nutWallFunctionFvPatchScalarField&, - const fvPatch&, - const DimensionedField&, - const fvPatchFieldMapper& - ); - - //- Construct as copy - nutWallFunctionFvPatchScalarField - ( - const nutWallFunctionFvPatchScalarField& - ); - - //- Construct and return a clone - virtual tmp clone() const - { - return tmp - ( - new nutWallFunctionFvPatchScalarField(*this) - ); - } - - //- Construct as copy setting internal field reference - nutWallFunctionFvPatchScalarField - ( - const nutWallFunctionFvPatchScalarField&, - const DimensionedField& - ); - - //- Construct and return a clone setting internal field reference - virtual tmp clone - ( - const DimensionedField& iF - ) const - { - return tmp - ( - new nutWallFunctionFvPatchScalarField(*this, iF) - ); - } - - - // Member functions - - // Evaluation functions - - //- Evaluate the patchField - virtual void evaluate - ( - const Pstream::commsTypes commsType=Pstream::blocking - ); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace RASModels -} // End namespace incompressible -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // From ada4bd4fa57f331ea5f09246c9be768d8b36a23f Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 27 Aug 2008 17:11:38 +0100 Subject: [PATCH 05/44] adding new wall function methods --- .../RAS/incompressible/LRR/LRR.C | 26 +- .../LaunderGibsonRSTM/LaunderGibsonRSTM.C | 27 +- .../RAS/incompressible/Make/files | 16 +- .../RAS/incompressible/RASModel/RASModel.C | 14 +- .../RAS/incompressible/RASModel/RASModel.H | 22 +- .../incompressible/RNGkEpsilon/RNGkEpsilon.C | 27 +- .../epsilonWallFunctionFvPatchScalarField.C | 209 ++++++++++++ .../epsilonWallFunctionFvPatchScalarField.H | 162 ++++++++++ .../fixedInternalValueFvPatchField.C | 184 +++++++++++ .../fixedInternalValueFvPatchField.H | 174 ++++++++++ .../fixedInternalValueFvPatchFields.C | 45 +++ .../fixedInternalValueFvPatchFields.H | 50 +++ .../kWallFunctionFvPatchScalarField.C | 155 +++++++++ .../kWallFunctionFvPatchScalarField.H | 161 ++++++++++ .../nutRoughWallFunctionFvPatchScalarField.C | 204 ++++++++++++ .../nutRoughWallFunctionFvPatchScalarField.H | 167 ++++++++++ ...ndardRoughWallFunctionFvPatchScalarField.C | 302 ++++++++++++++++++ ...ndardRoughWallFunctionFvPatchScalarField.H | 208 ++++++++++++ ...asStandardWallFunctionFvPatchScalarField.C | 172 ++++++++++ ...asStandardWallFunctionFvPatchScalarField.H | 160 ++++++++++ ...rtAllmarasWallFunctionFvPatchScalarField.C | 180 +++++++++++ ...rtAllmarasWallFunctionFvPatchScalarField.H | 153 +++++++++ .../nutWallFunctionFvPatchScalarField.C | 157 +++++++++ .../nutWallFunctionFvPatchScalarField.H | 154 +++++++++ .../omegaWallFunctionFvPatchScalarField.C | 200 ++++++++++++ .../omegaWallFunctionFvPatchScalarField.H | 159 +++++++++ .../RAS/incompressible/kEpsilon/kEpsilon.C | 27 +- .../RAS/incompressible/kOmegaSST/kOmegaSST.C | 33 +- .../realizableKE/realizableKE.C | 28 +- 29 files changed, 3522 insertions(+), 54 deletions(-) create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H diff --git a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C index 45384f3612..6a6aad2333 100644 --- a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C +++ b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C @@ -175,9 +175,21 @@ LRR::LRR mesh_ ), - nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_)) + nut_ + ( + IOobject + ( + "nut", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) { -# include "wallViscosityI.H" + nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_.correctBoundaryConditions(); if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) { @@ -289,9 +301,10 @@ void LRR::correct() RASModel::correct(); volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_)); - volScalarField G = 0.5*tr(P); + volScalarField G("G", 0.5*tr(P)); -# include "wallFunctionsI.H" + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); // Dissipation equation tmp epsEqn @@ -307,7 +320,7 @@ void LRR::correct() epsEqn().relax(); -# include "wallDissipationI.H" + epsEqn().boundaryManipulate(epsilon_.boundaryField()); solve(epsEqn); bound(epsilon_, epsilon0_); @@ -370,8 +383,7 @@ void LRR::correct() // Re-calculate viscosity nut_ = Cmu_*sqr(k_)/epsilon_; - -# include "wallViscosityI.H" + nut_.correctBoundaryConditions(); // Correct wall shear stresses diff --git a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C index 47d7773c85..d45af4201f 100644 --- a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -204,9 +204,21 @@ LaunderGibsonRSTM::LaunderGibsonRSTM mesh_ ), - nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_)) + nut_ + ( + IOobject + ( + "nut", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) { -# include "wallViscosityI.H" + nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_.correctBoundaryConditions(); if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) { @@ -321,9 +333,10 @@ void LaunderGibsonRSTM::correct() } volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_)); - volScalarField G = 0.5*tr(P); + volScalarField G("G", 0.5*tr(P)); -# include "wallFunctionsI.H" + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); // Dissipation equation tmp epsEqn @@ -339,7 +352,7 @@ void LaunderGibsonRSTM::correct() epsEqn().relax(); -# include "wallDissipationI.H" + epsEqn().boundaryManipulate(epsilon_.boundaryField()); solve(epsEqn); bound(epsilon_, epsilon0_); @@ -411,9 +424,7 @@ void LaunderGibsonRSTM::correct() // Re-calculate turbulent viscosity nut_ = Cmu_*sqr(k_)/epsilon_; - - -# include "wallViscosityI.H" + nut_.correctBoundaryConditions(); // Correct wall shear stresses diff --git a/src/turbulenceModels/RAS/incompressible/Make/files b/src/turbulenceModels/RAS/incompressible/Make/files index c7746e7fd2..991c22d26b 100644 --- a/src/turbulenceModels/RAS/incompressible/Make/files +++ b/src/turbulenceModels/RAS/incompressible/Make/files @@ -18,9 +18,19 @@ LienLeschzinerLowRe/LienLeschzinerLowRe.C LamBremhorstKE/LamBremhorstKE.C /* Wall functions */ -wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C -wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFvPatchScalarField.C -wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.C +derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C +derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C + +derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C +derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C + +derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C + +derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C + +derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.C + /* Patch fields */ derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C index b33dcb752f..ec41fae3aa 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C @@ -82,13 +82,14 @@ RASModel::RASModel turbulence_(lookup("turbulence")), printCoeffs_(lookupOrDefault("printCoeffs", false)), coeffDict_(subDict(type + "Coeffs")), + wallFunctionDict_(subDict("wallFunctionCoeffs")), kappa_ ( dimensioned::lookupOrAddToDict ( "kappa", - subDict("wallFunctionCoeffs"), + wallFunctionDict_, 0.4187 ) ), @@ -97,10 +98,19 @@ RASModel::RASModel dimensioned::lookupOrAddToDict ( "E", - subDict("wallFunctionCoeffs"), + wallFunctionDict_, 9.0 ) ), + Cmu_ + ( + dimensioned::lookupOrAddToDict + ( + "Cmu", + wallFunctionDict_, + 0.09 + ) + ), yPlusLam_(yPlusLam(kappa_.value(), E_.value())), diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H index 345565fbab..21220f2e3a 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H @@ -88,8 +88,10 @@ protected: Switch printCoeffs_; dictionary coeffDict_; + dictionary wallFunctionDict_; dimensionedScalar kappa_; dimensionedScalar E_; + dimensionedScalar Cmu_; scalar yPlusLam(const scalar kappa, const scalar E); scalar yPlusLam_; @@ -192,7 +194,6 @@ public: return epsilonSmall_; } - //- Allow k0 to be changed dimensionedScalar& k0() { @@ -211,7 +212,6 @@ public: return epsilonSmall_; } - //- Return kappa for use in wall-functions dimensionedScalar kappa() const { @@ -224,6 +224,18 @@ public: return E_; } + //- Return Cmu for use in wall-functions + dimensionedScalar Cmu() const + { + return Cmu_; + } + + //- Return the near wall distances + const nearWallDist& y() const + { + return y_; + } + //- Return y+ at the edge of the laminar sublayer // for use in wall-functions scalar yPlusLam() const @@ -237,6 +249,12 @@ public: return coeffDict_; } + //- Const access to the wall functions coefficients dictionary + const dictionary& walLFunctionDict() const + { + return wallFunctionDict_; + } + //- Return the laminar viscosity const volScalarField& nu() const diff --git a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C index 602adee89b..7003d6d26c 100644 --- a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C +++ b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C @@ -143,9 +143,21 @@ RNGkEpsilon::RNGkEpsilon mesh_ ), - nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_)) + nut_ + ( + IOobject + ( + "nut", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) { -# include "wallViscosityI.H" + nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_.correctBoundaryConditions(); printCoeffs(); } @@ -239,13 +251,14 @@ void RNGkEpsilon::correct() volScalarField S2 = 2*magSqr(symm(fvc::grad(U_))); - volScalarField G = nut_*S2; + volScalarField G("G", nut_*S2); volScalarField eta = sqrt(S2)*k_/epsilon_; volScalarField R = ((eta*(scalar(1) - eta/eta0_))/(scalar(1) + beta_*eta*sqr(eta))); -# include "wallFunctionsI.H" + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); // Dissipation equation tmp epsEqn @@ -261,7 +274,7 @@ void RNGkEpsilon::correct() epsEqn().relax(); -# include "wallDissipationI.H" + epsEqn().boundaryManipulate(epsilon_.boundaryField()); solve(epsEqn); bound(epsilon_, epsilon0_); @@ -285,9 +298,7 @@ void RNGkEpsilon::correct() // Re-calculate viscosity nut_ = Cmu_*sqr(k_)/epsilon_; - -# include "wallViscosityI.H" - + nut_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..7765dc0757 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -0,0 +1,209 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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 "epsilonWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void epsilonWallFunctionFvPatchScalarField::checkType() +{ + if (!isA(patch())) + { + FatalErrorIn("epsilonWallFunctionFvPatchScalarField::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); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(p, iF) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const epsilonWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedInternalValueFvPatchField(ptf, p, iF, mapper) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedInternalValueFvPatchField(p, iF, dict) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const epsilonWallFunctionFvPatchScalarField& ewfpsf +) +: + fixedInternalValueFvPatchField(ewfpsf) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const epsilonWallFunctionFvPatchScalarField& ewfpsf, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(ewfpsf, iF) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void epsilonWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + const scalar Cmu75 = pow(Cmu, 0.75); + const scalar kappa = ras.kappa().value(); + const scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + volScalarField& G = const_cast + (db().lookupObject("G")); + + volScalarField& epsilon = const_cast + (db().lookupObject("epsilon")); + + const scalarField& k = db().lookupObject("k"); + + const scalarField& nuw = + patch().lookupPatchField("nu"); + + const scalarField& nutw = + patch().lookupPatchField("nut"); + + const fvPatchVectorField& Uw = + patch().lookupPatchField("U"); + + const scalarField magGradUw = mag(Uw.snGrad()); + + // Set epsilon and G + forAll(nutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar yPlus = Cmu25*y[faceCellI]*sqrt(k[faceCellI])/nuw[faceI]; + + epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa*y[faceCellI]); + + if (yPlus > yPlusLam) + { + G[faceCellI] = + (nutw[faceI] + nuw[faceI]) + *magGradUw[faceI] + *Cmu25*sqrt(k[faceCellI]) + /(kappa*y[faceCellI]); + } + } + + // TODO: perform averaging for cells sharing more than one boundary face +} + + +void epsilonWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes commsType +) +{ + fixedInternalValueFvPatchField::evaluate(commsType); +} + + +void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fixedInternalValueFvPatchField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + epsilonWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..3fb9121d73 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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::epsilonWallFunctionFvPatchScalarField + +Description + Replaces functionality in wallFunctionsI.H + +SourceFiles + epsilonWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef epsilonWallFunctionFvPatchScalarField_H +#define epsilonWallFunctionFvPatchScalarField_H + +#include "fixedInternalValueFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class epsilonWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class epsilonWallFunctionFvPatchScalarField +: + public fixedInternalValueFvPatchField +{ + + // Private member functions + + //- Check the type of the patch + void checkType(); + + +public: + + //- Runtime type information + TypeName("epsilonWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + epsilonWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + epsilonWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // epsilonWallFunctionFvPatchScalarField + // onto a new patch + epsilonWallFunctionFvPatchScalarField + ( + const epsilonWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + epsilonWallFunctionFvPatchScalarField + ( + const epsilonWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new epsilonWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + epsilonWallFunctionFvPatchScalarField + ( + const epsilonWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new epsilonWallFunctionFvPatchScalarField(*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 + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C new file mode 100644 index 0000000000..a808b78a58 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C @@ -0,0 +1,184 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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 "fixedInternalValueFvPatchField.H" +#include "fvPatchFieldMapper.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +fixedInternalValueFvPatchField::fixedInternalValueFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + zeroGradientFvPatchField(p, iF) +{} + + +template +fixedInternalValueFvPatchField::fixedInternalValueFvPatchField +( + const fixedInternalValueFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + zeroGradientFvPatchField(ptf, p, iF, mapper) +{} + + +template +fixedInternalValueFvPatchField::fixedInternalValueFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + zeroGradientFvPatchField(p, iF, dict) +{ + fvPatchField::operator=(this->patchInternalField()); +} + + +template +fixedInternalValueFvPatchField::fixedInternalValueFvPatchField +( + const fixedInternalValueFvPatchField& fivpf +) +: + zeroGradientFvPatchField(fivpf) +{} + + +template +fixedInternalValueFvPatchField::fixedInternalValueFvPatchField +( + const fixedInternalValueFvPatchField& fivpf, + const DimensionedField& iF +) +: + zeroGradientFvPatchField(fivpf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void fixedInternalValueFvPatchField::evaluate(const Pstream::commsTypes) +{ + if (!this->updated()) + { + this->updateCoeffs(); + } + + Info<< "fixedInternalValueFvPatchField::evaluate" << endl; + zeroGradientFvPatchField::evaluate(); +} + + +template +tmp > fixedInternalValueFvPatchField::valueInternalCoeffs +( + const tmp& +) const +{ + Info<< "fixedInternalValueFvPatchField::valueInternalCoeffs" << endl; + return tmp > + ( + new Field(this->size(), pTraits::one) + ); +} + + +template +tmp > fixedInternalValueFvPatchField::valueBoundaryCoeffs +( + const tmp& +) const +{ + Info<< "fixedInternalValueFvPatchField::valueBoundaryCoeffs" << endl; +// return tmp > +// ( +// new Field(this->size(), pTraits::zero) +// ); + return this->patchInternalField(); +} + + +template +tmp > fixedInternalValueFvPatchField:: +gradientInternalCoeffs() const +{ + Info<< "fixedInternalValueFvPatchField::gradientInternalCoeffs" + << endl; + return tmp > + ( + new Field(this->size(), pTraits::zero) + ); +} + + +template +tmp > fixedInternalValueFvPatchField:: +gradientBoundaryCoeffs() const +{ + Info<< "fixedInternalValueFvPatchField::gradientBoundaryCoeffs" + << endl; + return tmp > + ( + new Field(this->size(), pTraits::zero) + ); +} + + +template +void fixedInternalValueFvPatchField::manipulateMatrix +( + fvMatrix& matrix +) +{ + Info<< "fixedInternalValueFvPatchField::manipulateMatrix(...)" + << endl; + + // Apply the patch internal field as a constraint in the matrix + matrix.setValues(this->patch().faceCells(), this->patchInternalField()); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H new file mode 100644 index 0000000000..220b7d570e --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H @@ -0,0 +1,174 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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 + fixedInternalValueFvPatchField + +Description + +SourceFiles + fixedInternalValueFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedInternalValueFvPatchField_H +#define fixedInternalValueFvPatchField_H + +#include "zeroGradientFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class fixedInternalValueFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class fixedInternalValueFvPatchField +: + public zeroGradientFvPatchField +{ + +public: + + //- Runtime type information + TypeName("fixedInternalValue"); + + + // Constructors + + //- Construct from patch and internal field + fixedInternalValueFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + fixedInternalValueFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping the given fixedInternalValueFvPatchField + // onto a new patch + fixedInternalValueFvPatchField + ( + const fixedInternalValueFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + fixedInternalValueFvPatchField + ( + const fixedInternalValueFvPatchField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new fixedInternalValueFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + fixedInternalValueFvPatchField + ( + const fixedInternalValueFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new fixedInternalValueFvPatchField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patch field + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::Pstream::blocking + ); + + //- Return the matrix diagonal coefficients corresponding to the + // evaluation of the value of this patchField with given weights + virtual tmp > valueInternalCoeffs + ( + const tmp& + ) const; + + //- Return the matrix source coefficients corresponding to the + // evaluation of the value of this patchField with given weights + virtual tmp > valueBoundaryCoeffs + ( + const tmp& + ) const; + + //- Return the matrix diagonal coefficients corresponding to the + // evaluation of the gradient of this patchField + virtual tmp > gradientInternalCoeffs() const; + + //- Return the matrix source coefficients corresponding to the + // evaluation of the gradient of this patchField + virtual tmp > gradientBoundaryCoeffs() const; + + //-Manipulate a matrix + virtual void manipulateMatrix(fvMatrix& matrix); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "fixedInternalValueFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C new file mode 100644 index 0000000000..cd6d5d4901 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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 "fixedInternalValueFvPatchFields.H" +#include "fvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(fixedInternalValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H new file mode 100644 index 0000000000..779339f443 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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 + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedInternalValueFvPatchFields_H +#define fixedInternalValueFvPatchFields_H + +#include "fixedInternalValueFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(fixedInternalValue) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..2d164f9931 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.C @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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 "kWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void kWallFunctionFvPatchScalarField::checkType() +{ + if (!isA(patch())) + { + FatalErrorIn("kWallFunctionFvPatchScalarField::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); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +kWallFunctionFvPatchScalarField::kWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + zeroGradientFvPatchScalarField(p, iF) +{ + checkType(); +} + + +kWallFunctionFvPatchScalarField::kWallFunctionFvPatchScalarField +( + const kWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + zeroGradientFvPatchScalarField(ptf, p, iF, mapper) +{ + checkType(); +} + + +kWallFunctionFvPatchScalarField::kWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + zeroGradientFvPatchScalarField(p, iF, dict) +{ + checkType(); +} + + +kWallFunctionFvPatchScalarField::kWallFunctionFvPatchScalarField +( + const kWallFunctionFvPatchScalarField& tppsf +) +: + zeroGradientFvPatchScalarField(tppsf) +{ + checkType(); +} + + +kWallFunctionFvPatchScalarField::kWallFunctionFvPatchScalarField +( + const kWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + zeroGradientFvPatchScalarField(tppsf, iF) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void kWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes commsType +) +{ + zeroGradientFvPatchScalarField::evaluate(commsType); +} + + +void kWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + zeroGradientFvPatchScalarField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + kWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..10e8a255ef --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H @@ -0,0 +1,161 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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::kWallFunctionFvPatchScalarField + +Description + +SourceFiles + kWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef kWallFunctionFvPatchScalarField_H +#define kWallFunctionFvPatchScalarField_H + +#include "zeroGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class kWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class kWallFunctionFvPatchScalarField +: + public zeroGradientFvPatchScalarField +{ + + // Private member functions + + //- Check the type of the patch + void checkType(); + + +public: + + //- Runtime type information + TypeName("kWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + kWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + kWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // kWallFunctionFvPatchScalarField + // onto a new patch + kWallFunctionFvPatchScalarField + ( + const kWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + kWallFunctionFvPatchScalarField + ( + const kWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new kWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + kWallFunctionFvPatchScalarField + ( + const kWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new kWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::Pstream::blocking + ); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..233ab8de50 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C @@ -0,0 +1,204 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "nutRoughWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +scalar nutRoughWallFunctionFvPatchScalarField::fnRough +( + const scalar KsPlus, + const scalar kappa +) const +{ + // Set deltaB based on non-dimensional roughness height + scalar deltaB = 0.0; + if (KsPlus <= 2.25) + { + deltaB = 0.0; + } + else if ((KsPlus > 2.25) && (KsPlus <= 90.0)) + { + deltaB = + 1.0/kappa + *log((KsPlus - 2.25)/87.75 + Cs_*KsPlus) + *sin(0.4258*(log(KsPlus) - 0.811)); + } + else + { + deltaB = 1.0/kappa*(1.0 + Cs_*KsPlus); + } + + return exp(deltaB*kappa); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +nutRoughWallFunctionFvPatchScalarField:: +nutRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + Ks_(0.0), + Cs_(0.0) +{} + + +nutRoughWallFunctionFvPatchScalarField:: +nutRoughWallFunctionFvPatchScalarField +( + const nutRoughWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + Ks_(ptf.Ks_), + Cs_(ptf.Cs_) +{} + + +nutRoughWallFunctionFvPatchScalarField:: +nutRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + Ks_(readScalar(dict.lookup("Ks"))), + Cs_(readScalar(dict.lookup("Cs"))) +{} + + +nutRoughWallFunctionFvPatchScalarField:: +nutRoughWallFunctionFvPatchScalarField +( + const nutRoughWallFunctionFvPatchScalarField& nrwfpsf +) +: + fixedValueFvPatchScalarField(nrwfpsf), + Ks_(nrwfpsf.Ks_), + Cs_(nrwfpsf.Cs_) +{} + + +nutRoughWallFunctionFvPatchScalarField:: +nutRoughWallFunctionFvPatchScalarField +( + const nutRoughWallFunctionFvPatchScalarField& nrwfpsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(nrwfpsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void nutRoughWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + const scalar kappa = ras.kappa().value(); + const scalar E = ras.E().value(); + const scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + const scalarField& k = db().lookupObject("k"); + + const scalarField& nuw = + patch().lookupPatchField("nu"); + + scalarField& nutw = *this; + + forAll(nutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar uStar = Cmu25*sqrt(k[faceCellI]); + + scalar yPlus = uStar*y[faceCellI]/nuw[faceI]; + + scalar KsPlus = uStar*Ks_/nuw[faceI]; + + scalar Edash = E/fnRough(KsPlus, kappa); + + if (yPlus > yPlusLam) + { + nutw[faceI] = nuw[faceI]*(yPlus*kappa/log(Edash*yPlus) - 1); + } + else + { + nutw[faceI] = 0.0; + } + } +} + + +void nutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField::write(os); + os.writeKeyword("Cs") << Cs_ << token::END_STATEMENT << nl; + os.writeKeyword("Ks") << Ks_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, nutRoughWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..785b1c55f6 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H @@ -0,0 +1,167 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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::nutRoughWallFunctionFvPatchScalarField + +Description + Rough wall function boundary condition + +SourceFiles + nutRoughWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef nutRoughWallFunctionFvPatchScalarField_H +#define nutRoughWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class nutWallFunctionFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class nutRoughWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Roughness height + scalar Ks_; + + //- Roughness constant + scalar Cs_; + + + // Private member functions + + //- Compute the roughness function + scalar fnRough(const scalar KsPlus, const scalar kappa) const; + + +public: + + //- Runtime type information + TypeName("nutWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + nutRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + nutRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // nutRoughWallFunctionFvPatchScalarField + // onto a new patch + nutRoughWallFunctionFvPatchScalarField + ( + const nutRoughWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + nutRoughWallFunctionFvPatchScalarField + ( + const nutRoughWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new nutRoughWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + nutRoughWallFunctionFvPatchScalarField + ( + const nutRoughWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new nutRoughWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..0455576df4 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C @@ -0,0 +1,302 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + roughnessHeight_(pTraits::zero), + roughnessConstant_(pTraits::zero), + roughnessFudgeFactor_(pTraits::zero) +{} + + +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +( + const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + roughnessHeight_(ptf.roughnessHeight_), + roughnessConstant_(ptf.roughnessConstant_), + roughnessFudgeFactor_(ptf.roughnessFudgeFactor_) +{} + + +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + roughnessHeight_(readScalar(dict.lookup("roughnessHeight"))), + roughnessConstant_(readScalar(dict.lookup("roughnessConstant"))), + roughnessFudgeFactor_(readScalar(dict.lookup("roughnessFudgeFactor"))) +{} + + +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +( + const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf), + roughnessHeight_(tppsf.roughnessHeight_), + roughnessConstant_(tppsf.roughnessConstant_), + roughnessFudgeFactor_(tppsf.roughnessFudgeFactor_) +{} + + +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +( + const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF), + roughnessHeight_(tppsf.roughnessHeight_), + roughnessConstant_(tppsf.roughnessConstant_), + roughnessFudgeFactor_(tppsf.roughnessFudgeFactor_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar kappa = ras.kappa().value(); + const scalar E = ras.E().value(); + const scalar yPlusLam = 11.225; + + // The reciprical of the distance to the adjacent cell centre. + const scalarField& ry = patch().deltaCoeffs(); + + const fvPatchVectorField& U = + patch().lookupPatchField("U"); + + // The flow velocity at the adjacent cell centre. + scalarField magUp = mag(U.patchInternalField() - U); + + const scalarField& nuw = + patch().lookupPatchField("nu"); + scalarField& nutw = *this; + + scalarField magFaceGradU = mag(U.snGrad()); + + if (roughnessHeight_ > 0.0) + { + // Rough Walls. + const scalar c_1 = 1/(90 - 2.25) + roughnessConstant_; + static const scalar c_2 = 2.25/(90 - 2.25); + static const scalar c_3 = 2.0*atan(1.0)/log(90/2.25); + static const scalar c_4 = c_3*log(2.25); + + //if (KsPlusBasedOnYPlus_) + { + // If KsPlus is based on YPlus the extra term added to the law + // of the wall will depend on yPlus. + forAll(nutw, facei) + { + const scalar magUpara = magUp[facei]; + const scalar Re = magUpara/(nuw[facei]*ry[facei]); + const scalar kappaRe = kappa*Re; + + scalar yPlus = yPlusLam; + const scalar ryPlusLam = 1.0/yPlus; + + int iter = 0; + scalar yPlusLast = 0.0; + scalar dKsPlusdYPlus = roughnessHeight_*ry[facei]; + + // Enforce the roughnessHeight to be less than the distance to + // the first cell centre. + if(dKsPlusdYPlus > 1) + { + dKsPlusdYPlus = 1; + } + + // Fudge factor to get results to be similar to fluent + // (at least difference between rough and smooth). + dKsPlusdYPlus *= roughnessFudgeFactor_; + + do + { + yPlusLast = yPlus; + + // The non-dimensional roughness height. + scalar KsPlus = yPlus*dKsPlusdYPlus; + + // The extra term in the law-of-the-wall. + scalar G = 0.0; + + scalar yPlusGPrime = 0.0; + + if (KsPlus >= 90) + { + const scalar t_1 = 1 + roughnessConstant_*KsPlus; + G = log(t_1); + yPlusGPrime = roughnessConstant_*KsPlus/t_1; + } + else if (KsPlus > 2.25) + { + const scalar t_1 = c_1*KsPlus - c_2; + const scalar t_2 = c_3*log(KsPlus) - c_4; + const scalar sint_2 = sin(t_2); + const scalar logt_1 = log(t_1); + G = logt_1*sint_2; + yPlusGPrime = + (c_1*sint_2*KsPlus/t_1) + (c_3*logt_1*cos(t_2)); + } + + scalar denom = 1.0 + log(E* yPlus) - G - yPlusGPrime; + if (mag(denom) > VSMALL) + { + yPlus = (kappaRe + yPlus*(1 - yPlusGPrime))/denom; + } + else + { + // Ensure immediate end and nutw = 0. + yPlus = 0; + } + + } while + ( + mag(ryPlusLam*(yPlus - yPlusLast)) > 0.0001 + && ++iter < 10 + && yPlus > VSMALL + ); + + if (yPlus > yPlusLam) + { + nutw[facei] = nuw[facei]*(yPlus*yPlus/Re - 1); + } + else + { + nutw[facei] = 0.0; + } + } + } + } + else + { + // Smooth Walls. + forAll(nutw, facei) + { + const scalar magUpara = magUp[facei]; + const scalar Re = magUpara/(nuw[facei]*ry[facei]); + const scalar kappaRe = kappa*Re; + + scalar yPlus = yPlusLam; + const scalar ryPlusLam = 1.0/yPlus; + + int iter = 0; + scalar yPlusLast = 0.0; + + do + { + yPlusLast = yPlus; + yPlus = (kappaRe + yPlus)/(1.0 + log(E*yPlus)); + + } while(mag(ryPlusLam*(yPlus - yPlusLast)) > 0.0001 && ++iter < 10); + + if (yPlus > yPlusLam) + { + nutw[facei] = nuw[facei]*(yPlus*yPlus/Re - 1); + } + else + { + nutw[facei] = 0.0; + } + } + } +} + + +void nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::write +( + Ostream& os +) const +{ + fixedValueFvPatchScalarField::write(os); + os.writeKeyword("roughnessHeight") + << roughnessHeight_ << token::END_STATEMENT << nl; + os.writeKeyword("roughnessConstant") + << roughnessConstant_ << token::END_STATEMENT << nl; + os.writeKeyword("roughnessFudgeFactor") + << roughnessFudgeFactor_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..2806288b2a --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H @@ -0,0 +1,208 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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:: + nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + +Description + Wall function boundary condition for rough walls + +SourceFiles + nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H +#define nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ +Class nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + scalar roughnessHeight_; + scalar roughnessConstant_; + scalar roughnessFudgeFactor_; + + +public: + + //- Runtime type information + TypeName("nutSpalartAllmarasStandardRoughWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + // onto a new patch + nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + const nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Access + + //- Return the fluctuation scale + const scalar& roughnessHeight() const + { + return roughnessHeight_; + } + + //- Return reference to the fluctuation scale to allow adjustment + scalar& roughnessHeight() + { + return roughnessHeight_; + } + + + //- Return the fluctuation scale + const scalar& roughnessConstant() const + { + return roughnessConstant_; + } + + //- Return reference to the fluctuation scale to allow adjustment + scalar& roughnessConstant() + { + return roughnessConstant_; + } + + //- Return the fluctuation scale + const scalar& roughnessFudgeFactor() const + { + return roughnessFudgeFactor_; + } + + //- Return reference to the fluctuation scale to allow adjustment + scalar& roughnessFudgeFactor() + { + return roughnessFudgeFactor_; + } + + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); + + + //- Write + virtual void write(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..c60e065f05 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{} + + +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + scalar kappa = ras.kappa().value(); + scalar E = ras.E().value(); + scalar yPlusLam = ras.yPlusLam(); + + const scalarField& ry = patch().deltaCoeffs(); + + const fvPatchVectorField& U = + patch().lookupPatchField("U"); + + scalarField magUp = mag(U.patchInternalField() - U); + + const scalarField& nuw = + patch().lookupPatchField("nu"); + scalarField& nutw = *this; + + scalarField magFaceGradU = mag(U.snGrad()); + + forAll(nutw, facei) + { + scalar magUpara = magUp[facei]; + + scalar kappaRe = kappa*magUpara/(nuw[facei]*ry[facei]); + + scalar yPlus = yPlusLam; + scalar ryPlusLam = 1.0/yPlus; + + int iter = 0; + scalar yPlusLast = 0.0; + + do + { + yPlusLast = yPlus; + yPlus = (kappaRe + yPlus)/(1.0 + log(E*yPlus)); + + } while(mag(ryPlusLam*(yPlus - yPlusLast)) > 0.01 && ++iter < 10 ); + + if (yPlus > yPlusLam) + { + nutw[facei] = nuw[facei]*(yPlus*kappa/log(E*yPlus) - 1); + } + else + { + nutw[facei] = 0.0; + } + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + nutSpalartAllmarasStandardWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..7613962708 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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:: + nutSpalartAllmarasStandardWallFunctionFvPatchScalarField + +Description + Wall function boundary condition for walls + +SourceFiles + nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef nutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H +#define nutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class nutWallFunctionFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class nutSpalartAllmarasStandardWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + +public: + + //- Runtime type information + TypeName("nutSpalartAllmarasStandardWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + nutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + nutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // nutSpalartAllmarasStandardWallFunctionFvPatchScalarField + // onto a new patch + nutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + nutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new nutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + nutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const nutSpalartAllmarasStandardWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new nutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..6e37a19949 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -0,0 +1,180 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "nutSpalartAllmarasWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +nutSpalartAllmarasWallFunctionFvPatchScalarField:: +nutSpalartAllmarasWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +nutSpalartAllmarasWallFunctionFvPatchScalarField:: +nutSpalartAllmarasWallFunctionFvPatchScalarField +( + const nutSpalartAllmarasWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +nutSpalartAllmarasWallFunctionFvPatchScalarField:: +nutSpalartAllmarasWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +nutSpalartAllmarasWallFunctionFvPatchScalarField:: +nutSpalartAllmarasWallFunctionFvPatchScalarField +( + const nutSpalartAllmarasWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{} + + +nutSpalartAllmarasWallFunctionFvPatchScalarField:: +nutSpalartAllmarasWallFunctionFvPatchScalarField +( + const nutSpalartAllmarasWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void nutSpalartAllmarasWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + scalar kappa = ras.kappa().value(); + scalar E = ras.E().value(); + + const scalarField& ry = patch().deltaCoeffs(); + + const fvPatchVectorField& U = + patch().lookupPatchField("U"); + + scalarField magUp = mag(U.patchInternalField() - U); + + const scalarField& nuw = + patch().lookupPatchField("nu"); + + scalarField& nutw = *this; + + scalarField magFaceGradU = mag(U.snGrad()); + + forAll(nutw, facei) + { + scalar magUpara = magUp[facei]; + + scalar utau = sqrt((nutw[facei] + nuw[facei])*magFaceGradU[facei]); + + if (utau > VSMALL) + { + int iter = 0; + scalar err = GREAT; + + do + { + scalar kUu = min(kappa*magUpara/utau, 50); + scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu); + + scalar f = + - utau/(ry[facei]*nuw[facei]) + + magUpara/utau + + 1/E*(fkUu - 1.0/6.0*kUu*sqr(kUu)); + + scalar df = + 1.0/(ry[facei]*nuw[facei]) + + magUpara/sqr(utau) + + 1/E*kUu*fkUu/utau; + + scalar utauNew = utau + f/df; + err = mag((utau - utauNew)/utau); + utau = utauNew; + + } while (utau > VSMALL && err > 0.01 && ++iter < 10); + + nutw[facei] = + max(sqr(max(utau, 0))/magFaceGradU[facei] - nuw[facei], 0.0); + } + else + { + nutw[facei] = 0; + } + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, nutSpalartAllmarasWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..174b6e3a34 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.H @@ -0,0 +1,153 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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:: + nutSpalartAllmarasWallFunctionFvPatchScalarField + +Description + Wall function boundary condition for walls + +SourceFiles + nutSpalartAllmarasWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef nutSpalartAllmarasWallFunctionFvPatchScalarField_H +#define nutSpalartAllmarasWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class nutSpalartAllmarasWallFunctionFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class nutSpalartAllmarasWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + +public: + + //- Runtime type information + TypeName("nutSpalartAllmarasWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + nutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + nutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // nutSpalartAllmarasWallFunctionFvPatchScalarField + // onto a new patch + nutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const nutSpalartAllmarasWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + nutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const nutSpalartAllmarasWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new nutSpalartAllmarasWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + nutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const nutSpalartAllmarasWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new nutSpalartAllmarasWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..25bbee8a29 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "nutWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +nutWallFunctionFvPatchScalarField:: +nutWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +nutWallFunctionFvPatchScalarField:: +nutWallFunctionFvPatchScalarField +( + const nutWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +nutWallFunctionFvPatchScalarField:: +nutWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +nutWallFunctionFvPatchScalarField:: +nutWallFunctionFvPatchScalarField +( + const nutWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{} + + +nutWallFunctionFvPatchScalarField:: +nutWallFunctionFvPatchScalarField +( + const nutWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void nutWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + const scalar kappa = ras.kappa().value(); + const scalar E = ras.E().value(); + const scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + const scalarField& k = db().lookupObject("k"); + + const scalarField& nuw = + patch().lookupPatchField("nu"); + + scalarField& nutw = *this; + + forAll(nutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar yPlus = Cmu25*y[faceCellI]*sqrt(k[faceCellI])/nuw[faceI]; + + if (yPlus > yPlusLam) + { + nutw[faceI] = nuw[faceI]*(yPlus*kappa/log(E*yPlus) - 1); + } + else + { + nutw[faceI] = 0.0; + } + } +} + + +void nutWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, nutWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..bf3fe1753e --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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::nutWallFunctionFvPatchScalarField + +Description + Wall function boundary condition + - replicates OpenFOAM v1.5 (and lower) behaviour + +SourceFiles + nutWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef nutWallFunctionFvPatchScalarField_H +#define nutWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class nutWallFunctionFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class nutWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + +public: + + //- Runtime type information + TypeName("nutWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + nutWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + nutWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // nutWallFunctionFvPatchScalarField + // onto a new patch + nutWallFunctionFvPatchScalarField + ( + const nutWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + nutWallFunctionFvPatchScalarField + ( + const nutWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new nutWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + nutWallFunctionFvPatchScalarField + ( + const nutWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new nutWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..63bdc2e7d4 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -0,0 +1,200 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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 "omegaWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void omegaWallFunctionFvPatchScalarField::checkType() +{ + if (!isA(patch())) + { + FatalErrorIn("omegaWallFunctionFvPatchScalarField::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); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(p, iF) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const omegaWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedInternalValueFvPatchField(ptf, p, iF, mapper) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedInternalValueFvPatchField(p, iF, dict) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const omegaWallFunctionFvPatchScalarField& ewfpsf +) +: + fixedInternalValueFvPatchField(ewfpsf) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const omegaWallFunctionFvPatchScalarField& ewfpsf, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(ewfpsf, iF) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void omegaWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + + const scalar kappa = ras.kappa().value(); + const scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + volScalarField& G = const_cast + (db().lookupObject("G")); + + volScalarField& omega = const_cast + (db().lookupObject("omega")); + + const scalarField& k = db().lookupObject("k"); + + const scalarField& nuw = + patch().lookupPatchField("nu"); + + const scalarField& nutw = + patch().lookupPatchField("nut"); + + const fvPatchVectorField& Uw = + patch().lookupPatchField("U"); + + const scalarField magGradUw = mag(Uw.snGrad()); + + // Set epsilon and G + forAll(nutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar yPlus = Cmu25*y[faceCellI]*sqrt(k[faceCellI])/nuw[faceI]; + + omega[faceCellI] = sqrt(k[faceCellI])/(Cmu25*kappa*y[faceCellI]); + + if (yPlus > yPlusLam) + { + G[faceCellI] = + (nutw[faceI] + nuw[faceI]) + *magGradUw[faceI] + *Cmu25*sqrt(k[faceCellI]) + /(kappa*y[faceCellI]); + } + } + + // TODO: perform averaging for cells sharing more than one boundary face +} + + +void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fixedInternalValueFvPatchField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + omegaWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..604cf71577 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H @@ -0,0 +1,159 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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::omegaWallFunctionFvPatchScalarField + +Description + Replaces functionality in wallFunctionsI.H + +SourceFiles + omegaWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef omegaWallFunctionFvPatchScalarField_H +#define omegaWallFunctionFvPatchScalarField_H + +#include "fixedInternalValueFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class omegaWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class omegaWallFunctionFvPatchScalarField +: + public fixedInternalValueFvPatchField +{ + + // Private member functions + + //- Check the type of the patch + void checkType(); + + +public: + + //- Runtime type information + TypeName("omegaWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + omegaWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + omegaWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // omegaWallFunctionFvPatchScalarField + // onto a new patch + omegaWallFunctionFvPatchScalarField + ( + const omegaWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + omegaWallFunctionFvPatchScalarField + ( + const omegaWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new omegaWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + omegaWallFunctionFvPatchScalarField + ( + const omegaWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new omegaWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C index 0f4e20df04..9bc9aad003 100644 --- a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C @@ -117,9 +117,21 @@ kEpsilon::kEpsilon mesh_ ), - nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_)) + nut_ + ( + IOobject + ( + "nut", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) { -# include "wallViscosityI.H" + nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_.correctBoundaryConditions(); printCoeffs(); } @@ -207,9 +219,10 @@ void kEpsilon::correct() RASModel::correct(); - volScalarField G = nut_*2*magSqr(symm(fvc::grad(U_))); + volScalarField G("G", nut_*2*magSqr(symm(fvc::grad(U_)))); -# include "wallFunctionsI.H" + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); // Dissipation equation tmp epsEqn @@ -225,7 +238,7 @@ void kEpsilon::correct() epsEqn().relax(); -# include "wallDissipationI.H" + epsEqn().boundaryManipulate(epsilon_.boundaryField()); solve(epsEqn); bound(epsilon_, epsilon0_); @@ -250,9 +263,7 @@ void kEpsilon::correct() // Re-calculate viscosity nut_ = Cmu_*sqr(k_)/epsilon_; - -# include "wallViscosityI.H" - + nut_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C index 1cf4a5c6d7..8a6886bc70 100644 --- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C @@ -237,9 +237,27 @@ kOmegaSST::kOmegaSST mesh_ ), - nut_(a1_*k_/max(a1_*(omega_ + omegaSmall_), F2()*mag(symm(fvc::grad(U_))))) + nut_ + ( + IOobject + ( + "nut", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) { -# include "kOmegaWallViscosityI.H" + nut_ == + a1_*k_ + /max + ( + a1_*(omega_ + omegaSmall_), + F2()*mag(symm(fvc::grad(U_))) + ); + nut_.correctBoundaryConditions(); printCoeffs(); } @@ -341,9 +359,10 @@ void kOmegaSST::correct() } volScalarField S2 = magSqr(symm(fvc::grad(U_))); - volScalarField G = nut_*2*S2; + volScalarField G("G", nut_*2*S2); -# include "kOmegaWallFunctionsI.H" + // Update omega and G at the wall + omega_.boundaryField().updateCoeffs(); volScalarField CDkOmega = (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_; @@ -369,7 +388,7 @@ void kOmegaSST::correct() omegaEqn().relax(); -# include "wallOmegaI.H" + omegaEqn().boundaryManipulate(omega_.boundaryField()); solve(omegaEqn); bound(omega_, omega0_); @@ -393,9 +412,7 @@ void kOmegaSST::correct() // Re-calculate viscosity nut_ = a1_*k_/max(a1_*omega_, F2()*sqrt(S2)); - -# include "kOmegaWallViscosityI.H" - + nut_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C index a9d2cbc601..7ef65a01de 100644 --- a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C +++ b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C @@ -166,11 +166,24 @@ realizableKE::realizableKE mesh_ ), - nut_(rCmu(fvc::grad(U_))*sqr(k_)/(epsilon_ + epsilonSmall_)) + nut_ + ( + IOobject + ( + "nut", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) { bound(k_, k0_); bound(epsilon_, epsilon0_); -# include "wallViscosityI.H" + + nut_ == rCmu(fvc::grad(U_))*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_.correctBoundaryConditions(); printCoeffs(); } @@ -266,9 +279,10 @@ void realizableKE::correct() volScalarField eta = magS*k_/epsilon_; volScalarField C1 = max(eta/(scalar(5) + eta), scalar(0.43)); - volScalarField G = nut_*S2; + volScalarField G("G", nut_*S2); -# include "wallFunctionsI.H" + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); // Dissipation equation @@ -289,7 +303,7 @@ void realizableKE::correct() epsEqn().relax(); -# include "wallDissipationI.H" + epsEqn().boundaryManipulate(epsilon_.boundaryField()); solve(epsEqn); bound(epsilon_, epsilon0_); @@ -313,9 +327,7 @@ void realizableKE::correct() // Re-calculate viscosity nut_ = rCmu(gradU, S2, magS)*sqr(k_)/epsilon_; - -# include "wallViscosityI.H" - + nut_.correctBoundaryConditions(); } From 857ea24090582c660b6ff6bc5e05044a74924c83 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 27 Aug 2008 17:44:52 +0100 Subject: [PATCH 06/44] clean-up --- .../kOmegaSST/checkkOmegaPatchFieldTypes.H | 19 --- .../RAS/incompressible/kOmegaSST/kOmegaSST.H | 3 - .../kOmegaSST/kOmegaWallFunctionsI.H | 125 ------------------ .../kOmegaSST/kOmegaWallViscosityI.H | 70 ---------- .../RAS/incompressible/kOmegaSST/wallOmegaI.H | 51 ------- 5 files changed, 268 deletions(-) delete mode 100644 src/turbulenceModels/RAS/incompressible/kOmegaSST/checkkOmegaPatchFieldTypes.H delete mode 100644 src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallFunctionsI.H delete mode 100644 src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallViscosityI.H delete mode 100644 src/turbulenceModels/RAS/incompressible/kOmegaSST/wallOmegaI.H diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/checkkOmegaPatchFieldTypes.H b/src/turbulenceModels/RAS/incompressible/kOmegaSST/checkkOmegaPatchFieldTypes.H deleted file mode 100644 index 025c06bb9c..0000000000 --- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/checkkOmegaPatchFieldTypes.H +++ /dev/null @@ -1,19 +0,0 @@ -if (!isType(k_.boundaryField()[patchi])) -{ - FatalErrorIn("wall-function evaluation") - << k_.boundaryField()[patchi].type() - << " is the wrong k patchField type for wall-functions on patch " - << curPatch.name() << nl - << " should be zeroGradient" - << exit(FatalError); -} - -if (!isType(omega_.boundaryField()[patchi])) -{ - FatalErrorIn("wall-function evaluation") - << omega_.boundaryField()[patchi].type() - << " is the wrong omega patchField type for wall-functions on patch " - << curPatch.name() << nl - << " should be zeroGradient" - << exit(FatalError); -} diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.H b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.H index ef44b6a9ac..ce77847c45 100644 --- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.H +++ b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.H @@ -75,9 +75,6 @@ Description SourceFiles kOmegaSST.C - kOmegaWallFunctionsI.H - kOmegaWallViscosityI.H - wallOmegaI.H \*---------------------------------------------------------------------------*/ diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallFunctionsI.H b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallFunctionsI.H deleted file mode 100644 index 82d8b933c3..0000000000 --- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallFunctionsI.H +++ /dev/null @@ -1,125 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 - -Global - kOmegaWallFunctions - -Description - Calculate wall generation and frequency omega from wall-functions. - -\*---------------------------------------------------------------------------*/ - -{ - labelList cellBoundaryFaceCount(omega_.size(), 0); - - scalar Cmu25 = pow(Cmu_.value(), 0.25); - - const fvPatchList& patches = mesh_.boundary(); - - //- Initialise the near-wall omega and G fields to zero - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - omega_[faceCelli] = 0.0; - G[faceCelli] = 0.0; - } - } - } - - //- Accumulate the wall face contributions to omega and G - // Increment cellBoundaryFaceCount for each face for averaging - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { -# include "checkkOmegaPatchFieldTypes.H" - - const scalarField& nuw = nu().boundaryField()[patchi]; - const scalarField& nutw = nut_.boundaryField()[patchi]; - - scalarField magFaceGradU = - mag(U_.boundaryField()[patchi].snGrad()); - - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - scalar yPlus = - Cmu25*y_[faceCelli] - *sqrt(k_[faceCelli]) - /nuw[facei]; - - // For corner cells (with two boundary or more faces), - // omega and G in the near-wall cell are calculated - // as an average - - cellBoundaryFaceCount[faceCelli]++; - - omega_[faceCelli] += - sqrt(k_[faceCelli]) - /(Cmu25*kappa_.value()*y_[faceCelli]); - - if (yPlus > yPlusLam_) - { - G[faceCelli] += - (nutw[facei] + nuw[facei]) - *magFaceGradU[facei] - *Cmu25*sqrt(k_[faceCelli]) - /(kappa_.value()*y_[faceCelli]); - } - } - } - } - - - // Perform the averaging - - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - omega_[faceCelli] /= cellBoundaryFaceCount[faceCelli]; - G[faceCelli] /= cellBoundaryFaceCount[faceCelli]; - } - } - } -} - - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallViscosityI.H b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallViscosityI.H deleted file mode 100644 index 2cf371eedf..0000000000 --- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaWallViscosityI.H +++ /dev/null @@ -1,70 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 - -Global - kOmegaWallViscosity - -Description - Calculate wall viscosity from wall-functions. - -\*---------------------------------------------------------------------------*/ - -{ - scalar Cmu25 = pow(Cmu_.value(), 0.25); - - const fvPatchList& patches = mesh_.boundary(); - - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { - const scalarField& nuw = nu().boundaryField()[patchi]; - scalarField& nutw = nut_.boundaryField()[patchi]; - - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - scalar yPlus = - Cmu25*y_[faceCelli]*sqrt(k_[faceCelli])/nuw[facei]; - - if (yPlus > yPlusLam_) - { - nutw[facei] = - nuw[facei] - *(yPlus*kappa_.value()/log(E_.value()*yPlus) - 1); - } - else - { - nutw[facei] = 0.0; - } - } - } - } -} - - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/wallOmegaI.H b/src/turbulenceModels/RAS/incompressible/kOmegaSST/wallOmegaI.H deleted file mode 100644 index eb1b3c5919..0000000000 --- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/wallOmegaI.H +++ /dev/null @@ -1,51 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 - -Global - wallOmega - -Description - Set wall dissipation in the omega matrix - -\*---------------------------------------------------------------------------*/ - -{ - const fvPatchList& patches = mesh_.boundary(); - - forAll(patches, patchi) - { - const fvPatch& p = patches[patchi]; - - if (isType(p)) - { - omegaEqn().setValues - ( - p.faceCells(), - omega_.boundaryField()[patchi].patchInternalField() - ); - } - } -} - -// ************************************************************************* // From 7e30b79e87fee0d0f4a045648453bb4a657e7887 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 27 Aug 2008 17:45:26 +0100 Subject: [PATCH 07/44] moving to .old for future reference --- .../wallFunctions/{wallFunctionsI.H => wallFunctionsI.H.old} | 0 .../wallFunctions/{wallViscosityI.H => wallViscosityI.H.old} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/turbulenceModels/RAS/incompressible/wallFunctions/{wallFunctionsI.H => wallFunctionsI.H.old} (100%) rename src/turbulenceModels/RAS/incompressible/wallFunctions/{wallViscosityI.H => wallViscosityI.H.old} (100%) diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/wallFunctionsI.H b/src/turbulenceModels/RAS/incompressible/wallFunctions/wallFunctionsI.H.old similarity index 100% rename from src/turbulenceModels/RAS/incompressible/wallFunctions/wallFunctionsI.H rename to src/turbulenceModels/RAS/incompressible/wallFunctions/wallFunctionsI.H.old diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/wallViscosityI.H b/src/turbulenceModels/RAS/incompressible/wallFunctions/wallViscosityI.H.old similarity index 100% rename from src/turbulenceModels/RAS/incompressible/wallFunctions/wallViscosityI.H rename to src/turbulenceModels/RAS/incompressible/wallFunctions/wallViscosityI.H.old From b02d23f1141524ba0348aa3b38c7217221f1c7e7 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 27 Aug 2008 18:11:16 +0100 Subject: [PATCH 08/44] minor clean-up and comments --- src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C | 2 +- .../epsilonWallFunctionFvPatchScalarField.H | 4 +++- .../fixedInternalValueFvPatchField.H | 3 +++ .../kWallFunction/kWallFunctionFvPatchScalarField.H | 2 ++ .../nutRoughWallFunctionFvPatchScalarField.H | 6 +++++- .../nutSpalartAllmarasWallFunctionFvPatchScalarField.H | 2 +- .../nutWallFunction/nutWallFunctionFvPatchScalarField.H | 5 +++-- 7 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C index ec41fae3aa..09bf558499 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C @@ -82,8 +82,8 @@ RASModel::RASModel turbulence_(lookup("turbulence")), printCoeffs_(lookupOrDefault("printCoeffs", false)), coeffDict_(subDict(type + "Coeffs")), - wallFunctionDict_(subDict("wallFunctionCoeffs")), + wallFunctionDict_(subDict("wallFunctionCoeffs")), kappa_ ( dimensioned::lookupOrAddToDict diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H index 3fb9121d73..eabca4d50b 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H @@ -26,7 +26,9 @@ Class Foam::epsilonWallFunctionFvPatchScalarField Description - Replaces functionality in wallFunctionsI.H + Boundary condition for epsilon when using wall functions + - calculates epsilon and G + - epsilon values added directly into the matrix to act as a constraint SourceFiles epsilonWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H index 220b7d570e..a6daa7b422 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H @@ -26,6 +26,9 @@ Class fixedInternalValueFvPatchField Description + Boundary condition providing mechanism to set boundary (cell) values + directly into a matrix, i.e. to set a constraint condition. Default + behaviour is to act as a zero gradient condition. SourceFiles fixedInternalValueFvPatchField.C diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H index 10e8a255ef..864ef3e153 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H @@ -26,6 +26,8 @@ Class Foam::kWallFunctionFvPatchScalarField Description + Boundary condition for turbulence kinetic energy when using wall functions. + Simply acts as a zero gradient condition. SourceFiles kWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H index 785b1c55f6..afdbf82ad2 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H @@ -26,7 +26,11 @@ Class Foam::incompressible::RASModels::nutRoughWallFunctionFvPatchScalarField Description - Rough wall function boundary condition + Boundary condition for turbulent (kinematic) viscosity when using wall + functions for rough walls. + + Manipulates the E parameter to account for roughness effects, based on + KsPlus. SourceFiles nutRoughWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.H index 174b6e3a34..70f1107de3 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.H @@ -49,7 +49,7 @@ namespace RASModels { /*---------------------------------------------------------------------------*\ - Class nutSpalartAllmarasWallFunctionFvPatch Declaration + Class nutSpalartAllmarasWallFunctionFvPatch Declaration \*---------------------------------------------------------------------------*/ class nutSpalartAllmarasWallFunctionFvPatchScalarField diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H index bf3fe1753e..6ed73f7637 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H @@ -26,8 +26,9 @@ Class Foam::incompressible::RASModels::nutWallFunctionFvPatchScalarField Description - Wall function boundary condition - - replicates OpenFOAM v1.5 (and lower) behaviour + Boundary condition for turbulent (kinematic) viscosity when using wall + functions + - replicates OpenFOAM v1.5 (and earlier) behaviour SourceFiles nutWallFunctionFvPatchScalarField.C From f220dfc200ae5cc38713fb41bb4c7296d9b605af Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 28 Aug 2008 18:28:26 +0100 Subject: [PATCH 09/44] tidying up --- src/turbulenceModels/RAS/incompressible/Make/files | 2 ++ .../fixedInternalValueFvPatchField.C | 7 +++++++ .../fixedInternalValueFvPatchField.H | 6 ++++++ .../fixedInternalValueFvPatchFields.C | 6 ++++++ .../fixedInternalValueFvPatchFields.H | 6 ++++++ .../nutRoughWallFunctionFvPatchScalarField.H | 2 +- 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/turbulenceModels/RAS/incompressible/Make/files b/src/turbulenceModels/RAS/incompressible/Make/files index 991c22d26b..034b00e1af 100644 --- a/src/turbulenceModels/RAS/incompressible/Make/files +++ b/src/turbulenceModels/RAS/incompressible/Make/files @@ -25,6 +25,8 @@ derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFuncti derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C +derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H + derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C index a808b78a58..0a25cf0527 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C @@ -26,11 +26,16 @@ License #include "fixedInternalValueFvPatchField.H" #include "fvPatchFieldMapper.H" +#include "fvMatrix.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { +namespace incompressible +{ +namespace RASModels +{ // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -179,6 +184,8 @@ void fixedInternalValueFvPatchField::manipulateMatrix // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace RASModels +} // End namespace incompressible } // End namespace Foam // ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H index a6daa7b422..4783f65400 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H @@ -44,6 +44,10 @@ SourceFiles namespace Foam { +namespace incompressible +{ +namespace RASModels +{ /*---------------------------------------------------------------------------*\ Class fixedInternalValueFvPatchField Declaration @@ -162,6 +166,8 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace RASModels +} // End namespace incompressible } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C index cd6d5d4901..f2598e78f2 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C @@ -33,6 +33,10 @@ License namespace Foam { +namespace incompressible +{ +namespace RASModels +{ // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -40,6 +44,8 @@ makePatchFields(fixedInternalValue); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace RASModels +} // End namespace incompressible } // End namespace Foam // ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H index 779339f443..d2d48936d4 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H @@ -34,6 +34,10 @@ License namespace Foam { +namespace incompressible +{ +namespace RASModels +{ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -41,6 +45,8 @@ makePatchTypeFieldTypedefs(fixedInternalValue) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +} // End namespace RASModels +} // End namespace incompressible } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H index afdbf82ad2..e0c8122e4a 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H @@ -77,7 +77,7 @@ class nutRoughWallFunctionFvPatchScalarField public: //- Runtime type information - TypeName("nutWallFunction"); + TypeName("nutRoughWallFunction"); // Constructors From 4225041831769d1b5151d26d6fa8553144f60564 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 29 Aug 2008 15:56:49 +0100 Subject: [PATCH 10/44] changed scalar kWallFunction to templated kQRWallFunction --- .../kQRWallFunctionFvPatchField.C} | 72 +++++++++---------- .../kQRWallFunctionFvPatchField.H} | 67 +++++++++-------- .../kQRWallFunctionFvPatchFields.C | 51 +++++++++++++ .../kQRWallFunctionFvPatchFields.H | 56 +++++++++++++++ 4 files changed, 180 insertions(+), 66 deletions(-) rename src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/{kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.C => kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C} (60%) rename src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/{kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H => kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H} (67%) create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C similarity index 60% rename from src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.C rename to src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C index 2d164f9931..afe0cd24c8 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ -#include "kWallFunctionFvPatchScalarField.H" +#include "kQRWallFunctionFvPatchField.H" #include "RASModel.H" #include "fvPatchFieldMapper.H" #include "volFields.H" @@ -42,15 +42,16 @@ namespace RASModels // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void kWallFunctionFvPatchScalarField::checkType() +template +void kQRWallFunctionFvPatchField::checkType() { - if (!isA(patch())) + if (!isA(this->patch())) { - FatalErrorIn("kWallFunctionFvPatchScalarField::checkType()") + FatalErrorIn("kQRWallFunctionFvPatchField::checkType()") << "Invalid wall function specification" << nl - << " Patch type for patch " << patch().name() + << " Patch type for patch " << this->patch().name() << " must be wall" << nl - << " Current patch type is " << patch().type() << nl << endl + << " Current patch type is " << this->patch().type() << nl << endl << abort(FatalError); } } @@ -58,63 +59,68 @@ void kWallFunctionFvPatchScalarField::checkType() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -kWallFunctionFvPatchScalarField::kWallFunctionFvPatchScalarField +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField ( const fvPatch& p, - const DimensionedField& iF + const DimensionedField& iF ) : - zeroGradientFvPatchScalarField(p, iF) + zeroGradientFvPatchField(p, iF) { checkType(); } -kWallFunctionFvPatchScalarField::kWallFunctionFvPatchScalarField +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField ( - const kWallFunctionFvPatchScalarField& ptf, + const kQRWallFunctionFvPatchField& ptf, const fvPatch& p, - const DimensionedField& iF, + const DimensionedField& iF, const fvPatchFieldMapper& mapper ) : - zeroGradientFvPatchScalarField(ptf, p, iF, mapper) + zeroGradientFvPatchField(ptf, p, iF, mapper) { checkType(); } -kWallFunctionFvPatchScalarField::kWallFunctionFvPatchScalarField +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField ( const fvPatch& p, - const DimensionedField& iF, + const DimensionedField& iF, const dictionary& dict ) : - zeroGradientFvPatchScalarField(p, iF, dict) + zeroGradientFvPatchField(p, iF, dict) { checkType(); } -kWallFunctionFvPatchScalarField::kWallFunctionFvPatchScalarField +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField ( - const kWallFunctionFvPatchScalarField& tppsf + const kQRWallFunctionFvPatchField& tkqrwfpf ) : - zeroGradientFvPatchScalarField(tppsf) + zeroGradientFvPatchField(tkqrwfpf) { checkType(); } -kWallFunctionFvPatchScalarField::kWallFunctionFvPatchScalarField +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField ( - const kWallFunctionFvPatchScalarField& tppsf, - const DimensionedField& iF + const kQRWallFunctionFvPatchField& tkqrwfpf, + const DimensionedField& iF ) : - zeroGradientFvPatchScalarField(tppsf, iF) + zeroGradientFvPatchField(tkqrwfpf, iF) { checkType(); } @@ -122,30 +128,24 @@ kWallFunctionFvPatchScalarField::kWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void kWallFunctionFvPatchScalarField::evaluate +template +void kQRWallFunctionFvPatchField::evaluate ( const Pstream::commsTypes commsType ) { - zeroGradientFvPatchScalarField::evaluate(commsType); + zeroGradientFvPatchField::evaluate(commsType); } -void kWallFunctionFvPatchScalarField::write(Ostream& os) const +template +void kQRWallFunctionFvPatchField::write(Ostream& os) const { - zeroGradientFvPatchScalarField::write(os); - writeEntry("value", os); + zeroGradientFvPatchField::write(os); + this->writeEntry("value", os); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makePatchTypeField -( - fvPatchScalarField, - kWallFunctionFvPatchScalarField -); - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace RASModels diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H similarity index 67% rename from src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H rename to src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H index 864ef3e153..04ae08df9b 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H @@ -23,21 +23,21 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::kWallFunctionFvPatchScalarField + Foam::kQRWallFunctionFvPatchField Description - Boundary condition for turbulence kinetic energy when using wall functions. + Boundary condition for turbulence k, Q, and R when using wall functions. Simply acts as a zero gradient condition. SourceFiles - kWallFunctionFvPatchScalarField.C + kQRWallFunctionFvPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef kWallFunctionFvPatchScalarField_H -#define kWallFunctionFvPatchScalarField_H +#ifndef kQRWallFunctionFvPatchField_H +#define kQRWallFunctionFvPatchField_H -#include "zeroGradientFvPatchFields.H" +#include "zeroGradientFvPatchField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,12 +49,13 @@ namespace RASModels { /*---------------------------------------------------------------------------*\ - Class kWallFunctionFvPatchScalarField Declaration + Class kQRWallFunctionFvPatchField Declaration \*---------------------------------------------------------------------------*/ -class kWallFunctionFvPatchScalarField +template +class kQRWallFunctionFvPatchField : - public zeroGradientFvPatchScalarField + public zeroGradientFvPatchField { // Private member functions @@ -66,68 +67,68 @@ class kWallFunctionFvPatchScalarField public: //- Runtime type information - TypeName("kWallFunction"); + TypeName("kQRWallFunction"); // Constructors //- Construct from patch and internal field - kWallFunctionFvPatchScalarField + kQRWallFunctionFvPatchField ( const fvPatch&, - const DimensionedField& + const DimensionedField& ); //- Construct from patch, internal field and dictionary - kWallFunctionFvPatchScalarField + kQRWallFunctionFvPatchField ( const fvPatch&, - const DimensionedField&, + const DimensionedField&, const dictionary& ); //- Construct by mapping given - // kWallFunctionFvPatchScalarField + // kQRWallFunctionFvPatchField // onto a new patch - kWallFunctionFvPatchScalarField + kQRWallFunctionFvPatchField ( - const kWallFunctionFvPatchScalarField&, + const kQRWallFunctionFvPatchField&, const fvPatch&, - const DimensionedField&, + const DimensionedField&, const fvPatchFieldMapper& ); //- Construct as copy - kWallFunctionFvPatchScalarField + kQRWallFunctionFvPatchField ( - const kWallFunctionFvPatchScalarField& + const kQRWallFunctionFvPatchField& ); //- Construct and return a clone - virtual tmp clone() const + virtual tmp > clone() const { - return tmp + return tmp > ( - new kWallFunctionFvPatchScalarField(*this) + new kQRWallFunctionFvPatchField(*this) ); } //- Construct as copy setting internal field reference - kWallFunctionFvPatchScalarField + kQRWallFunctionFvPatchField ( - const kWallFunctionFvPatchScalarField&, - const DimensionedField& + const kQRWallFunctionFvPatchField&, + const DimensionedField& ); //- Construct and return a clone setting internal field reference - virtual tmp clone + virtual tmp > clone ( - const DimensionedField& iF + const DimensionedField& iF ) const { - return tmp + return tmp > ( - new kWallFunctionFvPatchScalarField(*this, iF) + new kQRWallFunctionFvPatchField(*this, iF) ); } @@ -158,6 +159,12 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository +# include "kQRWallFunctionFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C new file mode 100644 index 0000000000..4378e87723 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "kQRWallFunctionFvPatchFields.H" +#include "fvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(kQRWallFunction); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H new file mode 100644 index 0000000000..f7a312a780 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H @@ -0,0 +1,56 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 + +\*---------------------------------------------------------------------------*/ + +#ifndef kQRWallFunctionFvPatchFields_H +#define kQRWallFunctionFvPatchFields_H + +#include "kQRWallFunctionFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(kQRWallFunction) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 913c912e87c72bc90ef9c0e37bfdcfdf3dc41efb Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 29 Aug 2008 15:57:54 +0100 Subject: [PATCH 11/44] further updates en-route to run-time selection functionality for incompressible RAS models --- .../RAS/incompressible/Make/files | 2 +- .../RAS/incompressible/RASModel/RASModel.C | 18 ++--- .../RAS/incompressible/RASModel/RASModel.H | 4 +- .../epsilonWallFunctionFvPatchScalarField.C | 12 ++-- .../fixedInternalValueFvPatchField.C | 71 ------------------- .../fixedInternalValueFvPatchField.H | 28 -------- .../nutRoughWallFunctionFvPatchScalarField.C | 59 +++++++++++---- .../nutRoughWallFunctionFvPatchScalarField.H | 29 +++++++- .../nutWallFunctionFvPatchScalarField.C | 4 +- .../RAS/incompressible/kEpsilon/kEpsilon.C | 7 +- 10 files changed, 100 insertions(+), 134 deletions(-) diff --git a/src/turbulenceModels/RAS/incompressible/Make/files b/src/turbulenceModels/RAS/incompressible/Make/files index 034b00e1af..eec2b9fe78 100644 --- a/src/turbulenceModels/RAS/incompressible/Make/files +++ b/src/turbulenceModels/RAS/incompressible/Make/files @@ -31,7 +31,7 @@ derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsi derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/kWallFunctions/kWallFunction/kWallFunctionFvPatchScalarField.C +derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C /* Patch fields */ diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C index 09bf558499..a5b0dd6a9d 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C @@ -128,7 +128,7 @@ RASModel::~RASModel() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -scalar RASModel::yPlusLam(const scalar kappa, const scalar E) +scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const { scalar ypl = 11.0; @@ -150,9 +150,7 @@ tmp RASModel::yPlus(const label patchNo) const if (typeid(curPatch) == typeid(wallFvPatch)) { - scalar Cmu(readScalar(coeffDict_.lookup("Cmu"))); - - Yp = pow(Cmu, 0.25)*y_[patchNo] + Yp = pow(Cmu_.value(), 0.25)*y_[patchNo] *sqrt(k()().boundaryField()[patchNo].patchInternalField()) /nu().boundaryField()[patchNo]; } @@ -161,9 +159,9 @@ tmp RASModel::yPlus(const label patchNo) const WarningIn ( "tmp RASModel::yPlus(const label patchNo)" - ) << "const : " << endl - << "Patch " << patchNo << " is not a wall. Returning blank field" - << endl; + ) << "const : " << nl + << "Patch " << patchNo << " is not a wall. Returning zero field" + << nl << endl; Yp.setSize(0); } @@ -187,9 +185,11 @@ bool RASModel::read() { lookup("turbulence") >> turbulence_; coeffDict_ = subDict(type() + "Coeffs"); + wallFunctionDict_ = subDict("wallFunctionCoeffs"); - kappa_.readIfPresent(subDict("wallFunctionCoeffs")); - E_.readIfPresent(subDict("wallFunctionCoeffs")); + kappa_.readIfPresent(wallFunctionDict_); + E_.readIfPresent(wallFunctionDict_); + Cmu_.readIfPresent(wallFunctionDict_); yPlusLam_ = yPlusLam(kappa_.value(), E_.value()); diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H index 21220f2e3a..b5edce3ea3 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H @@ -93,7 +93,6 @@ protected: dimensionedScalar E_; dimensionedScalar Cmu_; - scalar yPlusLam(const scalar kappa, const scalar E); scalar yPlusLam_; dimensionedScalar k0_; @@ -236,6 +235,9 @@ public: return y_; } + //- Calculate y+ at the edge of the laminar sublayer + scalar yPlusLam(const scalar kappa, const scalar E) const; + //- Return y+ at the edge of the laminar sublayer // for use in wall-functions scalar yPlusLam() const diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index 7765dc0757..a4f0bd13f7 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -140,7 +140,7 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() volScalarField& epsilon = const_cast (db().lookupObject("epsilon")); - const scalarField& k = db().lookupObject("k"); + const volScalarField& k = db().lookupObject("k"); const scalarField& nuw = patch().lookupPatchField("nu"); @@ -158,9 +158,9 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() { label faceCellI = patch().faceCells()[faceI]; - scalar yPlus = Cmu25*y[faceCellI]*sqrt(k[faceCellI])/nuw[faceI]; + scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI]; - epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa*y[faceCellI]); + epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa*y[faceI]); if (yPlus > yPlusLam) { @@ -168,7 +168,11 @@ void epsilonWallFunctionFvPatchScalarField::updateCoeffs() (nutw[faceI] + nuw[faceI]) *magGradUw[faceI] *Cmu25*sqrt(k[faceCellI]) - /(kappa*y[faceCellI]); + /(kappa*y[faceI]); + } + else + { + G[faceCellI] = 0.0; } } diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C index 0a25cf0527..2f760cd9cf 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C @@ -100,83 +100,12 @@ fixedInternalValueFvPatchField::fixedInternalValueFvPatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -void fixedInternalValueFvPatchField::evaluate(const Pstream::commsTypes) -{ - if (!this->updated()) - { - this->updateCoeffs(); - } - - Info<< "fixedInternalValueFvPatchField::evaluate" << endl; - zeroGradientFvPatchField::evaluate(); -} - - -template -tmp > fixedInternalValueFvPatchField::valueInternalCoeffs -( - const tmp& -) const -{ - Info<< "fixedInternalValueFvPatchField::valueInternalCoeffs" << endl; - return tmp > - ( - new Field(this->size(), pTraits::one) - ); -} - - -template -tmp > fixedInternalValueFvPatchField::valueBoundaryCoeffs -( - const tmp& -) const -{ - Info<< "fixedInternalValueFvPatchField::valueBoundaryCoeffs" << endl; -// return tmp > -// ( -// new Field(this->size(), pTraits::zero) -// ); - return this->patchInternalField(); -} - - -template -tmp > fixedInternalValueFvPatchField:: -gradientInternalCoeffs() const -{ - Info<< "fixedInternalValueFvPatchField::gradientInternalCoeffs" - << endl; - return tmp > - ( - new Field(this->size(), pTraits::zero) - ); -} - - -template -tmp > fixedInternalValueFvPatchField:: -gradientBoundaryCoeffs() const -{ - Info<< "fixedInternalValueFvPatchField::gradientBoundaryCoeffs" - << endl; - return tmp > - ( - new Field(this->size(), pTraits::zero) - ); -} - - template void fixedInternalValueFvPatchField::manipulateMatrix ( fvMatrix& matrix ) { - Info<< "fixedInternalValueFvPatchField::manipulateMatrix(...)" - << endl; - // Apply the patch internal field as a constraint in the matrix matrix.setValues(this->patch().faceCells(), this->patchInternalField()); } diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H index 4783f65400..7ad3ed8f39 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H @@ -131,34 +131,6 @@ public: // Evaluation functions - //- Evaluate the patch field - virtual void evaluate - ( - const Pstream::commsTypes commsType=Pstream::Pstream::blocking - ); - - //- Return the matrix diagonal coefficients corresponding to the - // evaluation of the value of this patchField with given weights - virtual tmp > valueInternalCoeffs - ( - const tmp& - ) const; - - //- Return the matrix source coefficients corresponding to the - // evaluation of the value of this patchField with given weights - virtual tmp > valueBoundaryCoeffs - ( - const tmp& - ) const; - - //- Return the matrix diagonal coefficients corresponding to the - // evaluation of the gradient of this patchField - virtual tmp > gradientInternalCoeffs() const; - - //- Return the matrix source coefficients corresponding to the - // evaluation of the gradient of this patchField - virtual tmp > gradientBoundaryCoeffs() const; - //-Manipulate a matrix virtual void manipulateMatrix(fvMatrix& matrix); }; diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C index 233ab8de50..3cc934ebf7 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C @@ -45,6 +45,7 @@ namespace RASModels scalar nutRoughWallFunctionFvPatchScalarField::fnRough ( const scalar KsPlus, + const scalar Cs, const scalar kappa ) const { @@ -58,15 +59,15 @@ scalar nutRoughWallFunctionFvPatchScalarField::fnRough { deltaB = 1.0/kappa - *log((KsPlus - 2.25)/87.75 + Cs_*KsPlus) + *log((KsPlus - 2.25)/87.75 + Cs*KsPlus) *sin(0.4258*(log(KsPlus) - 0.811)); } else { - deltaB = 1.0/kappa*(1.0 + Cs_*KsPlus); + deltaB = 1.0/kappa*log(1.0 + Cs*KsPlus); } - return exp(deltaB*kappa); + return exp(min(deltaB*kappa, 50.0)); } @@ -80,8 +81,8 @@ nutRoughWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF), - Ks_(0.0), - Cs_(0.0) + Ks_(p.size(), 0.0), + Cs_(p.size(), 0.0) {} @@ -95,8 +96,8 @@ nutRoughWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(ptf, p, iF, mapper), - Ks_(ptf.Ks_), - Cs_(ptf.Cs_) + Ks_(ptf.Ks_, mapper), + Cs_(ptf.Cs_, mapper) {} @@ -109,8 +110,8 @@ nutRoughWallFunctionFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF, dict), - Ks_(readScalar(dict.lookup("Ks"))), - Cs_(readScalar(dict.lookup("Cs"))) + Ks_("Ks", dict, p.size()), + Cs_("Cs", dict, p.size()) {} @@ -133,12 +134,41 @@ nutRoughWallFunctionFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchScalarField(nrwfpsf, iF) + fixedValueFvPatchScalarField(nrwfpsf, iF), + Ks_(nrwfpsf.Ks_), + Cs_(nrwfpsf.Cs_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void nutRoughWallFunctionFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedValueFvPatchScalarField::autoMap(m); + Ks_.autoMap(m); + Cs_.autoMap(m); +} + + +void nutRoughWallFunctionFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchScalarField::rmap(ptf, addr); + + const nutRoughWallFunctionFvPatchScalarField& nrwfpsf = + refCast(ptf); + + Cs_.rmap(nrwfpsf.Cs_, addr); + Ks_.rmap(nrwfpsf.Ks_, addr); +} + + void nutRoughWallFunctionFvPatchScalarField::updateCoeffs() { const RASModel& ras = db().lookupObject("RASProperties"); @@ -147,7 +177,6 @@ void nutRoughWallFunctionFvPatchScalarField::updateCoeffs() const scalar Cmu25 = pow(Cmu, 0.25); const scalar kappa = ras.kappa().value(); const scalar E = ras.E().value(); - const scalar yPlusLam = ras.yPlusLam(); const scalarField& y = ras.y()[patch().index()]; @@ -164,11 +193,13 @@ void nutRoughWallFunctionFvPatchScalarField::updateCoeffs() scalar uStar = Cmu25*sqrt(k[faceCellI]); - scalar yPlus = uStar*y[faceCellI]/nuw[faceI]; + scalar yPlus = uStar*y[faceI]/nuw[faceI]; - scalar KsPlus = uStar*Ks_/nuw[faceI]; + scalar KsPlus = uStar*Ks_[faceI]/nuw[faceI]; - scalar Edash = E/fnRough(KsPlus, kappa); + scalar Edash = E/fnRough(KsPlus, Cs_[faceI], kappa); + + scalar yPlusLam = ras.yPlusLam(kappa, Edash); if (yPlus > yPlusLam) { diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H index e0c8122e4a..22f8a36cf2 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H @@ -32,6 +32,9 @@ Description 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) + SourceFiles nutRoughWallFunctionFvPatchScalarField.C @@ -62,16 +65,21 @@ class nutRoughWallFunctionFvPatchScalarField // Private data //- Roughness height - scalar Ks_; + scalarField Ks_; //- Roughness constant - scalar Cs_; + scalarField Cs_; // Private member functions //- Compute the roughness function - scalar fnRough(const scalar KsPlus, const scalar kappa) const; + scalar fnRough + ( + const scalar KsPlus, + const scalar Cs, + const scalar kappa + ) const; public: @@ -145,6 +153,21 @@ public: // Member functions + // 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& + ); + // Evaluation functions //- Update the coefficients associated with the patch field diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C index 25bbee8a29..d86963a792 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C @@ -112,7 +112,7 @@ void nutWallFunctionFvPatchScalarField::updateCoeffs() const scalarField& y = ras.y()[patch().index()]; - const scalarField& k = db().lookupObject("k"); + const volScalarField& k = db().lookupObject("k"); const scalarField& nuw = patch().lookupPatchField("nu"); @@ -123,7 +123,7 @@ void nutWallFunctionFvPatchScalarField::updateCoeffs() { label faceCellI = patch().faceCells()[faceI]; - scalar yPlus = Cmu25*y[faceCellI]*sqrt(k[faceCellI])/nuw[faceI]; + scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI]; if (yPlus > yPlusLam) { diff --git a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C index 9bc9aad003..213af8446c 100644 --- a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C @@ -130,7 +130,7 @@ kEpsilon::kEpsilon mesh_ ) { - nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); nut_.correctBoundaryConditions(); printCoeffs(); @@ -219,6 +219,11 @@ void kEpsilon::correct() RASModel::correct(); + if (mesh_.changing()) + { + y_.correct(); + } + volScalarField G("G", nut_*2*magSqr(symm(fvc::grad(U_)))); // Update espsilon and G at the wall From 7fbcce1596b201229d5486f647f04ae99fa69838 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 12 Sep 2008 11:58:07 +0100 Subject: [PATCH 12/44] new app to apply wall function BCs for incompressible RAS calcs --- .../Make/files | 3 + .../Make/options | 6 + .../applyWallFunctionBounaryConditions.C | 176 ++++++++++++++++++ 3 files changed, 185 insertions(+) create mode 100644 applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files create mode 100644 applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options create mode 100644 applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files new file mode 100644 index 0000000000..58f5dd3974 --- /dev/null +++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files @@ -0,0 +1,3 @@ +applyWallFunctionBounaryConditions.C + +EXE = $(FOAM_APPBIN)/applyWallFunctionBounaryConditions diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options new file mode 100644 index 0000000000..89e52b6d52 --- /dev/null +++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options @@ -0,0 +1,6 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lfiniteVolume + diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C new file mode 100644 index 0000000000..8b2eb197d7 --- /dev/null +++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C @@ -0,0 +1,176 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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 + +Application + applyWallFunctionBounaryConditions + +Description + Updates OpenFOAM incompressible RAS cases to use the new wall function + framework + + NOTE: For incompressible RAS calculations ONLY + +\*---------------------------------------------------------------------------*/ + + +#include "argList.H" +#include "fvMesh.H" +#include "Time.H" +#include "volFields.H" + +#include "wallPolyPatch.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// Main program: + +void createNut(const fvMesh& mesh) +{ + IOobject nutHeader + ( + "nut", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (!nutHeader.headerOk()) + { + Info<< "Creating field nut" << nl << endl; + + volScalarField nut + ( + IOobject + ( + "nut", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimensionSet(0, 2, -1, 0, 0), 0.0) + ); + + nut.write(); + } +} + + +void replaceBoundaryType +( + const fvMesh& mesh, + const word& fieldName, + const word& boundaryType, + const string& boundaryValue +) +{ + IOobject header + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (!header.headerOk()) + { + return; + } + + Info<< "Updating boundary types for field " << header.name() << endl; + + const word oldTypeName = IOdictionary::typeName; + const_cast(IOdictionary::typeName) = word::null; + + IOdictionary dict(header); + + const_cast(IOdictionary::typeName) = oldTypeName; + const_cast(dict.type()) = dict.headerClassName(); + + // Make a backup of the old field + word backupName(dict.name() + ".old"); + Info<< " copying original " << dict.name() << " to " + << backupName << endl; + IOdictionary dictOld = dict; + dictOld.rename(backupName); + dictOld.regIOobject::write(); + + // Loop through boundary patches and update + const polyBoundaryMesh& bMesh = mesh.boundaryMesh(); + dictionary& boundaryDict = dict.subDict("boundaryField"); + forAll(bMesh, patchI) + { + if (isType(bMesh[patchI])) + { + word patchName = bMesh[patchI].name(); + dictionary& oldPatch = boundaryDict.subDict(patchName); + + dictionary newPatch(dictionary::null); + newPatch.add("type", boundaryType); + newPatch.add("value", ("uniform " + boundaryValue).c_str()); + + oldPatch = newPatch; + } + } + + Info<< " writing updated " << dict.name() << nl << endl; + dict.regIOobject::write(); +} + + +int main(int argc, char *argv[]) +{ + +# include "addTimeOptions.H" +# include "setRootCase.H" +# include "createTime.H" +# include "createMesh.H" + + Info<< "Updating turbulence fields to operate using new run time " + << "selectable" << nl << "wall functions" << nl << nl + << ">>>>NOTE: only applicable to incompressible RAS models" + << nl << endl; + + createNut(mesh); + + replaceBoundaryType(mesh, "nut", "nutWallFunction", "0"); + replaceBoundaryType(mesh, "epsilon", "epsilonWallFunction", "0"); + replaceBoundaryType(mesh, "omega", "omegaWallFunction", "0"); + replaceBoundaryType(mesh, "k", "kQRWallFunction", "0"); + replaceBoundaryType(mesh, "q", "kQRWallFunction", "0"); + replaceBoundaryType(mesh, "R", "kQRWallFunction", "(0 0 0 0 0 0)"); + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // From dc69c60269e45c83518cbfce84a65175e7a93632 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 16 Sep 2008 12:13:12 +0100 Subject: [PATCH 13/44] update --- .../pitzDailyDirectMapped/constant/polyMesh/boundary | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/boundary b/tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/boundary index c67eadf385..3f70c82e67 100644 --- a/tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/boundary +++ b/tutorials/oodles/pitzDailyDirectMapped/constant/polyMesh/boundary @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.5 | +| \\ / O peration | Version: dev | | \\ / A nd | Web: http://www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -10,19 +10,22 @@ FoamFile version 2.0; format ascii; class polyBoundaryMesh; + location "constant/polyMesh"; object boundary; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + 5 ( inlet { + type directMappedPatch; nFaces 30; startFace 27238; - offset ( 0.0495 0 0 ); sampleMode nearestCell; samplePatch none; + offset ( 0.0495 0 0 ); } outlet @@ -55,4 +58,5 @@ frontAndBack ) + // ************************************************************************* // From 3acbb7bf74ba18a6c3cdc1667fdc3666717e135c Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 16 Sep 2008 13:37:08 +0100 Subject: [PATCH 14/44] adding new heat flux BCs --- .../RAS/compressible/Make/files | 1 + ...entHeatFluxTemperatureFvPatchScalarField.C | 203 ++++++++++++++++++ ...entHeatFluxTemperatureFvPatchScalarField.H | 176 +++++++++++++++ .../RAS/incompressible/Make/files | 1 + ...entHeatFluxTemperatureFvPatchScalarField.C | 191 ++++++++++++++++ ...entHeatFluxTemperatureFvPatchScalarField.H | 179 +++++++++++++++ 6 files changed, 751 insertions(+) create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H diff --git a/src/turbulenceModels/RAS/compressible/Make/files b/src/turbulenceModels/RAS/compressible/Make/files index aab9098c3d..34ecc34365 100644 --- a/src/turbulenceModels/RAS/compressible/Make/files +++ b/src/turbulenceModels/RAS/compressible/Make/files @@ -15,6 +15,7 @@ kOmegaSST/kOmegaSST.C wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.C /* Patch fields */ +derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C new file mode 100644 index 0000000000..9cd3901fe3 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C @@ -0,0 +1,203 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "turbulentHeatFluxTemperatureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(p, iF), + q_(p.size(), 0.0), + rhoName_("undefinedRho") +{} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const turbulentHeatFluxTemperatureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedGradientFvPatchScalarField(ptf, p, iF, mapper), + q_(ptf.q_, mapper), + rhoName_(ptf.rhoName_) +{} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedGradientFvPatchScalarField(p, iF), + q_("q", dict, p.size()), + rhoName_(dict.lookup("rho")) +{ + fvPatchField::operator=(patchInternalField()); + gradient() = 0.0; +} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf +) +: + fixedGradientFvPatchScalarField(thftpsf), + q_(thftpsf.q_), + rhoName_(thftpsf.rhoName_) +{} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(thftpsf, iF), + q_(thftpsf.q_), + rhoName_(thftpsf.rhoName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void turbulentHeatFluxTemperatureFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedGradientFvPatchScalarField::autoMap(m); + q_.autoMap(m); +} + + +void turbulentHeatFluxTemperatureFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedGradientFvPatchScalarField::rmap(ptf, addr); + + const turbulentHeatFluxTemperatureFvPatchScalarField& thftptf = + refCast + ( + ptf + ); + + q_.rmap(thftptf.q_, addr); +} + + +void turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const label patchI = patch().index(); + + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalarField alphaEffp = ras.alphaEff()().boundaryField()[patchI]; + + const basicThermo& thermo = + db().lookupObject("thermophysicalProperties"); + +// const scalarField& Tp = thermo.T().boundaryField()[patchI]; + const scalarField& Tp = *this; + + const scalarField Cpp = thermo.Cp(Tp, patchI); + + const scalarField& rhop = + patch().lookupPatchField(rhoName_); + + const scalar Ap = gSum(patch().magSf()); + + gradient() = q_/(Ap*rhop*Cpp*alphaEffp); + + fixedGradientFvPatchScalarField::updateCoeffs(); +} + + +void turbulentHeatFluxTemperatureFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + q_.writeEntry("q", os); + os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + gradient().writeEntry("gradient", os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentHeatFluxTemperatureFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + + +// ************************************************************************* // + diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H new file mode 100644 index 0000000000..c2ee7be012 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H @@ -0,0 +1,176 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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::turbulentHeatFluxTemperatureFvPatchScalarField + +Description + Fixed heat flux boundary condition for temperature. + +SourceFiles + turbulentHeatFluxTemperatureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulentHeatFluxTemperatureFvPatchScalarFields_H +#define turbulentHeatFluxTemperatureFvPatchScalarFields_H + +#include "fvPatchFields.H" +#include "fixedGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentHeatFluxTemperatureFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentHeatFluxTemperatureFvPatchScalarField +: + public fixedGradientFvPatchScalarField +{ +// Private data + + //- Heat flux [W] + scalarField q_; + + //- Name of density field + word rhoName_; + + +public: + + //- Runtime type information + TypeName("turbulentHeatFluxTemperature"); + + + // Constructors + + //- Construct from patch and internal field + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentHeatFluxTemperatureFvPatchScalarField onto + // a new patch + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const turbulentHeatFluxTemperatureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const turbulentHeatFluxTemperatureFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new turbulentHeatFluxTemperatureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const turbulentHeatFluxTemperatureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new turbulentHeatFluxTemperatureFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // 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& + ); + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/Make/files b/src/turbulenceModels/RAS/incompressible/Make/files index 6584fc6113..8319edbe82 100644 --- a/src/turbulenceModels/RAS/incompressible/Make/files +++ b/src/turbulenceModels/RAS/incompressible/Make/files @@ -24,6 +24,7 @@ wallFunctions/nutWallFunctions/nutStandardWallFunction/nutStandardWallFunctionFv wallFunctions/nutWallFunctions/nutStandardRoughWallFunction/nutStandardRoughWallFunctionFvPatchScalarField.C /* Patch fields */ +derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C new file mode 100644 index 0000000000..f51ccb7251 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C @@ -0,0 +1,191 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "turbulentHeatFluxTemperatureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(p, iF), + q_(p.size(), 0.0), + alphaEffName_("undefinedAlphaEff"), + CpName_("undefinedCp") +{} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const turbulentHeatFluxTemperatureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedGradientFvPatchScalarField(ptf, p, iF, mapper), + q_(ptf.q_, mapper), + alphaEffName_(ptf.alphaEffName_), + CpName_(ptf.CpName_) +{} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedGradientFvPatchScalarField(p, iF), + q_("q", dict, p.size()), + alphaEffName_(dict.lookup("alphaEff")), + CpName_(dict.lookup("Cp")) +{ + fvPatchField::operator=(patchInternalField()); + gradient() = 0.0; +} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf +) +: + fixedGradientFvPatchScalarField(thftpsf), + q_(thftpsf.q_), + alphaEffName_(thftpsf.alphaEffName_), + CpName_(thftpsf.CpName_) +{} + + +turbulentHeatFluxTemperatureFvPatchScalarField:: +turbulentHeatFluxTemperatureFvPatchScalarField +( + const turbulentHeatFluxTemperatureFvPatchScalarField& thftpsf, + const DimensionedField& iF +) +: + fixedGradientFvPatchScalarField(thftpsf, iF), + q_(thftpsf.q_), + alphaEffName_(thftpsf.alphaEffName_), + CpName_(thftpsf.CpName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void turbulentHeatFluxTemperatureFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + scalarField::autoMap(m); + q_.autoMap(m); +} + + +void turbulentHeatFluxTemperatureFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedGradientFvPatchScalarField::rmap(ptf, addr); + + const turbulentHeatFluxTemperatureFvPatchScalarField& thftptf = + refCast + ( + ptf + ); + + q_.rmap(thftptf.q_, addr); +} + + +void turbulentHeatFluxTemperatureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const scalarField& alphaEffp = + patch().lookupPatchField(alphaEffName_); + + const scalarField& Cpp = + patch().lookupPatchField(CpName_); + + gradient() = q_/(Cpp*alphaEffp); + + fixedGradientFvPatchScalarField::updateCoeffs(); +} + + +void turbulentHeatFluxTemperatureFvPatchScalarField::write(Ostream& os) const +{ + fixedGradientFvPatchScalarField::write(os); + q_.writeEntry("q", os); + os.writeKeyword("alphaEff") << alphaEffName_ << token::END_STATEMENT << nl; + os.writeKeyword("Cp") << CpName_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentHeatFluxTemperatureFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace incompressible +} // End namespace Foam + + +// ************************************************************************* // + diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H new file mode 100644 index 0000000000..de677f0e91 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.H @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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::turbulentHeatFluxTemperatureFvPatchScalarField + +Description + Fixed heat flux boundary condition for temperature. + +SourceFiles + turbulentHeatFluxTemperatureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulentHeatFluxTemperatureFvPatchScalarFields_H +#define turbulentHeatFluxTemperatureFvPatchScalarFields_H + +#include "fvPatchFields.H" +#include "fixedGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentHeatFluxTemperatureFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentHeatFluxTemperatureFvPatchScalarField +: + public fixedGradientFvPatchScalarField +{ +// Private data + + //- Heat flux [W/m2] + scalarField q_; + + //- Name of effective thermal diffusivity field + word alphaEffName_; + + //- Name of specific heat capacity field + word CpName_; + + +public: + + //- Runtime type information + TypeName("turbulentHeatFluxTemperature"); + + + // Constructors + + //- Construct from patch and internal field + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentHeatFluxTemperatureFvPatchScalarField onto + // a new patch + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const turbulentHeatFluxTemperatureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const turbulentHeatFluxTemperatureFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new turbulentHeatFluxTemperatureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + turbulentHeatFluxTemperatureFvPatchScalarField + ( + const turbulentHeatFluxTemperatureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new turbulentHeatFluxTemperatureFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // 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& + ); + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 17454ed31628d38bd4a2bffa09ed44da90dff2e1 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 19 Sep 2008 17:28:33 +0100 Subject: [PATCH 15/44] correcting typo --- src/sampling/sampledSet/sampledSets/sampledSets.C | 2 +- src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index eb31a2cabd..f9bb7a2067 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -269,7 +269,7 @@ void Foam::sampledSets::verbose(const bool verbosity) } -void::Foam::sampledSets::execute() +void Foam::sampledSets::execute() { // Do nothing - only valid on write } diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index 059be18833..0de0bc1d86 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -309,7 +309,7 @@ void Foam::sampledSurfaces::verbose(const bool verbosity) } -void::Foam::sampledSurfaces::execute() +void Foam::sampledSurfaces::execute() { // Do nothing - only valid on write } From 459024f8392e15054e7c6af1896f9ae3f444cd9e Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 19 Sep 2008 20:04:15 +0100 Subject: [PATCH 16/44] Changed gcc version to 4.3.2 and improved the "settings" scripts. --- etc/settings.csh | 14 ++++++-------- etc/settings.sh | 9 ++++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/etc/settings.csh b/etc/settings.csh index d21268aafb..cfa1927ef2 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -82,7 +82,10 @@ switch ("$WM_COMPILER_INST") case OpenFOAM: switch ("$WM_COMPILER") case Gcc: - setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH + #setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH + setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH + _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.3/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib breaksw case Gcc42: setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH @@ -105,13 +108,8 @@ case OpenFOAM: endsw if ($?WM_COMPILER_BIN) then - set path=($WM_COMPILER_BIN $path) - - if ($?LD_LIBRARY_PATH) then - setenv LD_LIBRARY_PATH ${WM_COMPILER_LIB}:${LD_LIBRARY_PATH} - else - setenv LD_LIBRARY_PATH ${WM_COMPILER_LIB} - endif + _foamAddPath $WM_COMPILER_BIN + _foamAddLib $WM_COMPILER_LIB endif unset WM_COMPILER_BIN diff --git a/etc/settings.sh b/etc/settings.sh index 612719e292..743d8e1fc0 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -99,7 +99,10 @@ case "$WM_COMPILER_INST" in OpenFOAM) case "$WM_COMPILER" in Gcc) - export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH + #export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.1/platforms/$WM_ARCH$WM_COMPILER_ARCH + export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH + _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.3/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib ;; Gcc42) export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH @@ -123,8 +126,8 @@ OpenFOAM) esac if [ -d "$WM_COMPILER_BIN" ]; then - export PATH=$WM_COMPILER_BIN:$PATH - export LD_LIBRARY_PATH=$WM_COMPILER_LIB:$LD_LIBRARY_PATH + _foamAddPath $WM_COMPILER_BIN + _foamAddLib $WM_COMPILER_LIB fi unset WM_COMPILER_BIN WM_COMPILER_LIB From 6f92026da453813ccbe9dfd95d68e085228d3f46 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 23 Sep 2008 12:54:07 +0100 Subject: [PATCH 17/44] Updated compressible RAS models to use the new run-time selectable wall functions, and added commpressible variants of the mut wall functions employed in the incompressible libraray. - minor updates to the icompressible RAS model library --- .../fixedInternalValueFvPatchField.C | 0 .../fixedInternalValueFvPatchField.H | 2 +- .../fixedInternalValueFvPatchFields.C | 0 .../fixedInternalValueFvPatchFields.H | 0 .../RAS/compressible/LRR/LRR.C | 20 +- .../LaunderGibsonRSTM/LaunderGibsonRSTM.C | 21 +- .../RAS/compressible/Make/files | 15 +- .../RAS/compressible/RASModel/RASModel.C | 12 +- .../RAS/compressible/RASModel/RASModel.H | 24 +- .../compressible/RNGkEpsilon/RNGkEpsilon.C | 21 +- .../epsilonWallFunctionFvPatchScalarField.C | 218 +++++++++++++++ .../epsilonWallFunctionFvPatchScalarField.H | 164 ++++++++++++ .../kQRWallFunctionFvPatchField.C | 155 +++++++++++ .../kQRWallFunctionFvPatchField.H | 170 ++++++++++++ .../kQRWallFunctionFvPatchFields.C | 51 ++++ .../kQRWallFunctionFvPatchFields.H | 56 ++++ .../mutRoughWallFunctionFvPatchScalarField.C | 248 ++++++++++++++++++ .../mutRoughWallFunctionFvPatchScalarField.H | 194 ++++++++++++++ ...dardRoughWallFunctionFvPatchScalarField.C} | 37 +-- ...dardRoughWallFunctionFvPatchScalarField.H} | 46 ++-- ...asStandardWallFunctionFvPatchScalarField.C | 175 ++++++++++++ ...asStandardWallFunctionFvPatchScalarField.H | 158 +++++++++++ ...rtAllmarasWallFunctionFvPatchScalarField.C | 187 +++++++++++++ ...rtAllmarasWallFunctionFvPatchScalarField.H | 150 +++++++++++ .../mutWallFunctionFvPatchScalarField.C | 162 ++++++++++++ .../mutWallFunctionFvPatchScalarField.H | 155 +++++++++++ .../omegaWallFunctionFvPatchScalarField.C | 205 +++++++++++++++ .../omegaWallFunctionFvPatchScalarField.H | 159 +++++++++++ .../wallDissipationI.H | 0 .../wallFunctionsI.H | 0 .../wallViscosityI.H | 0 .../RAS/compressible/kEpsilon/kEpsilon.C | 24 +- .../RAS/compressible/kOmegaSST/kOmegaSST.C | 23 +- .../compressible/realizableKE/realizableKE.C | 22 +- .../RAS/incompressible/LRR/LRR.C | 2 +- .../LaunderGibsonRSTM/LaunderGibsonRSTM.C | 2 +- .../incompressible/LienCubicKE/LienCubicKE.C | 39 ++- .../incompressible/RNGkEpsilon/RNGkEpsilon.C | 2 +- .../epsilonWallFunctionFvPatchScalarField.H | 2 +- .../kQRWallFunctionFvPatchField.H | 2 +- .../nutRoughWallFunctionFvPatchScalarField.H | 2 +- ...asStandardWallFunctionFvPatchScalarField.H | 2 +- .../nutWallFunctionFvPatchScalarField.H | 2 +- .../omegaWallFunctionFvPatchScalarField.H | 2 +- .../nonLinearWallFunctionsI.H | 0 .../wallDissipationI.H | 0 .../wallFunctionsI.H.old | 0 .../wallNonlinearViscosityI.H | 0 .../wallViscosityI.H.old | 0 .../RAS/incompressible/kOmega/kOmega.C | 2 +- .../RAS/incompressible/kOmegaSST/kOmegaSST.C | 2 +- .../realizableKE/realizableKE.C | 2 +- 52 files changed, 2812 insertions(+), 125 deletions(-) rename src/{turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions => finiteVolume/fields/fvPatchFields/derived}/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C (100%) rename src/{turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions => finiteVolume/fields/fvPatchFields/derived}/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H (98%) rename src/{turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions => finiteVolume/fields/fvPatchFields/derived}/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C (100%) rename src/{turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions => finiteVolume/fields/fvPatchFields/derived}/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H (100%) create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H rename src/turbulenceModels/RAS/compressible/{wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.C => derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C} (88%) rename src/turbulenceModels/RAS/compressible/{wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.H => derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H} (76%) create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H rename src/turbulenceModels/RAS/compressible/{wallFunctions => include}/wallDissipationI.H (100%) rename src/turbulenceModels/RAS/compressible/{wallFunctions => include}/wallFunctionsI.H (100%) rename src/turbulenceModels/RAS/compressible/{wallFunctions => include}/wallViscosityI.H (100%) rename src/turbulenceModels/RAS/incompressible/{wallFunctions => include}/nonLinearWallFunctionsI.H (100%) rename src/turbulenceModels/RAS/incompressible/{wallFunctions => include}/wallDissipationI.H (100%) rename src/turbulenceModels/RAS/incompressible/{wallFunctions => include}/wallFunctionsI.H.old (100%) rename src/turbulenceModels/RAS/incompressible/{wallFunctions => include}/wallNonlinearViscosityI.H (100%) rename src/turbulenceModels/RAS/incompressible/{wallFunctions => include}/wallViscosityI.H.old (100%) diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C similarity index 100% rename from src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C rename to src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H similarity index 98% rename from src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H rename to src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H index 7ad3ed8f39..2ba782a1e4 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - fixedInternalValueFvPatchField + Foam::incompressible::RASModels::fixedInternalValueFvPatchField Description Boundary condition providing mechanism to set boundary (cell) values diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C similarity index 100% rename from src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C rename to src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H similarity index 100% rename from src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H rename to src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H diff --git a/src/turbulenceModels/RAS/compressible/LRR/LRR.C b/src/turbulenceModels/RAS/compressible/LRR/LRR.C index 4a703d2c8f..b5b03a8f63 100644 --- a/src/turbulenceModels/RAS/compressible/LRR/LRR.C +++ b/src/turbulenceModels/RAS/compressible/LRR/LRR.C @@ -201,13 +201,14 @@ LRR::LRR "mut", runTime_.timeName(), mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::MUST_READ, + IOobject::AUTO_WRITE ), - Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_) + mesh_ ) { -# include "wallViscosityI.H" + mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) { @@ -311,15 +312,17 @@ void LRR::correct() { // Re-calculate viscosity mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); return; } RASModel::correct(); volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_)); - volScalarField G = 0.5*tr(P); + volScalarField G("G", 0.5*tr(P)); -# include "wallFunctionsI.H" + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); // Dissipation equation tmp epsEqn @@ -335,7 +338,7 @@ void LRR::correct() epsEqn().relax(); -# include "wallDissipationI.H" + epsEqn().boundaryManipulate(epsilon_.boundaryField()); solve(epsEqn); bound(epsilon_, epsilon0_); @@ -398,8 +401,7 @@ void LRR::correct() // Re-calculate viscosity mut_ = rho_*Cmu_*sqr(k_)/epsilon_; - -# include "wallViscosityI.H" + mut_.correctBoundaryConditions(); // Correct wall shear stresses diff --git a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C index 4b977f0809..2bb710ea88 100644 --- a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -223,13 +223,14 @@ LaunderGibsonRSTM::LaunderGibsonRSTM "mut", runTime_.timeName(), mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::MUST_READ, + IOobject::AUTO_WRITE ), - Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_) + mesh_ ) { -# include "wallViscosityI.H" + mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) { @@ -336,6 +337,7 @@ void LaunderGibsonRSTM::correct() { // Re-calculate viscosity mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); return; } @@ -347,9 +349,10 @@ void LaunderGibsonRSTM::correct() } volSymmTensorField P = -twoSymm(R_ & fvc::grad(U_)); - volScalarField G = 0.5*tr(P); + volScalarField G("G", 0.5*tr(P)); -# include "wallFunctionsI.H" + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); // Dissipation equation tmp epsEqn @@ -365,7 +368,7 @@ void LaunderGibsonRSTM::correct() epsEqn().relax(); -# include "wallDissipationI.H" + epsEqn().boundaryManipulate(epsilon_.boundaryField()); solve(epsEqn); bound(epsilon_, epsilon0_); @@ -437,9 +440,7 @@ void LaunderGibsonRSTM::correct() // Re-calculate turbulent viscosity mut_ = Cmu_*rho_*sqr(k_)/epsilon_; - - -# include "wallViscosityI.H" + mut_.correctBoundaryConditions(); // Correct wall shear stresses diff --git a/src/turbulenceModels/RAS/compressible/Make/files b/src/turbulenceModels/RAS/compressible/Make/files index aab9098c3d..14d8e96ebb 100644 --- a/src/turbulenceModels/RAS/compressible/Make/files +++ b/src/turbulenceModels/RAS/compressible/Make/files @@ -12,7 +12,20 @@ SpalartAllmaras/SpalartAllmaras.C kOmegaSST/kOmegaSST.C /* Wall functions */ -wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.C +derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C +derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C + +derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C +derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C + +derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H + +derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C + +derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C + +derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C /* Patch fields */ derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C index 38d6266d7b..a38da49b0e 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C @@ -87,6 +87,7 @@ RASModel::RASModel printCoeffs_(lookupOrDefault("printCoeffs", false)), coeffDict_(subDict(type + "Coeffs")), + wallFunctionDict_(subDict("wallFunctionCoeffs")), kappa_ ( dimensioned::lookupOrAddToDict @@ -105,6 +106,15 @@ RASModel::RASModel 9.0 ) ), + Cmu_ + ( + dimensioned::lookupOrAddToDict + ( + "Cmu", + wallFunctionDict_, + 0.09 + ) + ), yPlusLam_(yPlusLam(kappa_.value(), E_.value())), @@ -118,7 +128,7 @@ RASModel::RASModel // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -scalar RASModel::yPlusLam(const scalar kappa, const scalar E) +scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const { scalar ypl = 11.0; diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H index 47feaebe18..51b4e706da 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H @@ -91,10 +91,11 @@ protected: Switch printCoeffs_; dictionary coeffDict_; + dictionary wallFunctionDict_; dimensionedScalar kappa_; dimensionedScalar E_; + dimensionedScalar Cmu_; - scalar yPlusLam(const scalar kappa, const scalar E); scalar yPlusLam_; dimensionedScalar k0_; @@ -237,6 +238,21 @@ public: return E_; } + //- Return Cmu for use in wall-functions + dimensionedScalar Cmu() const + { + return Cmu_; + } + + //- Return the near wall distances + const nearWallDist& y() const + { + return y_; + } + + //- Calculate y+ at the edge of the laminar sublayer + scalar yPlusLam(const scalar kappa, const scalar E) const; + //- Return y+ at the edge of the laminar sublayer // for use in wall-functions scalar yPlusLam() const @@ -250,6 +266,12 @@ public: return coeffDict_; } + //- Const access to the wall functions coefficients dictionary + const dictionary& walLFunctionDict() const + { + return wallFunctionDict_; + } + //- Return the laminar viscosity const volScalarField& mu() const diff --git a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C index f2a3562365..3860918ea1 100644 --- a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C +++ b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C @@ -170,13 +170,14 @@ RNGkEpsilon::RNGkEpsilon "mut", runTime_.timeName(), mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::MUST_READ, + IOobject::AUTO_WRITE ), - Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_) + mesh_ ) { -# include "wallViscosityI.H" + mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); printCoeffs(); } @@ -263,6 +264,7 @@ void RNGkEpsilon::correct() { // Re-calculate viscosity mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); return; } @@ -279,7 +281,7 @@ void RNGkEpsilon::correct() volScalarField S2 = (tgradU() && dev(twoSymm(tgradU()))); tgradU.clear(); - volScalarField G = mut_*S2; + volScalarField G("G", mut_*S2); volScalarField eta = sqrt(mag(S2))*k_/epsilon_; volScalarField eta3 = eta*sqr(eta); @@ -287,7 +289,8 @@ void RNGkEpsilon::correct() volScalarField R = ((eta*(-eta/eta0_ + scalar(1)))/(beta_*eta3 + scalar(1))); -# include "wallFunctionsI.H" + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); // Dissipation equation tmp epsEqn @@ -303,7 +306,7 @@ void RNGkEpsilon::correct() epsEqn().relax(); -# include "wallDissipationI.H" + epsEqn().boundaryManipulate(epsilon_.boundaryField()); solve(epsEqn); bound(epsilon_, epsilon0_); @@ -328,9 +331,7 @@ void RNGkEpsilon::correct() // Re-calculate viscosity mut_ = rho_*Cmu_*sqr(k_)/epsilon_; - -# include "wallViscosityI.H" - + mut_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..b22c101340 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -0,0 +1,218 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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 "epsilonWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void epsilonWallFunctionFvPatchScalarField::checkType() +{ + if (!isA(patch())) + { + FatalErrorIn("epsilonWallFunctionFvPatchScalarField::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); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(p, iF) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const epsilonWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedInternalValueFvPatchField(ptf, p, iF, mapper) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedInternalValueFvPatchField(p, iF, dict) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const epsilonWallFunctionFvPatchScalarField& ewfpsf +) +: + fixedInternalValueFvPatchField(ewfpsf) +{ + checkType(); +} + + +epsilonWallFunctionFvPatchScalarField::epsilonWallFunctionFvPatchScalarField +( + const epsilonWallFunctionFvPatchScalarField& ewfpsf, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(ewfpsf, iF) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void epsilonWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + const scalar Cmu75 = pow(Cmu, 0.75); + const scalar kappa = ras.kappa().value(); + const scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + volScalarField& G = const_cast + (db().lookupObject("G")); + + volScalarField& epsilon = const_cast + (db().lookupObject("epsilon")); + + const volScalarField& k = db().lookupObject("k"); + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + + const scalarField& mutw = + patch().lookupPatchField("mut"); + + const fvPatchVectorField& Uw = + patch().lookupPatchField("U"); + + const scalarField magGradUw = mag(Uw.snGrad()); + + // Set epsilon and G + forAll(mutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar yPlus = + Cmu25*y[faceI]*sqrt(k[faceCellI]) + /(muw[faceI]/rhow[faceI]); + + epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa*y[faceI]); + + if (yPlus > yPlusLam) + { + G[faceCellI] = + (mutw[faceI] + muw[faceI]) + *magGradUw[faceI] + *Cmu25*sqrt(k[faceCellI]) + /(kappa*y[faceI]); + } + else + { + G[faceCellI] = 0.0; + } + } + + // TODO: perform averaging for cells sharing more than one boundary face +} + + +void epsilonWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes commsType +) +{ + fixedInternalValueFvPatchField::evaluate(commsType); +} + + +void epsilonWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fixedInternalValueFvPatchField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + epsilonWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..2cb6b336bf --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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::compressible::RASModels::epsilonWallFunctionFvPatchScalarField + +Description + Boundary condition for epsilon when using wall functions + - calculates epsilon and G + - epsilon values added directly into the matrix to act as a constraint + +SourceFiles + epsilonWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef epsilonWallFunctionFvPatchScalarField_H +#define epsilonWallFunctionFvPatchScalarField_H + +#include "fixedInternalValueFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class epsilonWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class epsilonWallFunctionFvPatchScalarField +: + public fixedInternalValueFvPatchField +{ + + // Private member functions + + //- Check the type of the patch + void checkType(); + + +public: + + //- Runtime type information + TypeName("epsilonWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + epsilonWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + epsilonWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // epsilonWallFunctionFvPatchScalarField + // onto a new patch + epsilonWallFunctionFvPatchScalarField + ( + const epsilonWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + epsilonWallFunctionFvPatchScalarField + ( + const epsilonWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new epsilonWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + epsilonWallFunctionFvPatchScalarField + ( + const epsilonWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new epsilonWallFunctionFvPatchScalarField(*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 + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C new file mode 100644 index 0000000000..9f6a7d71f9 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.C @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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 "kQRWallFunctionFvPatchField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void kQRWallFunctionFvPatchField::checkType() +{ + if (!isA(this->patch())) + { + FatalErrorIn("kQRWallFunctionFvPatchField::checkType()") + << "Invalid wall function specification" << nl + << " Patch type for patch " << this->patch().name() + << " must be wall" << nl + << " Current patch type is " << this->patch().type() + << nl << endl << abort(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + zeroGradientFvPatchField(p, iF) +{ + checkType(); +} + + +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField +( + const kQRWallFunctionFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + zeroGradientFvPatchField(ptf, p, iF, mapper) +{ + checkType(); +} + + +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + zeroGradientFvPatchField(p, iF, dict) +{ + checkType(); +} + + +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField +( + const kQRWallFunctionFvPatchField& tkqrwfpf +) +: + zeroGradientFvPatchField(tkqrwfpf) +{ + checkType(); +} + + +template +kQRWallFunctionFvPatchField::kQRWallFunctionFvPatchField +( + const kQRWallFunctionFvPatchField& tkqrwfpf, + const DimensionedField& iF +) +: + zeroGradientFvPatchField(tkqrwfpf, iF) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void kQRWallFunctionFvPatchField::evaluate +( + const Pstream::commsTypes commsType +) +{ + zeroGradientFvPatchField::evaluate(commsType); +} + + +template +void kQRWallFunctionFvPatchField::write(Ostream& os) const +{ + zeroGradientFvPatchField::write(os); + this->writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H new file mode 100644 index 0000000000..05ed2fbcb8 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H @@ -0,0 +1,170 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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::compressible::RASModels::kQRWallFunctionFvPatchField + +Description + Boundary condition for turbulence k, Q, and R when using wall functions. + Simply acts as a zero gradient condition. + +SourceFiles + kQRWallFunctionFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef kQRWallFunctionFvPatchField_H +#define kQRWallFunctionFvPatchField_H + +#include "zeroGradientFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class kQRWallFunctionFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class kQRWallFunctionFvPatchField +: + public zeroGradientFvPatchField +{ + + // Private member functions + + //- Check the type of the patch + void checkType(); + + +public: + + //- Runtime type information + TypeName("kQRWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + kQRWallFunctionFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + kQRWallFunctionFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // kQRWallFunctionFvPatchField + // onto a new patch + kQRWallFunctionFvPatchField + ( + const kQRWallFunctionFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + kQRWallFunctionFvPatchField + ( + const kQRWallFunctionFvPatchField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new kQRWallFunctionFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + kQRWallFunctionFvPatchField + ( + const kQRWallFunctionFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new kQRWallFunctionFvPatchField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::Pstream::blocking + ); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "kQRWallFunctionFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C new file mode 100644 index 0000000000..6942ba56b1 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "kQRWallFunctionFvPatchFields.H" +#include "fvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(kQRWallFunction); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H new file mode 100644 index 0000000000..e1297548be --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.H @@ -0,0 +1,56 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 + +\*---------------------------------------------------------------------------*/ + +#ifndef kQRWallFunctionFvPatchFields_H +#define kQRWallFunctionFvPatchFields_H + +#include "kQRWallFunctionFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(kQRWallFunction) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..67ad5536df --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C @@ -0,0 +1,248 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "mutRoughWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +scalar mutRoughWallFunctionFvPatchScalarField::fnRough +( + const scalar KsPlus, + const scalar Cs, + const scalar kappa +) const +{ + // Set deltaB based on non-dimensional roughness height + scalar deltaB = 0.0; + if (KsPlus < 90.0) + { + deltaB = + 1.0/kappa + *log((KsPlus - 2.25)/87.75 + Cs*KsPlus) + *sin(0.4258*(log(KsPlus) - 0.811)); + } + else + { + deltaB = 1.0/kappa*log(1.0 + Cs*KsPlus); + } + + return exp(min(deltaB*kappa, 50.0)); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mutRoughWallFunctionFvPatchScalarField:: +mutRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + Ks_(p.size(), 0.0), + Cs_(p.size(), 0.0) +{} + + +mutRoughWallFunctionFvPatchScalarField:: +mutRoughWallFunctionFvPatchScalarField +( + const mutRoughWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + Ks_(ptf.Ks_, mapper), + Cs_(ptf.Cs_, mapper) +{} + + +mutRoughWallFunctionFvPatchScalarField:: +mutRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + Ks_("Ks", dict, p.size()), + Cs_("Cs", dict, p.size()) +{} + + +mutRoughWallFunctionFvPatchScalarField:: +mutRoughWallFunctionFvPatchScalarField +( + const mutRoughWallFunctionFvPatchScalarField& nrwfpsf +) +: + fixedValueFvPatchScalarField(nrwfpsf), + Ks_(nrwfpsf.Ks_), + Cs_(nrwfpsf.Cs_) +{} + + +mutRoughWallFunctionFvPatchScalarField:: +mutRoughWallFunctionFvPatchScalarField +( + const mutRoughWallFunctionFvPatchScalarField& nrwfpsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(nrwfpsf, iF), + Ks_(nrwfpsf.Ks_), + Cs_(nrwfpsf.Cs_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void mutRoughWallFunctionFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedValueFvPatchScalarField::autoMap(m); + Ks_.autoMap(m); + Cs_.autoMap(m); +} + + +void mutRoughWallFunctionFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchScalarField::rmap(ptf, addr); + + const mutRoughWallFunctionFvPatchScalarField& nrwfpsf = + refCast(ptf); + + Cs_.rmap(nrwfpsf.Cs_, addr); + Ks_.rmap(nrwfpsf.Ks_, addr); +} + + +void mutRoughWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + const scalar kappa = ras.kappa().value(); + const scalar E = ras.E().value(); + scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const scalarField& k = db().lookupObject("k"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + + scalarField& mutw = *this; + + forAll(mutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar uStar = Cmu25*sqrt(k[faceCellI]); + + scalar yPlus = uStar*y[faceI]/(muw[faceI]/rhow[faceI]); + + scalar KsPlus = uStar*Ks_[faceI]/(muw[faceI]/rhow[faceI]); + + scalar Edash = E; + scalar yPlusLamNew = yPlusLam; + if (KsPlus > 2.25) + { + Edash = E/fnRough(KsPlus, Cs_[faceI], kappa); + yPlusLam = ras.yPlusLam(kappa, Edash); + } + + if (debug) + { + Info<< "yPlus = " << yPlus + << ", KsPlus = " << KsPlus + << ", Edash = " << Edash + << ", yPlusLam = " << yPlusLam + << endl; + } + + if (yPlus > yPlusLamNew) + { + mutw[faceI] = muw[faceI]*(yPlus*kappa/log(Edash*yPlus) - 1); + } + else + { + mutw[faceI] = 0.0; + } + } +} + + +void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField::write(os); + Cs_.writeEntry("Cs", os); + Ks_.writeEntry("Ks", os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, mutRoughWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..830e320646 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.H @@ -0,0 +1,194 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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::compressible::RASModels::nutRoughWallFunctionFvPatchScalarField + +Description + Boundary condition for turbulent (kinematic) 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) + +SourceFiles + mutRoughWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mutRoughWallFunctionFvPatchScalarField_H +#define mutRoughWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class mutRoughWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class mutRoughWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Roughness height + scalarField Ks_; + + //- Roughness constant + scalarField Cs_; + + + // Private member functions + + //- Compute the roughness function + scalar fnRough + ( + const scalar KsPlus, + const scalar Cs, + const scalar kappa + ) const; + + +public: + + //- Runtime type information + TypeName("mutRoughWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + mutRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + mutRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // mutRoughWallFunctionFvPatchScalarField + // onto a new patch + mutRoughWallFunctionFvPatchScalarField + ( + const mutRoughWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + mutRoughWallFunctionFvPatchScalarField + ( + const mutRoughWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new mutRoughWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + mutRoughWallFunctionFvPatchScalarField + ( + const mutRoughWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new mutRoughWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // 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& + ); + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C similarity index 88% rename from src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.C rename to src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C index d712e56bd9..8cff5793be 100644 --- a/src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ -#include "mutStandardRoughWallFunctionFvPatchScalarField.H" +#include "mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H" #include "RASModel.H" #include "fvPatchFieldMapper.H" #include "volFields.H" @@ -41,8 +41,8 @@ namespace RASModels // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -mutStandardRoughWallFunctionFvPatchScalarField:: -mutStandardRoughWallFunctionFvPatchScalarField +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF @@ -55,10 +55,10 @@ mutStandardRoughWallFunctionFvPatchScalarField {} -mutStandardRoughWallFunctionFvPatchScalarField:: -mutStandardRoughWallFunctionFvPatchScalarField +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField ( - const mutStandardRoughWallFunctionFvPatchScalarField& ptf, + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& ptf, const fvPatch& p, const DimensionedField& iF, const fvPatchFieldMapper& mapper @@ -71,8 +71,8 @@ mutStandardRoughWallFunctionFvPatchScalarField {} -mutStandardRoughWallFunctionFvPatchScalarField:: -mutStandardRoughWallFunctionFvPatchScalarField +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField& iF, @@ -86,10 +86,10 @@ mutStandardRoughWallFunctionFvPatchScalarField {} -mutStandardRoughWallFunctionFvPatchScalarField:: -mutStandardRoughWallFunctionFvPatchScalarField +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField ( - const mutStandardRoughWallFunctionFvPatchScalarField& tppsf + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf ) : fixedValueFvPatchScalarField(tppsf), @@ -99,10 +99,10 @@ mutStandardRoughWallFunctionFvPatchScalarField {} -mutStandardRoughWallFunctionFvPatchScalarField:: -mutStandardRoughWallFunctionFvPatchScalarField +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField ( - const mutStandardRoughWallFunctionFvPatchScalarField& tppsf, + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& tppsf, const DimensionedField& iF ) : @@ -115,7 +115,7 @@ mutStandardRoughWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void mutStandardRoughWallFunctionFvPatchScalarField::evaluate +void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::evaluate ( const Pstream::commsTypes ) @@ -282,7 +282,10 @@ void mutStandardRoughWallFunctionFvPatchScalarField::evaluate } -void mutStandardRoughWallFunctionFvPatchScalarField::write(Ostream& os) const +void mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::write +( + Ostream& os +) const { fixedValueFvPatchScalarField::write(os); os.writeKeyword("roughnessHeight") @@ -299,7 +302,7 @@ void mutStandardRoughWallFunctionFvPatchScalarField::write(Ostream& os) const makePatchTypeField ( fvPatchScalarField, - mutStandardRoughWallFunctionFvPatchScalarField + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H similarity index 76% rename from src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.H rename to src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H index 7c8e561793..7341cea241 100644 --- a/src/turbulenceModels/RAS/compressible/wallFunctions/mutWallFunctions/mutStandardRoughWallFunction/mutStandardRoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.H @@ -23,18 +23,19 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::compressible::RASModels::mutStandardRoughWallFunctionFvPatchScalarField + Foam::compressible::RASModels:: + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField Description Wall function boundary condition for rough walls SourceFiles - mutStandardWallFunctionFvPatchScalarField.C + mutSpalartAllamarasStandardWallFunctionFvPatchScalarField.C \*---------------------------------------------------------------------------*/ -#ifndef mutStandardRoughWallFunctionFvPatchScalarField_H -#define mutStandardRoughWallFunctionFvPatchScalarField_H +#ifndef mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H +#define mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField_H #include "fixedValueFvPatchFields.H" @@ -48,10 +49,10 @@ namespace RASModels { /*---------------------------------------------------------------------------*\ - Class mutWallFunctionFvPatch Declaration +Class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ -class mutStandardRoughWallFunctionFvPatchScalarField +class mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField : public fixedValueFvPatchScalarField { @@ -65,41 +66,41 @@ class mutStandardRoughWallFunctionFvPatchScalarField public: //- Runtime type information - TypeName("mutStandardRoughWallFunction"); + TypeName("mutSpalartAllmarasStandardRoughWallFunction"); // Constructors //- Construct from patch and internal field - mutStandardRoughWallFunctionFvPatchScalarField + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField ( const fvPatch&, const DimensionedField& ); //- Construct from patch, internal field and dictionary - mutStandardRoughWallFunctionFvPatchScalarField + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField ( const fvPatch&, const DimensionedField&, const dictionary& ); - //- Construct by mapping given - // mutStandardRoughWallFunctionFvPatchScalarField + //- Construct by mapping given + // mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField // onto a new patch - mutStandardRoughWallFunctionFvPatchScalarField + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField ( - const mutStandardRoughWallFunctionFvPatchScalarField&, + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&, const fvPatch&, const DimensionedField&, const fvPatchFieldMapper& ); //- Construct as copy - mutStandardRoughWallFunctionFvPatchScalarField + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField ( - const mutStandardRoughWallFunctionFvPatchScalarField& + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField& ); //- Construct and return a clone @@ -107,14 +108,17 @@ public: { return tmp ( - new mutStandardRoughWallFunctionFvPatchScalarField(*this) + new mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + *this + ) ); } //- Construct as copy setting internal field reference - mutStandardRoughWallFunctionFvPatchScalarField + mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField ( - const mutStandardRoughWallFunctionFvPatchScalarField&, + const mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField&, const DimensionedField& ); @@ -126,7 +130,11 @@ public: { return tmp ( - new mutStandardRoughWallFunctionFvPatchScalarField(*this, iF) + new mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField + ( + *this, + iF + ) ); } diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..669d0e72f8 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -0,0 +1,175 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{} + + +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + scalar kappa = ras.kappa().value(); + scalar E = ras.E().value(); + scalar yPlusLam = ras.yPlusLam(); + + const scalarField& ry = patch().deltaCoeffs(); + + const fvPatchVectorField& U = + patch().lookupPatchField("U"); + + scalarField magUp = mag(U.patchInternalField() - U); + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + scalarField& mutw = *this; + + scalarField magFaceGradU = mag(U.snGrad()); + + forAll(mutw, faceI) + { + scalar magUpara = magUp[faceI]; + + scalar kappaRe = kappa*magUpara/((muw[faceI]/rhow[faceI])*ry[faceI]); + + scalar yPlus = yPlusLam; + scalar ryPlusLam = 1.0/yPlus; + + int iter = 0; + scalar yPlusLast = 0.0; + + do + { + yPlusLast = yPlus; + yPlus = (kappaRe + yPlus)/(1.0 + log(E*yPlus)); + + } while(mag(ryPlusLam*(yPlus - yPlusLast)) > 0.01 && ++iter < 10 ); + + if (yPlus > yPlusLam) + { + mutw[faceI] = muw[faceI]*(yPlus*kappa/log(E*yPlus) - 1); + } + else + { + mutw[faceI] = 0.0; + } + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..c55a1fb0c6 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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::compressible::RASModels:: + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + +Description + Wall function boundary condition for walls + +SourceFiles + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H +#define mutSpalartAllmarasStandardWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class mutSpalartAllmarasStandardWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class mutSpalartAllmarasStandardWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + +public: + + //- Runtime type information + TypeName("mutSpalartAllmarasStandardWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + // onto a new patch + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasStandardWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new mutSpalartAllmarasStandardWallFunctionFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..f9e92d19ba --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -0,0 +1,187 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "mutSpalartAllmarasWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mutSpalartAllmarasWallFunctionFvPatchScalarField:: +mutSpalartAllmarasWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +mutSpalartAllmarasWallFunctionFvPatchScalarField:: +mutSpalartAllmarasWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +mutSpalartAllmarasWallFunctionFvPatchScalarField:: +mutSpalartAllmarasWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +mutSpalartAllmarasWallFunctionFvPatchScalarField:: +mutSpalartAllmarasWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{} + + +mutSpalartAllmarasWallFunctionFvPatchScalarField:: +mutSpalartAllmarasWallFunctionFvPatchScalarField +( + const mutSpalartAllmarasWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void mutSpalartAllmarasWallFunctionFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + scalar kappa = ras.kappa().value(); + scalar E = ras.E().value(); + + const scalarField& ry = patch().deltaCoeffs(); + + const fvPatchVectorField& U = + patch().lookupPatchField("U"); + + scalarField magUp = mag(U.patchInternalField() - U); + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + + scalarField& mutw = *this; + + scalarField magFaceGradU = mag(U.snGrad()); + + forAll(mutw, faceI) + { + scalar magUpara = magUp[faceI]; + + scalar utau = + sqrt((mutw[faceI] + muw[faceI])*magFaceGradU[faceI]/rhow[faceI]); + + if (utau > VSMALL) + { + int iter = 0; + scalar err = GREAT; + + do + { + scalar kUu = min(kappa*magUpara/utau, 50); + scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu); + + scalar f = + - utau/(ry[faceI]*(muw[faceI]/rhow[faceI])) + + magUpara/utau + + 1/E*(fkUu - 1.0/6.0*kUu*sqr(kUu)); + + scalar df = + 1.0/(ry[faceI]*(muw[faceI]/rhow[faceI])) + + magUpara/sqr(utau) + + 1/E*kUu*fkUu/utau; + + scalar utauNew = utau + f/df; + err = mag((utau - utauNew)/utau); + utau = utauNew; + + } while (utau > VSMALL && err > 0.01 && ++iter < 10); + + mutw[faceI] = max + ( + rhow[faceI]*sqr(max(utau, 0))/magFaceGradU[faceI]- muw[faceI], + 0.0 + ); + } + else + { + mutw[faceI] = 0; + } + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, mutSpalartAllmarasWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..8967a243c2 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.H @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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::compressible::RASModels:: + mutSpalartAllmarasWallFunctionFvPatchScalarField + +Description + Wall function boundary condition for walls + +SourceFiles + mutSpalartAllmarasWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mutSpalartAllmarasWallFunctionFvPatchScalarField_H +#define mutSpalartAllmarasWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class mutSpalartAllmarasWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class mutSpalartAllmarasWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ +public: + + //- Runtime type information + TypeName("mutSpalartAllmarasWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + mutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + mutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // mutSpalartAllmarasWallFunctionFvPatchScalarField + // onto a new patch + mutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + mutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new mutSpalartAllmarasWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + mutSpalartAllmarasWallFunctionFvPatchScalarField + ( + const mutSpalartAllmarasWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new mutSpalartAllmarasWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes commsType=Pstream::blocking + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..f73e5b2a89 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "mutWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mutWallFunctionFvPatchScalarField:: +mutWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +mutWallFunctionFvPatchScalarField:: +mutWallFunctionFvPatchScalarField +( + const mutWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +mutWallFunctionFvPatchScalarField:: +mutWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +mutWallFunctionFvPatchScalarField:: +mutWallFunctionFvPatchScalarField +( + const mutWallFunctionFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf) +{} + + +mutWallFunctionFvPatchScalarField:: +mutWallFunctionFvPatchScalarField +( + const mutWallFunctionFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void mutWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + const scalar kappa = ras.kappa().value(); + const scalar E = ras.E().value(); + const scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const volScalarField& k = db().lookupObject("k"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + + scalarField& mutw = *this; + + forAll(mutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar yPlus = + Cmu25*y[faceI]*sqrt(k[faceCellI]) + /(muw[faceI]/rhow[faceI]); + + if (yPlus > yPlusLam) + { + mutw[faceI] = muw[faceI]*(yPlus*kappa/log(E*yPlus) - 1); + } + else + { + mutw[faceI] = 0.0; + } + } +} + + +void mutWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchScalarField, mutWallFunctionFvPatchScalarField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..815e50ca70 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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::compressible::RASModels::mutWallFunctionFvPatchScalarField + +Description + Boundary condition for turbulent (kinematic) viscosity when using wall + functions + - replicates OpenFOAM v1.5 (and earlier) behaviour + +SourceFiles + mutWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef mutWallFunctionFvPatchScalarField_H +#define mutWallFunctionFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class mutWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class mutWallFunctionFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + +public: + + //- Runtime type information + TypeName("mutWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + mutWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + mutWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // mutWallFunctionFvPatchScalarField + // onto a new patch + mutWallFunctionFvPatchScalarField + ( + const mutWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + mutWallFunctionFvPatchScalarField + ( + const mutWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new mutWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + mutWallFunctionFvPatchScalarField + ( + const mutWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new mutWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..a156b44da3 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -0,0 +1,205 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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 "omegaWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "wallFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void omegaWallFunctionFvPatchScalarField::checkType() +{ + if (!isA(patch())) + { + FatalErrorIn("omegaWallFunctionFvPatchScalarField::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); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(p, iF) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const omegaWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedInternalValueFvPatchField(ptf, p, iF, mapper) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedInternalValueFvPatchField(p, iF, dict) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const omegaWallFunctionFvPatchScalarField& ewfpsf +) +: + fixedInternalValueFvPatchField(ewfpsf) +{ + checkType(); +} + + +omegaWallFunctionFvPatchScalarField::omegaWallFunctionFvPatchScalarField +( + const omegaWallFunctionFvPatchScalarField& ewfpsf, + const DimensionedField& iF +) +: + fixedInternalValueFvPatchField(ewfpsf, iF) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void omegaWallFunctionFvPatchScalarField::updateCoeffs() +{ + const RASModel& ras = db().lookupObject("RASProperties"); + + const scalar Cmu = ras.Cmu().value(); + const scalar Cmu25 = pow(Cmu, 0.25); + + const scalar kappa = ras.kappa().value(); + const scalar yPlusLam = ras.yPlusLam(); + + const scalarField& y = ras.y()[patch().index()]; + + volScalarField& G = const_cast + (db().lookupObject("G")); + + volScalarField& omega = const_cast + (db().lookupObject("omega")); + + const scalarField& k = db().lookupObject("k"); + + const scalarField& rhow = + patch().lookupPatchField("rho"); + + const scalarField& muw = + patch().lookupPatchField("mu"); + + const scalarField& mutw = + patch().lookupPatchField("mut"); + + const fvPatchVectorField& Uw = + patch().lookupPatchField("U"); + + const scalarField magGradUw = mag(Uw.snGrad()); + + // Set epsilon and G + forAll(mutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar yPlus = + Cmu25*y[faceCellI]*sqrt(k[faceCellI]) + /(muw[faceI]/rhow[faceI]); + + omega[faceCellI] = sqrt(k[faceCellI])/(Cmu25*kappa*y[faceCellI]); + + if (yPlus > yPlusLam) + { + G[faceCellI] = + (mutw[faceI] + muw[faceI]) + *magGradUw[faceI] + *Cmu25*sqrt(k[faceCellI]) + /(kappa*y[faceCellI]); + } + } + + // TODO: perform averaging for cells sharing more than one boundary face +} + + +void omegaWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fixedInternalValueFvPatchField::write(os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + omegaWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..266e7987d5 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H @@ -0,0 +1,159 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 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::compressible::RASModels::omegaWallFunctionFvPatchScalarField + +Description + Replaces functionality in wallFunctionsI.H + +SourceFiles + omegaWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef omegaWallFunctionFvPatchScalarField_H +#define omegaWallFunctionFvPatchScalarField_H + +#include "fixedInternalValueFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class omegaWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class omegaWallFunctionFvPatchScalarField +: + public fixedInternalValueFvPatchField +{ + + // Private member functions + + //- Check the type of the patch + void checkType(); + + +public: + + //- Runtime type information + TypeName("omegaWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + omegaWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + omegaWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // omegaWallFunctionFvPatchScalarField + // onto a new patch + omegaWallFunctionFvPatchScalarField + ( + const omegaWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + omegaWallFunctionFvPatchScalarField + ( + const omegaWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new omegaWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + omegaWallFunctionFvPatchScalarField + ( + const omegaWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new omegaWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/wallFunctions/wallDissipationI.H b/src/turbulenceModels/RAS/compressible/include/wallDissipationI.H similarity index 100% rename from src/turbulenceModels/RAS/compressible/wallFunctions/wallDissipationI.H rename to src/turbulenceModels/RAS/compressible/include/wallDissipationI.H diff --git a/src/turbulenceModels/RAS/compressible/wallFunctions/wallFunctionsI.H b/src/turbulenceModels/RAS/compressible/include/wallFunctionsI.H similarity index 100% rename from src/turbulenceModels/RAS/compressible/wallFunctions/wallFunctionsI.H rename to src/turbulenceModels/RAS/compressible/include/wallFunctionsI.H diff --git a/src/turbulenceModels/RAS/compressible/wallFunctions/wallViscosityI.H b/src/turbulenceModels/RAS/compressible/include/wallViscosityI.H similarity index 100% rename from src/turbulenceModels/RAS/compressible/wallFunctions/wallViscosityI.H rename to src/turbulenceModels/RAS/compressible/include/wallViscosityI.H diff --git a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C index 60bd1c3fa2..a3e5efabfe 100644 --- a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C @@ -151,13 +151,14 @@ kEpsilon::kEpsilon "mut", runTime_.timeName(), mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::MUST_READ, + IOobject::AUTO_WRITE ), - Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_) + mesh_ ) { -# include "wallViscosityI.H" + mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); printCoeffs(); } @@ -243,7 +244,7 @@ void kEpsilon::correct() { // Re-calculate viscosity mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); -# include "wallViscosityI.H" + mut_.correctBoundaryConditions(); return; } @@ -257,10 +258,11 @@ void kEpsilon::correct() } tmp tgradU = fvc::grad(U_); - volScalarField G = mut_*(tgradU() && dev(twoSymm(tgradU()))); + volScalarField G("G", mut_*(tgradU() && dev(twoSymm(tgradU())))); tgradU.clear(); -# include "wallFunctionsI.H" + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); // Dissipation equation tmp epsEqn @@ -274,10 +276,10 @@ void kEpsilon::correct() - fvm::Sp(C2_*rho_*epsilon_/k_, epsilon_) ); -# include "wallDissipationI.H" - epsEqn().relax(); + epsEqn().boundaryManipulate(epsilon_.boundaryField()); + solve(epsEqn); bound(epsilon_, epsilon0_); @@ -302,9 +304,7 @@ void kEpsilon::correct() // Re-calculate viscosity mut_ = rho_*Cmu_*sqr(k_)/epsilon_; - -# include "wallViscosityI.H" - + mut_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C index ad9e49a858..665b1d7916 100644 --- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C @@ -254,13 +254,14 @@ kOmegaSST::kOmegaSST "mut", runTime_.timeName(), mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::MUST_READ, + IOobject::AUTO_WRITE ), - a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_))))) + mesh_ ) { -# include "kOmegaWallViscosityI.H" + mut_ = a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_))))); + mut_.correctBoundaryConditions(); printCoeffs(); } @@ -353,7 +354,8 @@ void kOmegaSST::correct() mut_ = a1_*rho_*k_ /max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_))))); -# include "kOmegaWallViscosityI.H" + mut_.correctBoundaryConditions(); + return; } @@ -374,10 +376,11 @@ void kOmegaSST::correct() tmp tgradU = fvc::grad(U_); volScalarField S2 = magSqr(symm(tgradU())); volScalarField GbyMu = (tgradU() && dev(twoSymm(tgradU()))); - volScalarField G = mut_*GbyMu; + volScalarField G("G", mut_*GbyMu); tgradU.clear(); -# include "kOmegaWallFunctionsI.H" + // Update omega and G at the wall + omega_.boundaryField().updateCoeffs(); volScalarField CDkOmega = (2*alphaOmega2_)*(fvc::grad(k_) & fvc::grad(omega_))/omega_; @@ -404,7 +407,7 @@ void kOmegaSST::correct() omegaEqn().relax(); -# include "wallOmegaI.H" + omegaEqn().boundaryManipulate(omega_.boundaryField()); solve(omegaEqn); bound(omega_, omega0_); @@ -428,9 +431,7 @@ void kOmegaSST::correct() // Re-calculate viscosity mut_ = a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(S2)); - -# include "kOmegaWallViscosityI.H" - + mut_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C index 405667906c..fe6133916e 100644 --- a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C +++ b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C @@ -183,15 +183,17 @@ realizableKE::realizableKE "mut", runTime_.timeName(), mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::MUST_READ, + IOobject::AUTO_WRITE ), - rCmu(fvc::grad(U_))*rho_*sqr(k_)/(epsilon_ + epsilonSmall_) + mesh_ ) { bound(k_, k0_); bound(epsilon_, epsilon0_); -# include "wallViscosityI.H" + + mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); + mut_.correctBoundaryConditions(); printCoeffs(); } @@ -275,6 +277,7 @@ void realizableKE::correct() { // Re-calculate viscosity mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_; + mut_.correctBoundaryConditions(); return; } @@ -294,9 +297,10 @@ void realizableKE::correct() volScalarField eta = magS*k_/epsilon_; volScalarField C1 = max(eta/(scalar(5) + eta), scalar(0.43)); - volScalarField G = mut_*(gradU && dev(twoSymm(gradU))); + volScalarField G("G", mut_*(gradU && dev(twoSymm(gradU)))); -# include "wallFunctionsI.H" + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); // Dissipation equation tmp epsEqn @@ -315,7 +319,7 @@ void realizableKE::correct() epsEqn().relax(); -# include "wallDissipationI.H" + epsEqn().boundaryManipulate(epsilon_.boundaryField()); solve(epsEqn); bound(epsilon_, epsilon0_); @@ -339,9 +343,7 @@ void realizableKE::correct() // Re-calculate viscosity mut_ = rCmu(gradU, S2, magS)*rho_*sqr(k_)/epsilon_; - -# include "wallViscosityI.H" - + mut_.correctBoundaryConditions(); } diff --git a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C index 6a6aad2333..519afa53d6 100644 --- a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C +++ b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C @@ -188,7 +188,7 @@ LRR::LRR mesh_ ) { - nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); nut_.correctBoundaryConditions(); if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) diff --git a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C index d45af4201f..4482949084 100644 --- a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -217,7 +217,7 @@ LaunderGibsonRSTM::LaunderGibsonRSTM mesh_ ) { - nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); nut_.correctBoundaryConditions(); if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0) diff --git a/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C b/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C index 5a64ab127c..1555c859b5 100644 --- a/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C +++ b/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C @@ -179,13 +179,25 @@ LienCubicKE::LienCubicKE C5viscosity_ ( - -2.0*pow(Cmu_, 3.0)*pow(k_, 4.0)/pow(epsilon_, 3.0)* - (magSqr(gradU_ + gradU_.T()) - magSqr(gradU_ - gradU_.T())) + - 2.0*pow3(Cmu_)*pow4(k_)/pow3(epsilon_) + *( + magSqr(gradU_ + gradU_.T()) + - magSqr(gradU_ - gradU_.T()) + ) ), - // C5 term, implicit - nut_(Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_) + C5viscosity_), - // turbulent viscosity, with implicit part of C5 + nut_ + ( + IOobject + ( + "nut", + runTime_.timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), nonlinearStress_ ( @@ -215,7 +227,8 @@ LienCubicKE::LienCubicKE ) ) { -# include "wallNonlinearViscosityI.H" + nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_) + C5viscosity_; + nut_.correctBoundaryConditions(); printCoeffs(); } @@ -315,9 +328,14 @@ void LienCubicKE::correct() // generation term volScalarField S2 = symm(gradU_) && gradU_; - volScalarField G = Cmu_*sqr(k_)/epsilon_*S2 - (nonlinearStress_ && gradU_); + volScalarField G + ( + "G", + Cmu_*sqr(k_)/epsilon_*S2 - (nonlinearStress_ && gradU_) + ); -# include "nonLinearWallFunctionsI.H" + // Update espsilon and G at the wall + epsilon_.boundaryField().updateCoeffs(); // Dissipation equation tmp epsEqn @@ -332,7 +350,7 @@ void LienCubicKE::correct() epsEqn().relax(); -# include "wallDissipationI.H" + epsEqn().boundaryManipulate(epsilon_.boundaryField()); solve(epsEqn); bound(epsilon_, epsilon0_); @@ -367,8 +385,7 @@ void LienCubicKE::correct() *(magSqr(gradU_ + gradU_.T()) - magSqr(gradU_ - gradU_.T())); nut_ = Cmu_*sqr(k_)/epsilon_ + C5viscosity_; - -# include "wallNonlinearViscosityI.H" + nut_.correctBoundaryConditions(); nonlinearStress_ = symm ( diff --git a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C index 7003d6d26c..5472dadb41 100644 --- a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C +++ b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C @@ -156,7 +156,7 @@ RNGkEpsilon::RNGkEpsilon mesh_ ) { - nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); nut_.correctBoundaryConditions(); printCoeffs(); diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H index eabca4d50b..7e81a50a34 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::epsilonWallFunctionFvPatchScalarField + Foam::incompressible::RASModels::epsilonWallFunctionFvPatchScalarField Description Boundary condition for epsilon when using wall functions diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H index 04ae08df9b..719836cf8f 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchField.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::kQRWallFunctionFvPatchField + Foam::incompressible::RASModels::kQRWallFunctionFvPatchField Description Boundary condition for turbulence k, Q, and R when using wall functions. diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H index 22f8a36cf2..299e55cc03 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.H @@ -55,7 +55,7 @@ namespace RASModels { /*---------------------------------------------------------------------------*\ - Class nutWallFunctionFvPatch Declaration + Class nutRoughWallFunctionFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class nutRoughWallFunctionFvPatchScalarField diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H index 7613962708..51ecc156f7 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.H @@ -49,7 +49,7 @@ namespace RASModels { /*---------------------------------------------------------------------------*\ - Class nutWallFunctionFvPatch Declaration + Class nutSpalartAllmarasStandardWallFunctionFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class nutSpalartAllmarasStandardWallFunctionFvPatchScalarField diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H index 6ed73f7637..ffb370608a 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H @@ -50,7 +50,7 @@ namespace RASModels { /*---------------------------------------------------------------------------*\ - Class nutWallFunctionFvPatch Declaration + Class nutWallFunctionFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class nutWallFunctionFvPatchScalarField diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H index 604cf71577..37c8d90188 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::omegaWallFunctionFvPatchScalarField + Foam::incompressible::RASModels::omegaWallFunctionFvPatchScalarField Description Replaces functionality in wallFunctionsI.H diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/nonLinearWallFunctionsI.H b/src/turbulenceModels/RAS/incompressible/include/nonLinearWallFunctionsI.H similarity index 100% rename from src/turbulenceModels/RAS/incompressible/wallFunctions/nonLinearWallFunctionsI.H rename to src/turbulenceModels/RAS/incompressible/include/nonLinearWallFunctionsI.H diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/wallDissipationI.H b/src/turbulenceModels/RAS/incompressible/include/wallDissipationI.H similarity index 100% rename from src/turbulenceModels/RAS/incompressible/wallFunctions/wallDissipationI.H rename to src/turbulenceModels/RAS/incompressible/include/wallDissipationI.H diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/wallFunctionsI.H.old b/src/turbulenceModels/RAS/incompressible/include/wallFunctionsI.H.old similarity index 100% rename from src/turbulenceModels/RAS/incompressible/wallFunctions/wallFunctionsI.H.old rename to src/turbulenceModels/RAS/incompressible/include/wallFunctionsI.H.old diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/wallNonlinearViscosityI.H b/src/turbulenceModels/RAS/incompressible/include/wallNonlinearViscosityI.H similarity index 100% rename from src/turbulenceModels/RAS/incompressible/wallFunctions/wallNonlinearViscosityI.H rename to src/turbulenceModels/RAS/incompressible/include/wallNonlinearViscosityI.H diff --git a/src/turbulenceModels/RAS/incompressible/wallFunctions/wallViscosityI.H.old b/src/turbulenceModels/RAS/incompressible/include/wallViscosityI.H.old similarity index 100% rename from src/turbulenceModels/RAS/incompressible/wallFunctions/wallViscosityI.H.old rename to src/turbulenceModels/RAS/incompressible/include/wallViscosityI.H.old diff --git a/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C b/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C index c15d5cbba3..08a2648dc2 100644 --- a/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C +++ b/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C @@ -141,7 +141,7 @@ kOmega::kOmega mesh_ ) { - nut_ == k_/(omega_ + omegaSmall_); + nut_ = k_/(omega_ + omegaSmall_); nut_.correctBoundaryConditions(); printCoeffs(); diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C index 8a6886bc70..4df9c90adf 100644 --- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C @@ -250,7 +250,7 @@ kOmegaSST::kOmegaSST mesh_ ) { - nut_ == + nut_ = a1_*k_ /max ( diff --git a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C index 7ef65a01de..b3fde6857e 100644 --- a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C +++ b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C @@ -182,7 +182,7 @@ realizableKE::realizableKE bound(k_, k0_); bound(epsilon_, epsilon0_); - nut_ == rCmu(fvc::grad(U_))*sqr(k_)/(epsilon_ + epsilonSmall_); + nut_ = rCmu(fvc::grad(U_))*sqr(k_)/(epsilon_ + epsilonSmall_); nut_.correctBoundaryConditions(); printCoeffs(); From 3b0dc6e946043241450c9613cfaeb7fe3c5249b8 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 23 Sep 2008 13:22:29 +0100 Subject: [PATCH 18/44] moved fixedInternalValueFvPatchField to finiteVolume library --- src/finiteVolume/Make/files | 1 + .../fixedInternalValueFvPatchField.C | 29 +++++-------------- .../fixedInternalValueFvPatchField.H | 8 +---- .../fixedInternalValueFvPatchFields.C | 6 ---- .../fixedInternalValueFvPatchFields.H | 6 ---- .../RAS/compressible/Make/files | 23 ++++++++------- .../RAS/incompressible/Make/files | 23 ++++++++------- 7 files changed, 35 insertions(+), 61 deletions(-) diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 64565a192f..b2ac955f0f 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -72,6 +72,7 @@ $(derivedFvPatchFields)/directMappedFixedValue/directMappedFixedValueFvPatchFiel $(derivedFvPatchFields)/fan/fanFvPatchFields.C $(derivedFvPatchFields)/fixedFluxBuoyantPressure/fixedFluxBuoyantPressureFvPatchScalarField.C $(derivedFvPatchFields)/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C +$(derivedFvPatchFields)/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C $(derivedFvPatchFields)/fixedNormalSlip/fixedNormalSlipFvPatchFields.C $(derivedFvPatchFields)/fluxCorrectedVelocity/fluxCorrectedVelocityFvPatchVectorField.C $(derivedFvPatchFields)/freestream/freestreamFvPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C index 2f760cd9cf..eba3522e36 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.C @@ -28,19 +28,10 @@ License #include "fvPatchFieldMapper.H" #include "fvMatrix.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace incompressible -{ -namespace RASModels -{ - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -fixedInternalValueFvPatchField::fixedInternalValueFvPatchField +Foam::fixedInternalValueFvPatchField::fixedInternalValueFvPatchField ( const fvPatch& p, const DimensionedField& iF @@ -51,7 +42,7 @@ fixedInternalValueFvPatchField::fixedInternalValueFvPatchField template -fixedInternalValueFvPatchField::fixedInternalValueFvPatchField +Foam::fixedInternalValueFvPatchField::fixedInternalValueFvPatchField ( const fixedInternalValueFvPatchField& ptf, const fvPatch& p, @@ -64,7 +55,7 @@ fixedInternalValueFvPatchField::fixedInternalValueFvPatchField template -fixedInternalValueFvPatchField::fixedInternalValueFvPatchField +Foam::fixedInternalValueFvPatchField::fixedInternalValueFvPatchField ( const fvPatch& p, const DimensionedField& iF, @@ -78,7 +69,7 @@ fixedInternalValueFvPatchField::fixedInternalValueFvPatchField template -fixedInternalValueFvPatchField::fixedInternalValueFvPatchField +Foam::fixedInternalValueFvPatchField::fixedInternalValueFvPatchField ( const fixedInternalValueFvPatchField& fivpf ) @@ -88,7 +79,7 @@ fixedInternalValueFvPatchField::fixedInternalValueFvPatchField template -fixedInternalValueFvPatchField::fixedInternalValueFvPatchField +Foam::fixedInternalValueFvPatchField::fixedInternalValueFvPatchField ( const fixedInternalValueFvPatchField& fivpf, const DimensionedField& iF @@ -101,7 +92,7 @@ fixedInternalValueFvPatchField::fixedInternalValueFvPatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -void fixedInternalValueFvPatchField::manipulateMatrix +void Foam::fixedInternalValueFvPatchField::manipulateMatrix ( fvMatrix& matrix ) @@ -111,10 +102,4 @@ void fixedInternalValueFvPatchField::manipulateMatrix } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace RASModels -} // End namespace incompressible -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H index 2ba782a1e4..99cfeb72f3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchField.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::incompressible::RASModels::fixedInternalValueFvPatchField + Foam::fixedInternalValueFvPatchField Description Boundary condition providing mechanism to set boundary (cell) values @@ -44,10 +44,6 @@ SourceFiles namespace Foam { -namespace incompressible -{ -namespace RASModels -{ /*---------------------------------------------------------------------------*\ Class fixedInternalValueFvPatchField Declaration @@ -138,8 +134,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace RASModels -} // End namespace incompressible } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C index f2598e78f2..cd6d5d4901 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.C @@ -33,10 +33,6 @@ License namespace Foam { -namespace incompressible -{ -namespace RASModels -{ // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -44,8 +40,6 @@ makePatchFields(fixedInternalValue); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace RASModels -} // End namespace incompressible } // End namespace Foam // ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H index d2d48936d4..779339f443 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H @@ -34,10 +34,6 @@ License namespace Foam { -namespace incompressible -{ -namespace RASModels -{ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -45,8 +41,6 @@ makePatchTypeFieldTypedefs(fixedInternalValue) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace RASModels -} // End namespace incompressible } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/turbulenceModels/RAS/compressible/Make/files b/src/turbulenceModels/RAS/compressible/Make/files index 14d8e96ebb..b4d8e310c7 100644 --- a/src/turbulenceModels/RAS/compressible/Make/files +++ b/src/turbulenceModels/RAS/compressible/Make/files @@ -12,20 +12,23 @@ SpalartAllmaras/SpalartAllmaras.C kOmegaSST/kOmegaSST.C /* Wall functions */ -derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C +wallFunctions = derivedFvPatchFields/wallFunctions -derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C +mutWallFunctions = $(wallFunctions)/mutWallFunctions +$(mutWallFunctions)/mutWallFunction/mutWallFunctionFvPatchScalarField.C +$(mutWallFunctions)/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C +$(mutWallFunctions)/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C +$(mutWallFunctions)/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +$(mutWallFunctions)/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H +epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions +$(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +omegaWallFunctions = $(wallFunctions)/omegaWallFunctions +$(omegaWallFunctions)/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C - -derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C +kQRWallFunctions = $(wallFunctions)/kQRWallFunctions +$(kQRWallFunctions)/kQRWallFunction/kQRWallFunctionFvPatchFields.C /* Patch fields */ derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C diff --git a/src/turbulenceModels/RAS/incompressible/Make/files b/src/turbulenceModels/RAS/incompressible/Make/files index 7b43583721..eaff934512 100644 --- a/src/turbulenceModels/RAS/incompressible/Make/files +++ b/src/turbulenceModels/RAS/incompressible/Make/files @@ -19,20 +19,23 @@ LienLeschzinerLowRe/LienLeschzinerLowRe.C LamBremhorstKE/LamBremhorstKE.C /* Wall functions */ -derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C +wallFunctions = derivedFvPatchFields/wallFunctions -derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C +nutWallFunctions = $(wallFunctions)/nutWallFunctions +$(nutWallFunctions)/nutWallFunction/nutWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/fixedInternalValueFvPatchField/fixedInternalValueFvPatchFields.H +epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions +$(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +omegaWallFunctions = $(wallFunctions)/omegaWallFunctions +$(omegaWallFunctions)/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C -derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C - -derivedFvPatchFields/wallFunctions/kQRWallFunctions/kQRWallFunction/kQRWallFunctionFvPatchFields.C +kQRWallFunctions = $(wallFunctions)/kQRWallFunctions +$(kQRWallFunctions)/kQRWallFunction/kQRWallFunctionFvPatchFields.C /* Patch fields */ From 776f31b9a7acabb8fed3c62f849f8e66827b75e4 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 23 Sep 2008 15:13:12 +0100 Subject: [PATCH 19/44] correct incorrect use of wall distance --- .../omegaWallFunctionFvPatchScalarField.C | 10 +++++++--- .../omegaWallFunctionFvPatchScalarField.C | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C index a156b44da3..5b0ee67630 100644 --- a/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/RAS/compressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -162,10 +162,10 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() label faceCellI = patch().faceCells()[faceI]; scalar yPlus = - Cmu25*y[faceCellI]*sqrt(k[faceCellI]) + Cmu25*y[faceI]*sqrt(k[faceCellI]) /(muw[faceI]/rhow[faceI]); - omega[faceCellI] = sqrt(k[faceCellI])/(Cmu25*kappa*y[faceCellI]); + omega[faceCellI] = sqrt(k[faceCellI])/(Cmu25*kappa*y[faceI]); if (yPlus > yPlusLam) { @@ -173,7 +173,11 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() (mutw[faceI] + muw[faceI]) *magGradUw[faceI] *Cmu25*sqrt(k[faceCellI]) - /(kappa*y[faceCellI]); + /(kappa*y[faceI]); + } + else + { + G[faceCellI] = 0.0; } } diff --git a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C index 63bdc2e7d4..2fed92c105 100644 --- a/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/RAS/incompressible/derivedFvPatchFields/wallFunctions/omegaWallFunctions/omegaWallFunction/omegaWallFunctionFvPatchScalarField.C @@ -158,7 +158,7 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() { label faceCellI = patch().faceCells()[faceI]; - scalar yPlus = Cmu25*y[faceCellI]*sqrt(k[faceCellI])/nuw[faceI]; + scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI]; omega[faceCellI] = sqrt(k[faceCellI])/(Cmu25*kappa*y[faceCellI]); @@ -170,6 +170,10 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs() *Cmu25*sqrt(k[faceCellI]) /(kappa*y[faceCellI]); } + else + { + G[faceCellI] = 0.0; + } } // TODO: perform averaging for cells sharing more than one boundary face From 9774bf2d0d1f4a960ff153470e63a0111b2d998c Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 23 Sep 2008 15:13:53 +0100 Subject: [PATCH 20/44] updaing to include compressible case --- .../applyWallFunctionBounaryConditions.C | 145 +++++++++++++++--- 1 file changed, 124 insertions(+), 21 deletions(-) diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C index 8b2eb197d7..e571cc4373 100644 --- a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C +++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C @@ -26,10 +26,9 @@ Application applyWallFunctionBounaryConditions Description - Updates OpenFOAM incompressible RAS cases to use the new wall function - framework - - NOTE: For incompressible RAS calculations ONLY + Updates OpenFOAM RAS cases to use the new wall function framework + Attempts to determine whether case is compressible or incompressible, or + can be supplied with -compressible command line argument \*---------------------------------------------------------------------------*/ @@ -38,6 +37,7 @@ Description #include "fvMesh.H" #include "Time.H" #include "volFields.H" +#include "surfaceFields.H" #include "wallPolyPatch.H" @@ -45,39 +45,124 @@ using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// Main program: - -void createNut(const fvMesh& mesh) +bool caseIsCompressible(const fvMesh& mesh) { - IOobject nutHeader + // Attempt flux field + IOobject phiHeader ( - "nut", + "phi", mesh.time().timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ); - if (!nutHeader.headerOk()) + if (phiHeader.headerOk()) { - Info<< "Creating field nut" << nl << endl; + surfaceScalarField phi(phiHeader, mesh); + if (phi.dimensions() == dimDensity*dimVelocity*dimArea) + { + return true; + } + } - volScalarField nut + // Attempt density field + IOobject rhoHeader + ( + "rho", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (rhoHeader.headerOk()) + { + volScalarField rho(rhoHeader, mesh); + if (rho.dimensions() == dimDensity) + { + return true; + } + } + + // Attempt pressure field + IOobject pHeader + ( + "p", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (pHeader.headerOk()) + { + volScalarField p(pHeader, mesh); + if (p.dimensions() == dimMass/sqr(dimTime)/dimLength) + { + return true; + } + } + + // Attempt hydrostatic pressure field + IOobject pdHeader + ( + "pd", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (pdHeader.headerOk()) + { + volScalarField pd(pdHeader, mesh); + if (pd.dimensions() == dimMass/sqr(dimTime)/dimLength) + { + return true; + } + } + + // If none of the above are true, assume that the case is incompressible + return false; +} + + +void createVolScalarField +( + const fvMesh& mesh, + const word& fieldName, + const dimensionSet& dims +) +{ + IOobject fieldHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (!fieldHeader.headerOk()) + { + Info<< "Creating field " << fieldName << nl << endl; + + volScalarField field ( IOobject ( - "nut", + fieldName, mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, - dimensionedScalar("zero", dimensionSet(0, 2, -1, 0, 0), 0.0) + dimensionedScalar("zero", dims, 0.0) ); - nut.write(); + field.write(); } } @@ -116,7 +201,7 @@ void replaceBoundaryType // Make a backup of the old field word backupName(dict.name() + ".old"); - Info<< " copying original " << dict.name() << " to " + Info<< " copying " << dict.name() << " to " << backupName << endl; IOdictionary dictOld = dict; dictOld.rename(backupName); @@ -149,18 +234,36 @@ int main(int argc, char *argv[]) { # include "addTimeOptions.H" + argList::validOptions.insert("compressible", ""); + # include "setRootCase.H" # include "createTime.H" # include "createMesh.H" + bool compressible = args.options().found("compressible"); + Info<< "Updating turbulence fields to operate using new run time " - << "selectable" << nl << "wall functions" << nl << nl - << ">>>>NOTE: only applicable to incompressible RAS models" + << "selectable" << nl << "wall functions" << nl << endl; - createNut(mesh); + if (compressible || caseIsCompressible(mesh)) + { + Info<< "Case treated as compressible" << nl << endl; + createVolScalarField + ( + mesh, + "mut", + dimArea/dimTime*dimDensity + ); + replaceBoundaryType(mesh, "mut", "mutWallFunction", "0"); + } + else + { + Info<< "Case treated as incompressible" << nl << endl; + createVolScalarField(mesh, "nut", dimArea/dimTime); + replaceBoundaryType(mesh, "nut", "nutWallFunction", "0"); + } - replaceBoundaryType(mesh, "nut", "nutWallFunction", "0"); replaceBoundaryType(mesh, "epsilon", "epsilonWallFunction", "0"); replaceBoundaryType(mesh, "omega", "omegaWallFunction", "0"); replaceBoundaryType(mesh, "k", "kQRWallFunction", "0"); From 3d1f0e205d34fc0512601a9c20fd08d0d5813242 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 23 Sep 2008 15:48:58 +0100 Subject: [PATCH 21/44] removing old include files --- .../kOmegaSST/checkkOmegaPatchFieldTypes.H | 19 --- .../kOmegaSST/kOmegaWallFunctionsI.H | 127 ------------------ .../kOmegaSST/kOmegaWallViscosityI.H | 73 ---------- .../RAS/compressible/kOmegaSST/wallOmegaI.H | 51 ------- .../kOmega/kOmegaWallFunctionsI.H | 125 ----------------- .../kOmega/kOmegaWallViscosityI.H | 70 ---------- .../RAS/incompressible/kOmega/wallOmegaI.H | 51 ------- 7 files changed, 516 deletions(-) delete mode 100644 src/turbulenceModels/RAS/compressible/kOmegaSST/checkkOmegaPatchFieldTypes.H delete mode 100644 src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallFunctionsI.H delete mode 100644 src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallViscosityI.H delete mode 100644 src/turbulenceModels/RAS/compressible/kOmegaSST/wallOmegaI.H delete mode 100644 src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallFunctionsI.H delete mode 100644 src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallViscosityI.H delete mode 100644 src/turbulenceModels/RAS/incompressible/kOmega/wallOmegaI.H diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/checkkOmegaPatchFieldTypes.H b/src/turbulenceModels/RAS/compressible/kOmegaSST/checkkOmegaPatchFieldTypes.H deleted file mode 100644 index 025c06bb9c..0000000000 --- a/src/turbulenceModels/RAS/compressible/kOmegaSST/checkkOmegaPatchFieldTypes.H +++ /dev/null @@ -1,19 +0,0 @@ -if (!isType(k_.boundaryField()[patchi])) -{ - FatalErrorIn("wall-function evaluation") - << k_.boundaryField()[patchi].type() - << " is the wrong k patchField type for wall-functions on patch " - << curPatch.name() << nl - << " should be zeroGradient" - << exit(FatalError); -} - -if (!isType(omega_.boundaryField()[patchi])) -{ - FatalErrorIn("wall-function evaluation") - << omega_.boundaryField()[patchi].type() - << " is the wrong omega patchField type for wall-functions on patch " - << curPatch.name() << nl - << " should be zeroGradient" - << exit(FatalError); -} diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallFunctionsI.H b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallFunctionsI.H deleted file mode 100644 index ff5cdf4514..0000000000 --- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallFunctionsI.H +++ /dev/null @@ -1,127 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 - -Global - kOmegaWallFunctions - -Description - Calculate wall generation and frequency omega from wall-functions. - -\*---------------------------------------------------------------------------*/ - -{ - labelList cellBoundaryFaceCount(omega_.size(), 0); - - scalar Cmu25 = pow(Cmu_.value(), 0.25); - - const fvPatchList& patches = mesh_.boundary(); - - //- Initialise the near-wall omega and G fields to zero - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - omega_[faceCelli] = 0.0; - G[faceCelli] = 0.0; - } - } - } - - //- Accumulate the wall face contributions to omega and G - // Increment cellBoundaryFaceCount for each face for averaging - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { -# include "checkkOmegaPatchFieldTypes.H" - - const scalarField& rhow = rho_.boundaryField()[patchi]; - - const scalarField& muw = mu().boundaryField()[patchi]; - const scalarField& mutw = mut_.boundaryField()[patchi]; - - scalarField magFaceGradU = - mag(U_.boundaryField()[patchi].snGrad()); - - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - scalar yPlus = - Cmu25*y_[faceCelli] - *sqrt(k_[faceCelli]) - /(muw[facei]/rhow[facei]); - - // For corner cells (with two boundary or more faces), - // omega and G in the near-wall cell are calculated - // as an average - - cellBoundaryFaceCount[faceCelli]++; - - omega_[faceCelli] += - sqrt(k_[faceCelli]) - /(Cmu25*kappa_.value()*y_[faceCelli]); - - if (yPlus > yPlusLam_) - { - G[faceCelli] += - (mutw[facei] + muw[facei]) - *magFaceGradU[facei] - *Cmu25*sqrt(k_[faceCelli]) - /(kappa_.value()*y_[faceCelli]); - } - } - } - } - - - // Perform the averaging - - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - omega_[faceCelli] /= cellBoundaryFaceCount[faceCelli]; - G[faceCelli] /= cellBoundaryFaceCount[faceCelli]; - } - } - } -} - - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallViscosityI.H b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallViscosityI.H deleted file mode 100644 index d1b048c020..0000000000 --- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaWallViscosityI.H +++ /dev/null @@ -1,73 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 - -Global - kOmegaWallViscosity - -Description - Calculate wall viscosity from wall-functions. - -\*---------------------------------------------------------------------------*/ - -{ - scalar Cmu25 = pow(Cmu_.value(), 0.25); - - const fvPatchList& patches = mesh_.boundary(); - - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { - const scalarField& rhow = rho_.boundaryField()[patchi]; - - const scalarField& muw = mu().boundaryField()[patchi]; - scalarField& mutw = mut_.boundaryField()[patchi]; - - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - scalar yPlus = - Cmu25*y_[faceCelli] - *sqrt(k_[faceCelli])/(muw[facei]/rhow[facei]); - - if (yPlus > yPlusLam_) - { - mutw[facei] = - muw[facei] - *(yPlus*kappa_.value()/log(E_.value()*yPlus) - 1); - } - else - { - mutw[facei] = 0.0; - } - } - } - } -} - - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/wallOmegaI.H b/src/turbulenceModels/RAS/compressible/kOmegaSST/wallOmegaI.H deleted file mode 100644 index eb1b3c5919..0000000000 --- a/src/turbulenceModels/RAS/compressible/kOmegaSST/wallOmegaI.H +++ /dev/null @@ -1,51 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 - -Global - wallOmega - -Description - Set wall dissipation in the omega matrix - -\*---------------------------------------------------------------------------*/ - -{ - const fvPatchList& patches = mesh_.boundary(); - - forAll(patches, patchi) - { - const fvPatch& p = patches[patchi]; - - if (isType(p)) - { - omegaEqn().setValues - ( - p.faceCells(), - omega_.boundaryField()[patchi].patchInternalField() - ); - } - } -} - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallFunctionsI.H b/src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallFunctionsI.H deleted file mode 100644 index aca757443e..0000000000 --- a/src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallFunctionsI.H +++ /dev/null @@ -1,125 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 - -Global - kOmegaWallFunctions - -Description - Calculate wall generation and frequency omega from wall-functions. - -\*---------------------------------------------------------------------------*/ - -{ - labelList cellBoundaryFaceCount(omega_.size(), 0); - - scalar Cmu25 = pow(Cmu_.value(), 0.25); - - const fvPatchList& patches = mesh_.boundary(); - - //- Initialise the near-wall omega and G fields to zero - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - omega_[faceCelli] = 0.0; - G[faceCelli] = 0.0; - } - } - } - - //- Accumulate the wall face contributions to omega and G - // Increment cellBoundaryFaceCount for each face for averaging - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { -# include "checkkOmegaPatchFieldTypes.H" - - const scalarField& nuw = nu().boundaryField()[patchi]; - const scalarField& nutw = nut_.boundaryField()[patchi]; - - scalarField magFaceGradU = - mag(U_.boundaryField()[patchi].snGrad()); - - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - scalar yPlus = - Cmu25*y_[patchi][facei] - *sqrt(k_[faceCelli]) - /nuw[facei]; - - // For corner cells (with two boundary or more faces), - // omega and G in the near-wall cell are calculated - // as an average - - cellBoundaryFaceCount[faceCelli]++; - - omega_[faceCelli] += - sqrt(k_[faceCelli]) - /(Cmu25*kappa_.value()*y_[patchi][facei]); - - if (yPlus > yPlusLam_) - { - G[faceCelli] += - (nutw[facei] + nuw[facei]) - *magFaceGradU[facei] - *Cmu25*sqrt(k_[faceCelli]) - /(kappa_.value()*y_[patchi][facei]); - } - } - } - } - - - // Perform the averaging - - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - omega_[faceCelli] /= cellBoundaryFaceCount[faceCelli]; - G[faceCelli] /= cellBoundaryFaceCount[faceCelli]; - } - } - } -} - - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallViscosityI.H b/src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallViscosityI.H deleted file mode 100644 index 0f0571c93c..0000000000 --- a/src/turbulenceModels/RAS/incompressible/kOmega/kOmegaWallViscosityI.H +++ /dev/null @@ -1,70 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 - -Global - kOmegaWallViscosity - -Description - Calculate wall viscosity from wall-functions. - -\*---------------------------------------------------------------------------*/ - -{ - scalar Cmu25 = pow(Cmu_.value(), 0.25); - - const fvPatchList& patches = mesh_.boundary(); - - forAll(patches, patchi) - { - const fvPatch& curPatch = patches[patchi]; - - if (isType(curPatch)) - { - const scalarField& nuw = nu().boundaryField()[patchi]; - scalarField& nutw = nut_.boundaryField()[patchi]; - - forAll(curPatch, facei) - { - label faceCelli = curPatch.faceCells()[facei]; - - scalar yPlus = - Cmu25*y_[patchi][facei]*sqrt(k_[faceCelli])/nuw[facei]; - - if (yPlus > yPlusLam_) - { - nutw[facei] = - nuw[facei] - *(yPlus*kappa_.value()/log(E_.value()*yPlus) - 1); - } - else - { - nutw[facei] = 0.0; - } - } - } - } -} - - -// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/kOmega/wallOmegaI.H b/src/turbulenceModels/RAS/incompressible/kOmega/wallOmegaI.H deleted file mode 100644 index eb1b3c5919..0000000000 --- a/src/turbulenceModels/RAS/incompressible/kOmega/wallOmegaI.H +++ /dev/null @@ -1,51 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2008 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 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 - -Global - wallOmega - -Description - Set wall dissipation in the omega matrix - -\*---------------------------------------------------------------------------*/ - -{ - const fvPatchList& patches = mesh_.boundary(); - - forAll(patches, patchi) - { - const fvPatch& p = patches[patchi]; - - if (isType(p)) - { - omegaEqn().setValues - ( - p.faceCells(), - omega_.boundaryField()[patchi].patchInternalField() - ); - } - } -} - -// ************************************************************************* // From 4cf87c65bdf4aca11d9475e495d077bef9cd9751 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 23 Sep 2008 15:50:04 +0100 Subject: [PATCH 22/44] updated structure for wall functions --- src/turbulenceModels/LES/compressible/Make/files | 8 ++++++-- .../muSgsWallFunctionFvPatchScalarField.C | 0 .../muSgsWallFunctionFvPatchScalarField.H | 0 src/turbulenceModels/LES/incompressible/Make/files | 9 ++++++++- .../nuSgsWallFunctionFvPatchScalarField.C | 0 .../nuSgsWallFunctionFvPatchScalarField.H | 0 6 files changed, 14 insertions(+), 3 deletions(-) rename src/turbulenceModels/LES/compressible/{wallFunc => derivedFvPatchFields/wallFunctions/muSgsWallFunctions}/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C (100%) rename src/turbulenceModels/LES/compressible/{wallFunc => derivedFvPatchFields/wallFunctions/muSgsWallFunctions}/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.H (100%) rename src/turbulenceModels/LES/incompressible/{wallFunc => derivedFvPatchFields/wallFunctions/nuSgsWallFunctions}/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C (100%) rename src/turbulenceModels/LES/incompressible/{wallFunc => derivedFvPatchFields/wallFunctions/nuSgsWallFunctions}/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.H (100%) diff --git a/src/turbulenceModels/LES/compressible/Make/files b/src/turbulenceModels/LES/compressible/Make/files index 59ced1fae2..06e7b76d45 100644 --- a/src/turbulenceModels/LES/compressible/Make/files +++ b/src/turbulenceModels/LES/compressible/Make/files @@ -1,5 +1,3 @@ -wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C - LESModel/LESModel.C LESModel/newLESModel.C GenEddyVisc/GenEddyVisc.C @@ -12,4 +10,10 @@ dynOneEqEddy/dynOneEqEddy.C DeardorffDiffStress/DeardorffDiffStress.C SpalartAllmaras/SpalartAllmaras.C +/* Wall functions */ +wallFunctions=derivedFvPatchFields/wallFunctions + +muSgsWallFunctions=$(wallFunctions)/muSgsWallFunctions +$(muSgsWallFunctions)/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C + LIB = $(FOAM_LIBBIN)/libcompressibleLESModels diff --git a/src/turbulenceModels/LES/compressible/wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C b/src/turbulenceModels/LES/compressible/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C similarity index 100% rename from src/turbulenceModels/LES/compressible/wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C rename to src/turbulenceModels/LES/compressible/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/LES/compressible/wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.H b/src/turbulenceModels/LES/compressible/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.H similarity index 100% rename from src/turbulenceModels/LES/compressible/wallFunc/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.H rename to src/turbulenceModels/LES/compressible/derivedFvPatchFields/wallFunctions/muSgsWallFunctions/muSgsWallFunction/muSgsWallFunctionFvPatchScalarField.H diff --git a/src/turbulenceModels/LES/incompressible/Make/files b/src/turbulenceModels/LES/incompressible/Make/files index ed45e8ffbc..0661520a6c 100644 --- a/src/turbulenceModels/LES/incompressible/Make/files +++ b/src/turbulenceModels/LES/incompressible/Make/files @@ -1,5 +1,4 @@ vanDriestDelta/vanDriestDelta.C -wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C LESModel/LESModel.C LESModel/newLESModel.C @@ -25,4 +24,12 @@ dynMixedSmagorinsky/dynMixedSmagorinsky.C /*Smagorinsky2/Smagorinsky2.C*/ + +/* Wall functions */ +wallFunctions=derivedFvPatchFields/wallFunctions + +nuSgsWallFunctions=$(wallFunctions)/nuSgsWallFunctions +$(nuSgsWallFunctions)/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C + + LIB = $(FOAM_LIBBIN)/libincompressibleLESModels diff --git a/src/turbulenceModels/LES/incompressible/wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C b/src/turbulenceModels/LES/incompressible/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C similarity index 100% rename from src/turbulenceModels/LES/incompressible/wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C rename to src/turbulenceModels/LES/incompressible/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/LES/incompressible/wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.H b/src/turbulenceModels/LES/incompressible/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.H similarity index 100% rename from src/turbulenceModels/LES/incompressible/wallFunc/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.H rename to src/turbulenceModels/LES/incompressible/derivedFvPatchFields/wallFunctions/nuSgsWallFunctions/nuSgsWallFunction/nuSgsWallFunctionFvPatchScalarField.H From 972190e98cdb6eb8e72c13dccb0230160dc84a04 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 23 Sep 2008 17:56:42 +0100 Subject: [PATCH 23/44] incorrect non-blocking transfer --- .../mapPolyMesh/mapDistribute/mapDistributeTemplates.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index 86a0a618c1..5f16ad1335 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -241,7 +241,7 @@ void Foam::mapDistribute::distribute Pstream::nonBlocking, domain, reinterpret_cast(subField.begin()), - subField.size() + subField.size()*sizeof(T) ); } } @@ -262,7 +262,7 @@ void Foam::mapDistribute::distribute Pstream::nonBlocking, domain, reinterpret_cast(recvFields[domain].begin()), - recvFields[domain].size() + recvFields[domain].size()*sizeof(T) ); } } From 8e4c7fb2c319e2507a3ba42484c9cbc6edabc5f1 Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 24 Sep 2008 11:10:45 +0100 Subject: [PATCH 24/44] Corrected output of patch area. --- .../postProcessing/patch/patchIntegrate/patchIntegrate.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C index 4b7a09acbf..3c0e18a9cf 100644 --- a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C +++ b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) } // Give patch area - Info<< " Patch area = " << sum(mesh.Sf()) << endl; + Info<< " Patch area = " << sum(mesh.Sf().boundaryField()[patchi]) << endl; if (fieldHeader.headerClassName() == "volScalarField") { From 7fe0ded9f849e5a7c8d5e3038c99fd2ba34d9b2a Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 24 Sep 2008 11:28:30 +0100 Subject: [PATCH 25/44] changed to UPtrList --- src/finiteVolume/fvMesh/wallDist/wallDistData.C | 4 ++-- src/meshTools/cellDist/patchWave/patchDataWave.C | 7 ++----- src/meshTools/cellDist/patchWave/patchDataWave.H | 6 +++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/finiteVolume/fvMesh/wallDist/wallDistData.C b/src/finiteVolume/fvMesh/wallDist/wallDistData.C index c7b9debba8..ebe0aa16ee 100644 --- a/src/finiteVolume/fvMesh/wallDist/wallDistData.C +++ b/src/finiteVolume/fvMesh/wallDist/wallDistData.C @@ -83,11 +83,11 @@ void Foam::wallDistData::correct() labelHashSet wallPatchIDs(getPatchIDs(wallPolyPatch::typeName)); // Collect pointers to data on patches - List*> patchData(mesh.boundaryMesh().size()); + UPtrList > patchData(mesh.boundaryMesh().size()); forAll(field_.boundaryField(), patchI) { - patchData[patchI] = &(field_.boundaryField()[patchI]); + patchData.set(patchI, &field_.boundaryField()[patchI]); } // Do mesh wave diff --git a/src/meshTools/cellDist/patchWave/patchDataWave.C b/src/meshTools/cellDist/patchWave/patchDataWave.C index 4d196fb1e9..beb76631c5 100644 --- a/src/meshTools/cellDist/patchWave/patchDataWave.C +++ b/src/meshTools/cellDist/patchWave/patchDataWave.C @@ -22,8 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "patchDataWave.H" @@ -50,8 +48,7 @@ void Foam::patchDataWave::setChangedFaces { const polyPatch& patch = mesh.boundaryMesh()[patchI]; - const Field& patchField = - *initialPatchValuePtrs_[patchI]; + const Field& patchField = initialPatchValuePtrs_[patchI]; forAll(patch.faceCentres(), patchFaceI) { @@ -176,7 +173,7 @@ Foam::patchDataWave::patchDataWave ( const polyMesh& mesh, const labelHashSet& patchIDs, - const List*>& initialPatchValuePtrs, + const UPtrList >& initialPatchValuePtrs, const bool correctWalls ) : diff --git a/src/meshTools/cellDist/patchWave/patchDataWave.H b/src/meshTools/cellDist/patchWave/patchDataWave.H index be7aae205f..241c378310 100644 --- a/src/meshTools/cellDist/patchWave/patchDataWave.H +++ b/src/meshTools/cellDist/patchWave/patchDataWave.H @@ -45,7 +45,7 @@ SourceFiles #include "cellDistFuncs.H" #include "FieldField.H" - +#include "UPtrList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -78,7 +78,7 @@ private: labelHashSet patchIDs_; //- Reference to initial extra data at patch faces - const List*>& initialPatchValuePtrs_; + const UPtrList >& initialPatchValuePtrs_; //- Do accurate distance calculation for near-wall cells. bool correctWalls_; @@ -129,7 +129,7 @@ public: ( const polyMesh& mesh, const labelHashSet& patchIDs, - const List*>& initialPatchValuePtrs, + const UPtrList >& initialPatchValuePtrs, bool correctWalls = true ); From d5c9c0ab435bf5a549cd1cd227622c22c9a040b1 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 24 Sep 2008 12:43:29 +0100 Subject: [PATCH 26/44] models now create/modify turbulence fields automatically on constrcution to comply with new wall function specification --- .../RAS/compressible/LRR/LRR.C | 55 +----- .../LaunderGibsonRSTM/LaunderGibsonRSTM.C | 41 +---- .../RAS/compressible/RASModel/RASModel.C | 128 +++++++++++++ .../RAS/compressible/RASModel/RASModel.H | 57 ++++++ .../compressible/RASModel/RASModelTemplates.C | 172 ++++++++++++++++++ .../compressible/RNGkEpsilon/RNGkEpsilon.C | 41 +---- .../RAS/compressible/kEpsilon/kEpsilon.C | 42 +---- .../RAS/compressible/kOmegaSST/kOmegaSST.C | 41 +---- .../compressible/realizableKE/realizableKE.C | 41 +---- .../RAS/incompressible/LRR/LRR.C | 55 +----- .../LaunderGibsonRSTM/LaunderGibsonRSTM.C | 55 +----- .../incompressible/LienCubicKE/LienCubicKE.C | 40 +--- .../RAS/incompressible/RASModel/RASModel.C | 129 +++++++++++++ .../RAS/incompressible/RASModel/RASModel.H | 57 ++++++ .../RASModel/RASModelTemplates.C | 172 ++++++++++++++++++ .../incompressible/RNGkEpsilon/RNGkEpsilon.C | 41 +---- .../RAS/incompressible/kEpsilon/kEpsilon.C | 41 +---- .../RAS/incompressible/kOmega/kOmega.C | 41 +---- .../RAS/incompressible/kOmegaSST/kOmegaSST.C | 41 +---- .../realizableKE/realizableKE.C | 41 +---- 20 files changed, 760 insertions(+), 571 deletions(-) create mode 100644 src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C create mode 100644 src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C diff --git a/src/turbulenceModels/RAS/compressible/LRR/LRR.C b/src/turbulenceModels/RAS/compressible/LRR/LRR.C index b5b03a8f63..6ed98cc0a2 100644 --- a/src/turbulenceModels/RAS/compressible/LRR/LRR.C +++ b/src/turbulenceModels/RAS/compressible/LRR/LRR.C @@ -155,57 +155,10 @@ LRR::LRR ) ), - R_ - ( - IOobject - ( - "R", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - epsilon_ - ( - IOobject - ( - "epsilon", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - mut_ - ( - IOobject - ( - "mut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + R_(autoCreateKQR("R", mesh_)), + k_(autoCreateKQR("k", mesh_)), + epsilon_(autoCreateEpsilon("epsilon", mesh_)), + mut_(autoCreateMut("mut", mesh_)) { mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); mut_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C index 2bb710ea88..b81e36ee6e 100644 --- a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -190,44 +190,9 @@ LaunderGibsonRSTM::LaunderGibsonRSTM mesh_ ), - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - epsilon_ - ( - IOobject - ( - "epsilon", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - mut_ - ( - IOobject - ( - "mut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + k_(autoCreateKQR("k", mesh_)), + epsilon_(autoCreateEpsilon("epsilon", mesh_)), + mut_(autoCreateMut("mut", mesh_)) { mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); mut_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C index a38da49b0e..eedfc4fdcd 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C @@ -29,6 +29,12 @@ License #include "wallFvPatch.H" #include "fixedValueFvPatchFields.H" +// Headers reqd for back-porting wall function boundary conditions +#include "calculatedFvPatchField.H" +#include "mutWallFunctionFvPatchScalarField.H" +#include "epsilonWallFunctionFvPatchScalarField.H" +#include "omegaWallFunctionFvPatchScalarField.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -52,6 +58,128 @@ void RASModel::printCoeffs() } +wordList RASModel::replaceWallBoundaryTypes +( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames +) const +{ + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList boundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isType(bm[patchI])) + { + boundaryTypes[patchI] = newTypeNames[patchI]; + } + else + { + boundaryTypes[patchI] = oldTypeNames[patchI]; + } + } + + return boundaryTypes; +} + + +tmp RASModel::autoCreateMut +( + const word& fieldName, + const fvMesh& mesh +) const +{ + IOobject mutHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ); + + if (mutHeader.headerOk()) + { + return tmp(new volScalarField(mutHeader, mesh)); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + wordList mutBoundaryTypes = replaceWallBoundaryTypes + ( + mesh, + wordList + ( + mesh.boundary().size(), + calculatedFvPatchField::typeName + ), + wordList + ( + mesh.boundary().size(), + RASModels::mutWallFunctionFvPatchScalarField::typeName + ) + ); + + tmp mut + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), + mutBoundaryTypes + ) + ); + + Info<< " Writing updated " << fieldName << endl; + mut().write(); + + return mut; + } +} + + +tmp RASModel::autoCreateEpsilon +( + const word& fieldName, + const fvMesh& mesh +) const +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::epsilonWallFunctionFvPatchScalarField::typeName + ); +} + + +tmp RASModel::autoCreateOmega +( + const word& fieldName, + const fvMesh& mesh +) const +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::omegaWallFunctionFvPatchScalarField::typeName + ); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // RASModel::RASModel diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H index 51b4e706da..0e9f78afc1 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H @@ -107,6 +107,57 @@ protected: // Protected member functions + // Auto creation of fields to provide backwards compatibility with + // runtime selectable wall functions + + //- Replace old wall BCs with new wall function BCs + wordList replaceWallBoundaryTypes + ( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames + ) const; + + //- mut + tmp autoCreateMut + ( + const word& fieldName, + const fvMesh& mesh + ) const; + + //- epsilon + tmp autoCreateEpsilon + ( + const word& fieldName, + const fvMesh& mesh + ) const; + + //- omega + tmp autoCreateOmega + ( + const word& fieldName, + const fvMesh& mesh + ) const; + + //- kQR + template + tmp > autoCreateKQR + ( + const word& fieldName, + const fvMesh& mesh + ) const; + + //- Helper function to create the new field + template + tmp > + autoCreateWallFunctionField + ( + const word& fieldName, + const fvMesh& mesh, + const word& wallFunctionName + ) const; + + //- Print model coefficients virtual void printCoeffs(); @@ -327,6 +378,12 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository +# include "RASModelTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C b/src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C new file mode 100644 index 0000000000..28af37ed9e --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "RASModel.H" + +#include "wallFvPatch.H" +#include "kQRWallFunctionFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +tmp > +RASModel::autoCreateWallFunctionField +( + const word& fieldName, + const fvMesh& mesh, + const word& wallFunctionName +) const +{ + IOobject mutHeader + ( + "mut", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ); + + typedef GeometricField fieldType; + + if (mutHeader.headerOk()) + { + return tmp + ( + new fieldType + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ) + ); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + // Read existing epsilon field + tmp fieldOrig + ( + new fieldType + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + mesh + ) + ); + + wordList fieldBoundaryTypes = replaceWallBoundaryTypes + ( + mesh, + fieldOrig().boundaryField().types(), + wordList + ( + fieldOrig().boundaryField().types().size(), + wallFunctionName + ) + ); + + tmp fieldNew + ( + new fieldType + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensioned + ( + "zero", + fieldOrig().dimensions(), + pTraits::zero + ), + fieldBoundaryTypes + ) + ); + + fieldNew() == fieldOrig(); + + Info<< " Writing backup of original " << fieldName << " to " + << fieldName << ".old" << endl; + fieldOrig().rename(fieldName + ".old"); + fieldOrig().write(); + + Info<< " Writing updated " << fieldName << endl; + fieldNew().write(); + + return fieldNew; + } +} + + +template +tmp > RASModel::autoCreateKQR +( + const word& fieldName, + const fvMesh& mesh +) const +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C index 3860918ea1..cdce325fb4 100644 --- a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C +++ b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C @@ -137,44 +137,9 @@ RNGkEpsilon::RNGkEpsilon ) ), - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - epsilon_ - ( - IOobject - ( - "epsilon", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - mut_ - ( - IOobject - ( - "mut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + k_(autoCreateKQR("k", mesh_)), + epsilon_(autoCreateEpsilon("epsilon", mesh_)), + mut_(autoCreateMut("mut", mesh_)) { mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); mut_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C index a3e5efabfe..11052b2f1e 100644 --- a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C @@ -117,45 +117,9 @@ kEpsilon::kEpsilon 1.0 ) ), - - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - epsilon_ - ( - IOobject - ( - "epsilon", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - mut_ - ( - IOobject - ( - "mut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + k_(autoCreateKQR("k", mesh_)), + epsilon_(autoCreateEpsilon("epsilon", mesh_)), + mut_(autoCreateMut("mut", mesh_)) { mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_); mut_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C index 665b1d7916..31932efc37 100644 --- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C @@ -221,44 +221,9 @@ kOmegaSST::kOmegaSST y_(mesh_), - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - omega_ - ( - IOobject - ( - "omega", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - mut_ - ( - IOobject - ( - "mut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + k_(autoCreateKQR("k", mesh_)), + omega_(autoCreateOmega("omega", mesh_)), + mut_(autoCreateMut("mut", mesh_)) { mut_ = a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_))))); mut_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C index fe6133916e..795fbb83c6 100644 --- a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C +++ b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C @@ -150,44 +150,9 @@ realizableKE::realizableKE ) ), - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - epsilon_ - ( - IOobject - ( - "epsilon", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - mut_ - ( - IOobject - ( - "mut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + k_(autoCreateKQR("k", mesh_)), + epsilon_(autoCreateEpsilon("epsilon", mesh_)), + mut_(autoCreateMut("mut", mesh_)) { bound(k_, k0_); bound(epsilon_, epsilon0_); diff --git a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C index 519afa53d6..31f26ce14e 100644 --- a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C +++ b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C @@ -136,57 +136,10 @@ LRR::LRR ) ), - R_ - ( - IOobject - ( - "R", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - epsilon_ - ( - IOobject - ( - "epsilon", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - nut_ - ( - IOobject - ( - "nut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + R_(autoCreateKQR("R", mesh_)), + k_(autoCreateKQR("k", mesh_)), + epsilon_(autoCreateEpsilon("epsilon", mesh_)), + nut_(autoCreateNut("nut", mesh_)) { nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); nut_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C index 4482949084..2b57bf7904 100644 --- a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -165,57 +165,10 @@ LaunderGibsonRSTM::LaunderGibsonRSTM yr_(mesh_), - R_ - ( - IOobject - ( - "R", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - epsilon_ - ( - IOobject - ( - "epsilon", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - nut_ - ( - IOobject - ( - "nut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + R_(autoCreateKQR("R", mesh_)), + k_(autoCreateKQR("k", mesh_)), + epsilon_(autoCreateEpsilon("epsilon", mesh_)), + nut_(autoCreateNut("nut", mesh_)) { nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); nut_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C b/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C index 1555c859b5..0181d7e88d 100644 --- a/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C +++ b/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C @@ -145,31 +145,8 @@ LienCubicKE::LienCubicKE ) ), - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - epsilon_ - ( - IOobject - ( - "epsilon", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), + k_(autoCreateKQR("k", mesh_)), + epsilon_(autoCreateEpsilon("epsilon", mesh_)), gradU_(fvc::grad(U)), eta_(k_/epsilon_*sqrt(2.0*magSqr(0.5*(gradU_ + gradU_.T())))), @@ -186,18 +163,7 @@ LienCubicKE::LienCubicKE ) ), - nut_ - ( - IOobject - ( - "nut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), + nut_(autoCreateNut("nut", mesh_)), nonlinearStress_ ( diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C index 628da387da..e282e27f4c 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C @@ -27,6 +27,13 @@ License #include "RASModel.H" #include "wallFvPatch.H" +// Headers reqd for back-porting wall function boundary conditions +#include "calculatedFvPatchField.H" +#include "nutWallFunctionFvPatchScalarField.H" +#include "epsilonWallFunctionFvPatchScalarField.H" +#include "omegaWallFunctionFvPatchScalarField.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -50,6 +57,128 @@ void RASModel::printCoeffs() } +wordList RASModel::replaceWallBoundaryTypes +( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames +) const +{ + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList boundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isType(bm[patchI])) + { + boundaryTypes[patchI] = newTypeNames[patchI]; + } + else + { + boundaryTypes[patchI] = oldTypeNames[patchI]; + } + } + + return boundaryTypes; +} + + +tmp RASModel::autoCreateNut +( + const word& fieldName, + const fvMesh& mesh +) const +{ + IOobject nutHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ); + + if (nutHeader.headerOk()) + { + return tmp(new volScalarField(nutHeader, mesh)); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + wordList nutBoundaryTypes = replaceWallBoundaryTypes + ( + mesh, + wordList + ( + mesh.boundary().size(), + calculatedFvPatchField::typeName + ), + wordList + ( + mesh.boundary().size(), + RASModels::nutWallFunctionFvPatchScalarField::typeName + ) + ); + + tmp nut + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimArea/dimTime, 0.0), + nutBoundaryTypes + ) + ); + + Info<< " Writing updated " << fieldName << endl; + nut().write(); + + return nut; + } +} + + +tmp RASModel::autoCreateEpsilon +( + const word& fieldName, + const fvMesh& mesh +) const +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::epsilonWallFunctionFvPatchScalarField::typeName + ); +} + + +tmp RASModel::autoCreateOmega +( + const word& fieldName, + const fvMesh& mesh +) const +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::omegaWallFunctionFvPatchScalarField::typeName + ); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // RASModel::RASModel diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H index b5edce3ea3..6928cbf771 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H @@ -104,6 +104,57 @@ protected: // Protected member functions + // Auto creation of fields to provide backwards compatibility with + // runtime selectable wall functions + + //- Replace old wall BCs with new wall function BCs + wordList replaceWallBoundaryTypes + ( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames + ) const; + + //- mut + tmp autoCreateNut + ( + const word& fieldName, + const fvMesh& mesh + ) const; + + //- epsilon + tmp autoCreateEpsilon + ( + const word& fieldName, + const fvMesh& mesh + ) const; + + //- omega + tmp autoCreateOmega + ( + const word& fieldName, + const fvMesh& mesh + ) const; + + //- kQR + template + tmp > autoCreateKQR + ( + const word& fieldName, + const fvMesh& mesh + ) const; + + //- Helper function to create the new field + template + tmp > + autoCreateWallFunctionField + ( + const word& fieldName, + const fvMesh& mesh, + const word& wallFunctionName + ) const; + + //- Print model coefficients virtual void printCoeffs(); @@ -309,6 +360,12 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository +# include "RASModelTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C b/src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C new file mode 100644 index 0000000000..d300add6fb --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "RASModel.H" + +#include "wallFvPatch.H" +#include "kQRWallFunctionFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +tmp > +RASModel::autoCreateWallFunctionField +( + const word& fieldName, + const fvMesh& mesh, + const word& wallFunctionName +) const +{ + IOobject nutHeader + ( + "nut", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ); + + typedef GeometricField fieldType; + + if (nutHeader.headerOk()) + { + return tmp + ( + new fieldType + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ) + ); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + // Read existing epsilon field + tmp fieldOrig + ( + new fieldType + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + mesh + ) + ); + + wordList fieldBoundaryTypes = replaceWallBoundaryTypes + ( + mesh, + fieldOrig().boundaryField().types(), + wordList + ( + fieldOrig().boundaryField().types().size(), + wallFunctionName + ) + ); + + tmp fieldNew + ( + new fieldType + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensioned + ( + "zero", + fieldOrig().dimensions(), + pTraits::zero + ), + fieldBoundaryTypes + ) + ); + + fieldNew() == fieldOrig(); + + Info<< " Writing backup of original " << fieldName << " to " + << fieldName << ".old" << endl; + fieldOrig().rename(fieldName + ".old"); + fieldOrig().write(); + + Info<< " Writing updated " << fieldName << endl; + fieldNew().write(); + + return fieldNew; + } +} + + +template +tmp > RASModel::autoCreateKQR +( + const word& fieldName, + const fvMesh& mesh +) const +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C index 5472dadb41..57c6e9dfe0 100644 --- a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C +++ b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C @@ -117,44 +117,9 @@ RNGkEpsilon::RNGkEpsilon ) ), - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - epsilon_ - ( - IOobject - ( - "epsilon", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - nut_ - ( - IOobject - ( - "nut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + k_(autoCreateKQR("k", mesh_)), + epsilon_(autoCreateEpsilon("epsilon", mesh_)), + nut_(autoCreateNut("nut", mesh_)) { nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); nut_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C index 213af8446c..81c548ca27 100644 --- a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C @@ -91,44 +91,9 @@ kEpsilon::kEpsilon ) ), - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - epsilon_ - ( - IOobject - ( - "epsilon", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - nut_ - ( - IOobject - ( - "nut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + k_(autoCreateKQR("k", mesh_)), + epsilon_(autoCreateEpsilon("epsilon", mesh_)), + nut_(autoCreateNut("nut", mesh_)) { nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_); nut_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C b/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C index 08a2648dc2..79adfef154 100644 --- a/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C +++ b/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C @@ -102,44 +102,9 @@ kOmega::kOmega omega0_("omega0", dimless/dimTime, SMALL), omegaSmall_("omegaSmall", dimless/dimTime, SMALL), - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - omega_ - ( - IOobject - ( - "omega", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - nut_ - ( - IOobject - ( - "nut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + k_(autoCreateKQR("k", mesh_)), + omega_(autoCreateOmega("omega", mesh_)), + nut_(autoCreateNut("nut", mesh_)) { nut_ = k_/(omega_ + omegaSmall_); nut_.correctBoundaryConditions(); diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C index 4df9c90adf..be68d1fa55 100644 --- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C @@ -211,44 +211,9 @@ kOmegaSST::kOmegaSST y_(mesh_), - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - omega_ - ( - IOobject - ( - "omega", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - nut_ - ( - IOobject - ( - "nut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + k_(autoCreateKQR("k", mesh_)), + omega_(autoCreateOmega("omega", mesh_)), + nut_(autoCreateNut("nut", mesh_)) { nut_ = a1_*k_ diff --git a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C index b3fde6857e..d805137d30 100644 --- a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C +++ b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C @@ -140,44 +140,9 @@ realizableKE::realizableKE ) ), - k_ - ( - IOobject - ( - "k", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - epsilon_ - ( - IOobject - ( - "epsilon", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ), - - nut_ - ( - IOobject - ( - "nut", - runTime_.timeName(), - mesh_, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh_ - ) + k_(autoCreateKQR("k", mesh_)), + epsilon_(autoCreateEpsilon("epsilon", mesh_)), + nut_(autoCreateNut("nut", mesh_)) { bound(k_, k0_); bound(epsilon_, epsilon0_); From aacc33e946e2bb412daec01886026c31e5321202 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 24 Sep 2008 13:43:13 +0100 Subject: [PATCH 27/44] removing spurious link to malloc --- applications/solvers/incompressible/simpleFoam/Make/options | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/applications/solvers/incompressible/simpleFoam/Make/options b/applications/solvers/incompressible/simpleFoam/Make/options index e1ffa28773..8a31f7e5ab 100644 --- a/applications/solvers/incompressible/simpleFoam/Make/options +++ b/applications/solvers/incompressible/simpleFoam/Make/options @@ -7,5 +7,4 @@ EXE_LIBS = \ -lincompressibleRASModels \ -lincompressibleTransportModels \ -lfiniteVolume \ - -lmeshTools \ - /* $(LIB_WM_OPTIONS_DIR)/libfbsdmalloc.o */ + -lmeshTools From b2652f3cee0470a449b02da37f8722b6d8a38c5e Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 24 Sep 2008 14:54:47 +0100 Subject: [PATCH 28/44] moving headers from templates to main RASModel.H to avoid breaking compilation of solvers and utilities due to new template functions --- src/turbulenceModels/RAS/compressible/RASModel/RASModel.H | 4 ++++ .../RAS/compressible/RASModel/RASModelTemplates.C | 3 --- src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H | 5 +++++ .../RAS/incompressible/RASModel/RASModelTemplates.C | 3 --- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H index 0e9f78afc1..f614a0cd34 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H @@ -58,6 +58,10 @@ SourceFiles #include "autoPtr.H" #include "runTimeSelectionTables.H" +// Headers reqd for back-porting wall function boundary conditions +#include "wallFvPatch.H" +#include "kQRWallFunctionFvPatchField.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C b/src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C index 28af37ed9e..6b0d4eb9d8 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C @@ -26,9 +26,6 @@ License #include "RASModel.H" -#include "wallFvPatch.H" -#include "kQRWallFunctionFvPatchField.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H index 6928cbf771..e06a310643 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H @@ -56,6 +56,11 @@ SourceFiles #include "autoPtr.H" #include "runTimeSelectionTables.H" +// Headers reqd for back-porting wall function boundary conditions +#include "wallFvPatch.H" +#include "kQRWallFunctionFvPatchField.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C b/src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C index d300add6fb..e01d965434 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C @@ -26,9 +26,6 @@ License #include "RASModel.H" -#include "wallFvPatch.H" -#include "kQRWallFunctionFvPatchField.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam From 0093a587c66561b0b983227c8a0f61a8f6a75dbc Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 24 Sep 2008 17:03:31 +0100 Subject: [PATCH 29/44] moved compatibility functions from RASModel classes to within turbulence namespace --- .../RAS/compressible/LRR/LRR.C | 6 +- .../LaunderGibsonRSTM/LaunderGibsonRSTM.C | 4 +- .../RAS/compressible/Make/files | 2 + .../RAS/compressible/RASModel/RASModel.C | 128 ----------- .../RAS/compressible/RASModel/RASModel.H | 61 ----- .../compressible/RNGkEpsilon/RNGkEpsilon.C | 4 +- .../backwardsCompatibilityWallFunctions.C | 217 ++++++++++++++++++ .../backwardsCompatibilityWallFunctions.H | 126 ++++++++++ ...ardsCompatibilityWallFunctionsTemplates.C} | 23 +- .../RAS/compressible/kEpsilon/kEpsilon.C | 4 +- .../RAS/compressible/kOmegaSST/kOmegaSST.C | 4 +- .../compressible/realizableKE/realizableKE.C | 4 +- .../RAS/incompressible/LRR/LRR.C | 6 +- .../LaunderGibsonRSTM/LaunderGibsonRSTM.C | 6 +- .../incompressible/LienCubicKE/LienCubicKE.C | 4 +- .../RAS/incompressible/Make/files | 2 + .../RAS/incompressible/RASModel/RASModel.C | 129 ----------- .../RAS/incompressible/RASModel/RASModel.H | 62 ----- .../incompressible/RNGkEpsilon/RNGkEpsilon.C | 4 +- .../backwardsCompatibilityWallFunctions.C | 217 ++++++++++++++++++ .../backwardsCompatibilityWallFunctions.H | 126 ++++++++++ ...ardsCompatibilityWallFunctionsTemplates.C} | 29 +-- .../RAS/incompressible/kEpsilon/kEpsilon.C | 4 +- .../RAS/incompressible/kOmega/kOmega.C | 4 +- .../RAS/incompressible/kOmegaSST/kOmegaSST.C | 4 +- .../realizableKE/realizableKE.C | 4 +- 26 files changed, 746 insertions(+), 438 deletions(-) create mode 100644 src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C create mode 100644 src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H rename src/turbulenceModels/RAS/compressible/{RASModel/RASModelTemplates.C => backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C} (91%) create mode 100644 src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C create mode 100644 src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H rename src/turbulenceModels/RAS/incompressible/{RASModel/RASModelTemplates.C => backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C} (90%) diff --git a/src/turbulenceModels/RAS/compressible/LRR/LRR.C b/src/turbulenceModels/RAS/compressible/LRR/LRR.C index 6ed98cc0a2..90c7f3ca17 100644 --- a/src/turbulenceModels/RAS/compressible/LRR/LRR.C +++ b/src/turbulenceModels/RAS/compressible/LRR/LRR.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -155,8 +157,8 @@ LRR::LRR ) ), - R_(autoCreateKQR("R", mesh_)), - k_(autoCreateKQR("k", mesh_)), + R_(autoCreateR("R", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C index b81e36ee6e..89b5ab1f09 100644 --- a/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/RAS/compressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -30,6 +30,8 @@ License #include "wallDist.H" #include "wallDistReflection.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -190,7 +192,7 @@ LaunderGibsonRSTM::LaunderGibsonRSTM mesh_ ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/compressible/Make/files b/src/turbulenceModels/RAS/compressible/Make/files index b4d8e310c7..48106587e3 100644 --- a/src/turbulenceModels/RAS/compressible/Make/files +++ b/src/turbulenceModels/RAS/compressible/Make/files @@ -34,4 +34,6 @@ $(kQRWallFunctions)/kQRWallFunction/kQRWallFunctionFvPatchFields.C derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C +backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C + LIB = $(FOAM_LIBBIN)/libcompressibleRASModels diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C index eedfc4fdcd..a38da49b0e 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.C @@ -29,12 +29,6 @@ License #include "wallFvPatch.H" #include "fixedValueFvPatchFields.H" -// Headers reqd for back-porting wall function boundary conditions -#include "calculatedFvPatchField.H" -#include "mutWallFunctionFvPatchScalarField.H" -#include "epsilonWallFunctionFvPatchScalarField.H" -#include "omegaWallFunctionFvPatchScalarField.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -58,128 +52,6 @@ void RASModel::printCoeffs() } -wordList RASModel::replaceWallBoundaryTypes -( - const fvMesh& mesh, - const wordList& oldTypeNames, - const wordList& newTypeNames -) const -{ - const fvBoundaryMesh& bm = mesh.boundary(); - - wordList boundaryTypes(bm.size()); - - forAll(bm, patchI) - { - if (isType(bm[patchI])) - { - boundaryTypes[patchI] = newTypeNames[patchI]; - } - else - { - boundaryTypes[patchI] = oldTypeNames[patchI]; - } - } - - return boundaryTypes; -} - - -tmp RASModel::autoCreateMut -( - const word& fieldName, - const fvMesh& mesh -) const -{ - IOobject mutHeader - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ); - - if (mutHeader.headerOk()) - { - return tmp(new volScalarField(mutHeader, mesh)); - } - else - { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; - - wordList mutBoundaryTypes = replaceWallBoundaryTypes - ( - mesh, - wordList - ( - mesh.boundary().size(), - calculatedFvPatchField::typeName - ), - wordList - ( - mesh.boundary().size(), - RASModels::mutWallFunctionFvPatchScalarField::typeName - ) - ); - - tmp mut - ( - new volScalarField - ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), - mutBoundaryTypes - ) - ); - - Info<< " Writing updated " << fieldName << endl; - mut().write(); - - return mut; - } -} - - -tmp RASModel::autoCreateEpsilon -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::epsilonWallFunctionFvPatchScalarField::typeName - ); -} - - -tmp RASModel::autoCreateOmega -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::omegaWallFunctionFvPatchScalarField::typeName - ); -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // RASModel::RASModel diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H index f614a0cd34..51b4e706da 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/compressible/RASModel/RASModel.H @@ -58,10 +58,6 @@ SourceFiles #include "autoPtr.H" #include "runTimeSelectionTables.H" -// Headers reqd for back-porting wall function boundary conditions -#include "wallFvPatch.H" -#include "kQRWallFunctionFvPatchField.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -111,57 +107,6 @@ protected: // Protected member functions - // Auto creation of fields to provide backwards compatibility with - // runtime selectable wall functions - - //- Replace old wall BCs with new wall function BCs - wordList replaceWallBoundaryTypes - ( - const fvMesh& mesh, - const wordList& oldTypeNames, - const wordList& newTypeNames - ) const; - - //- mut - tmp autoCreateMut - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- epsilon - tmp autoCreateEpsilon - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- omega - tmp autoCreateOmega - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- kQR - template - tmp > autoCreateKQR - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- Helper function to create the new field - template - tmp > - autoCreateWallFunctionField - ( - const word& fieldName, - const fvMesh& mesh, - const word& wallFunctionName - ) const; - - //- Print model coefficients virtual void printCoeffs(); @@ -382,12 +327,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "RASModelTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C index cdce325fb4..2930fb284f 100644 --- a/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C +++ b/src/turbulenceModels/RAS/compressible/RNGkEpsilon/RNGkEpsilon.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -137,7 +139,7 @@ RNGkEpsilon::RNGkEpsilon ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C new file mode 100644 index 0000000000..fdf205b930 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C @@ -0,0 +1,217 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "backwardsCompatibilityWallFunctions.H" + +#include "calculatedFvPatchField.H" +#include "mutWallFunctionFvPatchScalarField.H" +#include "epsilonWallFunctionFvPatchScalarField.H" +#include "kQRWallFunctionFvPatchField.H" +#include "omegaWallFunctionFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +wordList replaceWallBoundaryTypes +( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames +) +{ + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList boundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isType(bm[patchI])) + { + boundaryTypes[patchI] = newTypeNames[patchI]; + } + else + { + boundaryTypes[patchI] = oldTypeNames[patchI]; + } + } + + return boundaryTypes; +} + + +tmp autoCreateMut +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject mutHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ); + + if (mutHeader.headerOk()) + { + return tmp(new volScalarField(mutHeader, mesh)); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + wordList mutBoundaryTypes = replaceWallBoundaryTypes + ( + mesh, + wordList + ( + mesh.boundary().size(), + calculatedFvPatchField::typeName + ), + wordList + ( + mesh.boundary().size(), + RASModels::mutWallFunctionFvPatchScalarField::typeName + ) + ); + + tmp mut + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), + mutBoundaryTypes + ) + ); + + Info<< " Writing updated " << fieldName << endl; + mut().write(); + + return mut; + } +} + + +tmp autoCreateEpsilon +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::epsilonWallFunctionFvPatchScalarField::typeName + ); +} + + +tmp autoCreateOmega +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::omegaWallFunctionFvPatchScalarField::typeName + ); +} + + +tmp autoCreateK +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +tmp autoCreateQ +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +tmp autoCreateR +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // + diff --git a/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H new file mode 100644 index 0000000000..6650b79832 --- /dev/null +++ b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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::compressible + +Description + Auto creation of fields to provide backwards compatibility with + runtime selectable wall functions + +SourceFiles + backwardsCompatibilityWallFunctions.C + backwardsCompatibilityWallFunctionsTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef backwardsCompatibilityWallFunctions_H +#define backwardsCompatibilityWallFunctions_H + +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + + //- Replace old wall BCs with new wall function BCs + wordList replaceWallBoundaryTypes + ( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames + ); + + //- mut + tmp autoCreateMut + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- epsilon + tmp autoCreateEpsilon + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- omega + tmp autoCreateOmega + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- k + tmp autoCreateK + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- Q + tmp autoCreateQ + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- R + tmp autoCreateR + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- Helper function to create the new field + template + tmp > + autoCreateWallFunctionField + ( + const word& fieldName, + const fvMesh& mesh, + const word& wallFunctionName + ); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "backwardsCompatibilityWallFunctionsTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C similarity index 91% rename from src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C rename to src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C index 6b0d4eb9d8..fd7c9d59bf 100644 --- a/src/turbulenceModels/RAS/compressible/RASModel/RASModelTemplates.C +++ b/src/turbulenceModels/RAS/compressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C @@ -24,7 +24,8 @@ License \*---------------------------------------------------------------------------*/ -#include "RASModel.H" +#include "backwardsCompatibilityWallFunctions.H" +#include "Time.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -37,12 +38,12 @@ namespace compressible template tmp > -RASModel::autoCreateWallFunctionField +autoCreateWallFunctionField ( const word& fieldName, const fvMesh& mesh, const word& wallFunctionName -) const +) { IOobject mutHeader ( @@ -145,22 +146,6 @@ RASModel::autoCreateWallFunctionField } -template -tmp > RASModel::autoCreateKQR -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::kQRWallFunctionFvPatchField::typeName - ); -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace compressible diff --git a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C index 11052b2f1e..414690f6fd 100644 --- a/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/RAS/compressible/kEpsilon/kEpsilon.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -117,7 +119,7 @@ kEpsilon::kEpsilon 1.0 ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C index 31932efc37..32bb44bcbb 100644 --- a/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/RAS/compressible/kOmegaSST/kOmegaSST.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -221,7 +223,7 @@ kOmegaSST::kOmegaSST y_(mesh_), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), omega_(autoCreateOmega("omega", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C index 795fbb83c6..141a7376c9 100644 --- a/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C +++ b/src/turbulenceModels/RAS/compressible/realizableKE/realizableKE.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -150,7 +152,7 @@ realizableKE::realizableKE ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), mut_(autoCreateMut("mut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C index 31f26ce14e..a7304b7c6c 100644 --- a/src/turbulenceModels/RAS/incompressible/LRR/LRR.C +++ b/src/turbulenceModels/RAS/incompressible/LRR/LRR.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -136,8 +138,8 @@ LRR::LRR ) ), - R_(autoCreateKQR("R", mesh_)), - k_(autoCreateKQR("k", mesh_)), + R_(autoCreateR("R", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C index 2b57bf7904..ac7a036e49 100644 --- a/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C +++ b/src/turbulenceModels/RAS/incompressible/LaunderGibsonRSTM/LaunderGibsonRSTM.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -165,8 +167,8 @@ LaunderGibsonRSTM::LaunderGibsonRSTM yr_(mesh_), - R_(autoCreateKQR("R", mesh_)), - k_(autoCreateKQR("k", mesh_)), + R_(autoCreateR("R", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C b/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C index 0181d7e88d..6e877d6a42 100644 --- a/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C +++ b/src/turbulenceModels/RAS/incompressible/LienCubicKE/LienCubicKE.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -145,7 +147,7 @@ LienCubicKE::LienCubicKE ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), gradU_(fvc::grad(U)), diff --git a/src/turbulenceModels/RAS/incompressible/Make/files b/src/turbulenceModels/RAS/incompressible/Make/files index eaff934512..3943dcd0fc 100644 --- a/src/turbulenceModels/RAS/incompressible/Make/files +++ b/src/turbulenceModels/RAS/incompressible/Make/files @@ -42,4 +42,6 @@ $(kQRWallFunctions)/kQRWallFunction/kQRWallFunctionFvPatchFields.C derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C +backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C + LIB = $(FOAM_LIBBIN)/libincompressibleRASModels diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C index e282e27f4c..628da387da 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.C @@ -27,13 +27,6 @@ License #include "RASModel.H" #include "wallFvPatch.H" -// Headers reqd for back-porting wall function boundary conditions -#include "calculatedFvPatchField.H" -#include "nutWallFunctionFvPatchScalarField.H" -#include "epsilonWallFunctionFvPatchScalarField.H" -#include "omegaWallFunctionFvPatchScalarField.H" - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -57,128 +50,6 @@ void RASModel::printCoeffs() } -wordList RASModel::replaceWallBoundaryTypes -( - const fvMesh& mesh, - const wordList& oldTypeNames, - const wordList& newTypeNames -) const -{ - const fvBoundaryMesh& bm = mesh.boundary(); - - wordList boundaryTypes(bm.size()); - - forAll(bm, patchI) - { - if (isType(bm[patchI])) - { - boundaryTypes[patchI] = newTypeNames[patchI]; - } - else - { - boundaryTypes[patchI] = oldTypeNames[patchI]; - } - } - - return boundaryTypes; -} - - -tmp RASModel::autoCreateNut -( - const word& fieldName, - const fvMesh& mesh -) const -{ - IOobject nutHeader - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ); - - if (nutHeader.headerOk()) - { - return tmp(new volScalarField(nutHeader, mesh)); - } - else - { - Info<< "--> Upgrading " << fieldName << " to employ run-time " - << "selectable wall functions" << endl; - - wordList nutBoundaryTypes = replaceWallBoundaryTypes - ( - mesh, - wordList - ( - mesh.boundary().size(), - calculatedFvPatchField::typeName - ), - wordList - ( - mesh.boundary().size(), - RASModels::nutWallFunctionFvPatchScalarField::typeName - ) - ); - - tmp nut - ( - new volScalarField - ( - IOobject - ( - fieldName, - mesh.time().timeName(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - mesh, - dimensionedScalar("zero", dimArea/dimTime, 0.0), - nutBoundaryTypes - ) - ); - - Info<< " Writing updated " << fieldName << endl; - nut().write(); - - return nut; - } -} - - -tmp RASModel::autoCreateEpsilon -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::epsilonWallFunctionFvPatchScalarField::typeName - ); -} - - -tmp RASModel::autoCreateOmega -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::omegaWallFunctionFvPatchScalarField::typeName - ); -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // RASModel::RASModel diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H index e06a310643..b5edce3ea3 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H +++ b/src/turbulenceModels/RAS/incompressible/RASModel/RASModel.H @@ -56,11 +56,6 @@ SourceFiles #include "autoPtr.H" #include "runTimeSelectionTables.H" -// Headers reqd for back-porting wall function boundary conditions -#include "wallFvPatch.H" -#include "kQRWallFunctionFvPatchField.H" - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -109,57 +104,6 @@ protected: // Protected member functions - // Auto creation of fields to provide backwards compatibility with - // runtime selectable wall functions - - //- Replace old wall BCs with new wall function BCs - wordList replaceWallBoundaryTypes - ( - const fvMesh& mesh, - const wordList& oldTypeNames, - const wordList& newTypeNames - ) const; - - //- mut - tmp autoCreateNut - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- epsilon - tmp autoCreateEpsilon - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- omega - tmp autoCreateOmega - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- kQR - template - tmp > autoCreateKQR - ( - const word& fieldName, - const fvMesh& mesh - ) const; - - //- Helper function to create the new field - template - tmp > - autoCreateWallFunctionField - ( - const word& fieldName, - const fvMesh& mesh, - const word& wallFunctionName - ) const; - - //- Print model coefficients virtual void printCoeffs(); @@ -365,12 +309,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "RASModelTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C index 57c6e9dfe0..2029df47c9 100644 --- a/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C +++ b/src/turbulenceModels/RAS/incompressible/RNGkEpsilon/RNGkEpsilon.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -117,7 +119,7 @@ RNGkEpsilon::RNGkEpsilon ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C new file mode 100644 index 0000000000..567dbfb1fc --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.C @@ -0,0 +1,217 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 "backwardsCompatibilityWallFunctions.H" + +#include "calculatedFvPatchField.H" +#include "nutWallFunctionFvPatchScalarField.H" +#include "epsilonWallFunctionFvPatchScalarField.H" +#include "kQRWallFunctionFvPatchField.H" +#include "omegaWallFunctionFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +wordList replaceWallBoundaryTypes +( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames +) +{ + const fvBoundaryMesh& bm = mesh.boundary(); + + wordList boundaryTypes(bm.size()); + + forAll(bm, patchI) + { + if (isType(bm[patchI])) + { + boundaryTypes[patchI] = newTypeNames[patchI]; + } + else + { + boundaryTypes[patchI] = oldTypeNames[patchI]; + } + } + + return boundaryTypes; +} + + +tmp autoCreateNut +( + const word& fieldName, + const fvMesh& mesh +) +{ + IOobject nutHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ); + + if (nutHeader.headerOk()) + { + return tmp(new volScalarField(nutHeader, mesh)); + } + else + { + Info<< "--> Upgrading " << fieldName << " to employ run-time " + << "selectable wall functions" << endl; + + wordList nutBoundaryTypes = replaceWallBoundaryTypes + ( + mesh, + wordList + ( + mesh.boundary().size(), + calculatedFvPatchField::typeName + ), + wordList + ( + mesh.boundary().size(), + RASModels::nutWallFunctionFvPatchScalarField::typeName + ) + ); + + tmp nut + ( + new volScalarField + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0), + nutBoundaryTypes + ) + ); + + Info<< " Writing updated " << fieldName << endl; + nut().write(); + + return nut; + } +} + + +tmp autoCreateEpsilon +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::epsilonWallFunctionFvPatchScalarField::typeName + ); +} + + +tmp autoCreateOmega +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::omegaWallFunctionFvPatchScalarField::typeName + ); +} + + +tmp autoCreateK +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +tmp autoCreateQ +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +tmp autoCreateR +( + const word& fieldName, + const fvMesh& mesh +) +{ + return autoCreateWallFunctionField + ( + fieldName, + mesh, + RASModels::kQRWallFunctionFvPatchField::typeName + ); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // + diff --git a/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H new file mode 100644 index 0000000000..73c60014e0 --- /dev/null +++ b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctions.H @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 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 + +Description + Auto creation of fields to provide backwards compatibility with + runtime selectable wall functions + +SourceFiles + backwardsCompatibilityWallFunctions.C + backwardsCompatibilityWallFunctionsTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef backwardsCompatibilityWallFunctions_H +#define backwardsCompatibilityWallFunctions_H + +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ + + //- Replace old wall BCs with new wall function BCs + wordList replaceWallBoundaryTypes + ( + const fvMesh& mesh, + const wordList& oldTypeNames, + const wordList& newTypeNames + ); + + //- nut + tmp autoCreateNut + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- epsilon + tmp autoCreateEpsilon + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- omega + tmp autoCreateOmega + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- k + tmp autoCreateK + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- Q + tmp autoCreateQ + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- R + tmp autoCreateR + ( + const word& fieldName, + const fvMesh& mesh + ); + + //- Helper function to create the new field + template + tmp > + autoCreateWallFunctionField + ( + const word& fieldName, + const fvMesh& mesh, + const word& wallFunctionName + ); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "backwardsCompatibilityWallFunctionsTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C similarity index 90% rename from src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C rename to src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C index e01d965434..50b755ecbe 100644 --- a/src/turbulenceModels/RAS/incompressible/RASModel/RASModelTemplates.C +++ b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C @@ -24,7 +24,8 @@ License \*---------------------------------------------------------------------------*/ -#include "RASModel.H" +#include "backwardsCompatibilityWallFunctions.H" +#include "Time.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -37,16 +38,16 @@ namespace incompressible template tmp > -RASModel::autoCreateWallFunctionField +autoCreateWallFunctionField ( const word& fieldName, const fvMesh& mesh, const word& wallFunctionName -) const +) { - IOobject nutHeader + IOobject mutHeader ( - "nut", + "mut", mesh.time().timeName(), mesh, IOobject::MUST_READ, @@ -55,7 +56,7 @@ RASModel::autoCreateWallFunctionField typedef GeometricField fieldType; - if (nutHeader.headerOk()) + if (mutHeader.headerOk()) { return tmp ( @@ -145,22 +146,6 @@ RASModel::autoCreateWallFunctionField } -template -tmp > RASModel::autoCreateKQR -( - const word& fieldName, - const fvMesh& mesh -) const -{ - return autoCreateWallFunctionField - ( - fieldName, - mesh, - RASModels::kQRWallFunctionFvPatchField::typeName - ); -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace incompressible diff --git a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C index 81c548ca27..43f3fa2d2d 100644 --- a/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C +++ b/src/turbulenceModels/RAS/incompressible/kEpsilon/kEpsilon.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -91,7 +93,7 @@ kEpsilon::kEpsilon ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C b/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C index 79adfef154..fb8326b5b8 100644 --- a/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C +++ b/src/turbulenceModels/RAS/incompressible/kOmega/kOmega.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -102,7 +104,7 @@ kOmega::kOmega omega0_("omega0", dimless/dimTime, SMALL), omegaSmall_("omegaSmall", dimless/dimTime, SMALL), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), omega_(autoCreateOmega("omega", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C index be68d1fa55..ba8dc16525 100644 --- a/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C +++ b/src/turbulenceModels/RAS/incompressible/kOmegaSST/kOmegaSST.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -211,7 +213,7 @@ kOmegaSST::kOmegaSST y_(mesh_), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), omega_(autoCreateOmega("omega", mesh_)), nut_(autoCreateNut("nut", mesh_)) { diff --git a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C index d805137d30..c8f488f5a1 100644 --- a/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C +++ b/src/turbulenceModels/RAS/incompressible/realizableKE/realizableKE.C @@ -28,6 +28,8 @@ License #include "addToRunTimeSelectionTable.H" #include "wallFvPatch.H" +#include "backwardsCompatibilityWallFunctions.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -140,7 +142,7 @@ realizableKE::realizableKE ) ), - k_(autoCreateKQR("k", mesh_)), + k_(autoCreateK("k", mesh_)), epsilon_(autoCreateEpsilon("epsilon", mesh_)), nut_(autoCreateNut("nut", mesh_)) { From 19337533df8306f0a72909c72fe229596cdd9d74 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 25 Sep 2008 09:32:02 +0100 Subject: [PATCH 30/44] fixing typo for incompressible RAS models --- .../backwardsCompatibilityWallFunctionsTemplates.C | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C index 50b755ecbe..64da24799d 100644 --- a/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C +++ b/src/turbulenceModels/RAS/incompressible/backwardsCompatibilityWallFunctions/backwardsCompatibilityWallFunctionsTemplates.C @@ -45,9 +45,9 @@ autoCreateWallFunctionField const word& wallFunctionName ) { - IOobject mutHeader + IOobject nutHeader ( - "mut", + "nut", mesh.time().timeName(), mesh, IOobject::MUST_READ, @@ -56,7 +56,7 @@ autoCreateWallFunctionField typedef GeometricField fieldType; - if (mutHeader.headerOk()) + if (nutHeader.headerOk()) { return tmp ( From bdec40f49baf00a8c65d8f375588c3c3b2e435a6 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Sep 2008 09:43:38 +0100 Subject: [PATCH 31/44] on-the-fly addressing --- .../meshes/primitiveMesh/primitiveMesh.C | 2 - .../meshes/primitiveMesh/primitiveMesh.H | 60 ++++++++++-- .../primitiveMesh/primitiveMeshCellCells.C | 39 ++++---- .../primitiveMesh/primitiveMeshCellEdges.C | 8 ++ .../primitiveMesh/primitiveMeshCellPoints.C | 37 +++++--- .../primitiveMesh/primitiveMeshEdgeCells.C | 59 ++++++------ .../primitiveMesh/primitiveMeshEdgeFaces.C | 36 ++++--- .../meshes/primitiveMesh/primitiveMeshEdges.C | 66 +++++++------ .../primitiveMesh/primitiveMeshPointCells.C | 56 +++++------ .../primitiveMesh/primitiveMeshPointPoints.C | 37 +++++--- .../autoHexMeshDriver/autoSnapDriver.C | 18 ++-- .../meshRefinement/meshRefinementBaffles.C | 30 ++++-- .../motionSmoother/motionSmoother.C | 2 +- .../polyTopoChange/addPatchCellLayer.C | 19 +++- .../polyTopoChange/addPatchCellLayer.H | 1 + .../polyTopoChange/combineFaces.C | 13 ++- .../polyTopoChange/combineFaces.H | 1 + .../polyTopoChange/polyTopoChange/hexRef8.C | 93 ++++++++----------- .../polyTopoChange/polyTopoChange/hexRef8.H | 3 - .../polyTopoChange/removeFaces.C | 36 ++++--- .../polyTopoChange/removeFaces.H | 1 + 21 files changed, 372 insertions(+), 245 deletions(-) diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C index 8c21017269..6bcc2af56f 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C @@ -66,7 +66,6 @@ primitiveMesh::primitiveMesh() ppPtr_(NULL), cpPtr_(NULL), - allocSize_(0), labels_(0), cellCentresPtr_(NULL), @@ -109,7 +108,6 @@ primitiveMesh::primitiveMesh ppPtr_(NULL), cpPtr_(NULL), - allocSize_(0), labels_(0), cellCentresPtr_(NULL), diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H index 3868ba2b25..6f24944cbc 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H @@ -54,6 +54,7 @@ SourceFiles #ifndef primitiveMesh_H #define primitiveMesh_H +#include "DynamicList.H" #include "edgeList.H" #include "pointField.H" #include "SubField.H" @@ -157,10 +158,8 @@ class primitiveMesh // On-the-fly edge addresing storage - //- Temporary storage for addressing. allocSize is the real size - // of the labelList. - mutable label allocSize_; - mutable labelList labels_; + //- Temporary storage for addressing. + mutable DynamicList