53 const word& modelType,
56 const word& defaultAreaName
60 UName_(coeffs_.getOrDefault<
word>(
"U",
"U")),
61 max_(coeffs_.get<scalar>(
"max"))
74 coeffs_.readEntry(
"max", max_);
85 const scalar maxSqrU =
sqr(max_);
94 for (
const label facei : faces_)
96 auto& Uval = Uif[facei];
98 const scalar magSqrUi =
magSqr(Uval);
100 if (magSqrUi > maxSqrU)
102 Uval *=
sqrt(maxSqrU/
max(magSqrUi, SMALL));
108 label nEdgesAbove(0);
114 if (!Up.fixesValue())
116 for (
auto& Uval : Up)
118 const scalar magSqrUi =
magSqr(Uval);
120 if (magSqrUi > maxSqrU)
122 Uval *=
sqrt(maxSqrU/
max(magSqrUi, SMALL));
131 const auto percent = [](scalar num, label denom) -> scalar
133 return (denom ? 1
e-2*round(1e4*num/denom) : 0);
137 reduce(nFacesAbove, sumOp<label>());
138 reduce(nEdgesAbove, sumOp<label>());
140 Info<<
type() <<
' ' << name_ <<
" Limited "
141 << nFacesAbove <<
" ("
142 << percent(nFacesAbove, nTotFaces)
143 <<
"%) of faces, with max limit " << max_ <<
endl;
145 if (nFacesAbove || nEdgesAbove)
149 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.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
labelList faces_
Set of faces to apply source to.
virtual bool read(const dictionary &dict)
Read source dictionary.
bool useSubMesh() const noexcept
True if sub-selection should be used.
faceSetOption(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh, const word &defaultAreaName=word())
Construct from components.
Limits the maximum velocity magnitude to the specified max value.
word UName_
Name of operand velocity field.
limitVelocity(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh, const word &defaultAreaName=word())
Construct from components.
virtual void correct(areaVectorField &U)
Correct the velocity field.
virtual bool read(const dictionary &dict)
Read dictionary.
scalar max_
Maximum velocity magnitude.
Base abstract class for handling finite area options (i.e. faOption).
const fvMesh & mesh() const noexcept
Return const access to the volume mesh.
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
wordList fieldNames_
Field names to apply source to - populated by derived models.
dictionary coeffs_
Dictionary containing source coefficients.
const word & name() const noexcept
The source name.
const word name_
Source name.
Mesh data needed to do the Finite Volume discretisation.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Namespace for finite-area.
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.
faPatchField< vector > faPatchVectorField
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
GeometricField< vector, faPatchField, areaMesh > areaVectorField
dimensionedScalar sqrt(const dimensionedScalar &ds)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
Field< vector > vectorField
Specialisation of Field<T> for vector.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)