46#ifndef Foam_scalarPredicates_H
47#define Foam_scalarPredicates_H
69 public List<std::function<bool(Foam::scalar)>>
76 typedef std::function<bool(Foam::scalar)>
unary;
105 const scalar tol = VSMALL
108 return [=](
const scalar val)
119 const scalar tol = VSMALL
122 return [=](
const scalar val)
134 std::less<scalar>(), std::placeholders::_1, opVal
144 std::less_equal<scalar>(), std::placeholders::_1, opVal
155 std::greater<scalar>(), std::placeholders::_1, opVal
165 std::greater_equal<scalar>(), std::placeholders::_1, opVal
175 return [](
const scalar) {
return true; };
181 return [](
const scalar) {
return false; };
190 return [=](
const scalar value)
192 return (test1(value) && test2(value));
199 return [=](
const scalar value)
201 return (test1(value) || test2(value));
213 const scalar tol = VSMALL
221 const scalar tol = VSMALL
228 const scalar tol = VSMALL
234 const std::pair<word, scalar>& op,
235 const scalar tol = VSMALL
242 using List<
unary>::List;
247 std::initializer_list<std::pair<word, scalar>> entries
265 void assign(std::initializer_list<std::pair<word, scalar>> entries);
277 label
find(
const scalar value, label
pos = 0)
const;
283 label
rfind(
const scalar value, label
pos = -1)
const;
290 inline bool contains(
const scalar value, label
pos = 0)
const;
295 inline bool match(
const scalar value)
const;
300 inline bool matchAny(
const scalar value)
const;
305 inline bool matchAll(
const scalar value)
const;
334 bool found(
const scalar value, label
pos = 0)
const
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
UList(const UList< std::function< bool(Foam::scalar)> > &) noexcept=default
A list of unary predicates (tests) on scalars. Includes a number of standard comparison predicates (e...
bool contains(const scalar value, label pos=0) const
Matches any condition in the list after the offset position.
static unary lessOp(const scalar opVal)
Test if value is 'less' than prescribed.
std::function< bool(Foam::scalar)> unary
The unary function type for testing a scalar.
static unary andOp(const unary &test1, const unary &test2)
Combine unary tests as an AND operation.
bool operator()(const scalar value) const
Identical to contains(), match(), for use as a predicate.
static unary greaterEqualOp(const scalar opVal)
Test if value is 'greater_equal' to prescribed.
static unary falseOp()
Predicate that always returns false.
static unary notEqualOp(const scalar opVal, const scalar tol=VSMALL)
Compare for inequality, with specified tolerance (non-negative).
static unary lessEqualOp(const scalar opVal)
Test if value is 'less_equal' to prescribed.
static unary greaterOp(const scalar opVal)
Test if value is 'greater' than prescribed Compare scalar values for inequality.
label find(const scalar value, label pos=0) const
Index of the first matching test for the value.
static unary operation(const opType op, const scalar opVal, const scalar tol=VSMALL)
Standard comparison method by type.
bool found(const scalar value, label pos=0) const
Same as contains().
~scalars()=default
Destructor.
void assign(std::initializer_list< std::pair< word, scalar > > entries)
Assign new predicates from an initializer list of (opName opValue) tuples.
opType
Enumerations for some standard comparison predicates.
@ GREATER_EQUAL
"ge", "greaterEqual", "greaterEq"
@ LESS_EQUAL
"le", "lessEqual", "lessEq"
@ NOT_EQUAL
"neq", "notEqual"
static unary equalOp(const scalar opVal, const scalar tol=VSMALL)
Compare for equality, with specified tolerance (non-negative).
static const Enum< opType > opNames
Names for the opType enumeration.
bool matchAny(const scalar value) const
Matches any condition in the list.
label rfind(const scalar value, label pos=-1) const
Index of the last match for the value.
scalars(std::initializer_list< std::pair< word, scalar > > entries)
Construct from an initializer list of (opName opValue) tuples.
static unary trueOp()
Predicate that always returns true.
labelList matching(const scalar value) const
Extract list indices for all matches.
static unary orOp(const unary &test1, const unary &test2)
Combine unary tests as an OR operation.
bool match(const scalar value) const
Matches any condition in the list.
bool matchAll(const scalar value) const
Matches all conditions in the list.
A class for handling words, derived from Foam::string.
OBJstream os(runTime.globalPath()/outputName)
Constant predicate types.
dimensionedScalar pos(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Istream & operator>>(Istream &, directionInfo &)
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.