Public Types | Public Member Functions | Static Public Member Functions | Related Functions

PETScWrappers::BlockVector Class Reference
[PETScWrappersVector classes]

Inheritance diagram for PETScWrappers::BlockVector:
Inheritance graph
[legend]

List of all members.

Public Types

typedef BlockVectorBase< VectorBaseClass
typedef BaseClass::BlockType BlockType
typedef BaseClass::value_type value_type
typedef BaseClass::pointer pointer
typedef BaseClass::const_pointer const_pointer
typedef BaseClass::reference reference
typedef BaseClass::const_reference const_reference
typedef BaseClass::size_type size_type
typedef BaseClass::iterator iterator
typedef BaseClass::const_iterator const_iterator

Public Member Functions

 BlockVector (const unsigned int num_blocks=0, const unsigned int block_size=0)
 BlockVector (const BlockVector &V)
 BlockVector (const MPI::BlockVector &v)
 BlockVector (const std::vector< unsigned int > &n)
template<typename InputIterator >
 BlockVector (const std::vector< unsigned int > &n, const InputIterator first, const InputIterator end)
 ~BlockVector ()
BlockVectoroperator= (const value_type s)
BlockVectoroperator= (const BlockVector &V)
BlockVectoroperator= (const MPI::BlockVector &v)
void reinit (const unsigned int num_blocks, const unsigned int block_size, const bool fast=false)
void reinit (const std::vector< unsigned int > &N, const bool fast=false)
void reinit (const BlockVector &V, const bool fast=false)
void swap (BlockVector &v)
void print (std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const

Static Public Member Functions

::ExceptionBaseExcIteratorRangeDoesNotMatchVectorSize ()

Related Functions

(Note that these are not member functions.)


void swap (BlockVector &u, BlockVector &v)

Detailed Description

An implementation of block vectors based on the vector class implemented in PETScWrappers. While the base class provides for most of the interface, this class handles the actual allocation of vectors and provides functions that are specific to the underlying vector type.

See also:
Block (linear algebra)
Author:
Wolfgang Bangerth, 2004

Definition at line 46 of file petsc_block_vector.h.


Member Typedef Documentation

Typedef the base class for simpler access to its own typedefs.

Definition at line 53 of file petsc_block_vector.h.

Typedef the type of the underlying vector.

Reimplemented from BlockVectorBase< Vector >.

Definition at line 59 of file petsc_block_vector.h.

Import the typedefs from the base class.

Reimplemented from BlockVectorBase< Vector >.

Definition at line 65 of file petsc_block_vector.h.

Reimplemented from BlockVectorBase< Vector >.

Definition at line 66 of file petsc_block_vector.h.

Reimplemented from BlockVectorBase< Vector >.

Definition at line 67 of file petsc_block_vector.h.

Reimplemented from BlockVectorBase< Vector >.

Definition at line 68 of file petsc_block_vector.h.

Reimplemented from BlockVectorBase< Vector >.

Definition at line 69 of file petsc_block_vector.h.

Reimplemented from BlockVectorBase< Vector >.

Definition at line 70 of file petsc_block_vector.h.

Reimplemented from BlockVectorBase< Vector >.

Definition at line 71 of file petsc_block_vector.h.

Reimplemented from BlockVectorBase< Vector >.

Definition at line 72 of file petsc_block_vector.h.


Constructor & Destructor Documentation

BlockVector< Number >::BlockVector ( const unsigned int  num_blocks = 0,
const unsigned int  block_size = 0 
) [inline, explicit]

Constructor. There are three ways to use this constructor. First, without any arguments, it generates an object with no blocks. Given one argument, it initializes num_blocks blocks, but these blocks have size zero. The third variant finally initializes all blocks to the same size block_size.

Confer the other constructor further down if you intend to use blocks of different sizes.

Definition at line 319 of file petsc_block_vector.h.

References reinit().

BlockVector< Number >::BlockVector ( const BlockVector V ) [inline]
BlockVector< Number >::BlockVector ( const MPI::BlockVector v ) [inline, explicit]

Copy-constructor: copy the values from a PETSc wrapper parallel block vector class.

Note that due to the communication model of MPI, all processes have to actually perform this operation, even if they do not use the result. It is not sufficient if only one processor tries to copy the elements from the other processors over to its own process space.

Definition at line 349 of file petsc_block_vector.h.

References BlockVectorBase< VectorType >::block(), BlockVectorBase< Vector >::block_indices, BlockVectorBase< Vector >::components, BlockVectorBase< VectorType >::get_block_indices(), BlockVectorBase< Vector >::n_blocks(), and BlockIndices::size().

BlockVector< Number >::BlockVector ( const std::vector< unsigned int > &  n ) [inline]

Constructor. Set the number of blocks to n.size() and initialize each block with n[i] zero elements.

Definition at line 328 of file petsc_block_vector.h.

References reinit().

template<typename InputIterator >
BlockVector< InputIterator >::BlockVector ( const std::vector< unsigned int > &  n,
const InputIterator  first,
const InputIterator  end 
)

Constructor. Set the number of blocks to n.size(). Initialize the vector with the elements pointed to by the range of iterators given as second and third argument. Apart from the first argument, this constructor is in complete analogy to the respective constructor of the std::vector class, but the first argument is needed in order to know how to subdivide the block vector into different blocks.

Definition at line 363 of file petsc_block_vector.h.

References advance(), Assert, BlockVectorBase< Vector >::block(), ExcIteratorRangeDoesNotMatchVectorSize(), and reinit().

BlockVector< Number >::~BlockVector (  ) [inline]

Destructor. Clears memory

Definition at line 416 of file petsc_block_vector.h.


Member Function Documentation

BlockVector & BlockVector< Number >::operator= ( const value_type  s ) [inline]

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

Definition at line 387 of file petsc_block_vector.h.

References BlockVectorBase< Vector >::operator=().

BlockVector & BlockVector< Number >::operator= ( const BlockVector V ) [inline]

Copy operator for arguments of the same type.

Definition at line 397 of file petsc_block_vector.h.

References BlockVectorBase< Vector >::operator=().

BlockVector & BlockVector< Number >::operator= ( const MPI::BlockVector v ) [inline]

Copy all the elements of the parallel block vector v into this local vector. Note that due to the communication model of MPI, all processes have to actually perform this operation, even if they do not use the result. It is not sufficient if only one processor tries to copy the elements from the other processors over to its own process space.

Definition at line 407 of file petsc_block_vector.h.

References BlockVectorBase< Vector >::operator=().

void BlockVector< Number >::reinit ( const unsigned int  num_blocks,
const unsigned int  block_size,
const bool  fast = false 
) [inline]

Reinitialize the BlockVector to contain num_blocks blocks of size block_size each.

If fast==false, the vector is filled with zeros.

Definition at line 422 of file petsc_block_vector.h.

Referenced by BlockVector(), and reinit().

void BlockVector< Number >::reinit ( const std::vector< unsigned int > &  N,
const bool  fast = false 
) [inline]

Reinitialize the BlockVector such that it contains block_sizes.size() blocks. Each block is reinitialized to dimension block_sizes[i].

If the number of blocks is the same as before this function was called, all vectors remain the same and reinit() is called for each vector.

If fast==false, the vector is filled with zeros.

Note that you must call this (or the other reinit() functions) function, rather than calling the reinit() functions of an individual block, to allow the block vector to update its caches of vector sizes. If you call reinit() on one of the blocks, then subsequent actions on this object may yield unpredictable results since they may be routed to the wrong block.

Definition at line 434 of file petsc_block_vector.h.

References BlockVectorBase< Vector >::block_indices, BlockVectorBase< Vector >::components, BlockVectorBase< Vector >::n_blocks(), reinit(), and BlockIndices::reinit().

void BlockVector< Number >::reinit ( const BlockVector V,
const bool  fast = false 
) [inline]

Change the dimension to that of the vector V. The same applies as for the other reinit() function.

The elements of V are not copied, i.e. this function is the same as calling reinit (V.size(), fast).

Note that you must call this (or the other reinit() functions) function, rather than calling the reinit() functions of an individual block, to allow the block vector to update its caches of vector sizes. If you call reinit() of one of the blocks, then subsequent actions of this object may yield unpredictable results since they may be routed to the wrong block.

Definition at line 448 of file petsc_block_vector.h.

References BlockVectorBase< VectorType >::block(), BlockVectorBase< Vector >::block(), BlockVectorBase< Vector >::block_indices, BlockVectorBase< Vector >::components, BlockVectorBase< VectorType >::get_block_indices(), BlockVectorBase< Vector >::n_blocks(), and Vector< Number >::reinit().

void BlockVector< Number >::swap ( BlockVector v ) [inline]

Swap the contents of this vector and the other vector v. One could do this operation with a temporary variable and copying over the data elements, but this function is significantly more efficient since it only swaps the pointers to the data of the two vectors and therefore does not need to allocate temporary storage and move data around.

Limitation: right now this function only works if both vectors have the same number of blocks. If needed, the numbers of blocks should be exchanged, too.

This function is analog to the the swap() function of all C++ standard containers. Also, there is a global function swap(u,v) that simply calls u.swap(v), again in analogy to standard functions.

Definition at line 463 of file petsc_block_vector.h.

References Assert, BlockVectorBase< VectorType >::block_indices, BlockVectorBase< Vector >::block_indices, BlockVectorBase< VectorType >::components, BlockVectorBase< Vector >::components, StandardExceptions::ExcDimensionMismatch(), BlockVectorBase< VectorType >::n_blocks(), and BlockVectorBase< Vector >::n_blocks().

Referenced by swap().

void BlockVector< Number >::print ( std::ostream &  out,
const unsigned int  precision = 3,
const bool  scientific = true,
const bool  across = true 
) const [inline]

Print to a stream.

Definition at line 477 of file petsc_block_vector.h.

References BlockVectorBase< Vector >::components, and BlockVectorBase< Vector >::n_blocks().


Friends And Related Function Documentation

void swap ( BlockVector u,
BlockVector v 
) [related]

Global function which overloads the default implementation of the C++ standard library which uses a temporary object. The function simply exchanges the data of the two vectors.

Author:
Wolfgang Bangerth, 2000

Definition at line 504 of file petsc_block_vector.h.

References swap().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Fri Feb 3 2012 06:04:15 by doxygen 1.7.2