Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Public Types | Public Member Functions | Related Functions | List of all members
TrilinosWrappers::MPI::BlockVector Class Reference

#include <trilinos_parallel_block_vector.h>

Inheritance diagram for TrilinosWrappers::MPI::BlockVector:
[legend]

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 Types inherited from BlockVectorBase< Vector >
typedef Vector BlockType
 
typedef BlockType::value_type value_type
 
typedef value_type * pointer
 
typedef const value_type * const_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 types::global_dof_index size_type
 
typedef BlockType::real_type real_type
 

Public Member Functions

 BlockVector ()
 
 BlockVector (const std::vector< Epetra_Map > &parallel_partitioning)
 
 BlockVector (const std::vector< IndexSet > &parallel_partitioning, const MPI_Comm &communicator=MPI_COMM_WORLD)
 
 BlockVector (const std::vector< IndexSet > &parallel_partitioning, const std::vector< IndexSet > &ghost_values, const MPI_Comm &communicator)
 
 BlockVector (const BlockVector &V)
 
 BlockVector (const size_type num_blocks)
 
 ~BlockVector ()
 
BlockVectoroperator= (const value_type s)
 
BlockVectoroperator= (const BlockVector &V)
 
BlockVectoroperator= (const ::TrilinosWrappers::BlockVector &V)
 
template<typename Number >
BlockVectoroperator= (const ::BlockVector< Number > &V)
 
void reinit (const std::vector< Epetra_Map > &parallel_partitioning, const bool fast=false)
 
void reinit (const std::vector< IndexSet > &parallel_partitioning, const MPI_Comm &communicator=MPI_COMM_WORLD, const bool fast=false)
 
void reinit (const std::vector< IndexSet > &partitioning, const std::vector< IndexSet > &ghost_values, const MPI_Comm &communicator=MPI_COMM_WORLD)
 
void reinit (const BlockVector &V, const bool fast=false)
 
void reinit (const size_type num_blocks)
 
void import_nonlocal_data_for_fe (const TrilinosWrappers::BlockSparseMatrix &m, const BlockVector &v)
 
void compress (const Epetra_CombineMode last_action) DEAL_II_DEPRECATED
 
bool is_compressed () const
 
bool has_ghost_elements () const
 
void swap (BlockVector &v)
 
void print (std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
 
 DeclException0 (ExcIteratorRangeDoesNotMatchVectorSize)
 
 DeclException0 (ExcNonMatchingBlockVectors)
 
- Public Member Functions inherited from BlockVectorBase< Vector >
 BlockVectorBase ()
 
void collect_sizes ()
 
void compress (::VectorOperation::values operation)
 
void compress () DEAL_II_DEPRECATED
 
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
 
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)
 
void extract_subvector_to (const std::vector< size_type > &indices, std::vector< OtherNumber > &values) const
 
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= (const BlockVectorBase< VectorType2 > &V)
 
BlockVectorBaseoperator= (const Vector &v)
 
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 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)
 
void add (const std::vector< size_type > &indices, const std::vector< Number > &values)
 
void add (const std::vector< size_type > &indices, const Vector< Number > &values)
 
void add (const size_type n_elements, const size_type *indices, const Number *values)
 
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)
 
void scale (const BlockVector2 &v)
 
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)
 
void update_ghost_values () const
 
std::size_t memory_consumption () const
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
void subscribe (const char *identifier=0) const
 
void unsubscribe (const char *identifier=0) const
 
unsigned int n_subscriptions () const
 
void list_subscribers () const
 
 DeclException3 (ExcInUse, int, char *, std::string &,<< "Object of class "<< arg2<< " is still used by "<< arg1<< " other objects.\n"<< "(Additional information: "<< arg3<< ")\n"<< "Note the entry in the Frequently Asked Questions of "<< "deal.II (linked to from http://www.dealii.org/) for "<< "more information on what this error means.")
 
 DeclException2 (ExcNoSubscriber, char *, char *,<< "No subscriber with identifier \""<< arg2<< "\" did subscribe to this object of class "<< arg1)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Related Functions

(Note that these are not member functions.)

void swap (BlockVector &u, BlockVector &v)
 

Additional Inherited Members

- Static Public Attributes inherited from BlockVectorBase< Vector >
static const bool supports_distributed_data
 
- Protected Attributes inherited from BlockVectorBase< Vector >
std::vector< Vectorcomponents
 
BlockIndices block_indices
 

Detailed Description

An implementation of block vectors based on the vector class implemented in TrilinosWrappers. 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.

The model of distribution of data is such that each of the blocks is distributed across all MPI processes named in the MPI communicator. I.e. we don't just distribute the whole vector, but each component. In the constructors and reinit() functions, one therefore not only has to specify the sizes of the individual blocks, but also the number of elements of each of these blocks to be stored on the local process.

See also
Block (linear algebra)
Author
Martin Kronbichler, Wolfgang Bangerth, 2008, 2009

Definition at line 72 of file trilinos_parallel_block_vector.h.

Member Typedef Documentation

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

Definition at line 79 of file trilinos_parallel_block_vector.h.

Typedef the type of the underlying vector.

Definition at line 85 of file trilinos_parallel_block_vector.h.

typedef BaseClass::value_type TrilinosWrappers::MPI::BlockVector::value_type

Import the typedefs from the base class.

Definition at line 91 of file trilinos_parallel_block_vector.h.

Constructor & Destructor Documentation

BlockVector< Number >::BlockVector ( )
inline

Default constructor. Generate an empty vector without any blocks.

Definition at line 428 of file trilinos_parallel_block_vector.h.

BlockVector< Number >::BlockVector ( const std::vector< Epetra_Map > &  parallel_partitioning)
inlineexplicit

Constructor. Generate a block vector with as many blocks as there are entries in partitioning. Each Epetra_Map contains the layout of the distribution of data among the MPI processes.

Definition at line 434 of file trilinos_parallel_block_vector.h.

BlockVector< Number >::BlockVector ( const std::vector< IndexSet > &  parallel_partitioning,
const MPI_Comm &  communicator = MPI_COMM_WORLD 
)
inlineexplicit

Constructor. Generate a block vector with as many blocks as there are entries in partitioning. Each IndexSet together with the MPI communicator contains the layout of the distribution of data among the MPI processes.

Definition at line 442 of file trilinos_parallel_block_vector.h.

BlockVector< Number >::BlockVector ( const std::vector< IndexSet > &  parallel_partitioning,
const std::vector< IndexSet > &  ghost_values,
const MPI_Comm &  communicator 
)
inline

Creates a BlockVector with ghost elements. ghost_values may contain any elements in parallel_partitioning, they will be ignored.

Definition at line 450 of file trilinos_parallel_block_vector.h.

BlockVector< Number >::BlockVector ( const BlockVector V)
inline

Copy-Constructor. Set all the properties of the parallel vector to those of the given argument and copy the elements.

Definition at line 467 of file trilinos_parallel_block_vector.h.

BlockVector< Number >::BlockVector ( const size_type  num_blocks)
inlineexplicit

Creates a block vector consisting of num_blocks components, but there is no content in the individual components and the user has to fill appropriate data using a reinit of the blocks.

Definition at line 459 of file trilinos_parallel_block_vector.h.

TrilinosWrappers::MPI::BlockVector::~BlockVector ( )

Destructor. Clears memory

Member Function Documentation

BlockVector& TrilinosWrappers::MPI::BlockVector::operator= ( const value_type  s)

Copy operator: fill all components of the vector that are locally stored with the given scalar value.

BlockVector& TrilinosWrappers::MPI::BlockVector::operator= ( const BlockVector V)

Copy operator for arguments of the same type.

BlockVector& TrilinosWrappers::MPI::BlockVector::operator= ( const ::TrilinosWrappers::BlockVector V)

Copy operator for arguments of the localized Trilinos vector type.

template<typename Number >
BlockVector & BlockVector< Number >::operator= ( const ::BlockVector< Number > &  V)

Another copy function. This one takes a deal.II block vector and copies it into a TrilinosWrappers block vector. Note that the number of blocks has to be the same in the vector as in the input vector. Use the reinit() command for resizing the BlockVector or for changing the internal structure of the block components.

Since Trilinos only works on doubles, this function is limited to accept only one possible number type in the deal.II vector.

Definition at line 517 of file trilinos_parallel_block_vector.h.

void TrilinosWrappers::MPI::BlockVector::reinit ( const std::vector< Epetra_Map > &  parallel_partitioning,
const bool  fast = false 
)

Reinitialize the BlockVector to contain as many blocks as there are Epetra_Maps given in the input argument, according to the parallel distribution of the individual components described in the maps.

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

void TrilinosWrappers::MPI::BlockVector::reinit ( const std::vector< IndexSet > &  parallel_partitioning,
const MPI_Comm &  communicator = MPI_COMM_WORLD,
const bool  fast = false 
)

Reinitialize the BlockVector to contain as many blocks as there are index sets given in the input argument, according to the parallel distribution of the individual components described in the maps.

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

void TrilinosWrappers::MPI::BlockVector::reinit ( const std::vector< IndexSet > &  partitioning,
const std::vector< IndexSet > &  ghost_values,
const MPI_Comm &  communicator = MPI_COMM_WORLD 
)

like above, but with a second set of indices for ghost entries.

void TrilinosWrappers::MPI::BlockVector::reinit ( const BlockVector V,
const bool  fast = false 
)

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() on one of the blocks, then subsequent actions on this object may yield unpredictable results since they may be routed to the wrong block.

void TrilinosWrappers::MPI::BlockVector::reinit ( const size_type  num_blocks)

Change the number of blocks to num_blocks. The individual blocks will get initialized with zero size, so it is assumed that the user resizes the individual blocks by herself in an appropriate way, and calls collect_sizes afterwards.

void TrilinosWrappers::MPI::BlockVector::import_nonlocal_data_for_fe ( const TrilinosWrappers::BlockSparseMatrix m,
const BlockVector v 
)

This reinit function is meant to be used for parallel calculations where some non-local data has to be used. The typical situation where one needs this function is the call of the FEValues<dim>::get_function_values function (or of some derivatives) in parallel. Since it is usually faster to retrieve the data in advance, this function can be called before the assembly forks out to the different processors. What this function does is the following: It takes the information in the columns of the given matrix and looks which data couples between the different processors. That data is then queried from the input vector. Note that you should not write to the resulting vector any more, since the some data can be stored several times on different processors, leading to unpredictable results. In particular, such a vector cannot be used for matrix-vector products as for example done during the solution of linear systems.

void BlockVector< Number >::compress ( const Epetra_CombineMode  last_action)
inline

use compress(VectorOperation) instead

Deprecated:

See Compressingdistributed objects" for more information.

Definition at line 499 of file trilinos_parallel_block_vector.h.

bool BlockVector< Number >::is_compressed ( ) const
inline

Returns the state of the vector, i.e., whether compress() needs to be called after an operation requiring data exchange. Does only return non-true values when used in debug mode, since it is quite expensive to keep track of all operations that lead to the need for compress().

Definition at line 482 of file trilinos_parallel_block_vector.h.

bool BlockVector< Number >::has_ghost_elements ( ) const
inline

Returns if this Vector contains ghost elements.

Definition at line 538 of file trilinos_parallel_block_vector.h.

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 550 of file trilinos_parallel_block_vector.h.

void TrilinosWrappers::MPI::BlockVector::print ( std::ostream &  out,
const unsigned int  precision = 3,
const bool  scientific = true,
const bool  across = true 
) const

Print to a stream.

TrilinosWrappers::MPI::BlockVector::DeclException0 ( ExcIteratorRangeDoesNotMatchVectorSize  )

Exception

TrilinosWrappers::MPI::BlockVector::DeclException0 ( ExcNonMatchingBlockVectors  )

Exception

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
Martin Kronbichler, Wolfgang Bangerth, 2008

Definition at line 570 of file trilinos_parallel_block_vector.h.


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