Reference documentation for deal.II version 9.4.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
BlockVectorBase< VectorType > Class Template Reference

#include <deal.II/lac/block_vector_base.h>

Inheritance diagram for BlockVectorBase< VectorType >:

Public Types

using BlockType = VectorType
using value_type = typename BlockType::value_type
using pointer = value_type *
using const_pointer = const value_type *
using iterator = ::internal::BlockVectorIterators::Iterator< BlockVectorBase, false >
using const_iterator = ::internal::BlockVectorIterators::Iterator< BlockVectorBase, true >
using reference = typename BlockType::reference
using const_reference = typename BlockType::const_reference
using size_type = types::global_dof_index
using real_type = typename BlockType::real_type

Public Member Functions

 BlockVectorBase ()=default
 BlockVectorBase (const BlockVectorBase &)=default
 BlockVectorBase (BlockVectorBase &&) noexcept=default
void collect_sizes ()
void compress (::VectorOperation::values operation)
BlockTypeblock (const unsigned int i)
const BlockTypeblock (const unsigned int i) const
const BlockIndicesget_block_indices () const
unsigned int n_blocks () const
std::size_t size () const
std::size_t locally_owned_size () const
IndexSet locally_owned_elements () const
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
value_type operator() (const size_type i) const
reference operator() (const size_type i)
value_type operator[] (const size_type i) const
reference operator[] (const size_type i)
template<typename OtherNumber >
void extract_subvector_to (const std::vector< size_type > &indices, std::vector< OtherNumber > &values) const
template<typename ForwardIterator , typename OutputIterator >
void extract_subvector_to (ForwardIterator indices_begin, const ForwardIterator indices_end, OutputIterator values_begin) const
BlockVectorBaseoperator= (const value_type s)
BlockVectorBaseoperator= (const BlockVectorBase &V)
BlockVectorBaseoperator= (BlockVectorBase &&)=default
template<class VectorType2 >
BlockVectorBaseoperator= (const BlockVectorBase< VectorType2 > &V)
BlockVectorBaseoperator= (const VectorType &v)
template<class VectorType2 >
bool operator== (const BlockVectorBase< VectorType2 > &v) const
value_type operator* (const BlockVectorBase &V) const
real_type norm_sqr () const
value_type mean_value () const
real_type l1_norm () const
real_type l2_norm () const
real_type linfty_norm () const
value_type add_and_dot (const value_type a, const BlockVectorBase &V, const BlockVectorBase &W)
bool in_local_range (const size_type global_index) const
bool all_zero () const
bool is_non_negative () const
BlockVectorBaseoperator+= (const BlockVectorBase &V)
BlockVectorBaseoperator-= (const BlockVectorBase &V)
template<typename Number >
void add (const std::vector< size_type > &indices, const std::vector< Number > &values)
template<typename Number >
void add (const std::vector< size_type > &indices, const Vector< Number > &values)
template<typename Number >
void add (const size_type n_elements, const size_type *indices, const Number *values)
void add (const value_type s)
void add (const value_type a, const BlockVectorBase &V)
void add (const value_type a, const BlockVectorBase &V, const value_type b, const BlockVectorBase &W)
void sadd (const value_type s, const BlockVectorBase &V)
void sadd (const value_type s, const value_type a, const BlockVectorBase &V)
void sadd (const value_type s, const value_type a, const BlockVectorBase &V, const value_type b, const BlockVectorBase &W)
void sadd (const value_type s, const value_type a, const BlockVectorBase &V, const value_type b, const BlockVectorBase &W, const value_type c, const BlockVectorBase &X)
BlockVectorBaseoperator*= (const value_type factor)
BlockVectorBaseoperator/= (const value_type factor)
template<class BlockVector2 >
void scale (const BlockVector2 &v)
template<class BlockVector2 >
void equ (const value_type a, const BlockVector2 &V)
void update_ghost_values () const
std::size_t memory_consumption () const

Protected Attributes

std::vector< VectorType > components
BlockIndices block_indices


template<typename N , bool C>
class ::internal::BlockVectorIterators::Iterator
template<typename >
class BlockVectorBase

Subscriptor functionality

Classes derived from Subscriptor provide a facility to subscribe to this object. This is mostly used by the SmartPointer class.

void subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
void unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
unsigned int n_subscriptions () const
template<typename StreamType >
void list_subscribers (StreamType &stream) const
void list_subscribers () const
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
using map_value_type = decltype(counter_map)::value_type
using map_iterator = decltype(counter_map)::iterator
std::atomic< unsigned intcounter
std::map< std::string, unsigned intcounter_map
std::vector< std::atomic< bool > * > validity_pointers
const std::type_info * object_info
static std::mutex mutex
static ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)
static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)
void check_no_subscribers () const noexcept

Detailed Description

template<class VectorType>
class BlockVectorBase< VectorType >

A vector composed of several blocks each representing a vector of its own.

The BlockVector is a collection of vectors of a given type (e.g., deal.II Vector objects, PETScWrappers::MPI::Vector objects, etc.). 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.

Accessing individual blocks, and resizing vectors

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.

Warning: If you change the sizes of single blocks without calling collect_sizes(), results may be unpredictable. The debug version does not check consistency here for performance reasons!
See also
Block (linear algebra)

Definition at line 433 of file block_vector_base.h.

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