38 const bool pRefRequired
61 if (
dict.found(
"pMax") &&
dict.found(
"pMin"))
63 dict.readEntry(
"pMax", pMax_.value()); limitMaxP_ = true;
64 dict.readEntry(
"pMin", pMin_.value()); limitMinP_ = true;
68 const volScalarField::Boundary& pbf = p.boundaryField();
69 const volScalarField::Boundary& rhobf = rho.boundaryField();
71 scalar rhoRefMax = -GREAT;
72 scalar rhoRefMin = GREAT;
73 bool rhoLimits = false;
77 if (pbf[patchi].fixesValue())
82 pMax = max(pMax, max(pbf[patchi]));
83 pMin = min(pMin, min(pbf[patchi]));
85 rhoRefMax = max(rhoRefMax, max(rhobf[patchi]));
86 rhoRefMin = min(rhoRefMin, min(rhobf[patchi]));
100 if (
dict.readIfPresent(
"pMax", pMax_.value()))
104 else if (
dict.found(
"pMaxFactor"))
108 FatalIOErrorInFunction(dict)
109 <<
"'pMaxFactor' specified rather than 'pMax'" << nl
110 <<
" but the corresponding reference pressure cannot"
111 " be evaluated from the boundary conditions." << nl
112 <<
" Please specify 'pMax' rather than 'pMaxFactor'"
113 << exit(FatalIOError);
116 pMax_.value() = pMax *
dict.get<scalar>(
"pMaxFactor");
119 else if (
dict.found(
"rhoMax"))
123 IOWarningInFunction(dict)
124 <<
"'rhoMax' specified rather than 'pMax' or 'pMaxFactor'"
126 <<
" This is supported for backward-compatibility but"
127 " 'pMax' or 'pMaxFactor' are more reliable." << endl;
131 FatalIOErrorInFunction(dict)
132 <<
"'rhoMax' specified rather than 'pMax'" << nl
133 <<
" but the corresponding reference pressure cannot"
134 " be evaluated from the boundary conditions." << nl
135 <<
" Please specify 'pMax' rather than 'rhoMax'"
136 << exit(FatalIOError);
142 <<
"'rhoMax' specified rather than 'pMaxFactor'" <<
nl
143 <<
" but the corresponding reference density cannot"
144 " be evaluated from the boundary conditions." <<
nl
145 <<
" Please specify 'pMaxFactor' rather than 'rhoMax'"
151 pMax_.value() =
max(
rhoMax.value()/rhoRefMax, 1)*pMax;
164 <<
"'pMinFactor' specified rather than 'pMin'" <<
nl
165 <<
" but the corresponding reference pressure cannot"
166 " be evaluated from the boundary conditions." <<
nl
167 <<
" Please specify 'pMin' rather than 'pMinFactor'"
171 pMin_.value() =
pMin *
dict.
get<scalar>(
"pMinFactor");
179 <<
"'rhoMin' specified rather than 'pMin' or 'pMinFactor'" <<
nl
180 <<
" This is supported for backward-compatibility but"
181 " 'pMin' or 'pMinFactor' are more reliable." <<
endl;
186 <<
"'rhoMin' specified rather than 'pMin'" <<
nl
187 <<
" but the corresponding reference pressure cannot"
188 " be evaluated from the boundary conditions." <<
nl
189 <<
" Please specify 'pMin' rather than 'rhoMin'"
196 <<
"'rhoMin' specified rather than 'pMinFactor'" <<
nl
197 <<
" but the corresponding reference density cannot"
198 " be evaluated from the boundary conditions." <<
nl
199 <<
" Please specify 'pMinFactor' rather than 'rhoMin'"
210 if (limitMaxP_ || limitMinP_)
212 Info<<
"pressureControl" <<
nl;
216 Info<<
" pMax " << pMax_.value() <<
nl;
221 Info<<
" pMin " << pMin_.value() <<
nl;
233 if (limitMaxP_ || limitMinP_)
237 const scalar pMax =
max(
p).value();
239 if (pMax > pMax_.value())
241 Info<<
"pressureControl: p max " << pMax <<
endl;
const dimensionedScalar & pMin
static void reduceAnd(bool &value, const int communicator=worldComm)
Logical (and) reduction (MPI_AllReduce).
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
const Type & value() const noexcept
Return const reference to value.
bool limit(volScalarField &p) const
Limit the pressure if necessary and return true if so.
pressureControl(const volScalarField &p, const volScalarField &rho, const dictionary &dict, const bool pRefRequired=true)
Construct from the SIMPLE/PIMPLE sub-dictionary.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Find the reference cell nearest (in index) to the given cell but which is not on a cyclic,...
const dimensionedScalar rhoMin
const dimensionedScalar rhoMax
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
const dimensionSet dimPressure
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0).
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const dimensionSet dimDensity
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool setRefCell(const volScalarField &field, const volScalarField &fieldRef, const dictionary &dict, label &refCelli, scalar &refValue, const bool forceReference=false)
If the field fieldRef needs referencing find the reference cell nearest.
constexpr char nl
The newline '\n' character (0x0a).