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
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 349 Ostream&
operator<<(Ostream&
os,
const predicates::scalars& list)
355 Istream&
operator>>(Istream& is, predicates::scalars& list);
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.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
bool match(const scalar value) const
Matches any condition in the list.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label find(const scalar value, label pos=0) const
Index of the first matching test for the value.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
static unary notEqualOp(const scalar opVal, const scalar tol=VSMALL)
Compare for inequality, with specified tolerance (non-negative)
bool contains(const scalar value, label pos=0) const
Matches any condition in the list after the offset position.
"le", "lessEqual", "lessEq"
static unary equalOp(const scalar opVal, const scalar tol=VSMALL)
Compare for equality, with specified tolerance (non-negative)
bool matchAny(const scalar value) const
Matches any condition in the list.
void assign(std::initializer_list< std::pair< word, scalar >> entries)
Assign new predicates from an initializer list of (opName opValue) tuples.
static unary lessOp(const scalar opVal)
Test if value is 'less' than prescribed.
bool found(const scalar value, label pos=0) const
Same as contains()
dimensionedScalar pos(const dimensionedScalar &ds)
A class for handling words, derived from Foam::string.
label rfind(const scalar value, label pos=-1) const
Index of the last match for the value.
Istream & operator>>(Istream &, directionInfo &)
static Istream & input(Istream &is, IntRange< T > &range)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
static unary orOp(const unary &test1, const unary &test2)
Combine unary tests as an OR operation.
OBJstream os(runTime.globalPath()/outputName)
labelList matching(const scalar value) const
Extract list indices for all matches.
~scalars()=default
Destructor.
static unary andOp(const unary &test1, const unary &test2)
Combine unary tests as an AND operation.
static unary greaterEqualOp(const scalar opVal)
Test if value is 'greater_equal' to prescribed.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
static unary falseOp()
Predicate that always returns false.
bool matchAll(const scalar value) const
Matches all conditions in the list.
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.
bool operator()(const scalar value) const
Identical to contains(), match(), for use as a predicate.
std::function< bool(Foam::scalar)> unary
The unary function type for testing a scalar.
static unary operation(const opType op, const scalar opVal, const scalar tol=VSMALL)
Standard comparison method by type.
A list of unary predicates (tests) on scalars. Includes a number of standard comparison predicates (e...
static const Enum< opType > opNames
Names for the opType enumeration.
opType
Enumerations for some standard comparison predicates.
"ge", "greaterEqual", "greaterEq"