53 const word& modelType,
59 UName_(coeffs_.getOrDefault<
word>(
"U",
"U")),
60 max_(coeffs_.get<scalar>(
"max"))
73 coeffs_.readEntry(
"max", max_);
84 const scalar maxSqrU =
sqr(max_);
93 for (
const label facei : faces_)
95 auto& Uval = Uif[facei];
97 const scalar magSqrUi =
magSqr(Uval);
99 if (magSqrUi > maxSqrU)
101 Uval *=
sqrt(maxSqrU/
max(magSqrUi, SMALL));
107 label nEdgesAbove(0);
113 if (!Up.fixesValue())
115 for (
auto& Uval : Up)
117 const scalar magSqrUi =
magSqr(Uval);
119 if (magSqrUi > maxSqrU)
121 Uval *=
sqrt(maxSqrU/
max(magSqrUi, SMALL));
130 const auto percent = [](scalar num, label denom) -> scalar
132 return (denom ? 1
e-2*round(1e4*num/denom) : 0);
139 Info<<
type() <<
' ' << name_ <<
" Limited "
140 << nFacesAbove <<
" ("
141 << percent(nFacesAbove, nTotFaces)
142 <<
"%) of faces, with max limit " << max_ <<
endl;
144 if (nFacesAbove || nEdgesAbove)
148 U.correctBoundaryConditions();
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
void setSize(const label n)
Alias for resize()
virtual void correct()
Solve the turbulence equations and correct the turbulence viscosity.
virtual bool read()
Re-read model coefficients if they have changed.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Intermediate abstract class for handling face-set options for the derived faOptions.
bool useSubMesh() const noexcept
True if sub-selection should be used.
Limits the maximum velocity magnitude to the specified max value.
word UName_
Name of operand velocity field.
Base abstract class for handling finite area options (i.e. faOption).
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
wordList fieldNames_
Field names to apply source to - populated by derived models.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)