Reference documentation for deal.II version 9.1.1
|
#include <deal.II/fe/block_mask.h>
Public Member Functions | |
BlockMask ()=default | |
BlockMask (const std::vector< bool > &block_mask) | |
BlockMask (const unsigned int n_blocks, const bool initializer) | |
unsigned int | size () const |
bool | operator[] (const unsigned int block_index) const |
bool | represents_n_blocks (const unsigned int n) const |
unsigned int | n_selected_blocks (const unsigned int overall_number_of_blocks=numbers::invalid_unsigned_int) const |
unsigned int | first_selected_block (const unsigned int overall_number_of_blocks=numbers::invalid_unsigned_int) const |
bool | represents_the_all_selected_mask () const |
BlockMask | operator| (const BlockMask &mask) const |
BlockMask | operator & (const BlockMask &mask) const |
bool | operator== (const BlockMask &mask) const |
bool | operator!= (const BlockMask &mask) const |
std::size_t | memory_consumption () const |
Private Attributes | |
std::vector< bool > | block_mask |
Friends | |
std::ostream & | operator<< (std::ostream &out, const BlockMask &mask) |
This class represents a mask that can be used to select individual vector blocks of a finite element (see also this glossary entry). It will typically have as many elements as the finite element has blocks, and one can use operator[]
to query whether a particular block has been selected.
The semantics of this class are the same as the related ComponentMask class, i.e., a default constructed mask represents all possible blocks. See there for more information about these semantics.
Objects of this kind are used in many places where one wants to restrict operations to a certain subset of blocks, e.g. in DoFTools::extract_dofs. These objects can either be created by hand, or, simpler, by asking the finite element to generate a block mask from certain selected blocks using code such as this where we create a mask that only denotes the velocity block of a Stokes element (see Handling vector valued problems):
Note that by wrapping the velocity elements into a single FESystem object we make sure that the overall element has only 2 blocks. The result is a block mask that, in both 2d and 3d, would have values [false, true]
. (Compare this to the corresponding component mask discussed in the ComponentMask documentation.) Similarly, using
would result in a mask [true, false]
in both 2d and 3d.
Definition at line 74 of file block_mask.h.
|
default |
Initialize a block mask. The default is that a block mask represents a set of blocks that are all selected, i.e., calling this constructor results in a block mask that always returns true
whenever asked whether a block is selected.
|
inline |
Initialize an object of this type with a set of selected blocks specified by the argument.
block_mask | A vector of true/false entries that determine which blocks of a finite element are selected. If the length of the given vector is zero, then this interpreted as the case where every block is selected. |
Definition at line 240 of file block_mask.h.
|
inline |
Initialize the block mask with a number of elements that are either all true or false.
n_blocks | The number of elements of this mask |
initializer | The value each of these elements is supposed to have: either true or false. |
Definition at line 245 of file block_mask.h.
|
inline |
If this block mask has been initialized with a mask of size greater than zero, then return the size of the mask represented by this object. On the other hand, if this mask has been initialized as an empty object that represents a mask that is true for every element (i.e., if this object would return true when calling represents_the_all_selected_mask()) then return zero since no definite size is known.
Definition at line 251 of file block_mask.h.
|
inline |
Return whether a particular block is selected by this mask. If this mask represents the case of an object that selects all blocks (e.g. if it is created using the default constructor or is converted from an empty vector of type bool) then this function returns true regardless of the given argument.
block_index | The index for which the function should return whether the block is selected. If this object represents a mask in which all blocks are always selected then any index is allowed here. Otherwise, the given index needs to be between zero and the number of blocks that this mask represents. |
Definition at line 257 of file block_mask.h.
|
inline |
Return whether this block mask represents a mask with exactly n
blocks. This is true if either it was initialized with a vector with exactly n
entries of type bool
(in this case, n
must equal the result of size()) or if it was initialized with an empty vector (or using the default constructor) in which case it can represent a mask with an arbitrary number of blocks and will always say that a block is selected.
Definition at line 275 of file block_mask.h.
|
inline |
Return the number of blocks that are selected by this mask.
Since empty block masks represent a block mask that would return true
for every block, this function may not know the true size of the block mask and it therefore requires an argument that denotes the overall number of blocks.
If the object has been initialized with a non-empty mask (i.e., if the size() function returns something greater than zero, or equivalently if represents_the_all_selected_mask() returns false) then the argument can be omitted and the result of size() is taken.
Definition at line 282 of file block_mask.h.
|
inline |
Return the index of the first selected block. The argument is there for the same reason it exists with the n_selected_blocks() function.
The function throws an exception if no block is selected at all.
Definition at line 301 of file block_mask.h.
|
inline |
Return true if this mask represents a default constructed mask that corresponds to one in which all blocks are selected. If true, then the size() function will return zero.
Definition at line 322 of file block_mask.h.
Return a block mask that contains the union of the blocks selected by the current object and the one passed as an argument.
Definition at line 330 of file block_mask.h.
Return a block mask that has only those elements set that are set both in the current object as well as the one passed as an argument.
|
inline |
Return whether this object and the argument are identical.
Definition at line 375 of file block_mask.h.
|
inline |
Return whether this object and the argument are not identical.
Definition at line 382 of file block_mask.h.
std::size_t BlockMask::memory_consumption | ( | ) | const |
Determine an estimate for the memory consumption (in bytes) of this object.
Definition at line 47 of file block_mask.cc.
|
friend |
Write a block mask to an output stream. If the block mask represents one where all blocks are selected without specifying a particular size of the mask, then it writes the string [all blocks selected]
to the stream. Otherwise, it prints the block mask in a form like [true,true,true,false]
.
out | The stream to write to. |
mask | The mask to write. |
Definition at line 25 of file block_mask.cc.
|
private |
The actual block mask.
Definition at line 215 of file block_mask.h.