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);
136 reduce(nFacesAbove, sumOp<label>());
137 reduce(nEdgesAbove, sumOp<label>());
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();
virtual void correct(areaVectorField &U)
Correct the velocity field.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
addToRunTimeSelectionTable(option, limitHeight, dictionary)
wordList fieldNames_
Field names to apply source to - populated by derived models.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
virtual bool read(const dictionary &dict)
Read dictionary.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Macros for easy insertion into run-time selection tables.
bool useSubMesh() const noexcept
True if sub-selection should be used.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
defineTypeNameAndDebug(limitHeight, 0)
limitVelocity(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Mesh data needed to do the Finite Volume discretisation.
faPatchField< vector > faPatchVectorField
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
virtual bool read(const dictionary &dict)
Read source dictionary.
messageStream Info
Information stream (stdout output on master, null elsewhere)
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
word UName_
Name of operand velocity field.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)