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 e71b8cabd8
commit 64aa9925e4
33 changed files with 129 additions and 241 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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