BlockVectorBase< VectorType > Class Template Reference
[Vector classes]

Inheritance diagram for BlockVectorBase< VectorType >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef VectorType BlockType
typedef BlockType::value_type value_type
typedef value_typepointer
typedef const value_typeconst_pointer
typedef
internal::BlockVectorIterators::Iterator
< BlockVectorBase, false > 
iterator
typedef
internal::BlockVectorIterators::Iterator
< BlockVectorBase, true > 
const_iterator
typedef BlockType::reference reference
typedef BlockType::const_reference const_reference
typedef std::size_t size_type
typedef BlockType::real_type real_type

Public Member Functions

 BlockVectorBase ()
void collect_sizes ()
void compress ()
BlockTypeblock (const unsigned int i)
const BlockTypeblock (const unsigned int i) const
const BlockIndicesget_block_indices () const
unsigned int n_blocks () const
unsigned int size () const
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
value_type operator() (const unsigned int i) const
reference operator() (const unsigned int i)
BlockVectorBaseoperator= (const value_type s)
BlockVectorBaseoperator= (const BlockVectorBase &V)
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
bool all_zero () const
bool is_non_negative () const
BlockVectorBaseoperator+= (const BlockVectorBase &V)
BlockVectorBaseoperator-= (const BlockVectorBase &V)
void add (const value_type s)
void add (const BlockVectorBase &V)
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 equ (const value_type a, const BlockVectorBase &V, const value_type b, const BlockVectorBase &W)
unsigned int memory_consumption () const

Protected Attributes

std::vector< VectorType > components
BlockIndices block_indices

Friends

class internal::BlockVectorIterators::Iterator
class BlockVectorBase

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 (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.

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.

Attention:
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!
Author:
Wolfgang Bangerth, Guido Kanschat, 1999, 2000, 2001, 2002, 2004

Member Typedef Documentation

template<class VectorType>
typedef VectorType BlockVectorBase< VectorType >::BlockType
template<class VectorType>
typedef BlockType::value_type BlockVectorBase< VectorType >::value_type
template<class VectorType>
typedef value_type* BlockVectorBase< VectorType >::pointer
template<class VectorType>
typedef const value_type* BlockVectorBase< VectorType >::const_pointer
template<class VectorType>
typedef internal::BlockVectorIterators::Iterator<BlockVectorBase,false> BlockVectorBase< VectorType >::iterator
template<class VectorType>
typedef internal::BlockVectorIterators::Iterator<BlockVectorBase,true> BlockVectorBase< VectorType >::const_iterator
template<class VectorType>
typedef BlockType::reference BlockVectorBase< VectorType >::reference
template<class VectorType>
typedef BlockType::const_reference BlockVectorBase< VectorType >::const_reference
template<class VectorType>
typedef std::size_t BlockVectorBase< VectorType >::size_type
template<class VectorType>
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 >.


Constructor & Destructor Documentation

template<class VectorType>
BlockVectorBase< VectorType >::BlockVectorBase (  ) 

Default constructor.


Member Function Documentation

template<class VectorType>
void BlockVectorBase< VectorType >::collect_sizes (  ) 

Update internal structures after resizing vectors. Whenever you reinited a block of a block vector, the internal data structures are corrupted. Therefore, you should call this function after al blocks got their new size.

template<class VectorType>
void BlockVectorBase< VectorType >::compress (  ) 

Call the compress() function on all the subblocks of the matrix.

Reimplemented in TrilinosWrappers::MPI::BlockVector.

template<class VectorType>
BlockType& BlockVectorBase< VectorType >::block ( const unsigned int  i  ) 
template<class VectorType>
const BlockType& BlockVectorBase< VectorType >::block ( const unsigned int  i  )  const

Read-only access to a single block.

template<class VectorType>
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().

template<class VectorType>
unsigned int BlockVectorBase< VectorType >::n_blocks (  )  const
template<class VectorType>
unsigned int BlockVectorBase< VectorType >::size (  )  const

Return dimension of the vector. This is the sum of the dimensions of all components.

template<class VectorType>
iterator BlockVectorBase< VectorType >::begin (  ) 

Return an iterator pointing to the first element.

template<class VectorType>
const_iterator BlockVectorBase< VectorType >::begin (  )  const

Return an iterator pointing to the first element of a constant block vector.

template<class VectorType>
iterator BlockVectorBase< VectorType >::end (  ) 

Return an iterator pointing to the element past the end.

template<class VectorType>
const_iterator BlockVectorBase< VectorType >::end (  )  const

Return an iterator pointing to the element past the end of a constant block vector.

template<class VectorType>
value_type BlockVectorBase< VectorType >::operator() ( const unsigned int  i  )  const

Access components, returns U(i).

template<class VectorType>
reference BlockVectorBase< VectorType >::operator() ( const unsigned int  i  ) 

Access components, returns U(i) as a writeable reference.

template<class VectorType>
BlockVectorBase& BlockVectorBase< VectorType >::operator= ( const value_type  s  ) 

Copy operator: fill all components of the vector with the given scalar value.

template<class VectorType>
BlockVectorBase& BlockVectorBase< VectorType >::operator= ( const BlockVectorBase< VectorType > &  V  ) 

Copy operator for arguments of the same type.

Reimplemented from Subscriptor.

template<class VectorType>
template<class VectorType2 >
BlockVectorBase& BlockVectorBase< VectorType >::operator= ( const BlockVectorBase< VectorType2 > &  V  )  [inline]

Copy operator for template arguments of different types.

Reimplemented from Subscriptor.

template<class VectorType>
BlockVectorBase& BlockVectorBase< VectorType >::operator= ( const VectorType &  v  ) 

Copy operator from non-block vectors to block vectors.

Reimplemented in BlockVector< Number >.

template<class VectorType>
template<class VectorType2 >
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.

template<class VectorType>
value_type BlockVectorBase< VectorType >::operator* ( const BlockVectorBase< VectorType > &  V  )  const

$U = U * V$: scalar product.

template<class VectorType>
real_type BlockVectorBase< VectorType >::norm_sqr (  )  const

Return square of the $l_2$-norm.

template<class VectorType>
value_type BlockVectorBase< VectorType >::mean_value (  )  const

Return the mean value of the elements of this vector.

template<class VectorType>
real_type BlockVectorBase< VectorType >::l1_norm (  )  const

Return the $l_1$-norm of the vector, i.e. the sum of the absolute values.

template<class VectorType>
real_type BlockVectorBase< VectorType >::l2_norm (  )  const

Return the $l_2$-norm of the vector, i.e. the square root of the sum of the squares of the elements.

template<class VectorType>
real_type BlockVectorBase< VectorType >::linfty_norm (  )  const

Return the maximum absolute value of the elements of this vector, which is the $l_\infty$-norm of a vector.

template<class VectorType>
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.

template<class VectorType>
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).

template<class VectorType>
BlockVectorBase& BlockVectorBase< VectorType >::operator+= ( const BlockVectorBase< VectorType > &  V  ) 

Addition operator. Fast equivalent to U.add(1, V).

template<class VectorType>
BlockVectorBase& BlockVectorBase< VectorType >::operator-= ( const BlockVectorBase< VectorType > &  V  ) 

Subtraction operator. Fast equivalent to U.add(-1, V).

template<class VectorType>
void BlockVectorBase< VectorType >::add ( const value_type  s  ) 

$U(0-DIM)+=s$. Addition of s to all components. Note that s is a scalar and not a vector.

template<class VectorType>
void BlockVectorBase< VectorType >::add ( const BlockVectorBase< VectorType > &  V  ) 

U+=V. Simple vector addition, equal to the operator +=.

template<class VectorType>
void BlockVectorBase< VectorType >::add ( const value_type  a,
const BlockVectorBase< VectorType > &  V 
)

U+=a*V. Simple addition of a scaled vector.

template<class VectorType>
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.

template<class VectorType>
void BlockVectorBase< VectorType >::sadd ( const value_type  s,
const BlockVectorBase< VectorType > &  V 
)

U=s*U+V. Scaling and simple vector addition.

template<class VectorType>
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.

template<class VectorType>
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.

template<class VectorType>
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.

template<class VectorType>
BlockVectorBase& BlockVectorBase< VectorType >::operator*= ( const value_type  factor  ) 

Scale each element of the vector by a constant value.

template<class VectorType>
BlockVectorBase& BlockVectorBase< VectorType >::operator/= ( const value_type  factor  ) 

Scale each element of the vector by the inverse of the given value.

template<class VectorType>
template<class BlockVector2 >
void BlockVectorBase< VectorType >::scale ( const BlockVector2 &  v  )  [inline]

Multiply each element of this vector by the corresponding element of v.

Reimplemented in BlockVector< Number >.

template<class VectorType>
template<class BlockVector2 >
void BlockVectorBase< VectorType >::equ ( const value_type  a,
const BlockVector2 &  V 
) [inline]

U=a*V. Assignment.

template<class VectorType>
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.

template<class VectorType>
unsigned int BlockVectorBase< VectorType >::memory_consumption (  )  const

Determine an estimate for the memory consumption (in bytes) of this object.


Friends And Related Function Documentation

template<class VectorType>
friend class internal::BlockVectorIterators::Iterator [friend]

Make the iterator class a friend. We have to work around a compiler bug here again.

template<class VectorType>
friend class BlockVectorBase [friend]

Member Data Documentation

template<class VectorType>
std::vector<VectorType> BlockVectorBase< VectorType >::components [protected]
template<class VectorType>
BlockIndices BlockVectorBase< VectorType >::block_indices [protected]

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

deal.II documentation generated on Mon Nov 23 22:57:31 2009 by doxygen 1.6.1