porousBafflePressure: Corrected and added support for compressible flow

This commit is contained in:
Henry 2015-02-02 12:23:31 +00:00
parent a79b912a31
commit 5eafa16bc6
2 changed files with 54 additions and 24 deletions

View file

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,27 +37,14 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
) )
: :
fixedJumpFvPatchField<scalar>(p, iF), fixedJumpFvPatchField<scalar>(p, iF),
phiName_("phi"),
rhoName_("rho"),
D_(0), D_(0),
I_(0), I_(0),
length_(0) length_(0)
{} {}
Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
(
const porousBafflePressureFvPatchField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedJumpFvPatchField<scalar>(ptf, p, iF, mapper),
D_(ptf.D_),
I_(ptf.I_),
length_(ptf.length_)
{}
Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
( (
const fvPatch& p, const fvPatch& p,
@ -66,6 +53,8 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
) )
: :
fixedJumpFvPatchField<scalar>(p, iF), fixedJumpFvPatchField<scalar>(p, iF),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
D_(readScalar(dict.lookup("D"))), D_(readScalar(dict.lookup("D"))),
I_(readScalar(dict.lookup("I"))), I_(readScalar(dict.lookup("I"))),
length_(readScalar(dict.lookup("length"))) length_(readScalar(dict.lookup("length")))
@ -77,6 +66,23 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
} }
Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
(
const porousBafflePressureFvPatchField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedJumpFvPatchField<scalar>(ptf, p, iF, mapper),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
D_(ptf.D_),
I_(ptf.I_),
length_(ptf.length_)
{}
Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
( (
const porousBafflePressureFvPatchField& ptf const porousBafflePressureFvPatchField& ptf
@ -84,6 +90,8 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
: :
cyclicLduInterfaceField(), cyclicLduInterfaceField(),
fixedJumpFvPatchField<scalar>(ptf), fixedJumpFvPatchField<scalar>(ptf),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
D_(ptf.D_), D_(ptf.D_),
I_(ptf.I_), I_(ptf.I_),
length_(ptf.length_) length_(ptf.length_)
@ -97,6 +105,8 @@ Foam::porousBafflePressureFvPatchField::porousBafflePressureFvPatchField
) )
: :
fixedJumpFvPatchField<scalar>(ptf, iF), fixedJumpFvPatchField<scalar>(ptf, iF),
phiName_(ptf.phiName_),
rhoName_(ptf.rhoName_),
D_(ptf.D_), D_(ptf.D_),
I_(ptf.I_), I_(ptf.I_),
length_(ptf.length_) length_(ptf.length_)
@ -113,13 +123,18 @@ void Foam::porousBafflePressureFvPatchField::updateCoeffs()
} }
const surfaceScalarField& phi = const surfaceScalarField& phi =
db().lookupObject<surfaceScalarField>("phi"); db().lookupObject<surfaceScalarField>(phiName_);
const fvsPatchField<scalar>& phip = const fvsPatchField<scalar>& phip =
patch().patchField<surfaceScalarField, scalar>(phi); patch().patchField<surfaceScalarField, scalar>(phi);
scalarField Un(phip/patch().magSf()); scalarField Un(phip/patch().magSf());
if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0))
{
Un /= patch().lookupPatchField<volScalarField, scalar>(rhoName_);
}
scalarField magUn(mag(Un)); scalarField magUn(mag(Un));
const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
@ -134,10 +149,15 @@ void Foam::porousBafflePressureFvPatchField::updateCoeffs()
jump_ = jump_ =
-sign(Un) -sign(Un)
*( *(
I_*turbModel.nuEff(patch().index()) D_*turbModel.nu(patch().index())
+ D_*0.5*magUn + I_*0.5*magUn
)*magUn*length_; )*magUn*length_;
if (dimensionedInternalField().dimensions() == dimPressure)
{
jump_ *= patch().lookupPatchField<volScalarField, scalar>(rhoName_);
}
if (debug) if (debug)
{ {
scalar avePressureJump = gAverage(jump_); scalar avePressureJump = gAverage(jump_);
@ -157,6 +177,8 @@ void Foam::porousBafflePressureFvPatchField::updateCoeffs()
void Foam::porousBafflePressureFvPatchField::write(Ostream& os) const void Foam::porousBafflePressureFvPatchField::write(Ostream& os) const
{ {
fixedJumpFvPatchField<scalar>::write(os); fixedJumpFvPatchField<scalar>::write(os);
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
os.writeKeyword("D") << D_ << token::END_STATEMENT << nl; os.writeKeyword("D") << D_ << token::END_STATEMENT << nl;
os.writeKeyword("I") << I_ << token::END_STATEMENT << nl; os.writeKeyword("I") << I_ << token::END_STATEMENT << nl;
os.writeKeyword("length") << length_ << token::END_STATEMENT << nl; os.writeKeyword("length") << length_ << token::END_STATEMENT << nl;

View file

@ -25,7 +25,7 @@ Class
Foam::porousBafflePressureFvPatchField Foam::porousBafflePressureFvPatchField
Group Group
grpCoupledBoundaryConditions grpTurbulenceBoundaryConditions grpCoupledBoundaryConditions
Description Description
This boundary condition provides a jump condition, using the \c cyclic 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: The porous baffle introduces a pressure jump defined by:
\f[ \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] \f]
where where
@ -42,7 +42,7 @@ Description
\vartable \vartable
p | pressure [Pa] p | pressure [Pa]
\rho | density [kg/m3] \rho | density [kg/m3]
\mu | viscosity [Pa s] \mu | laminar viscosity [Pa s]
I | inertial coefficient I | inertial coefficient
D | Darcy coefficient D | Darcy coefficient
L | porous media length in the flow direction L | porous media length in the flow direction
@ -54,6 +54,8 @@ Description
\table \table
Property | Description | Required | Default value Property | Description | Required | Default value
patchType | underlying patch type should be \c cyclic| yes | 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 | D | Darcy coefficient | yes |
I | inertial coefficient | yes | I | inertial coefficient | yes |
L | porous media length in the flow direction | yes | L | porous media length in the flow direction | yes |
@ -66,8 +68,8 @@ Description
type porousBafflePressure; type porousBafflePressure;
patchType cyclic; patchType cyclic;
jump uniform 0; jump uniform 0;
D 1000000; D 0.001;
I 0.001; I 1000000;
L 0.1; L 0.1;
value uniform 0; value uniform 0;
} }
@ -101,6 +103,12 @@ class porousBafflePressureFvPatchField
{ {
// Private data // Private data
//- Name of flux field (default = phi)
const word phiName_;
//- Name of density field (default = rho)
const word rhoName_;
//- Darcy pressure loss coefficient //- Darcy pressure loss coefficient
scalar D_; scalar D_;