diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C index cf18efa60..24768b780 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.C @@ -39,11 +39,15 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchField(p, iF), - UName_("U"), - intensity_(0.05) -{} - + inletOutletFvPatchScalarField(p, iF), + intensity_(0.0), + UName_("undefined-U"), + phiName_("undefined-phi") +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField:: turbulentIntensityKineticEnergyInletFvPatchScalarField @@ -54,9 +58,10 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchField(ptf, p, iF, mapper), + inletOutletFvPatchScalarField(ptf, p, iF, mapper), + intensity_(ptf.intensity_), UName_(ptf.UName_), - intensity_(ptf.intensity_) + phiName_(ptf.phiName_) {} @@ -68,9 +73,10 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField const dictionary& dict ) : - fixedValueFvPatchField(p, iF, dict), + inletOutletFvPatchScalarField(p, iF), + intensity_(readScalar(dict.lookup("intensity"))), UName_(dict.lookupOrDefault("U", "U")), - intensity_(readScalar(dict.lookup("intensity"))) + phiName_(dict.lookupOrDefault("phi", "phi")) { if (intensity_ < 0 || intensity_ > 1) { @@ -88,8 +94,13 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalError); } -} + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField:: turbulentIntensityKineticEnergyInletFvPatchScalarField @@ -97,9 +108,10 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField const turbulentIntensityKineticEnergyInletFvPatchScalarField& ptf ) : - fixedValueFvPatchField(ptf), + inletOutletFvPatchScalarField(ptf), + intensity_(ptf.intensity_), UName_(ptf.UName_), - intensity_(ptf.intensity_) + phiName_(ptf.phiName_) {} @@ -110,16 +122,16 @@ turbulentIntensityKineticEnergyInletFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchField(ptf, iF), + inletOutletFvPatchScalarField(ptf, iF), + intensity_(ptf.intensity_), UName_(ptf.UName_), - intensity_(ptf.intensity_) + phiName_(ptf.phiName_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void -Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField:: +void Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField:: updateCoeffs() { if (updated()) @@ -127,12 +139,16 @@ updateCoeffs() return; } - const fvPatchField& Up = - lookupPatchField(UName_); + const fvPatchVectorField& Up = + patch().lookupPatchField(UName_); - operator==(1.5*sqr(intensity_)*magSqr(Up)); + const fvsPatchScalarField& phip = + patch().lookupPatchField(phiName_); - fixedValueFvPatchField::updateCoeffs(); + this->refValue() = SMALL + 1.5*sqr(intensity_)*magSqr(Up); + this->valueFraction() = neg(phip); + + inletOutletFvPatchScalarField::updateCoeffs(); } @@ -141,12 +157,10 @@ void Foam::turbulentIntensityKineticEnergyInletFvPatchScalarField::write Ostream& os ) const { - fvPatchField::write(os); - if (UName_ != "U") - { - os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; - } + fvPatchScalarField::write(os); os.writeKeyword("intensity") << intensity_ << token::END_STATEMENT << nl; + os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.H index 5d9be11c4..27f890b66 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentIntensityKineticEnergyInlet/turbulentIntensityKineticEnergyInletFvPatchScalarField.H @@ -30,7 +30,7 @@ Description fraction of the mean velocity Example of the boundary condition specification: - @verbatim + \verbatim inlet { type turbulentIntensityKineticEnergyInlet; @@ -38,7 +38,7 @@ Description intensity 0.05; // 5% turbulence value uniform 1; // placeholder } - @endverbatim + \endverbatim SourceFiles turbulentIntensityKineticEnergyInletFvPatchScalarField.C @@ -48,7 +48,7 @@ SourceFiles #ifndef turbulentIntensityKineticEnergyInletFvPatchScalarField_H #define turbulentIntensityKineticEnergyInletFvPatchScalarField_H -#include "fixedValueFvPatchFields.H" +#include "inletOutletFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,16 +61,19 @@ namespace Foam class turbulentIntensityKineticEnergyInletFvPatchScalarField : - public fixedValueFvPatchScalarField + public inletOutletFvPatchScalarField { // Private data - //- Name of velocity field - word UName_; - //- Turbulent intensity as fraction of mean velocity scalar intensity_; + //- Name of the velocity field + word UName_; + + //- Name of the flux field + word phiName_; + public: diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C index ccf73512a..5ad07b5e4 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C @@ -47,9 +47,15 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchField(p, iF), - mixingLength_(0.001) -{} + inletOutletFvPatchScalarField(p, iF), + mixingLength_(0.0), + phiName_("undefined-phi"), + kName_("undefined-k") +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} turbulentMixingLengthDissipationRateInletFvPatchScalarField:: turbulentMixingLengthDissipationRateInletFvPatchScalarField @@ -60,8 +66,10 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchField(ptf, p, iF, mapper), - mixingLength_(ptf.mixingLength_) + inletOutletFvPatchScalarField(ptf, p, iF, mapper), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) {} turbulentMixingLengthDissipationRateInletFvPatchScalarField:: @@ -72,9 +80,17 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField const dictionary& dict ) : - fixedValueFvPatchField(p, iF, dict), - mixingLength_(readScalar(dict.lookup("mixingLength"))) -{} + inletOutletFvPatchScalarField(p, iF), + mixingLength_(readScalar(dict.lookup("mixingLength"))), + phiName_(dict.lookupOrDefault("phi", "phi")), + kName_(dict.lookupOrDefault("k", "k")) +{ + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} turbulentMixingLengthDissipationRateInletFvPatchScalarField:: turbulentMixingLengthDissipationRateInletFvPatchScalarField @@ -82,8 +98,10 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField const turbulentMixingLengthDissipationRateInletFvPatchScalarField& ptf ) : - fixedValueFvPatchField(ptf), - mixingLength_(ptf.mixingLength_) + inletOutletFvPatchScalarField(ptf), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) {} turbulentMixingLengthDissipationRateInletFvPatchScalarField:: @@ -93,8 +111,10 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchField(ptf, iF), - mixingLength_(ptf.mixingLength_) + inletOutletFvPatchScalarField(ptf, iF), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) {} @@ -115,12 +135,16 @@ void turbulentMixingLengthDissipationRateInletFvPatchScalarField::updateCoeffs() const scalar Cmu75 = pow(Cmu, 0.75); - const fvPatchField& kp = - lookupPatchField("k"); + const fvPatchScalarField& kp = + patch().lookupPatchField(kName_); - operator==(Cmu75*kp*sqrt(kp)/mixingLength_); + const fvsPatchScalarField& phip = + patch().lookupPatchField(phiName_); - fixedValueFvPatchField::updateCoeffs(); + this->refValue() = Cmu75*kp*sqrt(kp)/mixingLength_; + this->valueFraction() = neg(phip); + + inletOutletFvPatchScalarField::updateCoeffs(); } @@ -129,9 +153,11 @@ void turbulentMixingLengthDissipationRateInletFvPatchScalarField::write Ostream& os ) const { - fvPatchField::write(os); + fvPatchScalarField::write(os); os.writeKeyword("mixingLength") << mixingLength_ << token::END_STATEMENT << nl; + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + os.writeKeyword("k") << kName_ << token::END_STATEMENT << nl; writeEntry("value", os); } diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H index 961410247..95291f330 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H @@ -30,14 +30,14 @@ Description Calculate epsilon via the mixing length [m] Example of the boundary condition specification: - @verbatim + \verbatim inlet { type compressible::turbulentMixingLengthDissipationRateInlet; mixingLength 0.005; // 5 mm value uniform 200; // placeholder } - @endverbatim + \endverbatim SourceFiles turbulentMixingLengthDissipationRateInletFvPatchScalarField.C @@ -47,7 +47,7 @@ SourceFiles #ifndef compressibleturbulentMixingLengthDissipationRateInletFvPatchField_H #define compressibleturbulentMixingLengthDissipationRateInletFvPatchField_H -#include "fixedValueFvPatchFields.H" +#include "inletOutletFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -62,13 +62,20 @@ namespace compressible class turbulentMixingLengthDissipationRateInletFvPatchScalarField : - public fixedValueFvPatchScalarField + public inletOutletFvPatchScalarField { // Private data //- turbulent length scale scalar mixingLength_; + //- Name of the flux field + word phiName_; + + //- Name of the turbulent kinetic energy field + word kName_; + + public: //- Runtime type information diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C index 22e10b44b..1750b104b 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C @@ -47,10 +47,15 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchField(p, iF), + inletOutletFvPatchScalarField(p, iF), mixingLength_(0.0), - kName_("k") -{} + phiName_("undefined-phi"), + kName_("undefined-k") +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} turbulentMixingLengthFrequencyInletFvPatchScalarField:: turbulentMixingLengthFrequencyInletFvPatchScalarField @@ -61,8 +66,9 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchField(ptf, p, iF, mapper), + inletOutletFvPatchScalarField(ptf, p, iF, mapper), mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), kName_(ptf.kName_) {} @@ -74,10 +80,17 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField const dictionary& dict ) : - fixedValueFvPatchField(p, iF, dict), + inletOutletFvPatchScalarField(p, iF), mixingLength_(readScalar(dict.lookup("mixingLength"))), + phiName_(dict.lookupOrDefault("phi", "phi")), kName_(dict.lookupOrDefault("k", "k")) -{} +{ + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} turbulentMixingLengthFrequencyInletFvPatchScalarField:: turbulentMixingLengthFrequencyInletFvPatchScalarField @@ -85,8 +98,9 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField const turbulentMixingLengthFrequencyInletFvPatchScalarField& ptf ) : - fixedValueFvPatchField(ptf), + inletOutletFvPatchScalarField(ptf), mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), kName_(ptf.kName_) {} @@ -97,8 +111,9 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchField(ptf, iF), + inletOutletFvPatchScalarField(ptf, iF), mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), kName_(ptf.kName_) {} @@ -120,12 +135,16 @@ void turbulentMixingLengthFrequencyInletFvPatchScalarField::updateCoeffs() const scalar Cmu25 = pow(Cmu, 0.25); - const fvPatchField& kp = - lookupPatchField(kName_); + const fvPatchScalarField& kp = + patch().lookupPatchField(kName_); - operator==(sqrt(kp)/(Cmu25*mixingLength_)); + const fvsPatchScalarField& phip = + patch().lookupPatchField(phiName_); - fixedValueFvPatchField::updateCoeffs(); + this->refValue() = sqrt(kp)/(Cmu25*mixingLength_); + this->valueFraction() = neg(phip); + + inletOutletFvPatchScalarField::updateCoeffs(); } @@ -134,9 +153,10 @@ void turbulentMixingLengthFrequencyInletFvPatchScalarField::write Ostream& os ) const { - fvPatchField::write(os); + fvPatchScalarField::write(os); os.writeKeyword("mixingLength") << mixingLength_ << token::END_STATEMENT << nl; + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; os.writeKeyword("k") << kName_ << token::END_STATEMENT << nl; writeEntry("value", os); } diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H index d981ff5ad..290daa8d9 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H @@ -25,19 +25,52 @@ License Class Foam::compressible::turbulentMixingLengthFrequencyInletFvPatchScalarField +Group + grpIcoRASBoundaryConditions grpInletBoundaryConditions + Description - Calculate omega via the mixing length + This boundary condition provides a turbulence specific dissipation, + \f$\omega\f$ (omega) inlet condition based on a specified mixing length. + The patch values are calculated using: + + \f[ + \omega_p = \frac{k^{0.5}}{C_{\mu}^{0.25} L} + \f] + + where + + \vartable + \omega_p | patch omega values + C_{\mu} | Model coefficient, set to 0.09 + k | turbulence kinetic energy + L | length scale + \endvartable + + \heading Patch usage + + \table + Property | Description | Required | Default value + mixingLength | Length scale [m] | yes | + phi | flux field name | no | phi + k | turbulence kinetic energy field name | no | k + \endtable Example of the boundary condition specification: - @verbatim - inlet - { - type compressible::turbulentMixingLengthFrequencyInlet; - mixingLength 0.005; // 5 mm - k k; // turbulent k field - value uniform 5; // initial value - } - @endverbatim + \verbatim + myPatch + { + type turbulentMixingLengthFrequencyInlet; + mixingLength 0.005; + value uniform 200; // placeholder + } + \endverbatim + +Note + In the event of reverse flow, a zero-gradient condition is applied + +SeeAlso + Foam::inletOutletFvPatchField + SourceFiles turbulentMixingLengthFrequencyInletFvPatchScalarField.C @@ -47,7 +80,7 @@ SourceFiles #ifndef compressibleturbulentMixingLengthFrequencyInletFvPatchScalarField_H #define compressibleturbulentMixingLengthFrequencyInletFvPatchScalarField_H -#include "fixedValueFvPatchFields.H" +#include "inletOutletFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -62,13 +95,16 @@ namespace compressible class turbulentMixingLengthFrequencyInletFvPatchScalarField : - public fixedValueFvPatchScalarField + public inletOutletFvPatchScalarField { // Private data //- Turbulent length scale scalar mixingLength_; + //- Name of the flux field + word phiName_; + //- Name of the turbulent kinetic energy field word kName_; diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C index 81274631f..a6b064601 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C @@ -47,9 +47,15 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchField(p, iF), - mixingLength_(0.001) -{} + inletOutletFvPatchScalarField(p, iF), + mixingLength_(0.0), + phiName_("undefined-phi"), + kName_("undefined-k") +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} turbulentMixingLengthDissipationRateInletFvPatchScalarField:: turbulentMixingLengthDissipationRateInletFvPatchScalarField @@ -60,8 +66,10 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchField(ptf, p, iF, mapper), - mixingLength_(ptf.mixingLength_) + inletOutletFvPatchScalarField(ptf, p, iF, mapper), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) {} turbulentMixingLengthDissipationRateInletFvPatchScalarField:: @@ -72,9 +80,17 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField const dictionary& dict ) : - fixedValueFvPatchField(p, iF, dict), - mixingLength_(readScalar(dict.lookup("mixingLength"))) -{} + inletOutletFvPatchScalarField(p, iF), + mixingLength_(readScalar(dict.lookup("mixingLength"))), + phiName_(dict.lookupOrDefault("phi", "phi")), + kName_(dict.lookupOrDefault("k", "k")) +{ + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} turbulentMixingLengthDissipationRateInletFvPatchScalarField:: turbulentMixingLengthDissipationRateInletFvPatchScalarField @@ -82,8 +98,10 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField const turbulentMixingLengthDissipationRateInletFvPatchScalarField& ptf ) : - fixedValueFvPatchField(ptf), - mixingLength_(ptf.mixingLength_) + inletOutletFvPatchScalarField(ptf), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) {} turbulentMixingLengthDissipationRateInletFvPatchScalarField:: @@ -93,8 +111,10 @@ turbulentMixingLengthDissipationRateInletFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchField(ptf, iF), - mixingLength_(ptf.mixingLength_) + inletOutletFvPatchScalarField(ptf, iF), + mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), + kName_(ptf.kName_) {} @@ -115,12 +135,16 @@ void turbulentMixingLengthDissipationRateInletFvPatchScalarField::updateCoeffs() const scalar Cmu75 = pow(Cmu, 0.75); - const fvPatchField& kp = - lookupPatchField("k"); + const fvPatchScalarField& kp = + patch().lookupPatchField(kName_); - operator==(Cmu75*kp*sqrt(kp)/mixingLength_); + const fvsPatchScalarField& phip = + patch().lookupPatchField(phiName_); - fixedValueFvPatchField::updateCoeffs(); + this->refValue() = Cmu75*kp*sqrt(kp)/mixingLength_; + this->valueFraction() = neg(phip); + + inletOutletFvPatchScalarField::updateCoeffs(); } @@ -129,9 +153,11 @@ void turbulentMixingLengthDissipationRateInletFvPatchScalarField::write Ostream& os ) const { - fvPatchField::write(os); + fvPatchScalarField::write(os); os.writeKeyword("mixingLength") << mixingLength_ << token::END_STATEMENT << nl; + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + os.writeKeyword("k") << kName_ << token::END_STATEMENT << nl; writeEntry("value", os); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H index bcc31e04e..2fe448f9f 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.H @@ -30,14 +30,14 @@ Description Calculate epsilon via the mixing length [m] Example of the boundary condition specification: - @verbatim + \verbatim inlet { type turbulentMixingLengthDissipationRateInlet; mixingLength 0.005; // 5 mm value uniform 200; // placeholder } - @endverbatim + \endverbatim SourceFiles turbulentMixingLengthDissipationRateInletFvPatchScalarField.C @@ -47,7 +47,7 @@ SourceFiles #ifndef incompressibleturbulentMixingLengthDissipationRateInlet_H #define incompressibleturbulentMixingLengthDissipationRateInlet_H -#include "fixedValueFvPatchFields.H" +#include "inletOutletFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -62,13 +62,20 @@ namespace incompressible class turbulentMixingLengthDissipationRateInletFvPatchScalarField : - public fixedValueFvPatchScalarField + public inletOutletFvPatchScalarField { // Private data //- turbulent length scale scalar mixingLength_; + //- Name of the flux field + word phiName_; + + //- Name of the turbulent kinetic energy field + word kName_; + + public: //- Runtime type information diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C index 86413bf52..e686099e0 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C @@ -47,10 +47,15 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchField(p, iF), + inletOutletFvPatchScalarField(p, iF), mixingLength_(0.0), + phiName_("undefined-phi"), kName_("undefined-k") -{} +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} turbulentMixingLengthFrequencyInletFvPatchScalarField:: turbulentMixingLengthFrequencyInletFvPatchScalarField @@ -61,8 +66,9 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchField(ptf, p, iF, mapper), + inletOutletFvPatchScalarField(ptf, p, iF, mapper), mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), kName_(ptf.kName_) {} @@ -74,10 +80,17 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField const dictionary& dict ) : - fixedValueFvPatchField(p, iF, dict), + inletOutletFvPatchScalarField(p, iF), mixingLength_(readScalar(dict.lookup("mixingLength"))), + phiName_(dict.lookupOrDefault("phi", "phi")), kName_(dict.lookupOrDefault("k", "k")) -{} +{ + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 0.0; +} turbulentMixingLengthFrequencyInletFvPatchScalarField:: turbulentMixingLengthFrequencyInletFvPatchScalarField @@ -85,8 +98,9 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField const turbulentMixingLengthFrequencyInletFvPatchScalarField& ptf ) : - fixedValueFvPatchField(ptf), + inletOutletFvPatchScalarField(ptf), mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), kName_(ptf.kName_) {} @@ -97,8 +111,9 @@ turbulentMixingLengthFrequencyInletFvPatchScalarField const DimensionedField& iF ) : - fixedValueFvPatchField(ptf, iF), + inletOutletFvPatchScalarField(ptf, iF), mixingLength_(ptf.mixingLength_), + phiName_(ptf.phiName_), kName_(ptf.kName_) {} @@ -120,12 +135,16 @@ void turbulentMixingLengthFrequencyInletFvPatchScalarField::updateCoeffs() const scalar Cmu25 = pow(Cmu, 0.25); - const fvPatchField& kp = - lookupPatchField(kName_); + const fvPatchScalarField& kp = + patch().lookupPatchField(kName_); - operator==(sqrt(kp)/(Cmu25*mixingLength_)); + const fvsPatchScalarField& phip = + patch().lookupPatchField(phiName_); - fixedValueFvPatchField::updateCoeffs(); + this->refValue() = sqrt(kp)/(Cmu25*mixingLength_); + this->valueFraction() = neg(phip); + + inletOutletFvPatchScalarField::updateCoeffs(); } @@ -134,9 +153,10 @@ void turbulentMixingLengthFrequencyInletFvPatchScalarField::write Ostream& os ) const { - fvPatchField::write(os); + fvPatchScalarField::write(os); os.writeKeyword("mixingLength") << mixingLength_ << token::END_STATEMENT << nl; + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; os.writeKeyword("k") << kName_ << token::END_STATEMENT << nl; writeEntry("value", os); } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H index 50aa9d909..f568ddb99 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.H @@ -25,19 +25,52 @@ License Class Foam::incompressible::turbulentMixingLengthFrequencyInletFvPatchScalarField +Group + grpIcoRASBoundaryConditions grpInletBoundaryConditions + Description - Calculate omega via the mixing length + This boundary condition provides a turbulence specific dissipation, + \f$\omega\f$ (omega) inlet condition based on a specified mixing length. + The patch values are calculated using: + + \f[ + \omega_p = \frac{k^{0.5}}{C_{\mu}^{0.25} L} + \f] + + where + + \vartable + \omega_p | patch omega values + C_{\mu} | Model coefficient, set to 0.09 + k | turbulence kinetic energy + L | length scale + \endvartable + + \heading Patch usage + + \table + Property | Description | Required | Default value + mixingLength | Length scale [m] | yes | + phi | flux field name | no | phi + k | turbulence kinetic energy field name | no | k + \endtable Example of the boundary condition specification: - @verbatim - inlet - { - type turbulentMixingLengthFrequencyInlet; - mixingLength 0.005; // 5 mm - k k; // turbulent k field - value uniform 5; // initial value - } - @endverbatim + \verbatim + myPatch + { + type turbulentMixingLengthFrequencyInlet; + mixingLength 0.005; + value uniform 200; // placeholder + } + \endverbatim + +Note + In the event of reverse flow, a zero-gradient condition is applied + +SeeAlso + Foam::inletOutletFvPatchField + SourceFiles turbulentMixingLengthFrequencyInletFvPatchScalarField.C @@ -47,7 +80,7 @@ SourceFiles #ifndef incompressibleturbulentMixingLengthFrequencyInletFvPatchScalarField_H #define incompressibleturbulentMixingLengthFrequencyInletFvPatchScalarField_H -#include "fixedValueFvPatchFields.H" +#include "inletOutletFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -62,13 +95,16 @@ namespace incompressible class turbulentMixingLengthFrequencyInletFvPatchScalarField : - public fixedValueFvPatchScalarField + public inletOutletFvPatchScalarField { // Private data //- Turbulent length scale scalar mixingLength_; + //- Name of the flux field + word phiName_; + //- Name of the turbulent kinetic energy field word kName_;