GEOS
Classes | List of all members
geos::ComponentMask< MAX_COMP > Class Template Reference

Utility class that represents a mask for included/excluded component of a mask. More...

#include <ComponentMask.hpp>

Classes

class  Iterator
 Forward const iterator over the set components (bits). More...
 

Public Member Functions

Constructors.
GEOS_HOST_DEVICE ComponentMask (int const numComp, bool const includeAll)
 Constructor. More...
 
GEOS_HOST_DEVICE ComponentMask (int const numComp=0)
 Constructor. More...
 
GEOS_HOST_DEVICE ComponentMask (int const numComp, int const lo, int const hi)
 Range constructor, includes contiguous range of components. More...
 
template<int N, typename = std::enable_if_t< ( N < MAX_COMP ) >>
GEOS_HOST_DEVICE ComponentMask (ComponentMask< N > const &other)
 Converting constructor from another mask with fewer max components. More...
 
Inspection methods.
GEOS_HOST_DEVICE Iterator begin () const
 
GEOS_HOST_DEVICE Iterator end () const
 
GEOS_HOST_DEVICE int size () const
 
GEOS_HOST_DEVICE int numComp () const
 
GEOS_HOST_DEVICE bool empty () const
 
GEOS_HOST_DEVICE bool operator[] (int const i) const
 Check if a particular component is selected. More...
 

Modification methods/operators.

GEOS_HOST_DEVICE void clear ()
 Clear the mask, removing selected components.
 
GEOS_HOST_DEVICE void setNumComp (int const numComp)
 Set new component limit and truncate all components above. More...
 
GEOS_HOST_DEVICE void set (int const i)
 Add a component. More...
 
GEOS_HOST_DEVICE void unset (int const i)
 Remove a component. More...
 
GEOS_HOST_DEVICE void invert ()
 Invert component selection.
 
GEOS_HOST_DEVICE ComponentMaskoperator+= (int const i)
 Add a component. More...
 
GEOS_HOST_DEVICE ComponentMaskoperator-= (int const i)
 Remove a component. More...
 
GEOS_HOST_DEVICE ComponentMask operator~ () const
 Negation operator (inverts component selection). More...
 
GEOS_HOST_DEVICE friend ComponentMask operator+ (ComponentMask const &mask, int const i)
 Make a new mask by adding a component. More...
 
GEOS_HOST_DEVICE friend ComponentMask operator+ (int const i, ComponentMask const &mask)
 Make a new mask by adding a component. More...
 
GEOS_HOST_DEVICE friend ComponentMask operator- (ComponentMask const &mask, int const i)
 Make a new mask by removing a component. More...
 
GEOS_HOST_DEVICE friend ComponentMask operator- (int const i, ComponentMask const &mask)
 Make a new mask by removing a component. More...
 

Detailed Description

template<int MAX_COMP>
class geos::ComponentMask< MAX_COMP >

Utility class that represents a mask for included/excluded component of a mask.

Template Parameters
MAX_COMPmaximum number of components

The main advantage over std::bitset<N> is being CUDA-friendly. In addition, it provides convenience constructors and iteration over set bits.

Class intended to be used by DofManager to specify component mappings when constructing restriction/prolongation operators and during field-vector data copying.

Definition at line 90 of file ComponentMask.hpp.

Constructor & Destructor Documentation

◆ ComponentMask() [1/4]

template<int MAX_COMP>
GEOS_HOST_DEVICE geos::ComponentMask< MAX_COMP >::ComponentMask ( int const  numComp,
bool const  includeAll 
)
inline

Constructor.

Parameters
numComptotal number of components
includeAllif true, initializes the mask to include rather than exclude all components

Definition at line 113 of file ComponentMask.hpp.

◆ ComponentMask() [2/4]

template<int MAX_COMP>
GEOS_HOST_DEVICE geos::ComponentMask< MAX_COMP >::ComponentMask ( int const  numComp = 0)
inlineexplicit

Constructor.

Parameters
numComptotal number of components

Definition at line 124 of file ComponentMask.hpp.

◆ ComponentMask() [3/4]

template<int MAX_COMP>
GEOS_HOST_DEVICE geos::ComponentMask< MAX_COMP >::ComponentMask ( int const  numComp,
int const  lo,
int const  hi 
)
inline

Range constructor, includes contiguous range of components.

Parameters
numComptotal number of components
lofirst component number to include
hione-past last component number to include
Note
[lo,hi) form a half-open range, indexing is zero-based.

Definition at line 136 of file ComponentMask.hpp.

◆ ComponentMask() [4/4]

template<int MAX_COMP>
template<int N, typename = std::enable_if_t< ( N < MAX_COMP ) >>
GEOS_HOST_DEVICE geos::ComponentMask< MAX_COMP >::ComponentMask ( ComponentMask< N > const &  other)
inline

Converting constructor from another mask with fewer max components.

Template Parameters
Mnumber of components in source mask
Parameters
othersource mask

Definition at line 152 of file ComponentMask.hpp.

Member Function Documentation

◆ begin()

template<int MAX_COMP>
GEOS_HOST_DEVICE Iterator geos::ComponentMask< MAX_COMP >::begin ( ) const
inline
Returns
iterator to the start of the component index range

Definition at line 286 of file ComponentMask.hpp.

◆ empty()

template<int MAX_COMP>
GEOS_HOST_DEVICE bool geos::ComponentMask< MAX_COMP >::empty ( ) const
inline
Returns
true if mask is empty (no components selected), false otherwise.

Definition at line 328 of file ComponentMask.hpp.

◆ end()

template<int MAX_COMP>
GEOS_HOST_DEVICE Iterator geos::ComponentMask< MAX_COMP >::end ( ) const
inline
Returns
iterator past the end of the component index range

Definition at line 295 of file ComponentMask.hpp.

◆ numComp()

template<int MAX_COMP>
GEOS_HOST_DEVICE int geos::ComponentMask< MAX_COMP >::numComp ( ) const
inline
Returns
number of components

Definition at line 319 of file ComponentMask.hpp.

◆ operator+=()

template<int MAX_COMP>
GEOS_HOST_DEVICE ComponentMask& geos::ComponentMask< MAX_COMP >::operator+= ( int const  i)
inline

Add a component.

Parameters
icomponent index
Returns
reference to this object

Definition at line 417 of file ComponentMask.hpp.

◆ operator-=()

template<int MAX_COMP>
GEOS_HOST_DEVICE ComponentMask& geos::ComponentMask< MAX_COMP >::operator-= ( int const  i)
inline

Remove a component.

Parameters
icomponent index
Returns
reference to this object

Definition at line 429 of file ComponentMask.hpp.

◆ operator[]()

template<int MAX_COMP>
GEOS_HOST_DEVICE bool geos::ComponentMask< MAX_COMP >::operator[] ( int const  i) const
inline

Check if a particular component is selected.

Parameters
icomponent index
Returns
true if i-th component is selected, false otherwise

Definition at line 339 of file ComponentMask.hpp.

◆ operator~()

template<int MAX_COMP>
GEOS_HOST_DEVICE ComponentMask geos::ComponentMask< MAX_COMP >::operator~ ( ) const
inline

Negation operator (inverts component selection).

Returns
new mask that is the inversion of this object

Definition at line 440 of file ComponentMask.hpp.

◆ set()

template<int MAX_COMP>
GEOS_HOST_DEVICE void geos::ComponentMask< MAX_COMP >::set ( int const  i)
inline

Add a component.

Parameters
icomponent index

Definition at line 382 of file ComponentMask.hpp.

◆ setNumComp()

template<int MAX_COMP>
GEOS_HOST_DEVICE void geos::ComponentMask< MAX_COMP >::setNumComp ( int const  numComp)
inline

Set new component limit and truncate all components above.

Parameters
numCompnew max components value

Definition at line 366 of file ComponentMask.hpp.

◆ size()

template<int MAX_COMP>
GEOS_HOST_DEVICE int geos::ComponentMask< MAX_COMP >::size ( ) const
inline
Returns
the number of set components.

Definition at line 304 of file ComponentMask.hpp.

◆ unset()

template<int MAX_COMP>
GEOS_HOST_DEVICE void geos::ComponentMask< MAX_COMP >::unset ( int const  i)
inline

Remove a component.

Parameters
icomponent index

Definition at line 394 of file ComponentMask.hpp.

Friends And Related Function Documentation

◆ operator+ [1/2]

template<int MAX_COMP>
GEOS_HOST_DEVICE friend ComponentMask operator+ ( ComponentMask< MAX_COMP > const &  mask,
int const  i 
)
friend

Make a new mask by adding a component.

Parameters
maskthe mask to append to
icomponent index
Returns
new component mask

Definition at line 454 of file ComponentMask.hpp.

◆ operator+ [2/2]

template<int MAX_COMP>
GEOS_HOST_DEVICE friend ComponentMask operator+ ( int const  i,
ComponentMask< MAX_COMP > const &  mask 
)
friend

Make a new mask by adding a component.

Parameters
icomponent index
maskthe mask to append to
Returns
new component mask

Definition at line 468 of file ComponentMask.hpp.

◆ operator- [1/2]

template<int MAX_COMP>
GEOS_HOST_DEVICE friend ComponentMask operator- ( ComponentMask< MAX_COMP > const &  mask,
int const  i 
)
friend

Make a new mask by removing a component.

Parameters
maskthe mask to remove from
icomponent index
Returns
new component mask

Definition at line 480 of file ComponentMask.hpp.

◆ operator- [2/2]

template<int MAX_COMP>
GEOS_HOST_DEVICE friend ComponentMask operator- ( int const  i,
ComponentMask< MAX_COMP > const &  mask 
)
friend

Make a new mask by removing a component.

Parameters
icomponent index
maskthe mask to remove from
Returns
new component mask

Definition at line 494 of file ComponentMask.hpp.


The documentation for this class was generated from the following file: