mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
uniformDensityHydrostaticPressureFvPatchScalarField: pRefPoint now optional
If pRefPoint is not specified hRef is used. This provides compatibility with the original prghUniformDensityHydrostaticPressureFvPatchScalarField BC.
This commit is contained in:
@ -41,7 +41,8 @@ uniformDensityHydrostaticPressureFvPatchScalarField
|
|||||||
:
|
:
|
||||||
fixedValueFvPatchScalarField(p, iF),
|
fixedValueFvPatchScalarField(p, iF),
|
||||||
rho_(0.0),
|
rho_(0.0),
|
||||||
pRefValue_(0.0),
|
pRef_(0.0),
|
||||||
|
pRefPointSpecified_(false),
|
||||||
pRefPoint_(Zero)
|
pRefPoint_(Zero)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -54,11 +55,24 @@ uniformDensityHydrostaticPressureFvPatchScalarField
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
fixedValueFvPatchScalarField(p, iF, dict),
|
fixedValueFvPatchScalarField(p, iF, dict, false),
|
||||||
rho_(readScalar(dict.lookup("rho"))),
|
rho_(readScalar(dict.lookup("rhoRef"))),
|
||||||
pRefValue_(readScalar(dict.lookup("pRefValue"))),
|
pRef_(readScalar(dict.lookup("pRef"))),
|
||||||
pRefPoint_(dict.lookup("pRefPoint"))
|
pRefPointSpecified_(dict.found("pRefPoint")),
|
||||||
{}
|
pRefPoint_(dict.lookupOrDefault<vector>("pRefPoint", Zero))
|
||||||
|
{
|
||||||
|
if (dict.found("value"))
|
||||||
|
{
|
||||||
|
fvPatchScalarField::operator=
|
||||||
|
(
|
||||||
|
scalarField("value", dict, p.size())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fvPatchField<scalar>::operator=(pRef_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
|
Foam::uniformDensityHydrostaticPressureFvPatchScalarField::
|
||||||
@ -72,7 +86,8 @@ uniformDensityHydrostaticPressureFvPatchScalarField
|
|||||||
:
|
:
|
||||||
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
|
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
|
||||||
rho_(ptf.rho_),
|
rho_(ptf.rho_),
|
||||||
pRefValue_(ptf.pRefValue_),
|
pRef_(ptf.pRef_),
|
||||||
|
pRefPointSpecified_(ptf.pRefPointSpecified_),
|
||||||
pRefPoint_(ptf.pRefPoint_)
|
pRefPoint_(ptf.pRefPoint_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -85,7 +100,8 @@ uniformDensityHydrostaticPressureFvPatchScalarField
|
|||||||
:
|
:
|
||||||
fixedValueFvPatchScalarField(ptf),
|
fixedValueFvPatchScalarField(ptf),
|
||||||
rho_(ptf.rho_),
|
rho_(ptf.rho_),
|
||||||
pRefValue_(ptf.pRefValue_),
|
pRef_(ptf.pRef_),
|
||||||
|
pRefPointSpecified_(ptf.pRefPointSpecified_),
|
||||||
pRefPoint_(ptf.pRefPoint_)
|
pRefPoint_(ptf.pRefPoint_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -99,7 +115,8 @@ uniformDensityHydrostaticPressureFvPatchScalarField
|
|||||||
:
|
:
|
||||||
fixedValueFvPatchScalarField(ptf, iF),
|
fixedValueFvPatchScalarField(ptf, iF),
|
||||||
rho_(ptf.rho_),
|
rho_(ptf.rho_),
|
||||||
pRefValue_(ptf.pRefValue_),
|
pRef_(ptf.pRef_),
|
||||||
|
pRefPointSpecified_(ptf.pRefPointSpecified_),
|
||||||
pRefPoint_(ptf.pRefPoint_)
|
pRefPoint_(ptf.pRefPoint_)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -116,10 +133,25 @@ void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::updateCoeffs()
|
|||||||
const uniformDimensionedVectorField& g =
|
const uniformDimensionedVectorField& g =
|
||||||
db().lookupObject<uniformDimensionedVectorField>("g");
|
db().lookupObject<uniformDimensionedVectorField>("g");
|
||||||
|
|
||||||
|
scalar ghRef = g.value() & pRefPoint_;
|
||||||
|
|
||||||
|
if (!pRefPointSpecified_)
|
||||||
|
{
|
||||||
|
const uniformDimensionedScalarField& hRef =
|
||||||
|
db().lookupObject<uniformDimensionedScalarField>("hRef");
|
||||||
|
|
||||||
|
ghRef =
|
||||||
|
(
|
||||||
|
mag(g.value()) > small
|
||||||
|
? (g & (cmptMag(g.value())/mag(g.value()))*hRef).value()
|
||||||
|
: 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
operator==
|
operator==
|
||||||
(
|
(
|
||||||
pRefValue_
|
pRef_
|
||||||
+ rho_*((g.value() & patch().Cf()) - (g.value() & pRefPoint_))
|
+ rho_*((g.value() & patch().Cf()) - ghRef)
|
||||||
);
|
);
|
||||||
|
|
||||||
fixedValueFvPatchScalarField::updateCoeffs();
|
fixedValueFvPatchScalarField::updateCoeffs();
|
||||||
@ -132,9 +164,13 @@ void Foam::uniformDensityHydrostaticPressureFvPatchScalarField::write
|
|||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
fvPatchScalarField::write(os);
|
fvPatchScalarField::write(os);
|
||||||
os.writeKeyword("rho") << rho_ << token::END_STATEMENT << nl;
|
os.writeKeyword("rhoRef") << rho_ << token::END_STATEMENT << nl;
|
||||||
os.writeKeyword("pRefValue") << pRefValue_ << token::END_STATEMENT << nl;
|
os.writeKeyword("pRef") << pRef_ << token::END_STATEMENT << nl;
|
||||||
os.writeKeyword("pRefPoint") << pRefPoint_ << token::END_STATEMENT << nl;
|
if (pRefPointSpecified_)
|
||||||
|
{
|
||||||
|
os.writeKeyword("pRefPoint")
|
||||||
|
<< pRefPoint_ << token::END_STATEMENT << nl;
|
||||||
|
}
|
||||||
writeEntry("value", os);
|
writeEntry("value", os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,25 +32,25 @@ Description
|
|||||||
calculated as:
|
calculated as:
|
||||||
|
|
||||||
\f[
|
\f[
|
||||||
p_{hyd} = p_{ref} + \rho g (x - x_{ref})
|
p_{hyd} = p_{ref} + \rho_{ref} g (x - x_{ref})
|
||||||
\f]
|
\f]
|
||||||
|
|
||||||
where
|
where
|
||||||
\vartable
|
\vartable
|
||||||
p_{hyd} | Hydrostatic pressure [Pa]
|
p_{hyd} | Hydrostatic pressure [Pa]
|
||||||
p_{ref} | Reference pressure [Pa]
|
p_{ref} | Reference pressure [Pa]
|
||||||
x_{ref} | Reference point in Cartesian co-ordinates
|
x_{ref} | Reference point in Cartesian co-ordinates
|
||||||
\rho | Density (assumed uniform)
|
\rho_{ref} | Density (assumed uniform)
|
||||||
g | Acceleration due to gravity [m/s2]
|
g | Acceleration due to gravity [m/s2]
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
\table
|
\table
|
||||||
Property | Description | Required | Default value
|
Property | Description | Required | Default value
|
||||||
rho | Uniform density [kg/m3] | yes |
|
rhoRef | Uniform density [kg/m3] | yes |
|
||||||
pRefValue | Reference pressure [Pa] | yes |
|
pRef | Reference pressure [Pa] | yes |
|
||||||
pRefPoint | Reference pressure location | yes |
|
pRefPoint | Reference pressure location | no | hRef
|
||||||
value | Initial value | yes |
|
value | Initial value | no | pRef
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
Example of the boundary condition specification:
|
Example of the boundary condition specification:
|
||||||
@ -58,10 +58,9 @@ Usage
|
|||||||
<patchName>
|
<patchName>
|
||||||
{
|
{
|
||||||
type uniformDensityHydrostaticPressure;
|
type uniformDensityHydrostaticPressure;
|
||||||
rho rho;
|
rhoRef 1000;
|
||||||
pRefValue 1e5;
|
pRef 1e5;
|
||||||
pRefPoint (0 0 0);
|
pRefPoint (0 0 0);
|
||||||
value uniform 0; // Required initial value
|
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
@ -94,9 +93,12 @@ class uniformDensityHydrostaticPressureFvPatchScalarField
|
|||||||
scalar rho_;
|
scalar rho_;
|
||||||
|
|
||||||
//- Reference pressure
|
//- Reference pressure
|
||||||
scalar pRefValue_;
|
scalar pRef_;
|
||||||
|
|
||||||
//- Reference pressure location
|
//- True if the reference pressure location is specified
|
||||||
|
bool pRefPointSpecified_;
|
||||||
|
|
||||||
|
//- Optional reference pressure location
|
||||||
vector pRefPoint_;
|
vector pRefPoint_;
|
||||||
|
|
||||||
|
|
||||||
@ -190,15 +192,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- Return the reference pressure
|
//- Return the reference pressure
|
||||||
scalar pRefValue() const
|
scalar pRef() const
|
||||||
{
|
{
|
||||||
return pRefValue_;
|
return pRef_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return reference to the reference pressure to allow adjustment
|
//- Return reference to the reference pressure to allow adjustment
|
||||||
scalar& pRefValue()
|
scalar& pRef()
|
||||||
{
|
{
|
||||||
return pRefValue_;
|
return pRef_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return the pressure reference location
|
//- Return the pressure reference location
|
||||||
|
|||||||
Reference in New Issue
Block a user