44 { actionType::ALL,
"all" },
45 { actionType::CLEAR,
"clear" },
46 { actionType::INVERT,
"invert" },
47 { actionType::USE,
"use" },
48 { actionType::ADD,
"add" },
49 { actionType::SUBTRACT,
"subtract" },
50 { actionType::SUBSET,
"subset" },
51 { actionType::IGNORE,
"ignore" },
61 { sourceType::FIELD,
"field" },
62 { sourceType::STRIDE,
"stride" },
71 { logicType::AND,
"and" },
72 { logicType::OR,
"or" },
80 template<
class Type,
class Predicate,
class AccessOp>
85 const Predicate& accept,
92 const label len = selection.
size();
99 if (actionType::USE == action)
105 for (label parceli = 0; parceli < len; ++parceli)
107 if (accept(aop(list[parceli])))
109 selection.
set(parceli);
115 case actionType::SUBTRACT:
117 for (label parceli = 0; parceli < len; ++parceli)
119 if (accept(aop(list[parceli])))
121 selection.
unset(parceli);
127 case actionType::SUBSET:
129 for (
const label parceli : selection)
131 if (!accept(aop(list[parceli])))
133 selection.unset(parceli);
165 label nParcels = pointsPtr->size();
170 reduce(nParcels, sumOp<label>());
172 Log <<
"Applying parcel filtering to " << nParcels <<
" parcels" <<
nl;
184 predicates::scalars tests(3);
188 if (!dEntry.isDict())
191 <<
"Ignoring non-dictionary entry "
207 Log <<
"- select all" <<
nl;
213 Log <<
"- clear" <<
nl;
219 Log <<
"- invert" <<
nl;
240 const label stride =
dict.get<label>(
"stride");
246 <<
" stride " << stride <<
nl;
252 <<
"Ignoring bad value for stride=" << stride <<
nl
255 else if (stride == 1)
280 [=](
const label
id) ->
bool {
return !(
id % stride); },
290 const word fieldName(
dict.get<word>(
"field"));
292 const auto* labelFld =
295 const auto* scalarFld =
298 const auto* vectorFld =
304 if (!labelFld && !scalarFld && !vectorFld)
308 <<
"No scalar/vector parcel field: " << fieldName
309 <<
" ignoring selection" <<
nl
316 ITstream& is =
e.stream();
323 Tuple2<word,scalar> expr1(is);
328 Log <<
" : " << expr1;
330 else if (9 == is.size())
336 Tuple2<word,scalar> expr1(is);
338 Tuple2<word,scalar> expr2(is);
358 Log <<
" : " << expr1 <<
' ' << logicName <<
' ' << expr2;
398 [](
const vector& val) -> scalar
400 return Foam::mag(val);
bool empty() const noexcept
True if the list is empty.
static const Enum< actionType > actionNames
Names for the actionType.
sourceType
Enumeration defining the valid sources.
@ STRIDE
"stride" - select based on stride (parcel id)
@ FIELD
"field" - select based on field value
bitSet parcelAddr_
The filtered parcel addressing. Eg, for the current cloud.
bool calculateFilter(const objectRegistry &obrTmp, const bool log=true)
Calculate parcel selection filter.
static const Enum< logicType > logicNames
Names for the logicType.
actionType
Enumeration defining the valid selection actions.
@ CLEAR
"clear" - clear the selection
@ IGNORE
"ignore" - dummy no-op
@ SUBTRACT
"subtract" - remove parcel selection
@ ALL
"all" - select all parcels
@ INVERT
"invert" - invert the selection
@ ADD
"add" - parcel selection
dictionary parcelSelect_
The filtered parcel addressing. Eg, for the current cloud.
logicType
Enumeration defining and/or logic.
static const Enum< sourceType > sourceNames
Names for the sourceType.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
An input stream of tokens.
void resize(const label numElem, const unsigned int val=0u)
Reset addressable list size, does not shrink the allocated size.
label size() const noexcept
Number of entries.
void clear()
Clear the list, i.e. set addressable size to zero.
void reset()
Clear all bits but do not adjust the addressable size.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & first()
Access first element of the list, position [0].
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...
void set(const bitSet &bitset)
Set specified bits from another bitset.
bitSet & unset(const bitSet &other)
Unset (subtract) the bits specified in the other bitset, which is a set difference corresponds to the...
static const IOField< point > * findIOPosition(const objectRegistry &obr)
Locate the "position" IOField within object registry.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A keyword and a list of tokens is an 'entry'.
Registry of regIOobjects.
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
A list of unary predicates (tests) on scalars. Includes a number of standard comparison predicates (e...
static unary andOp(const unary &test1, const unary &test2)
Combine unary tests as an AND operation.
static unary operation(const opType op, const scalar opVal, const scalar tol=VSMALL)
Standard comparison method by type.
static unary orOp(const unary &test1, const unary &test2)
Combine unary tests as an OR operation.
A class for handling words, derived from Foam::string.
#define WarningInFunction
Report a warning using Foam::Warning.
static void apply(bitSet &selection, const Detail::parcelSelection::actionType action, const Predicate &accept, const UList< Type > &list, const AccessOp &aop)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar log(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
Field< vector > vectorField
Specialisation of Field<T> for vector.
Field< label > labelField
Specialisation of Field<T> for label.
constexpr char nl
The newline '\n' character (0x0a).
Object access operator or list access operator (default is pass-through).