From d9535b4b35baf3481fa137ca9512e0916411d1f6 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 27 Aug 2008 11:12:57 +0100 Subject: [PATCH 01/82] 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/82] 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/82] 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/82] 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/82] 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/82] 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/82] 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/82] 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/82] 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/82] 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/82] 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 44f647d5add48998a58f060e9f207d81f7826ad2 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 10 Sep 2008 10:26:54 +0100 Subject: [PATCH 12/82] adding randomise foamCalc function --- .../foamCalcFunctions/Make/files | 1 + .../field/randomise/randomise.C | 164 ++++++++++++++++++ .../field/randomise/randomise.H | 141 +++++++++++++++ .../field/randomise/writeRandomField.C | 73 ++++++++ 4 files changed, 379 insertions(+) create mode 100644 src/postProcessing/foamCalcFunctions/field/randomise/randomise.C create mode 100644 src/postProcessing/foamCalcFunctions/field/randomise/randomise.H create mode 100644 src/postProcessing/foamCalcFunctions/field/randomise/writeRandomField.C diff --git a/src/postProcessing/foamCalcFunctions/Make/files b/src/postProcessing/foamCalcFunctions/Make/files index 016ae77604..36dacdedb6 100644 --- a/src/postProcessing/foamCalcFunctions/Make/files +++ b/src/postProcessing/foamCalcFunctions/Make/files @@ -6,5 +6,6 @@ field/mag/mag.C field/magSqr/magSqr.C field/magGrad/magGrad.C field/div/div.C +field/randomise/randomise.C LIB = $(FOAM_LIBBIN)/libfoamCalcFunctions diff --git a/src/postProcessing/foamCalcFunctions/field/randomise/randomise.C b/src/postProcessing/foamCalcFunctions/field/randomise/randomise.C new file mode 100644 index 0000000000..be8befc080 --- /dev/null +++ b/src/postProcessing/foamCalcFunctions/field/randomise/randomise.C @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "randomise.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace calcTypes + { + defineTypeNameAndDebug(randomise, 0); + addToRunTimeSelectionTable(calcType, randomise, dictionary); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::calcTypes::randomise::randomise() +: + calcType() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::calcTypes::randomise::~randomise() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::calcTypes::randomise::init() +{ + argList::validArgs.append("randomise"); + argList::validArgs.append("perturbation"); + argList::validArgs.append("fieldName1 .. fieldNameN"); +} + + +void Foam::calcTypes::randomise::preCalc +( + const argList& args, + const Time& runTime, + const fvMesh& mesh +) +{ + if (args.additionalArgs().size() < 3) + { + Info<< nl + << "must specify perturbation magnitude and one" + << "or more fields" + << nl; + args.printUsage(); + FatalError.exit(); + } +} + + +void Foam::calcTypes::randomise::calc +( + const argList& args, + const Time& runTime, + const fvMesh& mesh +) +{ + const stringList& params = args.additionalArgs(); + const scalar pertMag = readScalar(IStringStream(params[1])()); + + Random rand(1234567); + + for (label fieldi=2; fieldi + ( + fieldHeader, + pertMag, + rand, + mesh, + processed + ); + writeRandomField + ( + fieldHeader, + pertMag, + rand, + mesh, + processed + ); + writeRandomField + ( + fieldHeader, + pertMag, + rand, + mesh, + processed + ); + writeRandomField + ( + fieldHeader, + pertMag, + rand, + mesh, + processed + ); + + if (!processed) + { + FatalError + << "Unable to process " << fieldName << nl + << "No call to randomise for fields of type " + << fieldHeader.headerClassName() << nl << nl + << exit(FatalError); + } + } + else + { + Info<< " No " << fieldName << endl; + } + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/foamCalcFunctions/field/randomise/randomise.H b/src/postProcessing/foamCalcFunctions/field/randomise/randomise.H new file mode 100644 index 0000000000..61a01dc9de --- /dev/null +++ b/src/postProcessing/foamCalcFunctions/field/randomise/randomise.H @@ -0,0 +1,141 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::calcTypes::randomise + +Description + Adds a random component to a field, with a given perturbation magnitude. + +SourceFiles + randomise.C + +\*---------------------------------------------------------------------------*/ + +#ifndef randomise_H +#define randomise_H + +#include "calcType.H" +#include "Random.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +namespace calcTypes +{ + +/*---------------------------------------------------------------------------*\ + Class randomise Declaration +\*---------------------------------------------------------------------------*/ + +class randomise +: + public calcType +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + randomise(const randomise&); + + //- Disallow default bitwise assignment + void operator=(const randomise&); + + +protected: + + // Member Functions + + // Calculation routines + + //- Initialise - typically setting static variables, + // e.g. command line arguments + virtual void init(); + + //- Pre-time loop calculations + virtual void preCalc + ( + const argList& args, + const Time& runTime, + const fvMesh& mesh + ); + + //- Time loop calculations + virtual void calc + ( + const argList& args, + const Time& runTime, + const fvMesh& mesh + ); + + + // I-O + + //- Write component fields + template + void writeRandomField + ( + const IOobject& header, + const scalar pertMag, + Random& rand, + const fvMesh& mesh, + bool& processed + ); + + +public: + + //- Runtime type information + TypeName("randomise"); + + + // Constructors + + //- Construct null + randomise(); + + + // Destructor + + virtual ~randomise(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace calcTypes +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "writeRandomField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/foamCalcFunctions/field/randomise/writeRandomField.C b/src/postProcessing/foamCalcFunctions/field/randomise/writeRandomField.C new file mode 100644 index 0000000000..b43af5e83a --- /dev/null +++ b/src/postProcessing/foamCalcFunctions/field/randomise/writeRandomField.C @@ -0,0 +1,73 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 + +\*---------------------------------------------------------------------------*/ + +template +void Foam::calcTypes::randomise::writeRandomField +( + const IOobject& header, + const scalar pertMag, + Random& rand, + const fvMesh& mesh, + bool& processed +) +{ + typedef GeometricField fieldType; + + if (header.headerClassName() == fieldType::typeName) + { + Info<< " Reading " << header.name() << endl; + fieldType field(header, mesh); + + forAll(field, cellI) + { + Type rndPert; + rand.randomise(rndPert); + rndPert = 2.0*rndPert - pTraits::one; + rndPert /= mag(rndPert); + field[cellI] += pertMag*rndPert; + } + + fieldType randomisedField + ( + IOobject + ( + header.name() + "Random", + mesh.time().timeName(), + mesh, + IOobject::NO_READ + ), + field + ); + + Info<< " Writing " << header.name() << "Random" << endl; + randomisedField.write(); + + processed = true; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // From e60638fd4f9909c9b903bc43be519a0423857364 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 10 Sep 2008 10:31:01 +0100 Subject: [PATCH 13/82] adding pressure gradient volumetric source (kinematic only) --- src/finiteVolume/Make/files | 1 + .../pressureGradientExplicitSource.C | 170 ++++++++++++++++++ .../pressureGradientExplicitSource.H | 134 ++++++++++++++ 3 files changed, 305 insertions(+) create mode 100644 src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C create mode 100644 src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.H diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 83dff1819d..2d5186a550 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -261,6 +261,7 @@ cfdTools/general/porousMedia/porousZone.C cfdTools/general/porousMedia/porousZones.C cfdTools/general/MRF/MRFZone.C cfdTools/general/MRF/MRFZones.C +cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C cfdTools/general/fieldSources/timeActivatedExplicitSource/timeActivatedExplicitSource.C cfdTools/general/SRF/SRFModel/SRFModel/SRFModel.C cfdTools/general/SRF/SRFModel/SRFModel/newSRFModel.C diff --git a/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C b/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C new file mode 100644 index 0000000000..3783df0723 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/pressureGradientExplicitSource/pressureGradientExplicitSource.C @@ -0,0 +1,170 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "pressureGradientExplicitSource.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::pressureGradientExplicitSource::pressureGradientExplicitSource +( + const word& sourceName, + const fvMesh& mesh, + volVectorField& U +) +: + dict_ + ( + IOobject + ( + sourceName + "Properties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + mesh_(mesh), + U_(U), + Ubar_(dict_.lookup("Ubar")), + gradPini_(readScalar(dict_.lookup("gradPini"))), + gradP_(gradPini_), + flowDir_(Ubar_/mag(Ubar_)), + cellSource_(dict_.lookup("cellSource")), + cellSelector_ + ( + topoSetSource::New + ( + cellSource_, + mesh, + dict_.subDict(cellSource_ + "Coeffs") + ) + ), + selectedCellSet_ + ( + mesh, + "pressureGradientExplicitSourceCellSet", + mesh.nCells()/10 + 1 // Reasonable size estimate. + ) +{ + // Create the cell set + cellSelector_->applyToSet + ( + topoSetSource::NEW, + selectedCellSet_ + ); + + // Give some feedback + Info<< "pressureGradientExplicitSource(" << sourceName << ")" << nl + << "Selected " << returnReduce(selectedCellSet_.size(), sumOp