39 namespace functionObjects
55 { ISENTROPIC,
"isentropic" },
56 { STATIC_COEFF,
"staticCoeff" },
57 { TOTAL_COEFF,
"totalCoeff" },
69 { SUBTRACT,
"subtract" },
75 Foam::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";
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'" 160 const tmp<volScalarField>& tsf
165 return lookupObject<volScalarField>(rhoName_)*tsf;
172 void Foam::functionObjects::pressure::addHydrostaticContribution
180 if (hydrostaticMode_ == NONE)
190 if (!hRefInitialised_)
197 (g_ & (
cmptMag(g_.value())/
mag(g_.value())))*hRef_
203 tmp<volScalarField> rgh = rhoScale(
p, (g_ & mesh_.C()) - ghRef);
205 switch (hydrostaticMode_)
228 const tmp<volScalarField>& tp
239 auto& result = tresult.ref();
241 addHydrostaticContribution(
p, result);
253 + rhoScale(
p, 0.5*
magSqr(lookupObject<volVectorField>(UName_)));
257 if (mode_ & ISENTROPIC)
259 const basicThermo* thermoPtr =
265 <<
"Isentropic pressure calculation requires a " 266 <<
"thermodynamics package" 273 mag(lookupObject<volVectorField>(UName_))
287 const tmp<volScalarField>& tp
292 tmp<volScalarField> tpCoeff(tp.ptr());
293 auto& pCoeff = tpCoeff.ref();
306 return std::move(tp);
312 bool Foam::functionObjects::pressure::calc()
314 const auto* pptr = cfindObject<volScalarField>(fieldName_);
318 const auto&
p = *pptr;
324 coeff(calcPressure(
p, rhoScale(
p)))
327 return store(resultName_, tp);
345 hydrostaticMode_(NONE),
352 rhoInfInitialised_(false),
354 gInitialised_(false),
356 hRefInitialised_(false)
370 UName_ =
dict.getOrDefault<
word>(
"U",
"U");
371 rhoName_ =
dict.getOrDefault<
word>(
"rho",
"rho");
373 if (rhoName_ ==
"rhoInf")
375 dict.readEntry(
"rhoInf", rhoInf_);
376 rhoInfInitialised_ =
true;
379 if (!modeNames.readIfPresent(
"mode",
dict, mode_))
385 dict.getOrDefaultCompat<
bool>(
"mode", {{
"calcTotal", 1812}},
false);
387 dict.getOrDefaultCompat<
bool>(
"mode", {{
"calcCoeff", 1812}},
false);
400 mode_ =
static_cast<mode>(COEFF | mode_);
404 Info<<
" Operating mode: " << modeNames[mode_] <<
nl;
406 pRef_ =
dict.getOrDefault<scalar>(
"pRef", 0);
410 hydrostaticModeNames.readIfPresent
419 Info<<
" Hydrostatic mode: " 420 << hydrostaticModeNames[hydrostaticMode_]
422 gInitialised_ =
dict.readIfPresent(
"g", g_);
423 hRefInitialised_ =
dict.readIfPresent(
"hRef", hRef_);
427 Info<<
" Not including hydrostatic effects" <<
nl;
433 dict.readEntry(
"pInf", pInf_);
434 dict.readEntry(
"UInf", UInf_);
435 dict.readEntry(
"rhoInf", rhoInf_);
437 const scalar zeroCheck = 0.5*rhoInf_*
magSqr(UInf_) + pInf_;
439 if (
mag(zeroCheck) < ROOTVSMALL)
443 <<
"Coefficient calculation requested, but reference " 444 <<
"pressure level is zero. Please check the supplied " 445 <<
"values of pInf, UInf and rhoInf" <<
endl;
448 rhoInfInitialised_ =
true;
451 resultName_ =
dict.getOrDefault<word>(
"result", resultName());
word dictName() const
The local dictionary name (final part of scoped name)
defineTypeNameAndDebug(ObukhovLength, 0)
static int localConsistency
Enable local consistency.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static const Enum< hydrostaticMode > hydrostaticModeNames
UniformDimensionedField< vector > uniformDimensionedVectorField
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
word fieldName_
Name of field to process.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
mode
Enumeration for pressure calculation mode.
constexpr char nl
The newline '\n' character (0x0a)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual bool read(const dictionary &dict)
Read the fieldExpression data.
No type, or default initialized type.
pressure(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
UniformDimensionedField< scalar > uniformDimensionedScalarField
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Macros for easy insertion into run-time selection tables.
bool read(const char *buf, int32_t &val)
Same as readInt32.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const dimensionSet dimAcceleration
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
hydrostaticMode
Enumeration for hydrostatic contributions.
A class for handling words, derived from Foam::string.
virtual bool read(const dictionary &)
Read the pressure data.
const dimensionSet dimPressure
errorManip< error > abort(error &err)
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())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
const dimensionSet dimDensity
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
#define WarningInFunction
Report a warning using Foam::Warning.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Intermediate class for handling field expression function objects (e.g. blendingFactor etc...
static const word & calculatedType() noexcept
The type name for calculated patch fields.
messageStream Info
Information stream (stdout output on master, null elsewhere)
A class for managing temporary objects.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Request registration (bool: true)
Do not request registration (bool: false)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static const Enum< mode > modeNames
static constexpr const zero Zero
Global zero (0)
const dimensionSet dimVelocity