50 const word& modelType,
56 UName_(coeffs_.getOrDefault<
word>(
"U",
"U")),
57 max_(coeffs_.get<scalar>(
"max"))
70 coeffs_.readEntry(
"max", max_);
81 const scalar maxSqrU =
sqr(max_);
90 for (
const label celli : cells_)
92 auto& Uval = Uif[celli];
94 const scalar magSqrUi =
magSqr(Uval);
96 if (magSqrUi > maxSqrU)
98 Uval *=
sqrt(maxSqrU/magSqrUi);
105 label nFacesAbove(0);
112 if (!Up.fixesValue())
115 nTotFaces += Up.size();
117 for (
auto& Uval : Up)
119 const scalar magSqrUi =
magSqr(Uval);
121 if (magSqrUi > maxSqrU)
123 Uval *=
sqrt(maxSqrU/magSqrUi);
132 const auto percent = [](scalar num, label denom) -> scalar
134 return (denom ? 1
e-2*round(1e4*num/denom) : 0);
141 Info<<
type() <<
' ' << name_ <<
" Limited ";
143 Info<< nCellsAbove <<
" ("
144 << percent(nCellsAbove, nTotCells)
151 Info<<
", " << nFacesAbove <<
" ("
152 << percent(nFacesAbove, nTotFaces)
155 Info<<
", with max limit " << max_ <<
endl;
157 if (nCellsAbove || nFacesAbove)
161 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 resize(const label len)
Adjust allocated size of list.
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,...
Limits the maximum velocity magnitude to the specified max value.
Mesh data needed to do the Finite Volume discretisation.
Intermediate abstract class for handling cell-set options for the derived fvOptions.
bool useSubMesh() const noexcept
True if sub-selection should be used.
Corrects velocity field (i.e. T) within a specified region by applying a given maximum velocity magni...
word UName_
Name of operand velocity field.
Base abstract class for handling finite volume options (i.e. fvOption).
wordList fieldNames_
Field names to apply source to - populated by derived models.
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
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)