55 { ISENTROPIC,
"isentropic" },
56 { STATIC_COEFF,
"staticCoeff" },
57 { TOTAL_COEFF,
"totalCoeff" },
69 { SUBTRACT,
"subtract" },
75Foam::word Foam::functionObjects::pressure::resultName()
const
83 else if (mode_ &
TOTAL)
94 <<
"Unhandled calculation mode " <<
modeNames[mode_]
98 switch (hydrostaticMode_)
106 rName = rName +
"+rgh";
112 rName = rName +
"-rgh";
127Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::rhoScale
143 if (!rhoInfInitialised_)
147 <<
"pressure identified as incompressible, but reference "
148 <<
"density is not set. Please set 'rho' to 'rhoInf', and "
149 <<
"set an appropriate value for 'rhoInf'"
157Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::rhoScale
160 const tmp<volScalarField>& tsf
165 return lookupObject<volScalarField>(rhoName_)*tsf;
172void Foam::functionObjects::pressure::addHydrostaticContribution
180 if (hydrostaticMode_ == NONE)
190 if (!hRefInitialised_)
197 (g_ & (
cmptMag(g_.value())/
mag(g_.value())))*hRef_
202 tmp<volScalarField> rgh = rhoScale(
p, (g_ & mesh_.C()) - ghRef);
204 switch (hydrostaticMode_)
224Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::calcPressure
227 const tmp<volScalarField>& tp
238 auto& result = tresult.ref();
240 addHydrostaticContribution(
p, result);
252 + rhoScale(
p, 0.5*
magSqr(lookupObject<volVectorField>(UName_)));
256 if (mode_ & ISENTROPIC)
258 const basicThermo* thermoPtr =
264 <<
"Isentropic pressure calculation requires a "
265 <<
"thermodynamics package"
272 mag(lookupObject<volVectorField>(UName_))
284Foam::tmp<Foam::volScalarField> Foam::functionObjects::pressure::coeff
286 const tmp<volScalarField>& tp
291 tmp<volScalarField> tpCoeff(tp.ptr());
292 auto& pCoeff = tpCoeff.ref();
305 return std::move(tp);
313 const auto* pptr = cfindObject<volScalarField>(fieldName_);
317 const auto&
p = *pptr;
323 coeff(calcPressure(
p, rhoScale(
p)))
326 return store(resultName_, tp);
344 hydrostaticMode_(NONE),
351 rhoInfInitialised_(false),
353 gInitialised_(false),
355 hRefInitialised_(false)
369 UName_ =
dict.getOrDefault<
word>(
"U",
"U");
370 rhoName_ =
dict.getOrDefault<
word>(
"rho",
"rho");
372 if (rhoName_ ==
"rhoInf")
374 dict.readEntry(
"rhoInf", rhoInf_);
375 rhoInfInitialised_ =
true;
378 if (!modeNames.readIfPresent(
"mode",
dict, mode_))
384 dict.getOrDefaultCompat<
bool>(
"mode", {{
"calcTotal", 1812}},
false);
386 dict.getOrDefaultCompat<
bool>(
"mode", {{
"calcCoeff", 1812}},
false);
399 mode_ =
static_cast<mode>(COEFF | mode_);
403 Info<<
" Operating mode: " << modeNames[mode_] <<
nl;
405 pRef_ =
dict.getOrDefault<scalar>(
"pRef", 0);
409 hydrostaticModeNames.readIfPresent
418 Info<<
" Hydrostatic mode: "
419 << hydrostaticModeNames[hydrostaticMode_]
421 gInitialised_ =
dict.readIfPresent(
"g", g_);
422 hRefInitialised_ =
dict.readIfPresent(
"hRef", hRef_);
426 Info<<
" Not including hydrostatic effects" <<
nl;
432 dict.readEntry(
"pInf", pInf_);
433 dict.readEntry(
"UInf", UInf_);
434 dict.readEntry(
"rhoInf", rhoInf_);
436 const scalar zeroCheck = 0.5*rhoInf_*
magSqr(UInf_) + pInf_;
438 if (
mag(zeroCheck) < ROOTVSMALL)
442 <<
"Coefficient calculation requested, but reference "
443 <<
"pressure level is zero. Please check the supplied "
444 <<
"values of pInf, UInf and rhoInf" <<
endl;
447 rhoInfInitialised_ =
true;
450 resultName_ =
dict.getOrDefault<word>(
"result", resultName());
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
static int localBoundaryConsistency() noexcept
Get flag for local boundary consistency checks.
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< scalar >::calculatedType())
@ NO_REGISTER
Do not request registration (bool: false).
@ REGISTER
Request registration (bool: true).
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static const word dictName
The dictionary name ("thermophysicalProperties").
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Abstract base-class for Time/database function objects.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
word resultName_
Name of result field.
word fieldName_
Name of field to process.
fieldExpression(const word &name, const Time &runTime, const dictionary &dict, const word &fieldName=word::null, const word &resultName=word::null)
Construct from name, Time and dictionary.
virtual bool calc()=0
Calculate the components of the field and return true if successful.
Computes the magnitude of an input field.
Provides several methods to convert an input pressure field into derived forms, including:
pressure(const word &name, const Time &runTime, const dictionary &)
Construct from name, Time and dictionary.
static const Enum< hydrostaticMode > hydrostaticModeNames
Names for hydrostaticMode.
hydrostaticMode
Enumeration for hydrostatic contributions.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
static const Enum< mode > modeNames
Names for mode types.
mode
Enumeration for pressure calculation mode.
@ COEFF
Coefficient manipulator.
@ ISENTROPIC
Isentropic pressure.
static const word & calculatedType() noexcept
The type name for calculated patch fields.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
@ NONE
No type, or default initialized type.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
const dimensionSet dimPressure
bool read(const char *buf, int32_t &val)
Same as readInt32.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
UniformDimensionedField< scalar > uniformDimensionedScalarField
const dimensionSet dimVelocity
messageStream Info
Information stream (stdout output on master, null elsewhere).
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
UniformDimensionedField< vector > uniformDimensionedVectorField
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0).
const dimensionSet dimAcceleration
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimDensity
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
constexpr char nl
The newline '\n' character (0x0a).