totalPressureFvPatchScalarField, uniformTotalPressureFvPatchScalarField: simplified and rationalized

The modes of operation are set by the dimensions of the pressure field
    to which this boundary condition is applied, the \c psi entry and the value
    of \c gamma:
    \table
        Mode                    | dimensions | psi   | gamma
        incompressible subsonic | p/rho      |       |
        compressible subsonic   | p          | none  |
        compressible transonic  | p          | psi   | 1
        compressible supersonic | p          | psi   | > 1
    \endtable

    For most applications the totalPressure boundary condition now only
    requires p0 to be specified e.g.
    outlet
    {
        type            totalPressure;
        p0              uniform 1e5;
    }
This commit is contained in:
Henry Weller
2016-06-16 12:21:34 +01:00
parent 5a17dc9503
commit 07ae9b67cc
33 changed files with 129 additions and 241 deletions

View File

@ -41,7 +41,7 @@ Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField
fixedValueFvPatchScalarField(p, iF), fixedValueFvPatchScalarField(p, iF),
UName_("U"), UName_("U"),
phiName_("phi"), phiName_("phi"),
rhoName_("none"), rhoName_("rho"),
psiName_("none"), psiName_("none"),
gamma_(0.0), gamma_(0.0),
p0_(p.size(), 0.0) p0_(p.size(), 0.0)
@ -58,9 +58,9 @@ Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField
fixedValueFvPatchScalarField(p, iF), fixedValueFvPatchScalarField(p, iF),
UName_(dict.lookupOrDefault<word>("U", "U")), UName_(dict.lookupOrDefault<word>("U", "U")),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "none")), rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
psiName_(dict.lookupOrDefault<word>("psi", "none")), psiName_(dict.lookupOrDefault<word>("psi", "none")),
gamma_(readScalar(dict.lookup("gamma"))), gamma_(psiName_ != "none" ? readScalar(dict.lookup("gamma")) : 1),
p0_("p0", dict, p.size()) p0_("p0", dict, p.size())
{ {
if (dict.found("value")) if (dict.found("value"))
@ -167,18 +167,27 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs
const fvsPatchField<scalar>& phip = const fvsPatchField<scalar>& phip =
patch().lookupPatchField<surfaceScalarField, scalar>(phiName_); patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
if (psiName_ == "none" && rhoName_ == "none") if (internalField().dimensions() == dimPressure)
{ {
operator==(p0p - 0.5*(1.0 - pos(phip))*magSqr(Up)); if (psiName_ == "none")
{
// Variable density and low-speed compressible flow
const fvPatchField<scalar>& rho =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
operator==(p0p - 0.5*rho*(1.0 - pos(phip))*magSqr(Up));
} }
else if (rhoName_ == "none") else
{ {
// High-speed compressible flow
const fvPatchField<scalar>& psip = const fvPatchField<scalar>& psip =
patch().lookupPatchField<volScalarField, scalar>(psiName_); patch().lookupPatchField<volScalarField, scalar>(psiName_);
if (gamma_ > 1.0) if (gamma_ > 1)
{ {
scalar gM1ByG = (gamma_ - 1.0)/gamma_; scalar gM1ByG = (gamma_ - 1)/gamma_;
operator== operator==
( (
@ -195,21 +204,22 @@ void Foam::totalPressureFvPatchScalarField::updateCoeffs
operator==(p0p/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up))); operator==(p0p/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up)));
} }
} }
else if (psiName_ == "none")
{
const fvPatchField<scalar>& rho =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
operator==(p0p - 0.5*rho*(1.0 - pos(phip))*magSqr(Up)); }
else if (internalField().dimensions() == dimPressure/dimDensity)
{
// Incompressible flow
operator==(p0p - 0.5*(1.0 - pos(phip))*magSqr(Up));
} }
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< " rho or psi set inconsistently, rho = " << rhoName_ << " Incorrect pressure dimensions " << internalField().dimensions()
<< ", psi = " << psiName_ << ".\n" << nl
<< " Set either rho or psi or neither depending on the " << " Should be " << dimPressure
"definition of total pressure." << nl << " for compressible/variable density flow" << nl
<< " Set the unused variable(s) to 'none'.\n" << " or " << dimPressure/dimDensity
<< " for incompressible flow," << nl
<< " on patch " << this->patch().name() << " on patch " << this->patch().name()
<< " of field " << this->internalField().name() << " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath() << " in file " << this->internalField().objectPath()

View File

@ -54,7 +54,7 @@ Description
U | velocity U | velocity
\endvartable \endvartable
3. compressible transonic (\f$\gamma <= 1\f$): 3. compressible transonic (\f$\gamma = 1\f$):
\f[ \f[
p_p = \frac{p_0}{1 + 0.5 \psi |U|^2} p_p = \frac{p_0}{1 + 0.5 \psi |U|^2}
\f] \f]
@ -78,14 +78,15 @@ Description
G | coefficient given by \f$\frac{\gamma}{1-\gamma}\f$ G | coefficient given by \f$\frac{\gamma}{1-\gamma}\f$
\endvartable \endvartable
The modes of operation are set via the combination of \c phi, \c rho, and The modes of operation are set by the dimensions of the pressure field
\c psi entries: to which this boundary condition is applied, the \c psi entry and the value
of \c gamma:
\table \table
Mode | phi | rho | psi Mode | dimensions | psi | gamma
incompressible subsonic | phi | none | none incompressible subsonic | p/rho | |
compressible subsonic | phi | rho | none compressible subsonic | p | none |
compressible transonic | phi | none | psi compressible transonic | p | psi | 1
compressible supersonic | phi | none | psi compressible supersonic | p | psi | > 1
\endtable \endtable
@ -93,12 +94,12 @@ Description
\table \table
Property | Description | Required | Default value Property | Description | Required | Default value
U | velocity field name | no | U U | Velocity field name | no | U
phi | flux field name | no | phi phi | Flux field name | no | phi
rho | density field name | no | none rho | Density field name | no | rho
psi | compressibility field name | no | none psi | Compressibility field name | no | none
gamma | ratio of specific heats (Cp/Cv) | yes | gamma | (Cp/Cv) | no | 1
p0 | total pressure | yes | p0 | Total pressure | yes |
\endtable \endtable
Example of the boundary condition specification: Example of the boundary condition specification:
@ -106,18 +107,10 @@ Description
myPatch myPatch
{ {
type totalPressure; type totalPressure;
U U;
phi phi;
rho none;
psi none;
gamma 1.4;
p0 uniform 1e5; p0 uniform 1e5;
} }
\endverbatim \endverbatim
Note
The default boundary behaviour is for subsonic, incompressible flow.
SeeAlso SeeAlso
Foam::fixedValueFvPatchField Foam::fixedValueFvPatchField

View File

@ -41,10 +41,10 @@ uniformTotalPressureFvPatchScalarField
fixedValueFvPatchScalarField(p, iF), fixedValueFvPatchScalarField(p, iF),
UName_("U"), UName_("U"),
phiName_("phi"), phiName_("phi"),
rhoName_("none"), rhoName_("rho"),
psiName_("none"), psiName_("none"),
gamma_(0.0), gamma_(0.0),
pressure_() p0_()
{} {}
@ -59,10 +59,10 @@ uniformTotalPressureFvPatchScalarField
fixedValueFvPatchScalarField(p, iF), fixedValueFvPatchScalarField(p, iF),
UName_(dict.lookupOrDefault<word>("U", "U")), UName_(dict.lookupOrDefault<word>("U", "U")),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi")),
rhoName_(dict.lookupOrDefault<word>("rho", "none")), rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
psiName_(dict.lookupOrDefault<word>("psi", "none")), psiName_(dict.lookupOrDefault<word>("psi", "none")),
gamma_(readScalar(dict.lookup("gamma"))), gamma_(psiName_ != "none" ? readScalar(dict.lookup("gamma")) : 1),
pressure_(Function1<scalar>::New("pressure", dict)) p0_(Function1<scalar>::New("p0", dict))
{ {
if (dict.found("value")) if (dict.found("value"))
{ {
@ -74,7 +74,7 @@ uniformTotalPressureFvPatchScalarField
else else
{ {
const scalar t = this->db().time().timeOutputValue(); const scalar t = this->db().time().timeOutputValue();
fvPatchScalarField::operator==(pressure_->value(t)); fvPatchScalarField::operator==(p0_->value(t));
} }
} }
@ -94,14 +94,14 @@ uniformTotalPressureFvPatchScalarField
rhoName_(ptf.rhoName_), rhoName_(ptf.rhoName_),
psiName_(ptf.psiName_), psiName_(ptf.psiName_),
gamma_(ptf.gamma_), gamma_(ptf.gamma_),
pressure_(ptf.pressure_, false) p0_(ptf.p0_, false)
{ {
patchType() = ptf.patchType(); patchType() = ptf.patchType();
// Set the patch pressure to the current total pressure // Set the patch pressure to the current total pressure
// This is not ideal but avoids problems with the creation of patch faces // This is not ideal but avoids problems with the creation of patch faces
const scalar t = this->db().time().timeOutputValue(); const scalar t = this->db().time().timeOutputValue();
fvPatchScalarField::operator==(pressure_->value(t)); fvPatchScalarField::operator==(p0_->value(t));
} }
@ -117,7 +117,7 @@ uniformTotalPressureFvPatchScalarField
rhoName_(ptf.rhoName_), rhoName_(ptf.rhoName_),
psiName_(ptf.psiName_), psiName_(ptf.psiName_),
gamma_(ptf.gamma_), gamma_(ptf.gamma_),
pressure_(ptf.pressure_, false) p0_(ptf.p0_, false)
{} {}
@ -134,7 +134,7 @@ uniformTotalPressureFvPatchScalarField
rhoName_(ptf.rhoName_), rhoName_(ptf.rhoName_),
psiName_(ptf.psiName_), psiName_(ptf.psiName_),
gamma_(ptf.gamma_), gamma_(ptf.gamma_),
pressure_(ptf.pressure_, false) p0_(ptf.p0_, false)
{} {}
@ -150,23 +150,32 @@ void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs
return; return;
} }
scalar p0 = pressure_->value(this->db().time().timeOutputValue()); scalar p0 = p0_->value(this->db().time().timeOutputValue());
const fvsPatchField<scalar>& phip = const fvsPatchField<scalar>& phip =
patch().lookupPatchField<surfaceScalarField, scalar>(phiName_); patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
if (psiName_ == "none" && rhoName_ == "none") if (internalField().dimensions() == dimPressure)
{ {
operator==(p0 - 0.5*(1.0 - pos(phip))*magSqr(Up)); if (psiName_ == "none")
{
// Variable density and low-speed compressible flow
const fvPatchField<scalar>& rho =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
operator==(p0 - 0.5*rho*(1.0 - pos(phip))*magSqr(Up));
} }
else if (rhoName_ == "none") else
{ {
// High-speed compressible flow
const fvPatchField<scalar>& psip = const fvPatchField<scalar>& psip =
patch().lookupPatchField<volScalarField, scalar>(psiName_); patch().lookupPatchField<volScalarField, scalar>(psiName_);
if (gamma_ > 1.0) if (gamma_ > 1)
{ {
scalar gM1ByG = (gamma_ - 1.0)/gamma_; scalar gM1ByG = (gamma_ - 1)/gamma_;
operator== operator==
( (
@ -183,21 +192,22 @@ void Foam::uniformTotalPressureFvPatchScalarField::updateCoeffs
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")
{
const fvPatchField<scalar>& rho =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
operator==(p0 - 0.5*rho*(1.0 - pos(phip))*magSqr(Up)); }
else if (internalField().dimensions() == dimPressure/dimDensity)
{
// Incompressible flow
operator==(p0 - 0.5*(1.0 - pos(phip))*magSqr(Up));
} }
else else
{ {
FatalErrorInFunction FatalErrorInFunction
<< " rho or psi set inconsitently, rho = " << rhoName_ << " Incorrect pressure dimensions " << internalField().dimensions()
<< ", psi = " << psiName_ << ".\n" << nl
<< " Set either rho or psi or neither depending on the " << " Should be " << dimPressure
"definition of total pressure.\n" << " for compressible/variable density flow" << nl
<< " Set the unused variables to 'none'.\n" << " or " << dimPressure/dimDensity
<< " for incompressible flow," << nl
<< " on patch " << this->patch().name() << " on patch " << this->patch().name()
<< " of field " << this->internalField().name() << " of field " << this->internalField().name()
<< " in file " << this->internalField().objectPath() << " in file " << this->internalField().objectPath()
@ -222,7 +232,7 @@ void Foam::uniformTotalPressureFvPatchScalarField::write(Ostream& os) const
os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
pressure_->writeData(os); p0_->writeData(os);
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -29,18 +29,18 @@ Group
Description Description
This boundary condition provides a time-varying form of the uniform total This boundary condition provides a time-varying form of the uniform total
pressure boundary condition. pressure boundary condition Foam::totalPressureFvPatchField.
\heading Patch usage \heading Patch usage
\table \table
Property | Description | Required | Default value Property | Description | Required | Default value
U | velocity field name | no | U U | Velocity field name | no | U
phi | flux field name | no | phi phi | Flux field name | no | phi
rho | density field name | no | none rho | Density field name | no | rho
psi | compressibility field name | no | none psi | Compressibility field name | no | none
gamma | ratio of specific heats (Cp/Cv) | yes | gamma | (Cp/Cv) | no | 1
pressure | total pressure as a function of time | yes | p0 | Total pressure as a function of time | yes |
\endtable \endtable
Example of the boundary condition specification: Example of the boundary condition specification:
@ -48,22 +48,13 @@ Description
myPatch myPatch
{ {
type uniformTotalPressure; type uniformTotalPressure;
U U; p0 uniform 1e5;
phi phi;
rho rho;
psi psi;
gamma 1.4;
pressure uniform 1e5;
} }
\endverbatim \endverbatim
The \c pressure entry is specified as a Function1 type, able to describe The \c p0 entry is specified as a Function1 type, able to describe
time varying functions. time varying functions.
Note
The default boundary behaviour is for subsonic, incompressible flow.
SeeAlso SeeAlso
Foam::Function1Types Foam::Function1Types
Foam::uniformFixedValueFvPatchField Foam::uniformFixedValueFvPatchField
@ -112,7 +103,7 @@ class uniformTotalPressureFvPatchScalarField
scalar gamma_; scalar gamma_;
//- Table of time vs total pressure, including the bounding treatment //- Table of time vs total pressure, including the bounding treatment
autoPtr<Function1<scalar>> pressure_; autoPtr<Function1<scalar>> p0_;
public: public:

View File

@ -33,10 +33,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 $internalField; p0 $internalField;
rho none;
psi none;
gamma 1;
value $internalField;
} }
frontAndBack frontAndBack
{ {

View File

@ -33,10 +33,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 $internalField; p0 $internalField;
rho none;
psi none;
gamma 1;
value $internalField;
} }
frontAndBack frontAndBack
{ {

View File

@ -39,10 +39,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 $internalField; p0 $internalField;
rho none;
psi none;
gamma 1;
value $internalField;
} }
farField farField

View File

@ -42,11 +42,7 @@ outlet
p p
{ {
type totalPressure; type totalPressure;
value uniform 1e5;
p0 uniform 1e5; p0 uniform 1e5;
rho rho;
psi none;
gamma 1.4;
} }
U U

View File

@ -39,10 +39,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 $internalField; p0 $internalField;
rho none;
psi none;
gamma 1;
value $internalField;
} }
farField farField

View File

@ -39,10 +39,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 $internalField; p0 $internalField;
rho none;
psi none;
gamma 1;
value uniform 0;
} }
farField farField

View File

@ -23,16 +23,11 @@ boundaryField
inlet inlet
{ {
type uniformTotalPressure; type uniformTotalPressure;
pressure table p0 table
( (
(0 10) (0 10)
(1 40) (1 40)
); );
p0 40; // only used for restarts
rho none;
psi none;
gamma 1;
value uniform 40;
} }
outlet1 outlet1

View File

@ -24,17 +24,11 @@ boundaryField
inlet inlet
{ {
type uniformTotalPressure; type uniformTotalPressure;
rho none; p0 table
psi none;
gamma 1;
pressure table
2
( (
(0 10) (0 10)
(1 40) (1 40)
) );
;
value uniform 40;
} }
outlet1 outlet1
{ {

View File

@ -33,10 +33,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 $internalField; p0 $internalField;
rho none;
psi none;
gamma 1;
value $internalField;
} }
frontAndBack frontAndBack
{ {

View File

@ -23,9 +23,6 @@ boundaryField
inlet inlet
{ {
type totalPressure; type totalPressure;
rho rho;
psi none;
gamma 1;
p0 uniform 300e5; p0 uniform 300e5;
} }

View File

@ -23,9 +23,6 @@ boundaryField
inlet inlet
{ {
type totalPressure; type totalPressure;
rho rho;
psi none;
gamma 1;
p0 uniform 300e5; p0 uniform 300e5;
} }

View File

@ -23,9 +23,6 @@ boundaryField
inlet inlet
{ {
type totalPressure; type totalPressure;
rho rho;
psi none;
gamma 1;
p0 uniform 300e5; p0 uniform 300e5;
} }

View File

@ -42,10 +42,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 1e5; p0 uniform 1e5;
rho rho;
psi none;
gamma 1;
value $internalField;
} }
defaultFaces defaultFaces

View File

@ -39,10 +39,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value $internalField;
} }
hull hull

View File

@ -38,10 +38,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value uniform 0;
} }
} }

View File

@ -28,10 +28,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value uniform 0;
} }
floatingObject floatingObject
{ {

View File

@ -42,10 +42,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value uniform 0;
} }
defaultFaces defaultFaces

View File

@ -39,10 +39,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value uniform 0;
} }
front front

View File

@ -39,10 +39,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value $internalField;
} }
hull hull

View File

@ -42,10 +42,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value uniform 0;
} }
defaultFaces defaultFaces

View File

@ -42,11 +42,7 @@ boundaryField
atmosphere atmosphere
{ {
type totalPressure; type totalPressure;
rho rho;
psi none;
gamma 1;
p0 uniform 0; p0 uniform 0;
value uniform 0;
} }
defaultFaces defaultFaces
{ {

View File

@ -24,10 +24,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value uniform 0;
} }
".*" ".*"

View File

@ -41,10 +41,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho none;
psi none;
gamma 1;
value uniform $pressure;
} }
defaultFaces defaultFaces

View File

@ -42,10 +42,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value uniform 0;
} }
defaultFaces defaultFaces

View File

@ -33,10 +33,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 $internalField; p0 $internalField;
rho rho;
psi none;
gamma 1;
value $internalField;
} }
wall wall

View File

@ -44,10 +44,6 @@ boundaryField
p0 uniform 0; p0 uniform 0;
U U.air; U U.air;
phi phi.air; phi phi.air;
rho rho;
psi none;
gamma 1;
value uniform 0;
} }
defaultFaces defaultFaces

View File

@ -42,10 +42,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value uniform 0;
} }
defaultFaces defaultFaces

View File

@ -42,10 +42,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value uniform 0;
} }
defaultFaces defaultFaces

View File

@ -42,10 +42,6 @@ boundaryField
{ {
type totalPressure; type totalPressure;
p0 uniform 0; p0 uniform 0;
rho rho;
psi none;
gamma 1;
value uniform 0;
} }
defaultFaces defaultFaces