Postprocessing: IncludeMask documentation

This commit is contained in:
Hamidreza
2025-04-15 22:20:00 +03:30
parent 35f10e5a94
commit 7c9a724174
3 changed files with 124 additions and 3 deletions

View File

@ -18,6 +18,39 @@ Licence:
-----------------------------------------------------------------------------*/
/**
* @brief A template class implementing includeMask for filtering data based on field values
*
* The IncludeMask class creates boolean masks that identify which elements from a field
* satisfy a given condition. It applies an operator to each element of a field and
* generates a mask (vector of booleans) where true means the element satisfies the
* condition and should be included.
*
* @tparam T The data type of the field (real, realx3, realx4)
* @tparam Operator The operation class that defines the condition (e.g., greaterThanOp)
*
* The class has a specialized implementation for allOp operator which includes all elements.
*
* Usage example in postprocessDataDict:
* ```
* // Create a dictionary with the required configuration for filtering
*
* {
* includeMask lessThan;
*
* // Diameter of par1 is 0.003, so these settings
* // will select only particles of type par1
* lessThanInfo
* {
* field diameter;
* value 0.0031;
* }
*
* }
*
* ```
*/
#ifndef __IncludeMask_hpp__
#define __IncludeMask_hpp__
@ -31,7 +64,6 @@ Licence:
namespace pFlow
{
template<typename T, typename Operator>
class IncludeMask
:
@ -39,18 +71,24 @@ class IncludeMask
{
public:
/// Type alias for the mask container returned by getMask()
using Mask = typename includeMask::Mask;
private:
/// Boolean vector the filtering status of each element (true = include)
std::vector<bool> mask_;
/// Comparison operator instance that evaluates the filtering condition
Operator operator_;
/// Name of the field to apply filtering on
word fieldName_;
/// Timestamp when mask was last updated (-1 indicates never updated)
timeValue lastUpdated_ = -1;
/// Updates the mask based on current field values if needed, returns true if successful
bool updateMask()
{
timeValue t = database().currentTime();
@ -91,6 +129,7 @@ private:
return true;
}
/// Returns the name of the operator as a string (from operator's TYPENAME)
static
word operatorName()
{
@ -101,6 +140,7 @@ public:
TypeInfoTemplate12("IncludeMask", T, Operator);
/// Constructs an IncludeMask using settings from dictionary and field database
IncludeMask(
const dictionary& dict,
fieldsDataBase& feildsDB)
@ -113,12 +153,14 @@ public:
operatorName()+"Info"
).getVal<word>("field"))
{}
/// Add virtual constructor pattern for creating instances
add_vCtor(
includeMask,
IncludeMask,
dictionary);
/// Returns the mask for filtering elements (updates the mask if necessary)
Mask getMask() override
{
updateMask();