mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: Corrections to pressureTools function object
This commit is contained in:
@ -56,7 +56,7 @@ Foam::word Foam::pressureTools::pName() const
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensionedScalar Foam::pressureTools::rho
|
||||
Foam::dimensionedScalar Foam::pressureTools::rhoScale
|
||||
(
|
||||
const volScalarField& p
|
||||
) const
|
||||
@ -72,6 +72,38 @@ Foam::dimensionedScalar Foam::pressureTools::rho
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::pressureTools::rho
|
||||
(
|
||||
const volScalarField& p
|
||||
) const
|
||||
{
|
||||
if (p.dimensions() == dimPressure)
|
||||
{
|
||||
return p.mesh().lookupObject<volScalarField>(rhoName_);
|
||||
}
|
||||
else
|
||||
{
|
||||
return
|
||||
tmp<volScalarField>
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rho",
|
||||
p.mesh().time().timeName(),
|
||||
p.mesh(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
p.mesh(),
|
||||
dimensionedScalar("zero", dimDensity, rhoRef_)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensionedScalar Foam::pressureTools::pRef() const
|
||||
{
|
||||
dimensionedScalar value("pRef", dimPressure, 0.0);
|
||||
@ -81,11 +113,14 @@ Foam::dimensionedScalar Foam::pressureTools::pRef() const
|
||||
value.value() += pRef_;
|
||||
}
|
||||
|
||||
return pRef();
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::pressureTools::pDyn() const
|
||||
Foam::tmp<Foam::volScalarField> Foam::pressureTools::pDyn
|
||||
(
|
||||
const volScalarField& p
|
||||
) const
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
@ -110,7 +145,7 @@ Foam::tmp<Foam::volScalarField> Foam::pressureTools::pDyn() const
|
||||
{
|
||||
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
|
||||
|
||||
tpDyn() == 0.5*magSqr(U);
|
||||
tpDyn() == rho(p)*0.5*magSqr(U);
|
||||
}
|
||||
|
||||
return tpDyn;
|
||||
@ -126,7 +161,7 @@ Foam::tmp<Foam::volScalarField> Foam::pressureTools::convertToCoeff
|
||||
|
||||
if (calcCoeff_)
|
||||
{
|
||||
tCoeff() /= pDyn();
|
||||
tCoeff() /= pDyn(p);
|
||||
}
|
||||
|
||||
return tCoeff;
|
||||
@ -150,6 +185,7 @@ Foam::pressureTools::pressureTools
|
||||
calcCoeff_(false),
|
||||
pName_("p"),
|
||||
UName_("U"),
|
||||
rhoName_("rho"),
|
||||
pRef_(0.0),
|
||||
rhoRef_(1.0)
|
||||
{
|
||||
@ -188,6 +224,7 @@ void Foam::pressureTools::read(const dictionary& dict)
|
||||
{
|
||||
dict.readIfPresent("pName", pName_);
|
||||
dict.readIfPresent("UName", UName_);
|
||||
dict.readIfPresent("rhoName", rhoName_);
|
||||
|
||||
const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
|
||||
|
||||
@ -234,7 +271,7 @@ void Foam::pressureTools::write()
|
||||
obr_,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
convertToCoeff(rho(p)*(p + pDyn()) + pRef())
|
||||
convertToCoeff(rhoScale(p)*p + pDyn(p) + pRef())
|
||||
);
|
||||
|
||||
pResult.write();
|
||||
|
||||
@ -125,6 +125,9 @@ class pressureTools
|
||||
//- Name of velocity field, default is "U"
|
||||
word UName_;
|
||||
|
||||
//- Name of density field, default is "rho"
|
||||
word rhoName_;
|
||||
|
||||
//- Reference pressure level (used for total pressure)
|
||||
scalar pRef_;
|
||||
|
||||
@ -138,13 +141,16 @@ class pressureTools
|
||||
word pName() const;
|
||||
|
||||
//- Return the density scaling if supplied with kinematic pressure
|
||||
dimensionedScalar rho(const volScalarField& p) const;
|
||||
dimensionedScalar rhoScale(const volScalarField& p) const;
|
||||
|
||||
//- Return the density field
|
||||
tmp<volScalarField> rho(const volScalarField& p) const;
|
||||
|
||||
//- Return the reference pressure
|
||||
dimensionedScalar pRef() const;
|
||||
|
||||
//- Calculate and return the (kinematic) dynamic pressure
|
||||
tmp<volScalarField> pDyn() const;
|
||||
//- Calculate and return the dynamic pressure
|
||||
tmp<volScalarField> pDyn(const volScalarField& p) const;
|
||||
|
||||
//- Convert to coeff data by applying the pDyn scaling
|
||||
tmp<volScalarField> convertToCoeff(const volScalarField& p) const;
|
||||
|
||||
Reference in New Issue
Block a user