diff --git a/src/turbulenceModels/derivedFvPatchFields/Make/files b/src/turbulenceModels/derivedFvPatchFields/Make/files index 360b593edb..f0a5fdfa8a 100644 --- a/src/turbulenceModels/derivedFvPatchFields/Make/files +++ b/src/turbulenceModels/derivedFvPatchFields/Make/files @@ -1,3 +1,4 @@ porousBafflePressure/porousBafflePressureFvPatchFields.C +fixedShearStress/fixedShearStressFvPatchVectorField.C LIB = $(FOAM_LIBBIN)/libturbulenceDerivedFvPatchFields diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C b/src/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C similarity index 54% rename from src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C rename to src/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C index c5a2c5f8e8..0f1d19bb2e 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C +++ b/src/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C @@ -28,28 +28,25 @@ License #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" #include "volFields.H" -#include "RASModel.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace incompressible -{ +#include "incompressible/RAS/RASModel/RASModel.H" +#include "compressible/RAS/RASModel/RASModel.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField +Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField ( const fvPatch& p, const DimensionedField& iF ) : fixedValueFvPatchVectorField(p, iF), + phiName_("phi"), + rhoName_("rho"), tau0_(vector::zero) {} -fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField +Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField ( const fvPatch& p, const DimensionedField& iF, @@ -57,13 +54,15 @@ fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField ) : fixedValueFvPatchVectorField(p, iF), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")), tau0_(dict.lookupOrDefault("tau", vector::zero)) { fvPatchField::operator=(patchInternalField()); } -fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField +Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField ( const fixedShearStressFvPatchVectorField& ptf, const fvPatch& p, @@ -72,76 +71,102 @@ fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField ) : fixedValueFvPatchVectorField(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), tau0_(ptf.tau0_) {} -fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField +Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField ( const fixedShearStressFvPatchVectorField& ptf ) : fixedValueFvPatchVectorField(ptf), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), tau0_(ptf.tau0_) {} -fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField +Foam::fixedShearStressFvPatchVectorField::fixedShearStressFvPatchVectorField ( const fixedShearStressFvPatchVectorField& ptf, const DimensionedField& iF ) : fixedValueFvPatchVectorField(ptf, iF), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), tau0_(ptf.tau0_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void fixedShearStressFvPatchVectorField::updateCoeffs() +void Foam::fixedShearStressFvPatchVectorField::updateCoeffs() { if (updated()) { return; } - const label patchi = patch().index(); + const label patchI = patch().index(); - const turbulenceModel& turbModel = - db().lookupObject("turbulenceModel"); + const surfaceScalarField& phi = + db().lookupObject(phiName_); - const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; + scalarField nuEff; + if (phi.dimensions() == dimVelocity*dimArea) + { + const incompressible::turbulenceModel& turbModel = + db().lookupObject + ( + "turbulenceModel" + ); - const vectorField Ui(Uw.patchInternalField()); + nuEff = turbModel.nuEff()()[patchI]; + } + else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) + { + const compressible::turbulenceModel& turbModel = + db().lookupObject + ( + "turbulenceModel" + ); + + const fvPatchField& rhop = + patch().lookupPatchField(rhoName_); + + nuEff = turbModel.muEff()()[patchI]/rhop; + } + else + { + FatalErrorIn("fixedShearStressFvPatchVectorField::updateCoeffs()") + << "dimensions of phi are not correct" + << "\n on patch " << this->patch().name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << exit(FatalError); + } + + const vectorField Uc(patchInternalField()); vector tauHat = tau0_/(mag(tau0_) + ROOTVSMALL); const scalarField& ry = patch().deltaCoeffs(); - tmp tnuEff = turbModel.nuEff(); - const volScalarField& nuEff = tnuEff(); - const scalarField& nuEffw = nuEff.boundaryField()[patchi]; - - tmp UwUpdated = - tauHat*(tauHat & (tau0_*(1.0/(ry*nuEffw)) + Ui)); - - operator==(UwUpdated); - - if (debug) - { - tmp nHat = this->patch().nf(); - volSymmTensorField Reff(turbModel.devReff()); - Info << "tau : " << (nHat & Reff.boundaryField()[patchi])() << endl; - } + operator==(tauHat*(tauHat & (tau0_*(1.0/(ry*nuEff)) + Uc))); fixedValueFvPatchVectorField::updateCoeffs(); } -void fixedShearStressFvPatchVectorField::write(Ostream& os) const +void Foam::fixedShearStressFvPatchVectorField::write(Ostream& os) const { fixedValueFvPatchVectorField::write(os); + writeEntryIfDifferent(os, "phi", "phi", phiName_); + writeEntryIfDifferent(os, "rho", "rho", rhoName_); os.writeKeyword("tau") << tau0_ << token::END_STATEMENT << nl; writeEntry("value", os); } @@ -149,15 +174,13 @@ void fixedShearStressFvPatchVectorField::write(Ostream& os) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField -( - fvPatchVectorField, - fixedShearStressFvPatchVectorField -); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace incompressible -} // End namespace Foam +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + fixedShearStressFvPatchVectorField + ); +} // ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.H b/src/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.H similarity index 94% rename from src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.H rename to src/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.H index 6bbcf8c9c6..13b16e86d2 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.H +++ b/src/turbulenceModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,8 +43,7 @@ SourceFiles namespace Foam { -namespace incompressible -{ + /*---------------------------------------------------------------------------*\ Class fixedShearStressFvPatchVectorField Declaration \*---------------------------------------------------------------------------*/ @@ -55,6 +54,12 @@ class fixedShearStressFvPatchVectorField { // Private data + //- Name of flux field (default = phi) + const word phiName_; + + //- Name of density field (default = rho) + const word rhoName_; + //- Constant shear stress const vector tau0_; @@ -138,7 +143,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace incompressible } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/turbulenceModels/incompressible/RAS/Make/files b/src/turbulenceModels/incompressible/RAS/Make/files index b76fb0c411..ce75d38346 100644 --- a/src/turbulenceModels/incompressible/RAS/Make/files +++ b/src/turbulenceModels/incompressible/RAS/Make/files @@ -51,7 +51,6 @@ $(kappatWallFunctions)/kappatJayatillekeWallFunction/kappatJayatillekeWallFuncti derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C -derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C