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 |
| The value type the MinMax represents. More... | |
| typedef pTraits< T >::cmptType | cmptType |
| Component type. More... | |
Public Types inherited from Tuple2< T, T > | |
| typedef T | first_type |
| Type of member first, the first template parameter (T1) More... | |
| typedef T | second_type |
| Type of member second, the second template parameter (T2) More... | |
Public Member Functions | |
| MinMax () | |
| Construct inverted range. More... | |
| MinMax (const T &minVal, const T &maxVal) | |
| Copy construct from components. More... | |
| MinMax (const std::pair< T, T > &range) | |
| Copy construct from components. More... | |
| MinMax (const Pair< T > &range) | |
| Copy construct from components. More... | |
| MinMax (const Foam::zero) | |
| Construct with a single zero value. More... | |
| MinMax (const Foam::zero_one) | |
| Implicit construct from zero_one as 0-1 range (pTraits zero, one) More... | |
| MinMax (const T &val) | |
| Construct with a single initial value. More... | |
| MinMax (const UList< T > &vals) | |
| Construct from list of values. More... | |
| const T & | min () const noexcept |
| The min value (first) More... | |
| T & | min () noexcept |
| The min value (first) More... | |
| const T & | max () const noexcept |
| The max value (second) More... | |
| T & | max () noexcept |
| The max value (second) More... | |
| T | centre () const |
| The min/max average value. More... | |
| T | span () const |
| The min to max span. Zero if the range is invalid. More... | |
| scalar | mag () const |
| The magnitude of the min to max span. Zero if the range is invalid. More... | |
| bool | empty () const |
| Range is empty if it is inverted. More... | |
| bool | good () const |
| Range is non-inverted. More... | |
| bool | valid () const |
| Range is non-inverted. More... | |
| void | reset () |
| Reset to an inverted (invalid) range. More... | |
| void | reset (const T &val) |
| Reset min/max to be identical to the specified value. More... | |
| void | reset (const T &minVal, const T &maxVal) |
| Reset min/max to specified values. More... | |
| void | clear () |
| Same as reset() - reset to an inverted (invalid) range. More... | |
| bool | intersects (const MinMax< T > &b) const |
| Test if the ranges intersect (exclusive check) More... | |
| bool | overlaps (const MinMax< T > &b) const |
| Test if ranges overlap/touch (inclusive check) More... | |
| int | compare (const T &val) const |
| Compares the min/max range with the specified value. More... | |
| bool | contains (const T &val) const |
| True if the value is within the range (inclusive check) More... | |
| T | clamp (const T &val) const |
| Return value clamped component-wise. More... | |
| MinMax< T > & | add (const MinMax &other) |
| Extend the range to include the other min/max range. More... | |
| MinMax< T > & | add (const T &val) |
| Include the value into the range. More... | |
| MinMax< T > & | add (const UList< T > &vals) |
| Include the values into the range. More... | |
| bool | operator() (const T &val) const |
| Identical to contains(), for use as a predicate. More... | |
| MinMax< T > & | operator &= (const MinMax< T > &b) |
| Restrict min/max range to union with other range. More... | |
| MinMax< T > & | operator+= (const MinMax< T > &b) |
| Extend min/max range to include other range. More... | |
| MinMax< T > & | operator+= (const T &val) |
| Extend min/max range to include value. More... | |
| MinMax< T > & | operator+= (const UList< T > &vals) |
| Extend min/max range to include all values. More... | |
| MinMax< T > & | operator*= (const scalar &s) |
| Multiply range by scalar factor. More... | |
| MinMax< T > & | operator/= (const scalar &s) |
| Divide range by scalar factor. More... | |
| T | clip (const T &val) const |
| Old method name. Same as clamp (2023-01) More... | |
| void | inplaceClip (T &val) const |
| Old method (2023-01) More... | |
Public Member Functions inherited from Tuple2< T, T > | |
| Tuple2 ()=default | |
| Default construct. More... | |
| Tuple2 (const T &f, const T &s) | |
| Copy construct from components. More... | |
| Tuple2 (T &&f, T &&s) | |
| Move construct from components. More... | |
| Tuple2 (const std::pair< T, T > &vals) | |
| Copy construct from std::pair. More... | |
| Tuple2 (std::pair< T, T > &&vals) | |
| Move construct from std::pair. More... | |
| Tuple2 (Istream &is) | |
| Construct from Istream. More... | |
| const T & | first () const noexcept |
| Access the first element. More... | |
| T & | first () noexcept |
| Access the first element. More... | |
| const T & | second () const noexcept |
| Access the second element. More... | |
| T & | second () noexcept |
| Access the second element. More... | |
Static Public Member Functions | |
| static MinMax< T > | ge (const T &minVal) |
| A semi-infinite range from minVal to the type max. More... | |
| static MinMax< T > | le (const T &maxVal) |
| A semi-infinite range from type min to maxVal. More... | |
| static MinMax< T > | zero_one () |
| A 0-1 range corresponding to the pTraits zero, one. More... | |
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 advantage offered by MinMax is to clamp or limit values to a particular range. For example,
scalarMinMax range(lower, upper); scalar val; val = range.clamp(val) .. return clamped values // vs. val = min(max(value, lower), upper)
| typedef T value_type |
|
inlineexplicit |
|
inline |
|
inlinestatic |
A semi-infinite range from minVal to the type max.
Definition at line 24 of file MinMaxI.H.
Referenced by singleDirectionUniformBin::read(), writeFile::read(), externalCoupled::read(), and STDMD::read().

|
inlinestatic |
|
inlinestatic |
|
inlinenoexcept |
The min value (first)
Definition at line 107 of file MinMaxI.H.
Referenced by MinMax< scalar >::add(), Foam::getAnimationColour(), MinMax< scalar >::intersects(), limitFields::limitScalarField(), MinMax< scalar >::overlaps(), probes::storeResults(), turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs(), equalBinWidth::write(), GeometricField< Foam::vector, Foam::fvPatchField, Foam::volMesh >::writeMinMax(), and gltfWriter::writeTemplate().

|
inlinenoexcept |
The max value (second)
Definition at line 121 of file MinMaxI.H.
Referenced by MinMax< scalar >::add(), Foam::getAnimationColour(), MinMax< scalar >::intersects(), limitFields::limitScalarField(), MinMax< scalar >::overlaps(), probes::storeResults(), turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs(), equalBinWidth::write(), and gltfWriter::writeTemplate().

|
inline |
The min to max span. Zero if the range is invalid.
Definition at line 143 of file MinMaxI.H.
Referenced by equalBinWidth::write().

|
inline |
|
inline |
|
inline |
Range is non-inverted.
Definition at line 165 of file MinMaxI.H.
Referenced by MinMax< scalar >::valid(), and equalBinWidth::write().

|
inline |
Reset to an inverted (invalid) range.
Definition at line 172 of file MinMaxI.H.
Referenced by MinMax< scalar >::clear(), boundBox::intersects(), and equalBinWidth::read().

|
inline |
|
inline |
Test if ranges overlap/touch (inclusive check)
Definition at line 204 of file MinMaxI.H.
Referenced by boundBox::intersects().

|
inline |
|
inline |
Return value clamped component-wise.
If the range is invalid, just returns the value.
Definition at line 238 of file MinMaxI.H.
Referenced by MinMax< scalar >::clip(), and MinMax< scalar >::inplaceClip().

|
inline |
Extend the range to include the other min/max range.
Definition at line 250 of file MinMaxI.H.
Referenced by PDRblock::location::edgeLimits(), boundBox::intersects(), and Foam::minMaxMag().

|
inline |
|
inline |
|
inline |
Identical to contains(), for use as a predicate.
Restrict min/max range to union with other range.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.