Go to the documentation of this file.
39 namespace functionObjects
54 { ISENTROPIC,
"isentropic" },
55 { STATIC_COEFF,
"staticCoeff" },
56 { TOTAL_COEFF,
"totalCoeff" },
67 { SUBTRACT,
"subtract" },
72 Foam::word Foam::functionObjects::pressure::resultName()
const
80 else if (mode_ &
TOTAL)
91 <<
"Unhandled calculation mode " <<
modeNames[mode_]
95 switch (hydrostaticMode_)
103 rName = rName +
"+rgh";
109 rName = rName +
"-rgh";
136 p.mesh().time().timeName(),
147 if (!rhoInfInitialised_)
151 <<
"pressure identified as incompressible, but reference "
152 <<
"density is not set. Please set 'rho' to 'rhoInf', and "
153 <<
"set an appropriate value for 'rhoInf'"
164 const tmp<volScalarField>& tsf
169 return lookupObject<volScalarField>(rhoName_)*tsf;
176 void Foam::functionObjects::pressure::addHydrostaticContribution
183 if (hydrostaticMode_ == NONE)
193 if (!hRefInitialised_)
200 (g_ & (
cmptMag(g_.value())/
mag(g_.value())))*hRef_
203 tmp<volScalarField> rgh = rhoScale(
p, (g_ & mesh_.C()) - ghRef);
205 switch (hydrostaticMode_)
226 const tmp<volScalarField>& tp
236 mesh_.time().timeName(),
246 addHydrostaticContribution(result);
258 + rhoScale(
p, 0.5*
magSqr(lookupObject<volVectorField>(UName_)));
262 if (mode_ & ISENTROPIC)
264 const basicThermo* thermoPtr =
270 <<
"Isentropic pressure calculation requires a "
271 <<
"thermodynamics package"
278 mag(lookupObject<volVectorField>(UName_))
293 const tmp<volScalarField>& tp
298 tmp<volScalarField> tpCoeff(tp.ptr());
312 return std::move(tp);
318 bool Foam::functionObjects::pressure::calc()
320 if (foundObject<volScalarField>(fieldName_))
329 p.mesh().time().timeName(),
334 coeff(calcPressure(
p, rhoScale(
p)))
337 return store(resultName_, tp);
355 hydrostaticMode_(NONE),
362 rhoInfInitialised_(
false),
364 gInitialised_(
false),
366 hRefInitialised_(
false)
380 UName_ =
dict.lookupOrDefault<
word>(
"U",
"U");
381 rhoName_ =
dict.lookupOrDefault<
word>(
"rho",
"rho");
383 if (rhoName_ ==
"rhoInf")
385 dict.readEntry(
"rhoInf", rhoInf_);
386 rhoInfInitialised_ =
true;
389 if (!modeNames.readIfPresent(
"mode",
dict, mode_))
395 dict.getOrDefaultCompat<
bool>(
"mode", {{
"calcTotal", 1812}},
false);
397 dict.getOrDefaultCompat<
bool>(
"mode", {{
"calcCoeff", 1812}},
false);
410 mode_ =
static_cast<mode>(COEFF | mode_);
414 Info<<
" Operating mode: " << modeNames[mode_] <<
nl;
416 pRef_ =
dict.lookupOrDefault<scalar>(
"pRef", 0);
420 hydrostaticModeNames.readIfPresent
429 Info<<
" Hydrostatic mode: "
430 << hydrostaticModeNames[hydrostaticMode_]
432 gInitialised_ =
dict.readIfPresent(
"g", g_);
433 hRefInitialised_ =
dict.readIfPresent(
"hRef", hRef_);
437 Info<<
" Not including hydrostatic effects" <<
nl;
444 dict.readEntry(
"pInf", pInf_);
445 dict.readEntry(
"UInf", UInf_);
446 dict.readEntry(
"rhoInf", rhoInf_);
448 scalar zeroCheck = 0.5*rhoInf_*
magSqr(UInf_) + pInf_;
450 if (
mag(zeroCheck) < ROOTVSMALL)
454 <<
"Coefficient calculation requested, but reference "
455 <<
"pressure level is zero. Please check the supplied "
456 <<
"values of pInf, UInf and rhoInf" <<
endl;
459 rhoInfInitialised_ =
true;
462 resultName_ =
dict.lookupOrDefault<
word>(
"result", resultName());
mode
Enumeration for pressure calculation mode.
const dimensionSet dimPressure
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
A class for managing temporary objects.
static constexpr const zero Zero
Global zero.
const dimensionSet dimVelocity
const dimensionSet dimDensity
bool read(const char *buf, int32_t &val)
Same as readInt32.
virtual bool read(const dictionary &dict)
Read the fieldExpression data.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static const Enum< hydrostaticMode > hydrostaticModeNames
static const word & calculatedType()
Return the type of the calculated for of fvPatchField.
addToRunTimeSelectionTable(functionObject, add, dictionary)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
virtual bool read(const dictionary &)
Read the pressure data.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
messageStream Info
Information stream (uses stdout - output is on the master only)
pressure(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
word name(const complex &c)
Return string representation of complex.
UniformDimensionedField< vector > uniformDimensionedVectorField
UniformDimensionedField< scalar > uniformDimensionedScalarField
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
word dictName() const
The local dictionary name (final part of scoped name)
word fieldName_
Name of field to process.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Macros for easy insertion into run-time selection tables.
hydrostaticMode
Enumeration for hydrostatic contributions.
errorManip< error > abort(error &err)
errorManipArg< error, int > exit(error &err, const int errNo=1)
const dimensionSet dimAcceleration
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
static const Enum< mode > modeNames
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Base class for field expression function objects.
Internal & ref(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
#define WarningInFunction
Report a warning using Foam::Warning.