From 33d24875f742f73334f8eeee2d63c204585cd843 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 22 Aug 2012 09:58:18 +0100 Subject: [PATCH 1/3] ENH: LES turbulence - named k and epsilon fields returned by utililty functions --- .../LES/GenEddyVisc/GenEddyVisc.H | 20 ++++++++-- .../LES/GenSGSStress/GenSGSStress.H | 37 +++++++++++++++++-- .../LES/GenEddyVisc/GenEddyVisc.H | 18 ++++++++- .../LES/GenSGSStress/GenSGSStress.H | 35 ++++++++++++++++-- 4 files changed, 98 insertions(+), 12 deletions(-) diff --git a/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H index f11a06da9b..fb7558eec6 100644 --- a/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.H +++ b/src/turbulenceModels/compressible/LES/GenEddyVisc/GenEddyVisc.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 @@ -51,7 +51,7 @@ namespace LESModels { /*---------------------------------------------------------------------------*\ - Class GenEddyVisc Declaration + Class GenEddyVisc Declaration \*---------------------------------------------------------------------------*/ class GenEddyVisc @@ -108,7 +108,21 @@ public: //- Return sub-grid disipation rate virtual tmp epsilon() const { - return ce_*k()*sqrt(k())/delta(); + return tmp + ( + new volScalarField + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ce_*k()*sqrt(k())/delta() + ) + ); } //- Return viscosity diff --git a/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H index 20309c3203..ce0da3763f 100644 --- a/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.H +++ b/src/turbulenceModels/compressible/LES/GenSGSStress/GenSGSStress.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 @@ -52,7 +52,7 @@ namespace LESModels { /*---------------------------------------------------------------------------*\ - Class GenSGSStress Declaration + Class GenSGSStress Declaration \*---------------------------------------------------------------------------*/ class GenSGSStress @@ -109,14 +109,43 @@ public: //- Return the SGS turbulent kinetic energy virtual tmp k() const { - return 0.5*tr(B_); + return tmp + ( + new volScalarField + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + 0.5*tr(B_) + ) + ); } //- Return the SGS turbulent dissipation virtual tmp epsilon() const { const volScalarField K(k()); - return ce_*K*sqrt(K)/delta(); + + return tmp + ( + new volScalarField + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ce_*K*sqrt(K)/delta() + ) + ); } //- Return the SGS viscosity diff --git a/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.H b/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.H index 62c216ee3e..c40adc383b 100644 --- a/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.H +++ b/src/turbulenceModels/incompressible/LES/GenEddyVisc/GenEddyVisc.H @@ -51,7 +51,7 @@ namespace LESModels { /*---------------------------------------------------------------------------*\ - Class GenEddyVisc Declaration + Class GenEddyVisc Declaration \*---------------------------------------------------------------------------*/ class GenEddyVisc @@ -104,7 +104,21 @@ public: //- Return sub-grid disipation rate virtual tmp epsilon() const { - return ce_*k()*sqrt(k())/delta(); + return tmp + ( + new volScalarField + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ce_*k()*sqrt(k())/delta() + ) + ); } //- Return the SGS viscosity. diff --git a/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.H b/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.H index 0456d69a71..f7b6040f37 100644 --- a/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.H +++ b/src/turbulenceModels/incompressible/LES/GenSGSStress/GenSGSStress.H @@ -52,7 +52,7 @@ namespace LESModels { /*---------------------------------------------------------------------------*\ - Class GenSGSStress Declaration + Class GenSGSStress Declaration \*---------------------------------------------------------------------------*/ class GenSGSStress @@ -104,14 +104,43 @@ public: //- Return the SGS turbulent kinetic energy. virtual tmp k() const { - return 0.5*tr(B_); + return tmp + ( + new volScalarField + ( + IOobject + ( + "k", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + 0.5*tr(B_) + ) + ); } //- Return the SGS turbulent dissipation. virtual tmp epsilon() const { const volScalarField K(k()); - return ce_*K*sqrt(K)/delta(); + + return tmp + ( + new volScalarField + ( + IOobject + ( + "epsilon", + runTime_.timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + ce_*K*sqrt(K)/delta() + ) + ); } //- Return the SGS viscosity. From 37fbafd411f3c047c1ea371ba4f88456ec2fd549 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 22 Aug 2012 12:30:17 +0100 Subject: [PATCH 2/3] ENH: Replaced hard-coded TMax by constantProperties TMax --- .../ReactingMultiphaseParcel/ReactingMultiphaseParcel.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C index 84942b0349..461ec5b285 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C @@ -636,7 +636,7 @@ void Foam::ReactingMultiphaseParcel::calcSurfaceReactions *(sum(dMassSRGas) + sum(dMassSRLiquid) + sum(dMassSRSolid)) ); - const scalar xsi = min(T/5000.0, 1.0); + const scalar xsi = min(T/td.cloud().constProps().TMax(), 1.0); const scalar coeff = (1.0 - xsi*xsi)*td.cloud().constProps().hRetentionCoeff(); From a4ac852e9c43bcbb4fa6cb29433e0d9cb1c9f5a7 Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 17 Sep 2012 12:00:23 +0100 Subject: [PATCH 3/3] ENH: Refactored uniformTotalPressure BC so that P0_ is not required --- .../uniformTotalPressureFvPatchScalarField.C | 21 +++++++------------ .../uniformTotalPressureFvPatchScalarField.H | 17 +-------------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C index e9bd327072..c3b35384cd 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C @@ -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 @@ -44,7 +44,6 @@ uniformTotalPressureFvPatchScalarField rhoName_("none"), psiName_("none"), gamma_(0.0), - p0_(0.0), pressure_() {} @@ -63,7 +62,6 @@ uniformTotalPressureFvPatchScalarField rhoName_(dict.lookupOrDefault("rho", "none")), psiName_(dict.lookupOrDefault("psi", "none")), gamma_(readScalar(dict.lookup("gamma"))), - p0_(readScalar(dict.lookup("p0"))), pressure_(DataEntry::New("pressure", dict)) { if (dict.found("value")) @@ -75,7 +73,8 @@ uniformTotalPressureFvPatchScalarField } else { - fvPatchField::operator=(p0_); + scalar p0 = pressure_->value(this->db().time().timeOutputValue()); + fvPatchField::operator=(p0); } } @@ -95,7 +94,6 @@ uniformTotalPressureFvPatchScalarField rhoName_(ptf.rhoName_), psiName_(ptf.psiName_), gamma_(ptf.gamma_), - p0_(ptf.p0_), pressure_(ptf.pressure_().clone().ptr()) {} @@ -112,7 +110,6 @@ uniformTotalPressureFvPatchScalarField rhoName_(tppsf.rhoName_), psiName_(tppsf.psiName_), gamma_(tppsf.gamma_), - p0_(tppsf.p0_), pressure_(tppsf.pressure_().clone().ptr()) {} @@ -130,7 +127,6 @@ uniformTotalPressureFvPatchScalarField rhoName_(tppsf.rhoName_), psiName_(tppsf.psiName_), gamma_(tppsf.gamma_), - p0_(tppsf.p0_), pressure_(tppsf.pressure_().clone().ptr()) {} @@ -147,14 +143,14 @@ void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs return; } - p0_ = pressure_->value(this->db().time().timeOutputValue()); + scalar p0 = pressure_->value(this->db().time().timeOutputValue()); const fvsPatchField& phip = patch().lookupPatchField(phiName_); if (psiName_ == "none" && rhoName_ == "none") { - operator==(p0_ - 0.5*(1.0 - pos(phip))*magSqr(Up)); + operator==(p0 - 0.5*(1.0 - pos(phip))*magSqr(Up)); } else if (rhoName_ == "none") { @@ -167,7 +163,7 @@ void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs operator== ( - p0_ + p0 /pow ( (1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up)), @@ -177,7 +173,7 @@ void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs } else { - operator==(p0_/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up))); + operator==(p0/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up))); } } else if (psiName_ == "none") @@ -185,7 +181,7 @@ void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs const fvPatchField& rho = patch().lookupPatchField(rhoName_); - operator==(p0_ - 0.5*rho*(1.0 - pos(phip))*magSqr(Up)); + operator==(p0 - 0.5*rho*(1.0 - pos(phip))*magSqr(Up)); } else { @@ -219,7 +215,6 @@ void Foam::uniformTotalPressureFvPatchScalarField::write(Ostream& os) const os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; - os.writeKeyword("p0") << p0_ << token::END_STATEMENT << nl; pressure_->writeData(os); writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.H index aa77ffe2ca..325ed6e471 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.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 @@ -75,9 +75,6 @@ class uniformTotalPressureFvPatchScalarField //- Heat capacity ratio scalar gamma_; - //- Total pressure - scalar p0_; - //- Table of time vs total pressure, including the bounding treatment autoPtr > pressure_; @@ -178,18 +175,6 @@ public: return gamma_; } - //- Return the total pressure - scalar p0() const - { - return p0_; - } - - //- Return reference to the total pressure to allow adjustment - scalar p0() - { - return p0_; - } - // Evaluation functions