diff --git a/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C b/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C index 68f0c2a5bf926e1812886b95de3a6ea9f5bfb42e..878398220ef20ce73d72a8a7c823a6d71b2c525b 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<label>()) == -1) + { + FatalErrorIn("Foam::actuationDiskSource::checkData()") + << "upstream location " << upstreamPoint_ << " not found in mesh" + << exit(FatalIOError); + } } @@ -83,7 +89,9 @@ Foam::actuationDiskSource::actuationDiskSource diskDir_(coeffs_.lookup("diskDir")), Cp_(readScalar(coeffs_.lookup("Cp"))), Ct_(readScalar(coeffs_.lookup("Ct"))), - diskArea_(readScalar(coeffs_.lookup("diskArea"))) + diskArea_(readScalar(coeffs_.lookup("diskArea"))), + upstreamPoint_(coeffs_.lookup("upstreamPoint")), + upstreamCellId_(-1) { coeffs_.lookup("fieldNames") >> fieldNames_; applied_.setSize(fieldNames_.size(), false); @@ -91,6 +99,8 @@ Foam::actuationDiskSource::actuationDiskSource Info<< " - creating actuation disk zone: " << this->name() << endl; + upstreamCellId_ = mesh.findCell(upstreamPoint_); + checkData(); } diff --git a/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H b/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H index 077442589258e6d73bdf45a31d511af6225abb57..80cd7bd54a88c2da40b4580de14b90308cdf3b48 100644 --- a/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H +++ b/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H @@ -48,6 +48,7 @@ Description Cp 0.1; // power coefficient Ct 0.5; // thrust coefficient diskArea 5.0; // disk area + upstreamPoint (0 0 0); // upstream point } @@ -92,6 +93,12 @@ protected: //- Disk area scalar diskArea_; + //- Upstream point sample + point upstreamPoint_; + + //- Upstream cell ID + label upstreamCellId_; + private: diff --git a/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSourceTemplates.C b/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSourceTemplates.C index dbaf95c4b94d77bf14ae3e547462dbc59b40cd2e..959e86f5b3fedf05088ef1ee7bcb739e13605add 100644 --- a/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSourceTemplates.C +++ b/src/fieldSources/basicSource/actuationDiskSource/actuationDiskSourceTemplates.C @@ -42,20 +42,27 @@ void Foam::actuationDiskSource::addActuationDiskAxialInertialResistance ) const { scalar a = 1.0 - Cp_/Ct_; - scalarField T(cells.size()); vector uniDiskDir = diskDir_/mag(diskDir_); tensor E(tensor::zero); E.xx() = uniDiskDir.x(); E.yy() = uniDiskDir.y(); E.zz() = uniDiskDir.z(); - forAll(cells, i) + vector upU = vector(VGREAT, VGREAT, VGREAT); + scalar upRho = VGREAT; + if (upstreamCellId_ != -1) { - T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U[cells[i]])*a/(1.0 - a); + upU = U[upstreamCellId_]; + upRho = rho[upstreamCellId_]; } + reduce(upU, minOp<vector>()); + reduce(upRho, minOp<scalar>()); + + scalar T = 2.0*upRho*diskArea_*mag(upU)*a*(1 - a); + forAll(cells, i) { - Usource[cells[i]] -= ((Vcells[cells[i]]/V())*T[i]*E) & U[cells[i]]; + Usource[cells[i]] += ((Vcells[cells[i]]/V())*T*E) & upU; } } diff --git a/src/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSource.H b/src/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSource.H index 4c464bcfd36754571d947eca2af534ca456a8969..134e93b5eae64116d38e0e8048a29980598a8f27 100644 --- a/src/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSource.H +++ b/src/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSource.H @@ -53,6 +53,7 @@ Description Ct 0.5; // thrust coefficient diskArea 5.0; // disk area coeffs (0.1 0.5 0.01); // radial distribution coefficients + upstreamPoint (0 0 0); // upstream point } diff --git a/src/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSourceTemplates.C b/src/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSourceTemplates.C index 127263c94f2ff5dbc937020e6d8e45c862678b76..adea6154550cf1642d52834d7af47b26efe18d64 100644 --- a/src/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSourceTemplates.C +++ b/src/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSourceTemplates.C @@ -44,11 +44,9 @@ addRadialActuationDiskAxialInertialResistance ) const { scalar a = 1.0 - Cp_/Ct_; - scalarField T(cells.size()); scalarField Tr(cells.size()); const vector uniDiskDir = diskDir_/mag(diskDir_); - tensor E(tensor::zero); E.xx() = uniDiskDir.x(); E.yy() = uniDiskDir.y(); @@ -65,21 +63,27 @@ addRadialActuationDiskAxialInertialResistance + radialCoeffs_[1]*sqr(maxR)/2.0 + radialCoeffs_[2]*pow4(maxR)/3.0; - forAll(cells, i) + vector upU = vector(VGREAT, VGREAT, VGREAT); + scalar upRho = VGREAT; + if (upstreamCellId_ != -1) { - T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U[cells[i]])*a/(1.0 - a); + upU = U[upstreamCellId_]; + upRho = rho[upstreamCellId_]; + } + reduce(upU, minOp<vector>()); + reduce(upRho, minOp<scalar>()); + scalar T = 2.0*upRho*diskArea_*mag(upU)*a*(1.0 - a); + forAll(cells, i) + { scalar r2 = magSqr(mesh().cellCentres()[cells[i]] - avgCentre); Tr[i] = - T[i] + T *(radialCoeffs_[0] + radialCoeffs_[1]*r2 + radialCoeffs_[2]*sqr(r2)) /intCoeffs; - } - forAll(cells, i) - { - Usource[cells[i]] -= ((Vcells[cells[i]]/V_)*Tr[i]*E) & U[cells[i]]; + Usource[cells[i]] += ((Vcells[cells[i]]/V_)*Tr[i]*E) & upU; } if (debug) diff --git a/src/turbulenceModels/incompressible/RAS/Make/files b/src/turbulenceModels/incompressible/RAS/Make/files index e28a68590391b8cbd750611ab51f601a04872179..d667a8b26eacb9c5c620e095849988d87b11aeb7 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/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C index a3d313e30285ffb9eaf10ac5c4f658518f6abec0..4b4273ff32ffcbb39accd680c50c2ac391ec8496 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C @@ -51,6 +51,8 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField z_(pTraits<vector>::zero), z0_(0), kappa_(0.41), + Uref_(0), + Href_(0), zGround_(0) {} @@ -69,6 +71,8 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField z_(ptf.z_), z0_(ptf.z0_), kappa_(ptf.kappa_), + Uref_(ptf.Uref_), + Href_(ptf.Href_), zGround_(ptf.zGround_) {} @@ -82,10 +86,12 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField ) : fixedValueFvPatchScalarField(p, iF), - Ustar_(readScalar(dict.lookup("Ustar"))), + Ustar_(p.size()), z_(dict.lookup("z")), z0_(readScalar(dict.lookup("z0"))), kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), + Uref_(readScalar(dict.lookup("Uref"))), + Href_(readScalar(dict.lookup("Href"))), zGround_("zGround", dict, p.size()) { if (mag(z_) < SMALL) @@ -103,6 +109,11 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField << abort(FatalError); } + forAll (Ustar_, i) + { + Ustar_[i] = kappa_*Uref_/(log((Href_ + z0_[i])/max(z0_[i] , 0.001))); + } + z_ /= mag(z_); evaluate(); @@ -121,6 +132,8 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField z_(blpsf.z_), z0_(blpsf.z0_), kappa_(blpsf.kappa_), + Uref_(blpsf.Uref_), + Href_(blpsf.Href_), zGround_(blpsf.zGround_) {} @@ -138,14 +151,16 @@ void atmBoundaryLayerInletEpsilonFvPatchScalarField::updateCoeffs() void atmBoundaryLayerInletEpsilonFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - os.writeKeyword("Ustar") - << Ustar_ << token::END_STATEMENT << nl; os.writeKeyword("z") << z_ << token::END_STATEMENT << nl; os.writeKeyword("z0") << z0_ << token::END_STATEMENT << nl; os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; + os.writeKeyword("Uref") + << Uref_ << token::END_STATEMENT << nl; + os.writeKeyword("Href") + << Href_ << token::END_STATEMENT << nl; os.writeKeyword("zGround") << zGround_ << token::END_STATEMENT << nl; writeEntry("value", os); diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.H index ab08c621c95da1aa092c751da6192598e066a7d8..a1ff656334b9c5f17a9b0eefafc35615008fb6bc 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.H @@ -41,6 +41,16 @@ Description z0 is the surface roughness lenght zGround minium vlaue in z direction + + and: + + Ustar = K Uref/ln((Zref + z0)/z0) + + where: + + Uref is the reference velocity at Zref + Zref is the reference height. + \endverbatim Reference: @@ -78,17 +88,23 @@ class atmBoundaryLayerInletEpsilonFvPatchScalarField // Private data //- Frictional velocity - const scalar Ustar_; + scalarField Ustar_; //- Direction of the z-coordinate vector z_; //- Surface roughness lenght - const scalar z0_; + scalarField z0_; //- Von Karman constant const scalar kappa_; + //- Reference velocity + const scalar Uref_; + + //- Reference hight + const scalar Href_; + //- Minimum corrdinate value in z direction const scalarField zGround_; @@ -158,7 +174,7 @@ public: // Member functions //- Return max value - scalar Ustar() const + scalarField Ustar() const { return Ustar_; } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C index d2c3dfde62d47a8570b63b1ed07482463a381e92..628b300afd389db3bda931085dae6cbcc68b6089 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C @@ -88,16 +88,16 @@ atmBoundaryLayerInletVelocityFvPatchVectorField ) : fixedValueFvPatchVectorField(p, iF), - Ustar_(0), + Ustar_(p.size()), n_(dict.lookup("n")), z_(dict.lookup("z")), - z0_(readScalar(dict.lookup("z0"))), + z0_("z0", dict, p.size()), kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), Uref_(readScalar(dict.lookup("Uref"))), Href_(readScalar(dict.lookup("Href"))), zGround_("zGround", dict, p.size()) { - if (mag(n_) < SMALL || mag(z_) < SMALL || mag(z0_) < SMALL) + if (mag(n_) < SMALL || mag(z_) < SMALL) { FatalErrorIn ( @@ -108,14 +108,17 @@ atmBoundaryLayerInletVelocityFvPatchVectorField "onst dictionary&" ")" ) - << "magnitude of n, z and z0 vectors must be greater than zero" + << "magnitude of n or z must be greater than zero" << abort(FatalError); } n_ /= mag(n_); z_ /= mag(z_); - Ustar_ = kappa_*Uref_/(log((Href_ + z0_)/max(z0_ , 0.001))); + forAll (Ustar_, i) + { + Ustar_[i] = kappa_*Uref_/(log((Href_ + z0_[i])/max(z0_[i] , 0.001))); + } evaluate(); } @@ -153,12 +156,12 @@ void atmBoundaryLayerInletVelocityFvPatchVectorField::updateCoeffs() if ((coord[i] - zGround_[i]) < Href_) { Un[i] = - (Ustar_/kappa_) - * log((coord[i] - zGround_[i] + z0_)/max(z0_, 0.001)); + (Ustar_[i]/kappa_) + * log((coord[i] - zGround_[i] + z0_[i])/max(z0_[i], 0.001)); } else { - Un[i] = (Uref_); + Un[i] = Uref_; } } @@ -171,8 +174,7 @@ void atmBoundaryLayerInletVelocityFvPatchVectorField::updateCoeffs() void atmBoundaryLayerInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - os.writeKeyword("z0") - << z0_ << token::END_STATEMENT << nl; + zGround_.writeEntry("z0", os) ; os.writeKeyword("n") << n_ << token::END_STATEMENT << nl; os.writeKeyword("z") diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.H index a3a87ab9d2931cea7413a3df5bda2793e67466ce..684405ece39d259079c0200ef5fe88e960e41c90 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.H @@ -92,7 +92,7 @@ class atmBoundaryLayerInletVelocityFvPatchVectorField // Private data //- Frictional velocity - scalar Ustar_; + scalarField Ustar_; //- Flow direction vector n_; @@ -101,7 +101,7 @@ class atmBoundaryLayerInletVelocityFvPatchVectorField vector z_; //- Surface roughness lenght - const scalar z0_; + scalarField z0_; //- Von Karman constant const scalar kappa_; @@ -181,7 +181,7 @@ public: // Member functions //- Return Ustar - scalar& Ustar() + scalarField& Ustar() { return Ustar_; } 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 0000000000000000000000000000000000000000..162de9255a0d560f93176252f8c25468dbd59ac8 --- /dev/null +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.C @@ -0,0 +1,200 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#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<scalarField> nutkAtmRoughWallFunctionFvPatchScalarField::calcNut() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); + const scalarField& y = rasModel.y()[patchI]; + const tmp<volScalarField> tk = rasModel.k(); + const volScalarField& k = tk(); + const tmp<volScalarField> tnu = rasModel.nu(); + const volScalarField& nu = tnu(); + const scalarField& nuw = nu.boundaryField()[patchI]; + + const scalar Cmu25 = pow025(Cmu_); + + tmp<scalarField> 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])/z0_[faceI]; + + nutw[faceI] = + nuw[faceI]*(yPlus*kappa_/log(max(Edash, 1+1e-4)) - 1); + + if (debug) + { + Info<< "yPlus = " << yPlus + << ", Edash = " << Edash + << ", nutw = " << nutw[faceI] + << endl; + } + } + + return tnutw; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +nutkAtmRoughWallFunctionFvPatchScalarField:: +nutkAtmRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + nutkWallFunctionFvPatchScalarField(p, iF), + z0_(p.size(), 0.0) +{} + + +nutkAtmRoughWallFunctionFvPatchScalarField:: +nutkAtmRoughWallFunctionFvPatchScalarField +( + const nutkAtmRoughWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper), + z0_(ptf.z0_, mapper) +{} + + +nutkAtmRoughWallFunctionFvPatchScalarField:: +nutkAtmRoughWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + nutkWallFunctionFvPatchScalarField(p, iF, dict), + z0_("z0", dict, p.size()) +{} + + +nutkAtmRoughWallFunctionFvPatchScalarField:: +nutkAtmRoughWallFunctionFvPatchScalarField +( + const nutkAtmRoughWallFunctionFvPatchScalarField& rwfpsf +) +: + nutkWallFunctionFvPatchScalarField(rwfpsf), + z0_(rwfpsf.z0_) +{} + + +nutkAtmRoughWallFunctionFvPatchScalarField:: +nutkAtmRoughWallFunctionFvPatchScalarField +( + const nutkAtmRoughWallFunctionFvPatchScalarField& rwfpsf, + const DimensionedField<scalar, volMesh>& iF +) +: + nutkWallFunctionFvPatchScalarField(rwfpsf, iF), + z0_(rwfpsf.z0_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void nutkAtmRoughWallFunctionFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + nutkWallFunctionFvPatchScalarField::autoMap(m); + z0_.autoMap(m); +} + + +void nutkAtmRoughWallFunctionFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + nutkWallFunctionFvPatchScalarField::rmap(ptf, addr); + + const nutkAtmRoughWallFunctionFvPatchScalarField& nrwfpsf = + refCast<const nutkAtmRoughWallFunctionFvPatchScalarField>(ptf); + + z0_.rmap(nrwfpsf.z0_, addr); +} + + +void nutkAtmRoughWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField<scalar>::write(os); + writeLocalEntries(os); + z0_.writeEntry("z0", 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 0000000000000000000000000000000000000000..aa045de4234d019479a1cbb1ebd2ccc4eca8e575 --- /dev/null +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.H @@ -0,0 +1,195 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 <http://www.gnu.org/licenses/>. + +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_; + + + // Protected Member Functions + + + //- Calculate the turbulence viscosity + virtual tmp<scalarField> calcNut() const; + + +public: + + //- Runtime type information + TypeName("nutkAtmRoughWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + nutkAtmRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + nutkAtmRoughWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // nutkAtmRoughWallFunctionFvPatchScalarField + // onto a new patch + nutkAtmRoughWallFunctionFvPatchScalarField + ( + const nutkAtmRoughWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + nutkAtmRoughWallFunctionFvPatchScalarField + ( + const nutkAtmRoughWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new nutkAtmRoughWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + nutkAtmRoughWallFunctionFvPatchScalarField + ( + const nutkAtmRoughWallFunctionFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + 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 + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/turbineSiting/0/epsilon b/tutorials/incompressible/simpleFoam/turbineSiting/0/epsilon index 8a3f6570841ba0fb5562a5d22a9e636f8a6da612..cbbcc3aebf1d66be973620bc24c7b867d2b14c96 100644 --- a/tutorials/incompressible/simpleFoam/turbineSiting/0/epsilon +++ b/tutorials/incompressible/simpleFoam/turbineSiting/0/epsilon @@ -40,7 +40,8 @@ boundaryField inlet { type atmBoundaryLayerInletEpsilon; - Ustar $Ustar; + Uref $Uref; + Href $Href; z $zDirection; z0 $z0; value $internalField; diff --git a/tutorials/incompressible/simpleFoam/turbineSiting/0/include/ABLConditions b/tutorials/incompressible/simpleFoam/turbineSiting/0/include/ABLConditions index be005f46a0764e366af7149e6670fb6ba8826638..b63b50f4175e2d921da42ba7fbf516706c4df3e4 100644 --- a/tutorials/incompressible/simpleFoam/turbineSiting/0/include/ABLConditions +++ b/tutorials/incompressible/simpleFoam/turbineSiting/0/include/ABLConditions @@ -6,10 +6,9 @@ | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ -Ustar 0.82; Uref 10.0; Href 20; -z0 0.1; +z0 uniform 0.1; turbulentKE 1.3; windDirection (1 0 0); zDirection (0 0 1); diff --git a/tutorials/incompressible/simpleFoam/turbineSiting/0/nut b/tutorials/incompressible/simpleFoam/turbineSiting/0/nut index 5e17706e0a03a745d6377c9ebef48157cb080498..be1471daf357a8706ba9f6132434ac48bd875808 100644 --- a/tutorials/incompressible/simpleFoam/turbineSiting/0/nut +++ b/tutorials/incompressible/simpleFoam/turbineSiting/0/nut @@ -36,9 +36,8 @@ boundaryField "terrain_.*" { - type nutkRoughWallFunction; - Ks uniform 0.2; //Ks = 20 Z0 - Cs uniform 0.5; + type nutkAtmRoughWallFunction; + z0 $Z0; value uniform 0.0; } diff --git a/tutorials/incompressible/simpleFoam/turbineSiting/constant/polyMesh/boundary b/tutorials/incompressible/simpleFoam/turbineSiting/constant/polyMesh/boundary index 7abdd81f4fef7404693356fc268d5daa1c6fff5d..7b72e85f595d014f15070eef4db4e25d5088980a 100644 --- a/tutorials/incompressible/simpleFoam/turbineSiting/constant/polyMesh/boundary +++ b/tutorials/incompressible/simpleFoam/turbineSiting/constant/polyMesh/boundary @@ -15,43 +15,37 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -6 +5 ( outlet { type patch; - nFaces 922; - startFace 364825; + nFaces 600; + startFace 51900; } sides { type patch; - nFaces 1834; - startFace 365747; + nFaces 1200; + startFace 52500; } inlet { type patch; - nFaces 923; - startFace 367581; + nFaces 600; + startFace 53700; } ground { type wall; - nFaces 0; - startFace 368504; + nFaces 900; + startFace 54300; } top { type patch; nFaces 900; - startFace 368504; - } - terrain_patch0 - { - type wall; - nFaces 16037; - startFace 369404; + startFace 55200; } ) diff --git a/tutorials/incompressible/simpleFoam/turbineSiting/constant/sourcesProperties b/tutorials/incompressible/simpleFoam/turbineSiting/constant/sourcesProperties index 00249342e45a83992c644f81ecf52b52d495462f..a57b5a3b7b34398ead9e3db058e1b200e971a041 100644 --- a/tutorials/incompressible/simpleFoam/turbineSiting/constant/sourcesProperties +++ b/tutorials/incompressible/simpleFoam/turbineSiting/constant/sourcesProperties @@ -27,10 +27,11 @@ disk1 actuationDiskSourceCoeffs { fieldNames (U); - diskDir (-1 0 0); // orientation of the disk - Cp 0.53; // Cp - Ct 0.58; // Ct - diskArea 40; // disk area + diskDir (-1 0 0); // orientation of the disk + Cp 0.386; // Cp + Ct 0.58; // Ct + diskArea 40; // disk area + upstreamPoint (581849 4785810 1065); } } @@ -50,6 +51,7 @@ disk2 Cp 0.53; Ct 0.58; diskArea 40; + upstreamPoint (581753 4785663 1070); } } diff --git a/tutorials/incompressible/simpleFoam/turbineSiting/system/changeDictionaryDict b/tutorials/incompressible/simpleFoam/turbineSiting/system/changeDictionaryDict index 5ad20a759e52fbf70b8170677347d64dec979c0e..e90a3425ce88d78c34307ac640258a2943897b96 100644 --- a/tutorials/incompressible/simpleFoam/turbineSiting/system/changeDictionaryDict +++ b/tutorials/incompressible/simpleFoam/turbineSiting/system/changeDictionaryDict @@ -15,6 +15,7 @@ FoamFile // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "$FOAM_CASE/0/include/initialConditions" +#include "$FOAM_CASE/0/include/ABLConditions" dictionaryReplacement { @@ -99,12 +100,12 @@ dictionaryReplacement inlet { type atmBoundaryLayerInletVelocity; - Uref 10.0; - Href 20; - n (1 0 0); - z (0 0 1); - z0 0.1; - zGround 935.0; + Uref $Uref; + Href $Href; + n $windDirection; + z $zDirection; + z0 $z0; + zGround $zGround; value uniform $flowVelocity; } "terrain_.*" @@ -141,9 +142,8 @@ dictionaryReplacement } "terrain_.*" { - type nutkRoughWallFunction; - Ks uniform 0.2; //Ks = 20 Z0 - Cs uniform 0.5; + type nutkAtmRoughWallFunction; + z0 $z0; value uniform 0.0; } ground @@ -170,11 +170,12 @@ dictionaryReplacement inlet { type atmBoundaryLayerInletEpsilon; - Ustar 0.82; - z (0 0 1); - z0 0.1; + z $zDirection; + z0 $z0; + zGround $zGround; + Uref $Uref; + Href $Href; value uniform $turbulentEpsilon; - zGround 935.0; } "terrain_.*" {