From 5eafa16bc60294cba03e0a37ed9a2f62d057ee2a Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 2 Feb 2015 12:23:31 +0000 Subject: [PATCH] porousBafflePressure: Corrected and added support for compressible flow --- .../porousBafflePressureFvPatchField.C | 60 +++++++++++++------ .../porousBafflePressureFvPatchField.H | 18 ++++-- 2 files changed, 54 insertions(+), 24 deletions(-) diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C index c3e93912f..5abd82f3e 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,27 +37,14 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField ) : fixedJumpFvPatchField(p, iF), + phiName_("phi"), + rhoName_("rho"), D_(0), I_(0), length_(0) {} -Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField -( - const porousBafflePressureFvPatchField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedJumpFvPatchField(ptf, p, iF, mapper), - D_(ptf.D_), - I_(ptf.I_), - length_(ptf.length_) -{} - - Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField ( const fvPatch& p, @@ -66,6 +53,8 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField ) : fixedJumpFvPatchField(p, iF), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")), D_(readScalar(dict.lookup("D"))), I_(readScalar(dict.lookup("I"))), length_(readScalar(dict.lookup("length"))) @@ -77,6 +66,23 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField } +Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField +( + const porousBafflePressureFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedJumpFvPatchField(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), + D_(ptf.D_), + I_(ptf.I_), + length_(ptf.length_) +{} + + Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField ( const porousBafflePressureFvPatchField& ptf @@ -84,6 +90,8 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField : cyclicLduInterfaceField(), fixedJumpFvPatchField(ptf), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), D_(ptf.D_), I_(ptf.I_), length_(ptf.length_) @@ -97,6 +105,8 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField ) : fixedJumpFvPatchField(ptf, iF), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), D_(ptf.D_), I_(ptf.I_), length_(ptf.length_) @@ -113,13 +123,18 @@ void Foam::porousBafflePressureFvPatchField::updateCoeffs() } const surfaceScalarField& phi = - db().lookupObject("phi"); + db().lookupObject(phiName_); const fvsPatchField& phip = patch().patchField(phi); scalarField Un(phip/patch().magSf()); + if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0)) + { + Un /= patch().lookupPatchField(rhoName_); + } + scalarField magUn(mag(Un)); const turbulenceModel& turbModel = db().lookupObject @@ -134,10 +149,15 @@ void Foam::porousBafflePressureFvPatchField::updateCoeffs() jump_ = -sign(Un) *( - I_*turbModel.nuEff(patch().index()) - + D_*0.5*magUn + D_*turbModel.nu(patch().index()) + + I_*0.5*magUn )*magUn*length_; + if (dimensionedInternalField().dimensions() == dimPressure) + { + jump_ *= patch().lookupPatchField(rhoName_); + } + if (debug) { scalar avePressureJump = gAverage(jump_); @@ -157,6 +177,8 @@ void Foam::porousBafflePressureFvPatchField::updateCoeffs() void Foam::porousBafflePressureFvPatchField::write(Ostream& os) const { fixedJumpFvPatchField::write(os); + writeEntryIfDifferent(os, "phi", "phi", phiName_); + writeEntryIfDifferent(os, "rho", "rho", rhoName_); os.writeKeyword("D") << D_ << token::END_STATEMENT << nl; os.writeKeyword("I") << I_ << token::END_STATEMENT << nl; os.writeKeyword("length") << length_ << token::END_STATEMENT << nl; diff --git a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H index 09758c9ab..496ba8154 100644 --- a/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H +++ b/src/TurbulenceModels/turbulenceModels/derivedFvPatchFields/porousBafflePressure/porousBafflePressureFvPatchField.H @@ -25,7 +25,7 @@ Class Foam::porousBafflePressureFvPatchField Group - grpCoupledBoundaryConditions grpTurbulenceBoundaryConditions + grpCoupledBoundaryConditions Description This boundary condition provides a jump condition, using the \c cyclic @@ -34,7 +34,7 @@ Description The porous baffle introduces a pressure jump defined by: \f[ - \Delta p = -(I \mu U + 0.5 D \rho |U|^2 )L + \Delta p = -(D \mu U + 0.5 I \rho |U|^2 )L \f] where @@ -42,7 +42,7 @@ Description \vartable p | pressure [Pa] \rho | density [kg/m3] - \mu | viscosity [Pa s] + \mu | laminar viscosity [Pa s] I | inertial coefficient D | Darcy coefficient L | porous media length in the flow direction @@ -54,6 +54,8 @@ Description \table Property | Description | Required | Default value patchType | underlying patch type should be \c cyclic| yes | + phi | flux field name | no | phi + rho | density field name | no | rho D | Darcy coefficient | yes | I | inertial coefficient | yes | L | porous media length in the flow direction | yes | @@ -66,8 +68,8 @@ Description type porousBafflePressure; patchType cyclic; jump uniform 0; - D 1000000; - I 0.001; + D 0.001; + I 1000000; L 0.1; value uniform 0; } @@ -101,6 +103,12 @@ class porousBafflePressureFvPatchField { // Private data + //- Name of flux field (default = phi) + const word phiName_; + + //- Name of density field (default = rho) + const word rhoName_; + //- Darcy pressure loss coefficient scalar D_;