49 { limitType::CLAMP_MIN,
"min" },
50 { limitType::CLAMP_MAX,
"max" },
52 { limitType::CLAMP_RANGE,
"both" },
69 auto&
field = *fieldPtr;
71 Log <<
" Limiting field " << fieldName <<
":";
79 Log <<
" min(" << currentRange.min() <<
')';
83 Log <<
" max(" << currentRange.max() <<
')';
117 withBounds_(limitType::CLAMP_NONE),
129 withBounds_ = limitType::CLAMP_NONE;
135 withBounds_ = limitTypeNames_.get(
"limit",
dict);
137 if (withBounds_ & limitType::CLAMP_MIN)
139 min_ =
dict.get<scalar>(
"min");
140 Info<<
" Imposing lower limit " << min_ <<
nl;
143 if (withBounds_ & limitType::CLAMP_MAX)
145 max_ =
dict.get<scalar>(
"max");
146 Info<<
" Imposing upper limit " << max_ <<
nl;
149 fieldSet_.read(
dict);
162 fieldSet_.updateSelection();
166 label count = 0, total = 0;
168 for (
const word& fieldName : fieldSet_.selectionNames())
173 limitScalarField(fieldName)
174 || limitField<vector>(fieldName)
175 || limitField<sphericalTensor>(fieldName)
176 || limitField<symmTensor>(fieldName)
177 || limitField<tensor>(fieldName)
186 Log <<
" - limited " <<
count <<
'/' << total <<
" fields";
197 for (
const word& fieldName : fieldSet_.selectionNames())
199 lookupObject<regIOobject>(fieldName).write();
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
A min/max value pair with additional methods. In addition to conveniently storing values,...
const T & max() const noexcept
The max value.
const T & min() const noexcept
The min value.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Abstract base-class for Time/database function objects.
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
const fvMesh & mesh_
Reference to the fvMesh.
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
Limits input fields to user-specified min and max bounds.
@ CLAMP_RANGE
Clamp min/max.
@ CLAMP_MAX
Clamp maximum value.
@ CLAMP_MIN
Clamp minimum value.
scalar min_
Minimum limit.
bool limitScalarField(const word &fieldName)
Limit a scalar field.
volFieldSelection fieldSet_
Fields to limit.
static const Enum< limitType > limitTypeNames_
Limit type names.
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
scalar max_
Maximum limit.
limitFields(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
virtual bool execute()
Execute the function-object operations.
bool limitField(const word &fieldName)
Limit a field.
virtual bool write()
Write the function-object results.
limitType withBounds_
Limiting type.
const ObjectType & lookupObject(const word &fieldName) const
Lookup and return object (eg, a field) from the (sub) objectRegistry.
const objectRegistry & obr_
Reference to the region objectRegistry.
Type * getObjectPtr(const word &name, const bool recursive=false) const
Return non-const pointer to the object of the given Type, using a const-cast to have it behave like a...
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Namespace for handling debugging switches.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
bool read(const char *buf, int32_t &val)
Same as readInt32.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
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.
MinMax< Type > gMinMax(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
constexpr char nl
The newline '\n' character (0x0a).