33template<
class Tout,
class T1,
class UnaryOp>
45 <<
"Field sizes do not match: " << result.
size() <<
" ("
55template<
class Tout,
class T1,
class T2,
class BinaryOp>
68 <<
"Field sizes do not match: " << result.
size() <<
" ("
69 << a.
size() <<
' ' <<
b.size() <<
')' <<
nl
78template<
class T,
class BinaryOp>
91 <<
"Field sizes do not match: " << result.
size() <<
" ("
92 << a.
size() <<
' ' <<
b.size() <<
')' <<
nl
99 result[i] = bop(a[i],
b[i]) ? a[i] :
b[i];
104template<
class T,
class BoolListType,
class FlipOp>
108 const BoolListType& cond,
115 if (result.size() != a.size() || result.size() !=
b.size())
118 <<
"Field sizes do not match: " << result.size() <<
" ("
119 << a.size() <<
' ' <<
b.size() <<
')' << nl
120 << abort(FatalError);
126 result[i] = flip(cond[i]) ? a[i] :
b[i];
131template<
class T,
class FlipOp>
142 if (result.size() != a.size() || result.size() !=
b.size())
145 <<
"Field sizes do not match: " << result.size() <<
" ("
146 << a.size() <<
' ' <<
b.size() <<
')' << nl
147 << abort(FatalError);
153 result[i] = flip(cond[i]) ? a[i] :
b[i];
158template<
class T1,
class T2>
161 const Field<T1>& vals,
162 const Field<T2>& data
165 Tuple2<T1,T2> result(pTraits<T1>::max, Zero);
170 result.first() = vals[i];
171 result.second() = data[i];
174 Pstream::combineReduce(result, minFirstEqOp<T1>());
179template<
class T1,
class T2>
182 const Field<T1>& vals,
183 const Field<T2>& data
186 Tuple2<T1,T2> result(pTraits<T1>::min, Zero);
191 result.first() = vals[i];
192 result.second() = data[i];
195 Pstream::combineReduce(result, maxFirstEqOp<T1>());
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
iterator begin() noexcept
Return an iterator to begin traversing the UList.
const_iterator cend() const noexcept
Return const_iterator to end traversing the constant UList.
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing the constant UList.
void size(const label n)
Older name for setAddressableSize.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
A traits class, which is primarily used for primitives and vector-space.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void assign(Field< Tout > &result, const Field< T1 > &a, const UnaryOp &op)
Populate a field as the result of a unary operation on an input.
void ternarySelect(Field< T > &result, const BoolListType &cond, const Field< T > &a, const Field< T > &b, const FlipOp &flip)
Emulate a ternary operation, selecting values from a or b depending on the conditional.
Tuple2< T1, T2 > findMaxData(const Field< T1 > &vals, const Field< T2 > &data)
Locate the max value in a field and return it and associated data.
Tuple2< T1, T2 > findMinData(const Field< T1 > &vals, const Field< T2 > &data)
Locate the min value in a field and return it and associated data.
void ternary(Field< T > &result, const Field< T > &a, const Field< T > &b, const BinaryOp &bop)
Emulate a ternary operation, selecting values from a or b depending on the binary predicate.
label findMin(const ListType &input, label start=0)
Linear search for the index of the min element, similar to std::min_element but for lists and returns...
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
label findMax(const ListType &input, label start=0)
Linear search for the index of the max element, similar to std::max_element but for lists and returns...
constexpr char nl
The newline '\n' character (0x0a).
Various functors for unary and binary operations. Can be used for parallel combine-reduce operations ...
#define forAll(list, i)
Loop across all elements in list.