ENH: pessureTools function object - updated coeff calculation and usage documentation

This commit is contained in:
andy
2012-11-23 09:50:21 +00:00
parent 7d6b30ffc5
commit 7f71489895
2 changed files with 84 additions and 31 deletions

View File

@ -154,15 +154,20 @@ Foam::tmp<Foam::volScalarField> Foam::pressureTools::pDyn
Foam::tmp<Foam::volScalarField> Foam::pressureTools::convertToCoeff Foam::tmp<Foam::volScalarField> Foam::pressureTools::convertToCoeff
( (
const volScalarField& pCalculated, const volScalarField& p
const volScalarField& pIn
) const ) const
{ {
tmp<volScalarField> tCoeff(pCalculated); tmp<volScalarField> tCoeff(p);
if (calcCoeff_) if (calcCoeff_)
{ {
tCoeff() /= pDyn(pIn) + dimensionedScalar("p0", dimPressure, SMALL); tCoeff() -= dimensionedScalar("pInf", dimPressure, pInf_);
const dimensionedScalar p0("p0", dimPressure, SMALL);
const dimensionedVector U("U", dimVelocity, UInf_);
const dimensionedScalar rho("rho", dimDensity, rhoInf_);
tCoeff() /= 0.5*rho*magSqr(U) + p0;
} }
return tCoeff; return tCoeff;
@ -182,13 +187,16 @@ Foam::pressureTools::pressureTools
name_(name), name_(name),
obr_(obr), obr_(obr),
active_(true), active_(true),
calcTotal_(false),
calcCoeff_(false),
pName_("p"), pName_("p"),
UName_("U"), UName_("U"),
rhoName_("rho"), rhoName_("rho"),
rhoRef_(1.0),
calcTotal_(false),
pRef_(0.0), pRef_(0.0),
rhoRef_(1.0) calcCoeff_(false),
pInf_(0.0),
UInf_(vector::zero),
rhoInf_(0.0)
{ {
// Check if the available mesh is an fvMesh, otherwise deactivate // Check if the available mesh is an fvMesh, otherwise deactivate
if (!isA<fvMesh>(obr_)) if (!isA<fvMesh>(obr_))
@ -241,6 +249,12 @@ void Foam::pressureTools::read(const dictionary& dict)
} }
dict.lookup("calcCoeff") >> calcCoeff_; dict.lookup("calcCoeff") >> calcCoeff_;
if (calcCoeff_)
{
dict.lookup("pInf") >> pInf_;
dict.lookup("UInf") >> UInf_;
dict.lookup("rhoInf") >> rhoInf_;
}
} }
} }
@ -272,7 +286,7 @@ void Foam::pressureTools::write()
obr_, obr_,
IOobject::NO_READ IOobject::NO_READ
), ),
convertToCoeff(rhoScale(p)*p + pDyn(p) + pRef(), p) convertToCoeff(rhoScale(p)*p + pDyn(p) + pRef())
); );
pResult.write(); pResult.write();

View File

@ -41,15 +41,40 @@ Description
\f] \f]
- static pressure coefficient - static pressure coefficient
\f[ \f[
Cp_s = \frac{p_s}{0.5 \rho |U|^2} Cp_s = \frac{p_s - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
\f] \f]
- total pressure coefficient - total pressure coefficient
\f[ \f[
Cp_T = \frac{p_T}{0.5 \rho |U|^2} Cp_T = \frac{p_T - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
\f] \f]
The function object will operate on both kinematic (p_k) and static where
pressure (p_s) fields, and the result is written as a volScalarField. \vartable
\rho | density [kg/m3]
U | velocity [m/s]
\rho_{\inf} | freestream density [kg/m3]
p_{\inf} | freestream pressure [Pa]
U_{\inf} | freestream velocity [m/s]
p_k | kinematic pressure (p/rho)[m2/s2]
p_s | pressure [Pa]
p_T | total pressure [Pa]
p_{ref} | reference pressure level [Pa]
Cp_{s} | pressure coefficient
Cp_{T} | total pressure coefficient
\endvartable
The function object will operate on both kinematic (\f$ p_k \f$) and static
pressure (\f$ p_s \f$) fields, and the result is written as a
volScalarField.
The modes of operation are:
\table
Mode | calcTotal | calcCoeff
static pressure | no | no
total pressure | yes | no
pressure coefficient | no | yes
total pressure coefficient | yes | yes
\endtable
Example of function object specification to calculate pressure coefficient: Example of function object specification to calculate pressure coefficient:
\verbatim \verbatim
@ -67,10 +92,13 @@ Description
\table \table
Property | Description | Required | Default value Property | Description | Required | Default value
type | type name: pressureTools| yes | type | type name: pressureTools| yes |
calcCoeff | Calculate pressure coefficient | yes |
calcTotal | Calculate total coefficient | yes |
rhoRef | Reference density for incompressible cases | no | 1 rhoRef | Reference density for incompressible cases | no | 1
pRef | Reference pressure for total pressure |no| 0.0 calcTotal | Calculate total coefficient | yes |
pRef | Reference pressure for total pressure | no | 0.0
calcCoeff | Calculate pressure coefficient | yes |
pInf | Freestream pressure for coefficient calculation | no |
UInf | Freestream velocity for coefficient calculation | no |
rhoInf | Freestream density for coefficient calculation | no |
\endtable \endtable
SourceFiles SourceFiles
@ -113,12 +141,6 @@ class pressureTools
//- On/off switch //- On/off switch
bool active_; bool active_;
//- Flag to calculate total pressure
bool calcTotal_;
//- Flag to calculate pressure coefficient
bool calcCoeff_;
//- Name of pressure field, default is "p" //- Name of pressure field, default is "p"
word pName_; word pName_;
@ -128,13 +150,34 @@ class pressureTools
//- Name of density field, default is "rho" //- Name of density field, default is "rho"
word rhoName_; word rhoName_;
//- Reference pressure level (used for total pressure) //- Reference density employed for incompressible cases
scalar pRef_;
//- Reference density value
scalar rhoRef_; scalar rhoRef_;
// Total pressure calculation
//- Flag to calculate total pressure
bool calcTotal_;
//- Reference pressure level
scalar pRef_;
// Pressure coefficient calculation
//- Flag to calculate pressure coefficient
bool calcCoeff_;
//- Freestream pressure
scalar pInf_;
//- Freestream velocity
vector UInf_;
//- Freestream density
scalar rhoInf_;
// Private Member Functions // Private Member Functions
//- Return the name of the derived pressure field //- Return the name of the derived pressure field
@ -152,12 +195,8 @@ class pressureTools
//- Calculate and return the dynamic pressure //- Calculate and return the dynamic pressure
tmp<volScalarField> pDyn(const volScalarField& p) const; tmp<volScalarField> pDyn(const volScalarField& p) const;
//- Convert to coeff data by applying the pDyn scaling //- Convert to coeff by applying the freestream dynamic pressure scaling
tmp<volScalarField> convertToCoeff tmp<volScalarField> convertToCoeff(const volScalarField& p) const;
(
const volScalarField& pCalculated,
const volScalarField& pIn
) const;
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
pressureTools(const pressureTools&); pressureTools(const pressureTools&);