From 0463b16608cf3f216a7ffe9d82740afd743c327b Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 2 Feb 2012 10:20:33 +0000 Subject: [PATCH 1/4] ENH: nutAtmRoughWallFunction for atm boundary layer following the U profile described on atmVelocityinlet BC --- .../incompressible/RAS/Make/files | 1 + ...tkAtmRoughWallFunctionFvPatchScalarField.C | 220 ++++++++++++++++++ ...tkAtmRoughWallFunctionFvPatchScalarField.H | 198 ++++++++++++++++ 3 files changed, 419 insertions(+) create mode 100644 src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.C create mode 100644 src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.H diff --git a/src/turbulenceModels/incompressible/RAS/Make/files b/src/turbulenceModels/incompressible/RAS/Make/files index e28a685903..d667a8b26e 100644 --- a/src/turbulenceModels/incompressible/RAS/Make/files +++ b/src/turbulenceModels/incompressible/RAS/Make/files @@ -29,6 +29,7 @@ $(nutWallFunctions)/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScal $(nutWallFunctions)/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C $(nutWallFunctions)/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C $(nutWallFunctions)/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.C epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions $(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000..2ec45c7f60 --- /dev/null +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.C @@ -0,0 +1,220 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "nutkAtmRoughWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + + +tmp nutkAtmRoughWallFunctionFvPatchScalarField::calcNut() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalarField& y = rasModel.y()[patchI]; + const tmp tk = rasModel.k(); + const volScalarField& k = tk(); + const tmp tnu = rasModel.nu(); + const volScalarField& nu = tnu(); + const scalarField& nuw = nu.boundaryField()[patchI]; + + const scalar Cmu25 = pow025(Cmu_); + + tmp tnutw(new scalarField(*this)); + scalarField& nutw = tnutw(); + + forAll(nutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar uStar = Cmu25*sqrt(k[faceCellI]); + scalar yPlus = uStar*y[faceI]/nuw[faceI]; + + scalar Edash = (y[faceI] + z0_[faceI] - zGround_[faceI])/z0_[faceI]; + + scalar limitingNutw = max(nutw[faceI], nuw[faceI]); + + // To avoid oscillations limit the change in the wall viscosity + // which is particularly important if it temporarily becomes zero + nutw[faceI] = + max + ( + min + ( + nuw[faceI] + *(yPlus*kappa_/log(max(Edash, 1+1e-4)) - 1), + 2*limitingNutw + ), 0.5*limitingNutw + ); + + if (debug) + { + Info<< "yPlus = " << yPlus + << ", Edash = " << Edash + << ", nutw = " << nutw[faceI] + << endl; + } + } + + return tnutw; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +nutkAtmRoughWallFunctionFvPatchScalarField:: +nutkAtmRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + nutkWallFunctionFvPatchScalarField(p, iF), + z0_(p.size(), 0.0), + zGround_(p.size(), 0.0) +{} + + +nutkAtmRoughWallFunctionFvPatchScalarField:: +nutkAtmRoughWallFunctionFvPatchScalarField +( + const nutkAtmRoughWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper), + z0_(ptf.z0_, mapper), + zGround_(ptf.zGround_, mapper) +{} + + +nutkAtmRoughWallFunctionFvPatchScalarField:: +nutkAtmRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + nutkWallFunctionFvPatchScalarField(p, iF, dict), + z0_("z0", dict, p.size()), + zGround_("zGround", dict, p.size()) +{} + + +nutkAtmRoughWallFunctionFvPatchScalarField:: +nutkAtmRoughWallFunctionFvPatchScalarField +( + const nutkAtmRoughWallFunctionFvPatchScalarField& rwfpsf +) +: + nutkWallFunctionFvPatchScalarField(rwfpsf), + z0_(rwfpsf.z0_), + zGround_(rwfpsf.zGround_) +{} + + +nutkAtmRoughWallFunctionFvPatchScalarField:: +nutkAtmRoughWallFunctionFvPatchScalarField +( + const nutkAtmRoughWallFunctionFvPatchScalarField& rwfpsf, + const DimensionedField& iF +) +: + nutkWallFunctionFvPatchScalarField(rwfpsf, iF), + z0_(rwfpsf.z0_), + zGround_(rwfpsf.zGround_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void nutkAtmRoughWallFunctionFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + nutkWallFunctionFvPatchScalarField::autoMap(m); + z0_.autoMap(m); + zGround_.autoMap(m); +} + + +void nutkAtmRoughWallFunctionFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + nutkWallFunctionFvPatchScalarField::rmap(ptf, addr); + + const nutkAtmRoughWallFunctionFvPatchScalarField& nrwfpsf = + refCast(ptf); + + z0_.rmap(nrwfpsf.z0_, addr); + zGround_.rmap(nrwfpsf.zGround_, addr); +} + + +void nutkAtmRoughWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField::write(os); + writeLocalEntries(os); + z0_.writeEntry("z0", os); + zGround_.writeEntry("zGround", os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + nutkAtmRoughWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000..803985ced7 --- /dev/null +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.H @@ -0,0 +1,198 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::incompressible::RASModels:: + nutkAtmRoughWallFunctionFvPatchScalarField + +Description + Boundary condition for turbulent (kinematic) viscosity for atmospheric + velocity profiles. + Desinged to be used togheter with atmBoundaryLayerInletVelocity. + It follows U = (Ustar/K) ln((z - zGround + z0)/z0) + + where: + + Ustar is the frictional velocity + K is karman's constant + z0 is the surface roughness lenght + z is the verical coordinate + zGround is the minumum coordinate value in z direction. + + +SourceFiles + nutkAtmRoughWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef nutkAtmRoughWallFunctionFvPatchScalarField_H +#define nutkAtmRoughWallFunctionFvPatchScalarField_H + +#include "nutkWallFunctionFvPatchScalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class nutkAtmRoughWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class nutkAtmRoughWallFunctionFvPatchScalarField +: + public nutkWallFunctionFvPatchScalarField +{ +protected: + + // Protected data + + //- Surface roughness lenght + scalarField z0_; + + //- Minimum corrdinate value in z direction + scalarField zGround_; + + + // Protected Member Functions + + + //- Calculate the turbulence viscosity + virtual tmp calcNut() const; + + +public: + + //- Runtime type information + TypeName("nutkAtmRoughWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + nutkAtmRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + nutkAtmRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // nutkAtmRoughWallFunctionFvPatchScalarField + // onto a new patch + nutkAtmRoughWallFunctionFvPatchScalarField + ( + const nutkAtmRoughWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + nutkAtmRoughWallFunctionFvPatchScalarField + ( + const nutkAtmRoughWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new nutkAtmRoughWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + nutkAtmRoughWallFunctionFvPatchScalarField + ( + const nutkAtmRoughWallFunctionFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new nutkAtmRoughWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Acces functions + + // Return z0 + scalarField& z0() + { + return z0_; + } + + + // 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& + ); + + + // I-O + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 5eca8bd935af8c393da377217a54476ac89bc4b7 Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 2 Feb 2012 15:17:50 +0000 Subject: [PATCH 2/4] ENH: actuation disk modifications and rough Wall function for atm inlet --- .../actuationDiskSource/actuationDiskSource.C | 12 ++++++- .../actuationDiskSource/actuationDiskSource.H | 7 ++++ .../actuationDiskSourceTemplates.C | 15 +++++--- .../radialActuationDiskSource.H | 1 + .../radialActuationDiskSourceTemplates.C | 22 +++++++----- ...ndaryLayerInletEpsilonFvPatchScalarField.C | 21 ++++++++++-- ...ndaryLayerInletEpsilonFvPatchScalarField.H | 22 ++++++++++-- ...daryLayerInletVelocityFvPatchVectorField.C | 22 ++++++------ ...daryLayerInletVelocityFvPatchVectorField.H | 4 +-- ...tkAtmRoughWallFunctionFvPatchScalarField.C | 34 ++++--------------- ...tkAtmRoughWallFunctionFvPatchScalarField.H | 3 -- 11 files changed, 101 insertions(+), 62 deletions(-) diff --git a/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C b/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C index 68f0c2a5bf..878398220e 100644 --- a/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C +++ b/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C @@ -66,6 +66,12 @@ void Foam::actuationDiskSource::checkData() const << "disk direction vector is approximately zero" << exit(FatalIOError); } + if (returnReduce(upstreamCellId_, maxOp