Skip to content
Snippets Groups Projects
Commit f849409c authored by andy's avatar andy
Browse files

BUG: Corrected use of rho if reference pressure is kinematic

parent fe039d4c
Branches
Tags
No related merge requests found
...@@ -34,9 +34,16 @@ defineTypeNameAndDebug(Foam::pressureCoefficient, 0); ...@@ -34,9 +34,16 @@ defineTypeNameAndDebug(Foam::pressureCoefficient, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::tmp<Foam::volScalarField> Foam::pressureCoefficient::rho() const Foam::tmp<Foam::volScalarField> Foam::pressureCoefficient::rho
(
const volScalarField& p
) const
{ {
if (rhoName_ == "rhoInf") if (p.dimensions() == dimPressure)
{
return(obr_.lookupObject<volScalarField>(rhoName_));
}
else
{ {
const fvMesh& mesh = refCast<const fvMesh>(obr_); const fvMesh& mesh = refCast<const fvMesh>(obr_);
...@@ -51,14 +58,10 @@ Foam::tmp<Foam::volScalarField> Foam::pressureCoefficient::rho() const ...@@ -51,14 +58,10 @@ Foam::tmp<Foam::volScalarField> Foam::pressureCoefficient::rho() const
mesh mesh
), ),
mesh, mesh,
dimensionedScalar("rho", dimDensity, rhoRef_) dimensionedScalar("rho", dimless, 1.0)
) )
); );
} }
else
{
return(obr_.lookupObject<volScalarField>(rhoName_));
}
} }
...@@ -76,8 +79,7 @@ Foam::pressureCoefficient::pressureCoefficient ...@@ -76,8 +79,7 @@ Foam::pressureCoefficient::pressureCoefficient
obr_(obr), obr_(obr),
active_(true), active_(true),
pName_("p"), pName_("p"),
rhoName_(word::null), rhoName_("rho"),
rhoRef_(-GREAT),
magUinf_(0.0) magUinf_(0.0)
{ {
// Check if the available mesh is an fvMesh, otherwise deactivate // Check if the available mesh is an fvMesh, otherwise deactivate
...@@ -114,12 +116,7 @@ void Foam::pressureCoefficient::read(const dictionary& dict) ...@@ -114,12 +116,7 @@ void Foam::pressureCoefficient::read(const dictionary& dict)
if (active_) if (active_)
{ {
pName_ = dict.lookupOrDefault<word>("pName", "p"); pName_ = dict.lookupOrDefault<word>("pName", "p");
rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho"); rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho");
if (rhoName_ == "rhoInf")
{
dict.lookup("rhoInf") >> rhoRef_;
}
dict.lookup("magUinf") >> magUinf_; dict.lookup("magUinf") >> magUinf_;
} }
...@@ -153,7 +150,7 @@ void Foam::pressureCoefficient::write() ...@@ -153,7 +150,7 @@ void Foam::pressureCoefficient::write()
obr_, obr_,
IOobject::NO_READ IOobject::NO_READ
), ),
p/(0.5*rho()*sqr(magUinf_)) p/(0.5*rho(p)*sqr(magUinf_))
); );
pressureCoefficient.write(); pressureCoefficient.write();
......
...@@ -77,21 +77,15 @@ class pressureCoefficient ...@@ -77,21 +77,15 @@ class pressureCoefficient
//- Name of density field (optional) //- Name of density field (optional)
word rhoName_; word rhoName_;
//- Reference density needed for incompressible calculations [kg/m3]
scalar rhoRef_;
//- Free stream velocity magnitude [m/s] //- Free stream velocity magnitude [m/s]
scalar magUinf_; scalar magUinf_;
// Private Member Functions // Private Member Functions
//- Return rho if rhoName is specified otherwise rhoRef //- Return 1 if the pressure field is kinematic, i.e. p/rho
tmp<volScalarField> rho() const; // otherwise return rho from database
tmp<volScalarField> rho(const volScalarField& p) const;
//- Return rhoRef if the pressure field is dynamic, i.e. p/rho
// otherwise return 1
scalar rho(const volScalarField& p) const;
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
pressureCoefficient(const pressureCoefficient&); pressureCoefficient(const pressureCoefficient&);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment