A vector composed of several blocks each representing a vector of its own.
The BlockVector is a collection of Vectors (e.g. of either deal.II Vector objects or PETScWrappers::Vector object). Each of the vectors inside can have a different size.
The functionality of BlockVector includes everything a Vector can do, plus the access to a single Vector inside the BlockVector by block(i)
. It also has a complete random access iterator, just as the other Vector classes or the standard C++ library template std::vector
. Therefore, all algorithms working on iterators also work with objects of this class.
While this base class implements most of the functionality by dispatching calls to its member functions to the respective functions on each of the individual blocks, this class does not actually allocate some memory or change the size of vectors. For this, the constructors, assignment operators and reinit() functions of derived classes are responsible. This class only handles the common part that is independent of the actual vector type the block vector is built on.
Apart from using this object as a whole, you can use each block separately as a vector, using the block() function. There is a single caveat: if you have changed the size of one or several blocks, you must call the function collect_sizes() of the block vector to update its internal structures.
typedef VectorType BlockVectorBase< VectorType >::BlockType |
Typedef the type of the underlying vector.
Reimplemented in BlockVector< Number >, PETScWrappers::BlockVector, PETScWrappers::MPI::BlockVector, TrilinosWrappers::MPI::BlockVector, and TrilinosWrappers::BlockVector.
typedef BlockType::value_type BlockVectorBase< VectorType >::value_type |
typedef value_type* BlockVectorBase< VectorType >::pointer |
typedef const value_type* BlockVectorBase< VectorType >::const_pointer |
typedef internal::BlockVectorIterators::Iterator<BlockVectorBase,false> BlockVectorBase< VectorType >::iterator |
typedef internal::BlockVectorIterators::Iterator<BlockVectorBase,true> BlockVectorBase< VectorType >::const_iterator |
typedef BlockType::reference BlockVectorBase< VectorType >::reference |
typedef BlockType::const_reference BlockVectorBase< VectorType >::const_reference |
typedef std::size_t BlockVectorBase< VectorType >::size_type |
typedef BlockType::real_type BlockVectorBase< VectorType >::real_type |
Declare a type that has holds real-valued numbers with the same precision as the template argument to this class. If the template argument of this class is a real data type, then real_type equals the template argument. If the template argument is a std::complex type then real_type equals the type underlying the complex numbers.
This typedef is used to represent the return type of norms.
Reimplemented in BlockVector< Number >.
BlockVectorBase< VectorType >::BlockVectorBase | ( | ) |
Default constructor.
void BlockVectorBase< VectorType >::collect_sizes | ( | ) |
void BlockVectorBase< VectorType >::compress | ( | ) |
Call the compress() function on all the subblocks of the matrix.
Reimplemented in TrilinosWrappers::MPI::BlockVector.
BlockType& BlockVectorBase< VectorType >::block | ( | const unsigned int | i | ) |
Access to a single block.
Referenced by PETScWrappers::BlockVector::BlockVector(), PETScWrappers::MPI::BlockVector::reinit(), PETScWrappers::BlockVector::reinit(), TrilinosWrappers::BlockVector::swap(), and TrilinosWrappers::MPI::BlockVector::swap().
const BlockType& BlockVectorBase< VectorType >::block | ( | const unsigned int | i | ) | const |
Read-only access to a single block.
const BlockIndices& BlockVectorBase< VectorType >::get_block_indices | ( | ) | const |
Return a reference on the object that describes the mapping between block and global indices. The use of this function is highly deprecated and it should vanish in one of the next versions
Referenced by PETScWrappers::BlockVector::BlockVector(), PETScWrappers::MPI::BlockVector::reinit(), and PETScWrappers::BlockVector::reinit().
unsigned int BlockVectorBase< VectorType >::n_blocks | ( | ) | const |
Number of blocks.
Referenced by TrilinosWrappers::BlockVector::BlockVector(), TrilinosWrappers::MPI::BlockVector::BlockVector(), PETScWrappers::MPI::BlockVector::BlockVector(), PETScWrappers::BlockVector::BlockVector(), TrilinosWrappers::BlockVector::swap(), TrilinosWrappers::MPI::BlockVector::swap(), PETScWrappers::MPI::BlockVector::swap(), and PETScWrappers::BlockVector::swap().
unsigned int BlockVectorBase< VectorType >::size | ( | ) | const |
Return dimension of the vector. This is the sum of the dimensions of all components.
iterator BlockVectorBase< VectorType >::begin | ( | ) |
Return an iterator pointing to the first element.
const_iterator BlockVectorBase< VectorType >::begin | ( | ) | const |
Return an iterator pointing to the first element of a constant block vector.
iterator BlockVectorBase< VectorType >::end | ( | ) |
Return an iterator pointing to the element past the end.
const_iterator BlockVectorBase< VectorType >::end | ( | ) | const |
Return an iterator pointing to the element past the end of a constant block vector.
value_type BlockVectorBase< VectorType >::operator() | ( | const unsigned int | i | ) | const |
Access components, returns U(i).
reference BlockVectorBase< VectorType >::operator() | ( | const unsigned int | i | ) |
Access components, returns U(i) as a writeable reference.
BlockVectorBase& BlockVectorBase< VectorType >::operator= | ( | const value_type | s | ) |
Copy operator: fill all components of the vector with the given scalar value.
BlockVectorBase& BlockVectorBase< VectorType >::operator= | ( | const BlockVectorBase< VectorType > & | V | ) |
Copy operator for arguments of the same type.
Reimplemented from Subscriptor.
BlockVectorBase& BlockVectorBase< VectorType >::operator= | ( | const BlockVectorBase< VectorType2 > & | V | ) | [inline] |
Copy operator for template arguments of different types.
Reimplemented from Subscriptor.
BlockVectorBase& BlockVectorBase< VectorType >::operator= | ( | const VectorType & | v | ) |
Copy operator from non-block vectors to block vectors.
Reimplemented in BlockVector< Number >.
bool BlockVectorBase< VectorType >::operator== | ( | const BlockVectorBase< VectorType2 > & | v | ) | const [inline] |
Check for equality of two block vector types. This operation is only allowed if the two vectors already have the same block structure.
value_type BlockVectorBase< VectorType >::operator* | ( | const BlockVectorBase< VectorType > & | V | ) | const |
: scalar product.
real_type BlockVectorBase< VectorType >::norm_sqr | ( | ) | const |
Return square of the -norm.
value_type BlockVectorBase< VectorType >::mean_value | ( | ) | const |
Return the mean value of the elements of this vector.
real_type BlockVectorBase< VectorType >::l1_norm | ( | ) | const |
Return the -norm of the vector, i.e. the sum of the absolute values.
real_type BlockVectorBase< VectorType >::l2_norm | ( | ) | const |
Return the -norm of the vector, i.e. the square root of the sum of the squares of the elements.
real_type BlockVectorBase< VectorType >::linfty_norm | ( | ) | const |
Return the maximum absolute value of the elements of this vector, which is the -norm of a vector.
bool BlockVectorBase< VectorType >::all_zero | ( | ) | const |
Return whether the vector contains only elements with value zero. This function is mainly for internal consistency check and should seldomly be used when not in debug mode since it uses quite some time.
bool BlockVectorBase< VectorType >::is_non_negative | ( | ) | const |
Return true
if the vector has no negative entries, i.e. all entries are zero or positive. This function is used, for example, to check whether refinement indicators are really all positive (or zero).
BlockVectorBase& BlockVectorBase< VectorType >::operator+= | ( | const BlockVectorBase< VectorType > & | V | ) |
Addition operator. Fast equivalent to U.add(1, V)
.
BlockVectorBase& BlockVectorBase< VectorType >::operator-= | ( | const BlockVectorBase< VectorType > & | V | ) |
Subtraction operator. Fast equivalent to U.add(-1, V)
.
void BlockVectorBase< VectorType >::add | ( | const value_type | s | ) |
. Addition of
s
to all components. Note that s
is a scalar and not a vector.
void BlockVectorBase< VectorType >::add | ( | const BlockVectorBase< VectorType > & | V | ) |
U+=V. Simple vector addition, equal to the operator +=
.
void BlockVectorBase< VectorType >::add | ( | const value_type | a, | |
const BlockVectorBase< VectorType > & | V | |||
) |
U+=a*V. Simple addition of a scaled vector.
void BlockVectorBase< VectorType >::add | ( | const value_type | a, | |
const BlockVectorBase< VectorType > & | V, | |||
const value_type | b, | |||
const BlockVectorBase< VectorType > & | W | |||
) |
U+=a*V+b*W. Multiple addition of scaled vectors.
void BlockVectorBase< VectorType >::sadd | ( | const value_type | s, | |
const BlockVectorBase< VectorType > & | V | |||
) |
U=s*U+V. Scaling and simple vector addition.
void BlockVectorBase< VectorType >::sadd | ( | const value_type | s, | |
const value_type | a, | |||
const BlockVectorBase< VectorType > & | V | |||
) |
U=s*U+a*V. Scaling and simple addition.
void BlockVectorBase< VectorType >::sadd | ( | const value_type | s, | |
const value_type | a, | |||
const BlockVectorBase< VectorType > & | V, | |||
const value_type | b, | |||
const BlockVectorBase< VectorType > & | W | |||
) |
U=s*U+a*V+b*W. Scaling and multiple addition.
void BlockVectorBase< VectorType >::sadd | ( | const value_type | s, | |
const value_type | a, | |||
const BlockVectorBase< VectorType > & | V, | |||
const value_type | b, | |||
const BlockVectorBase< VectorType > & | W, | |||
const value_type | c, | |||
const BlockVectorBase< VectorType > & | X | |||
) |
U=s*U+a*V+b*W+c*X. Scaling and multiple addition.
BlockVectorBase& BlockVectorBase< VectorType >::operator*= | ( | const value_type | factor | ) |
Scale each element of the vector by a constant value.
BlockVectorBase& BlockVectorBase< VectorType >::operator/= | ( | const value_type | factor | ) |
Scale each element of the vector by the inverse of the given value.
void BlockVectorBase< VectorType >::scale | ( | const BlockVector2 & | v | ) | [inline] |
Multiply each element of this vector by the corresponding element of v
.
Reimplemented in BlockVector< Number >.
void BlockVectorBase< VectorType >::equ | ( | const value_type | a, | |
const BlockVector2 & | V | |||
) | [inline] |
U=a*V. Assignment.
void BlockVectorBase< VectorType >::equ | ( | const value_type | a, | |
const BlockVectorBase< VectorType > & | V, | |||
const value_type | b, | |||
const BlockVectorBase< VectorType > & | W | |||
) |
U=a*V+b*W. Replacing by sum.
unsigned int BlockVectorBase< VectorType >::memory_consumption | ( | ) | const |
Determine an estimate for the memory consumption (in bytes) of this object.
friend class internal::BlockVectorIterators::Iterator [friend] |
Make the iterator class a friend. We have to work around a compiler bug here again.
friend class BlockVectorBase [friend] |
std::vector<VectorType> BlockVectorBase< VectorType >::components [protected] |
Pointer to the array of components.
Referenced by TrilinosWrappers::BlockVector::BlockVector(), TrilinosWrappers::MPI::BlockVector::BlockVector(), PETScWrappers::MPI::BlockVector::BlockVector(), PETScWrappers::BlockVector::BlockVector(), PETScWrappers::MPI::BlockVector::swap(), and PETScWrappers::BlockVector::swap().
BlockIndices BlockVectorBase< VectorType >::block_indices [protected] |
Object managing the transformation between global indices and indices within the different blocks.
Referenced by TrilinosWrappers::BlockVector::BlockVector(), TrilinosWrappers::MPI::BlockVector::BlockVector(), PETScWrappers::MPI::BlockVector::BlockVector(), PETScWrappers::BlockVector::BlockVector(), PETScWrappers::MPI::BlockVector::swap(), and PETScWrappers::BlockVector::swap().