A min/max value pair with additional methods. In addition to conveniently storing values, it can be used for logic operations or to modify data. A few global functions and functors are also provided. More...
Public Types | |
typedef T | value_type |
typedef pTraits< T >::cmptType | cmptType |
Public Member Functions | |
MinMax () | |
MinMax (const T &minVal, const T &maxVal) | |
MinMax (const std::pair< T, T > &range) | |
MinMax (const Pair< T > &range) | |
MinMax (const Foam::zero) | |
MinMax (const T &val) | |
MinMax (const UList< T > &vals) | |
const T & | min () const noexcept |
T & | min () noexcept |
const T & | max () const noexcept |
T & | max () noexcept |
T | centre () const |
T | span () const |
scalar | mag () const |
bool | empty () const |
bool | valid () const |
void | clear () |
bool | intersect (const MinMax< T > &b) |
bool | overlaps (const MinMax< T > &b) const |
int | compare (const T &val) const |
bool | contains (const T &val) const |
const T & | clip (const T &val) const |
bool | inplaceClip (T &val) const |
MinMax< T > & | add (const MinMax &other) |
MinMax< T > & | add (const T &val) |
MinMax< T > & | add (const UList< T > &vals) |
bool | operator() (const T &val) const |
MinMax< T > & | operator+= (const MinMax< T > &b) |
MinMax< T > & | operator+= (const T &val) |
MinMax< T > & | operator+= (const UList< T > &vals) |
MinMax< T > & | operator*= (const scalar &s) |
MinMax< T > & | operator/= (const scalar &s) |
Static Public Member Functions | |
static MinMax< T > | ge (const T &minVal) |
static MinMax< T > | le (const T &maxVal) |
static MinMax< T > | zero_one () |
A min/max value pair with additional methods. In addition to conveniently storing values, it can be used for logic operations or to modify data. A few global functions and functors are also provided.
Determine min/max limits from a List of values:
List<scalar> values = ...; // on construction MinMax<scalar> range(values); range.clear(); range += val; // global minMax() function Info<< minMax(values) << nl;
General comparison operations
scalar val; if (val < range) ... value is below range min if (range.contains(val)) ... value within range if (range.compare(val) > 0) ... value is above range max if (range(val)) ... value within range - as predicate
Since the range has a predicate form, it can be used as a filter method. For example,
Info<< "values in range: " << subsetList(values, range) << nl; boolList mask = ListOps::create<bool>(values, range); Info<< "values values in range " << mask << nl;
One particular advantage offered by MinMax is to clip or limit values to a particular range. For example,
scalarMinMax range(lower, upper); scalar val; val = range.clip(val) .. return clip values // vs. val = min(max(value, lower, upper))
Or when working on lists, the values can be limited in a single pass of the data without intermediate memory allocation.
scalarField values = ...; for (scalar& val : values) { range.inplaceClip(val); } // vs. values = min(max(values, lower, upper))
typedef T value_type |
|
inlineexplicit |
|
inlinestatic |
Definition at line 24 of file MinMaxI.H.
Referenced by electrostaticDepositionFvPatchScalarField::electrostaticDepositionFvPatchScalarField(), writeFile::read(), log::read(), heatTransferCoeff::read(), electricPotential::read(), externalCoupled::read(), and STDMD::read().
|
inlinestatic |
|
inlinestatic |
Definition at line 38 of file MinMaxI.H.
Referenced by lumpedPointMovement::readDict().
|
inlinenoexcept |
Referenced by MinMax< scalar >::add(), MinMax< scalar >::overlaps(), and GeometricField< scalar, faPatchField, areaMesh >::writeMinMax().
|
inlinenoexcept |
|
inlinenoexcept |
Referenced by MinMax< scalar >::add(), and MinMax< scalar >::overlaps().
|
inlinenoexcept |
|
inline |
Definition at line 256 of file MinMaxI.H.
Referenced by PDRblock::location::edgeLimits(), Foam::minMax(), Foam::minMaxMag(), minMaxOp< T >::operator()(), and Foam::operator+().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.