Reference documentation for deal.II version 9.2.0
|
Here, we list all the classes that satisfy the VectorType
concept and may be used in linear solvers (see Linear solver classes) and for matrix-vector operations.
More...
Modules | |
Exceptions and assertions | |
This module contains classes that are used in the exception mechanism of deal.II. | |
Namespaces | |
internal | |
internal::BlockVectorIterators | |
internal::LinearOperatorImplementation | |
PETScWrappers | |
Enumerations | |
enum | VectorOperation::values { VectorOperation::unknown, VectorOperation::insert, VectorOperation::add, VectorOperation::min, VectorOperation::max } |
Friends | |
class | LinearAlgebra::Vector< Number >::boost::serialization::access |
template<typename Number2 > | |
class | LinearAlgebra::Vector< Number >::Vector |
4: Other vector operations not included in VectorSpaceVector | |
virtual Vector< Number, MemorySpace > & | LinearAlgebra::distributed::Vector< Number, MemorySpace >::operator= (const Number s) override |
template<typename OtherNumber > | |
void | LinearAlgebra::distributed::Vector< Number, MemorySpace >::add (const std::vector< size_type > &indices, const ::Vector< OtherNumber > &values) |
template<typename OtherNumber > | |
void | LinearAlgebra::distributed::Vector< Number, MemorySpace >::add (const size_type n_elements, const size_type *indices, const OtherNumber *values) |
void | LinearAlgebra::distributed::Vector< Number, MemorySpace >::sadd (const Number s, const Vector< Number, MemorySpace > &V) |
2: Data-Access | |
Number | LinearAlgebra::ReadWriteVector< Number >::operator() (const size_type global_index) const |
Number & | LinearAlgebra::ReadWriteVector< Number >::operator() (const size_type global_index) |
Number | LinearAlgebra::ReadWriteVector< Number >::operator[] (const size_type global_index) const |
Number & | LinearAlgebra::ReadWriteVector< Number >::operator[] (const size_type global_index) |
template<typename Number2 > | |
void | LinearAlgebra::ReadWriteVector< Number >::extract_subvector_to (const std::vector< size_type > &indices, std::vector< Number2 > &values) const |
template<typename ForwardIterator , typename OutputIterator > | |
void | LinearAlgebra::ReadWriteVector< Number >::extract_subvector_to (ForwardIterator indices_begin, const ForwardIterator indices_end, OutputIterator values_begin) const |
Number | LinearAlgebra::ReadWriteVector< Number >::local_element (const size_type local_index) const |
Number & | LinearAlgebra::ReadWriteVector< Number >::local_element (const size_type local_index) |
Basic object handling | |
Vector< Number >::Vector () | |
Vector< Number >::Vector (const Vector< Number > &v) | |
Vector< Number >::Vector (Vector< Number > &&v) noexcept=default | |
template<typename OtherNumber > | |
Vector< Number >::Vector (const Vector< OtherNumber > &v) | |
template<typename OtherNumber > | |
Vector< Number >::Vector (const std::initializer_list< OtherNumber > &v) | |
Vector< Number >::Vector (const PETScWrappers::VectorBase &v) | |
Vector< Number >::Vector (const TrilinosWrappers::MPI::Vector &v) | |
Vector< Number >::Vector (const size_type n) | |
template<typename InputIterator > | |
Vector< Number >::Vector (const InputIterator first, const InputIterator last) | |
virtual | Vector< Number >::~Vector () override=default |
void | Vector< Number >::compress (::VectorOperation::values operation=::VectorOperation::unknown) const |
virtual void | Vector< Number >::reinit (const size_type N, const bool omit_zeroing_entries=false) |
void | Vector< Number >::grow_or_shrink (const size_type N) |
void | Vector< Number >::apply_givens_rotation (const std::array< Number, 3 > &csr, const size_type i, const size_type k) |
template<typename Number2 > | |
void | Vector< Number >::reinit (const Vector< Number2 > &V, const bool omit_zeroing_entries=false) |
virtual void | Vector< Number >::swap (Vector< Number > &v) |
Vector< Number > & | Vector< Number >::operator= (const Number s) |
Vector< Number > & | Vector< Number >::operator= (const Vector< Number > &v) |
Vector< Number > & | Vector< Number >::operator= (Vector< Number > &&v) noexcept=default |
template<typename Number2 > | |
Vector< Number > & | Vector< Number >::operator= (const Vector< Number2 > &v) |
Vector< Number > & | Vector< Number >::operator= (const BlockVector< Number > &v) |
Vector< Number > & | Vector< Number >::operator= (const PETScWrappers::VectorBase &v) |
Vector< Number > & | Vector< Number >::operator= (const TrilinosWrappers::MPI::Vector &v) |
template<typename Number2 > | |
bool | Vector< Number >::operator== (const Vector< Number2 > &v) const |
template<typename Number2 > | |
bool | Vector< Number >::operator!= (const Vector< Number2 > &v) const |
Scalar products, norms and related operations | |
template<typename Number2 > | |
Number | Vector< Number >::operator* (const Vector< Number2 > &V) const |
real_type | Vector< Number >::norm_sqr () const |
Number | Vector< Number >::mean_value () const |
real_type | Vector< Number >::l1_norm () const |
real_type | Vector< Number >::l2_norm () const |
real_type | Vector< Number >::lp_norm (const real_type p) const |
real_type | Vector< Number >::linfty_norm () const |
Number | Vector< Number >::add_and_dot (const Number a, const Vector< Number > &V, const Vector< Number > &W) |
Data access | |
pointer | Vector< Number >::data () |
const_pointer | Vector< Number >::data () const |
iterator | Vector< Number >::begin () |
const_iterator | Vector< Number >::begin () const |
iterator | Vector< Number >::end () |
const_iterator | Vector< Number >::end () const |
Number | Vector< Number >::operator() (const size_type i) const |
Number & | Vector< Number >::operator() (const size_type i) |
Number | Vector< Number >::operator[] (const size_type i) const |
Number & | Vector< Number >::operator[] (const size_type i) |
template<typename OtherNumber > | |
void | Vector< Number >::extract_subvector_to (const std::vector< size_type > &indices, std::vector< OtherNumber > &values) const |
template<typename ForwardIterator , typename OutputIterator > | |
void | Vector< Number >::extract_subvector_to (ForwardIterator indices_begin, const ForwardIterator indices_end, OutputIterator values_begin) const |
Modification of vectors | |
Vector< Number > & | Vector< Number >::operator+= (const Vector< Number > &V) |
Vector< Number > & | Vector< Number >::operator-= (const Vector< Number > &V) |
template<typename OtherNumber > | |
void | Vector< Number >::add (const std::vector< size_type > &indices, const std::vector< OtherNumber > &values) |
template<typename OtherNumber > | |
void | Vector< Number >::add (const std::vector< size_type > &indices, const Vector< OtherNumber > &values) |
template<typename OtherNumber > | |
void | Vector< Number >::add (const size_type n_elements, const size_type *indices, const OtherNumber *values) |
void | Vector< Number >::add (const Number s) |
void | Vector< Number >::add (const Number a, const Vector< Number > &V, const Number b, const Vector< Number > &W) |
void | Vector< Number >::add (const Number a, const Vector< Number > &V) |
void | Vector< Number >::sadd (const Number s, const Vector< Number > &V) |
void | Vector< Number >::sadd (const Number s, const Number a, const Vector< Number > &V) |
Vector< Number > & | Vector< Number >::operator*= (const Number factor) |
Vector< Number > & | Vector< Number >::operator/= (const Number factor) |
void | Vector< Number >::scale (const Vector< Number > &scaling_factors) |
template<typename Number2 > | |
void | Vector< Number >::scale (const Vector< Number2 > &scaling_factors) |
void | Vector< Number >::equ (const Number a, const Vector< Number > &u) |
template<typename Number2 > | |
void | Vector< Number >::equ (const Number a, const Vector< Number2 > &u) |
void | Vector< Number >::update_ghost_values () const |
Input and output | |
void | Vector< Number >::print (std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const |
void | Vector< Number >::block_write (std::ostream &out) const |
void | Vector< Number >::block_read (std::istream &in) |
template<class Archive > | |
void | Vector< Number >::save (Archive &ar, const unsigned int version) const |
template<class Archive > | |
void | Vector< Number >::load (Archive &ar, const unsigned int version) |
template<class Archive > | |
void | Vector< Number >::serialize (Archive &archive, const unsigned int version) |
Information about the object | |
AlignedVector< Number > | Vector< Number >::values |
std::shared_ptr< parallel::internal::TBBPartitioner > | Vector< Number >::thread_loop_partitioner |
template<typename Number2 > | |
class | Vector< Number >::Vector |
bool | Vector< Number >::in_local_range (const size_type global_index) const |
IndexSet | Vector< Number >::locally_owned_elements () const |
size_type | Vector< Number >::size () const |
bool | Vector< Number >::all_zero () const |
bool | Vector< Number >::is_non_negative () const |
std::size_t | Vector< Number >::memory_consumption () const |
bool | Vector< Number >::has_ghost_elements () const |
void | Vector< Number >::maybe_reset_thread_partitioner () |
void | Vector< Number >::do_reinit (const size_type new_size, const bool omit_zeroing_entries, const bool reset_partitioner) |
Here, we list all the classes that satisfy the VectorType
concept and may be used in linear solvers (see Linear solver classes) and for matrix-vector operations.
using BlockVector< Number >::BaseClass = BlockVectorBase<Vector<Number> > |
Typedef the base class for simpler access to its own alias.
Definition at line 77 of file block_vector.h.
using BlockVector< Number >::BlockType = typename BaseClass::BlockType |
Typedef the type of the underlying vector.
Definition at line 82 of file block_vector.h.
using BlockVector< Number >::value_type = typename BaseClass::value_type |
Import the alias from the base class.
Definition at line 87 of file block_vector.h.
using BlockVector< Number >::real_type = typename BaseClass::real_type |
Definition at line 88 of file block_vector.h.
using BlockVector< Number >::pointer = typename BaseClass::pointer |
Definition at line 89 of file block_vector.h.
using BlockVector< Number >::const_pointer = typename BaseClass::const_pointer |
Definition at line 90 of file block_vector.h.
using BlockVector< Number >::reference = typename BaseClass::reference |
Definition at line 91 of file block_vector.h.
using BlockVector< Number >::const_reference = typename BaseClass::const_reference |
Definition at line 92 of file block_vector.h.
using BlockVector< Number >::size_type = typename BaseClass::size_type |
Definition at line 93 of file block_vector.h.
using BlockVector< Number >::iterator = typename BaseClass::iterator |
Definition at line 94 of file block_vector.h.
using BlockVector< Number >::const_iterator = typename BaseClass::const_iterator |
Definition at line 95 of file block_vector.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::size_type = types::global_dof_index |
Declare the type for container size.
Definition at line 145 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::value_type = typename std::conditional<Constness, const typename BlockVectorType::value_type, typename BlockVectorType::value_type>::type |
Type of the number this iterator points to. Depending on the value of the second template parameter, this is either a constant or non-const number.
Definition at line 155 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::iterator_category = std::random_access_iterator_tag |
Declare some alias which are standard for iterators and are used by algorithms to enquire about the specifics of the iterators they work on.
Definition at line 162 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::difference_type = std::ptrdiff_t |
Definition at line 163 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::reference = typename BlockVectorType::reference |
Definition at line 164 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::pointer = value_type * |
Definition at line 165 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::dereference_type = typename std::conditional< Constness, value_type, typename BlockVectorType::BlockType::reference>::type |
Definition at line 170 of file block_vector_base.h.
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::BlockVector = typename std:: conditional<Constness, const BlockVectorType, BlockVectorType>::type |
Typedef the type of the block vector (which differs in constness, depending on the second template parameter).
Definition at line 177 of file block_vector_base.h.
using LinearAlgebra::distributed::BlockVector< Number >::BaseClass = BlockVectorBase<Vector<Number> > |
Typedef the base class for simpler access to its own alias.
Definition at line 106 of file la_parallel_block_vector.h.
using LinearAlgebra::distributed::BlockVector< Number >::BlockType = typename BaseClass::BlockType |
Typedef the type of the underlying vector.
Definition at line 111 of file la_parallel_block_vector.h.
using LinearAlgebra::distributed::BlockVector< Number >::value_type = typename BaseClass::value_type |
Import the alias from the base class.
Definition at line 116 of file la_parallel_block_vector.h.
using LinearAlgebra::distributed::BlockVector< Number >::real_type = typename BaseClass::real_type |
Definition at line 117 of file la_parallel_block_vector.h.
using LinearAlgebra::distributed::BlockVector< Number >::pointer = typename BaseClass::pointer |
Definition at line 118 of file la_parallel_block_vector.h.
using LinearAlgebra::distributed::BlockVector< Number >::const_pointer = typename BaseClass::const_pointer |
Definition at line 119 of file la_parallel_block_vector.h.
using LinearAlgebra::distributed::BlockVector< Number >::reference = typename BaseClass::reference |
Definition at line 120 of file la_parallel_block_vector.h.
using LinearAlgebra::distributed::BlockVector< Number >::const_reference = typename BaseClass::const_reference |
Definition at line 121 of file la_parallel_block_vector.h.
using LinearAlgebra::distributed::BlockVector< Number >::size_type = typename BaseClass::size_type |
Definition at line 122 of file la_parallel_block_vector.h.
using LinearAlgebra::distributed::BlockVector< Number >::iterator = typename BaseClass::iterator |
Definition at line 123 of file la_parallel_block_vector.h.
using LinearAlgebra::distributed::BlockVector< Number >::const_iterator = typename BaseClass::const_iterator |
Definition at line 124 of file la_parallel_block_vector.h.
using LinearAlgebra::distributed::Vector< Number, MemorySpace >::memory_space = MemorySpace |
Definition at line 230 of file la_parallel_vector.h.
using LinearAlgebra::distributed::Vector< Number, MemorySpace >::value_type = Number |
Definition at line 231 of file la_parallel_vector.h.
using LinearAlgebra::distributed::Vector< Number, MemorySpace >::pointer = value_type * |
Definition at line 232 of file la_parallel_vector.h.
using LinearAlgebra::distributed::Vector< Number, MemorySpace >::const_pointer = const value_type * |
Definition at line 233 of file la_parallel_vector.h.
using LinearAlgebra::distributed::Vector< Number, MemorySpace >::iterator = value_type * |
Definition at line 234 of file la_parallel_vector.h.
using LinearAlgebra::distributed::Vector< Number, MemorySpace >::const_iterator = const value_type * |
Definition at line 235 of file la_parallel_vector.h.
using LinearAlgebra::distributed::Vector< Number, MemorySpace >::reference = value_type & |
Definition at line 236 of file la_parallel_vector.h.
using LinearAlgebra::distributed::Vector< Number, MemorySpace >::const_reference = const value_type & |
Definition at line 237 of file la_parallel_vector.h.
using LinearAlgebra::distributed::Vector< Number, MemorySpace >::size_type = types::global_dof_index |
Definition at line 238 of file la_parallel_vector.h.
using LinearAlgebra::distributed::Vector< Number, MemorySpace >::real_type = typename numbers::NumberTraits<Number>::real_type |
Definition at line 239 of file la_parallel_vector.h.
using LinearAlgebra::Vector< Number >::size_type = types::global_dof_index |
Definition at line 83 of file la_vector.h.
using LinearAlgebra::Vector< Number >::value_type = typename ReadWriteVector<Number>::value_type |
Definition at line 84 of file la_vector.h.
using parallel::distributed::BlockVector = typedef LinearAlgebra::distributed::BlockVector<Number> |
An implementation of block vectors based on distributed deal.II vectors. 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.
<float> and <double>
; others can be generated in application programs (see the section on Template instantiations in the manual).Definition at line 61 of file parallel_block_vector.h.
using parallel::distributed::Vector = typedef LinearAlgebra::distributed::Vector<Number> |
Implementation of a parallel vector class. The design of this class is similar to the standard Vector class in deal.II, with the exception that storage is distributed with MPI.
The vector is designed for the following scheme of parallel partitioning:
[my_first_index,my_last_index)
. reinit (locally_owned, ghost_indices, communicator)
, and retained until the partitioning is changed. This allows for efficient parallel communication of indices. In particular, it stores the communication pattern, rather than having to compute it again for every communication. For more information on ghost vectors, see also the glossary entry on vectors with ghost elements. local_element()
. Locally owned indices are placed first, [0, local_size()), and then all ghost indices follow after them contiguously, [local_size(), local_size()+n_ghost_entries()). Functions related to parallel functionality:
compress()
goes through the data associated with ghost indices and communicates it to the owner process, which can then add it to the correct position. This can be used e.g. after having run an assembly routine involving ghosts that fill this vector. Note that the insert
mode of compress()
does not set the elements included in ghost entries but simply discards them, assuming that the owning processor has set them to the desired value already (See also the glossary entry on compress). update_ghost_values()
function imports the data from the owning processor to the ghost indices in order to provide read access to the data associated with ghosts. This vector can take two different states with respect to ghost elements:
operator= (0.)
), the vector does only allow writing into ghost elements but not reading from ghost elements. true
exactly when ghost elements have been updated and false
otherwise, irrespective of the actual number of ghost entries in the vector layout (for that information, use n_ghost_entries() instead). This vector uses the facilities of the class Vector<Number> for implementing the operations on the local range of the vector. In particular, it also inherits thread parallelism that splits most vector-vector operations into smaller chunks if the program uses multiple threads. This may or may not be desired when working also with MPI.
This vector class is based on two different number types for indexing. The so-called global index type encodes the overall size of the vector. Its type is types::global_dof_index. The largest possible value is 2^32-1
or approximately 4 billion in case 64 bit integers are disabled at configuration of deal.II (default case) or 2^64-1
or approximately 10^19
if 64 bit integers are enabled (see the glossary entry on When to use types::global_dof_index instead of unsigned int for further information).
The second relevant index type is the local index used within one MPI rank. As opposed to the global index, the implementation assumes 32-bit unsigned integers unconditionally. In other words, to actually use a vector with more than four billion entries, you need to use MPI with more than one rank (which in general is a safe assumption since four billion entries consume at least 16 GB of memory for floats or 32 GB of memory for doubles) and enable 64-bit indices. If more than 4 billion local elements are present, the implementation tries to detect that, which triggers an exception and aborts the code. Note, however, that the detection of overflow is tricky and the detection mechanism might fail in some circumstances. Therefore, it is strongly recommended to not rely on this class to automatically detect the unsupported case.
Definition at line 148 of file parallel_vector.h.
using LinearAlgebra::ReadWriteVector< Number >::value_type = Number |
Declare standard types used in all containers. These types parallel those in the C++
standard libraries vector<...>
class.
Definition at line 139 of file read_write_vector.h.
using LinearAlgebra::ReadWriteVector< Number >::pointer = value_type * |
Definition at line 140 of file read_write_vector.h.
using LinearAlgebra::ReadWriteVector< Number >::const_pointer = const value_type * |
Definition at line 141 of file read_write_vector.h.
using LinearAlgebra::ReadWriteVector< Number >::iterator = value_type * |
Definition at line 142 of file read_write_vector.h.
using LinearAlgebra::ReadWriteVector< Number >::const_iterator = const value_type * |
Definition at line 143 of file read_write_vector.h.
using LinearAlgebra::ReadWriteVector< Number >::reference = value_type & |
Definition at line 144 of file read_write_vector.h.
using LinearAlgebra::ReadWriteVector< Number >::const_reference = const value_type & |
Definition at line 145 of file read_write_vector.h.
using LinearAlgebra::ReadWriteVector< Number >::size_type = types::global_dof_index |
Definition at line 146 of file read_write_vector.h.
using LinearAlgebra::ReadWriteVector< Number >::real_type = typename numbers::NumberTraits<Number>::real_type |
Definition at line 147 of file read_write_vector.h.
using Vector< Number >::value_type = Number |
using Vector< Number >::pointer = value_type * |
using Vector< Number >::const_pointer = const value_type * |
using Vector< Number >::iterator = value_type * |
using Vector< Number >::const_iterator = const value_type * |
using Vector< Number >::reference = value_type & |
using Vector< Number >::const_reference = const value_type & |
using Vector< Number >::size_type = types::global_dof_index |
using Vector< Number >::real_type = typename numbers::NumberTraits<Number>::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 alias is used to represent the return type of norms.
using LinearAlgebra::VectorSpaceVector< Number >::value_type = Number |
Definition at line 60 of file vector_space_vector.h.
using LinearAlgebra::VectorSpaceVector< Number >::size_type = types::global_dof_index |
Definition at line 61 of file vector_space_vector.h.
using LinearAlgebra::VectorSpaceVector< Number >::real_type = typename numbers::NumberTraits<Number>::real_type |
Definition at line 62 of file vector_space_vector.h.
Definition at line 40 of file vector_operation.h.
|
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 n_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.
BlockVector< Number >::BlockVector | ( | const BlockVector< Number > & | V | ) |
Copy Constructor. Dimension set to that of v
, all components are copied from v
.
|
defaultnoexcept |
Move constructor. Creates a new vector by stealing the internal data of the given argument vector.
|
explicit |
Copy constructor taking a BlockVector of another data type. This will fail if there is no conversion path from OtherNumber
to Number
. Note that you may lose accuracy when copying to a BlockVector with data elements with less accuracy.
Older versions of gcc did not honor the explicit
keyword on template constructors. In such cases, it is easy to accidentally write code that can be very inefficient, since the compiler starts performing hidden conversions. To avoid this, this function is disabled if we have detected a broken compiler during configuration.
BlockVector< Number >::BlockVector | ( | const TrilinosWrappers::MPI::BlockVector< Number > & | v | ) |
A copy constructor taking a (parallel) Trilinos block vector and copying it into the deal.II own format.
BlockVector< Number >::BlockVector | ( | const std::vector< size_type > & | block_sizes | ) |
Constructor. Set the number of blocks to block_sizes.size()
and initialize each block with block_sizes[i]
zero elements.
BlockVector< Number >::BlockVector | ( | const BlockIndices & | block_indices | ) |
Constructor. Initialize vector to the structure found in the BlockIndices argument.
BlockVector< Number >::BlockVector | ( | const std::vector< size_type > & | block_sizes, |
const InputIterator | first, | ||
const InputIterator | end | ||
) |
Constructor. Set the number of blocks to block_sizes.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.
|
overridedefault |
Destructor. Clears memory
void BlockVector< Number >::compress | ( | ::VectorOperation::values | operation = ::VectorOperation::unknown | ) |
Call the compress() function on all the subblocks.
This functionality only needs to be called if using MPI based vectors and exists in other objects for compatibility.
See Compressing distributed objects for more information.
bool BlockVector< Number >::has_ghost_elements | ( | ) | const |
Returns false
as this is a serial block vector.
This functionality only needs to be called if using MPI based vectors and exists in other objects for compatibility.
BlockVector& BlockVector< Number >::operator= | ( | const value_type | s | ) |
Copy operator: fill all components of the vector with the given scalar value.
BlockVector<Number>& BlockVector< Number >::operator= | ( | const BlockVector< Number > & | v | ) |
Copy operator for arguments of the same type. Resize the present vector if necessary.
|
default |
Move the given vector. This operator replaces the present vector with the contents of the given argument vector.
BlockVector<Number>& BlockVector< Number >::operator= | ( | const BlockVector< Number2 > & | V | ) |
Copy operator for template arguments of different types. Resize the present vector if necessary.
BlockVector<Number>& BlockVector< Number >::operator= | ( | const Vector< Number > & | V | ) |
Copy a regular vector into a block vector.
BlockVector<Number>& BlockVector< Number >::operator= | ( | const TrilinosWrappers::MPI::BlockVector< Number > & | V | ) |
A copy constructor from a Trilinos block vector to a deal.II block vector.
void BlockVector< Number >::reinit | ( | const unsigned int | n_blocks, |
const size_type | block_size = 0 , |
||
const bool | omit_zeroing_entries = false |
||
) |
Reinitialize the BlockVector to contain n_blocks
blocks of size block_size
each.
If the second argument is left at its default value, then the block vector allocates the specified number of blocks but leaves them at zero size. You then need to later reinitialize the individual blocks, and call collect_sizes() to update the block system's knowledge of its individual block's sizes.
If omit_zeroing_entries==false
, the vector is filled with zeros.
void BlockVector< Number >::reinit | ( | const std::vector< size_type > & | block_sizes, |
const bool | omit_zeroing_entries = false |
||
) |
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 omit_zeroing_entries==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.
void BlockVector< Number >::reinit | ( | const BlockIndices & | block_indices, |
const bool | omit_zeroing_entries = false |
||
) |
Reinitialize the BlockVector to reflect the structure found in BlockIndices.
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 omit_zeroing_entries==false
, the vector is filled with zeros.
void BlockVector< Number >::reinit | ( | const BlockVector< Number2 > & | V, |
const bool | omit_zeroing_entries = 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(), omit_zeroing_entries)
.
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.
void BlockVector< Number >::scale | ( | const BlockVector2 & | v | ) |
Multiply each element of this vector by the corresponding element of v
.
void BlockVector< Number >::swap | ( | BlockVector< Number > & | v | ) |
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.
This function is analogous to 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.
void BlockVector< Number >::print | ( | std::ostream & | out, |
const unsigned int | precision = 3 , |
||
const bool | scientific = true , |
||
const bool | across = true |
||
) | const |
Print to a stream.
void BlockVector< Number >::block_write | ( | std::ostream & | out | ) | const |
Write the vector en bloc to a stream. This is done in a binary mode, so the output is neither readable by humans nor (probably) by other computers using a different operating system or number format.
void BlockVector< Number >::block_read | ( | std::istream & | in | ) |
Read a vector en block from a file. This is done using the inverse operations to the above function, so it is reasonably fast because the bitstream is not interpreted.
The vector is resized if necessary.
A primitive form of error checking is performed which will recognize the bluntest attempts to interpret some data as a vector stored bitwise to a file, but not more.
|
inline |
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.
Definition at line 491 of file block_vector.h.
|
staticprivate |
Overload returning true if the class is derived from BlockVectorBase, which is what block vectors do.
|
staticprivate |
Catch all for all other potential vector types that are not block matrices.
internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::Iterator | ( | BlockVector & | parent, |
const size_type | global_index | ||
) |
Construct an iterator from a vector to which we point and the global index of the element pointed to.
Depending on the value of the Constness
template argument of this class, the first argument of this constructor is either is a const or non-const reference.
internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::Iterator | ( | const Iterator< BlockVectorType, !Constness > & | c | ) |
Copy constructor from an iterator of different constness.
static_assert
). internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::Iterator | ( | const Iterator< BlockVectorType, Constness > & | c | ) |
Copy constructor from an iterator with the same constness.
|
private |
Constructor used internally in this class. The arguments match exactly the values of the respective member variables.
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator= | ( | const Iterator< BlockVectorType, Constness > & | c | ) |
Copy operator.
dereference_type internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator* | ( | ) | const |
Dereferencing operator. If the template argument Constness
is true
, then no writing to the result is possible, making this a const_iterator.
dereference_type internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator[] | ( | const difference_type | d | ) | const |
Random access operator, grant access to arbitrary elements relative to the one presently pointed to.
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator++ | ( | ) |
Prefix increment operator. This operator advances the iterator to the next element and returns a reference to *this
.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator++ | ( | int | ) |
Postfix increment operator. This operator advances the iterator to the next element and returns a copy of the old value of this iterator.
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator-- | ( | ) |
Prefix decrement operator. This operator retracts the iterator to the previous element and returns a reference to *this
.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator-- | ( | int | ) |
Postfix decrement operator. This operator retracts the iterator to the previous element and returns a copy of the old value of this iterator.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator== | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Compare for equality of iterators. This operator checks whether the vectors pointed to are the same, and if not it throws an exception.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator!= | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Compare for inequality of iterators. This operator checks whether the vectors pointed to are the same, and if not it throws an exception.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator< | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Check whether this iterators points to an element previous to the one pointed to by the given argument. This operator checks whether the vectors pointed to are the same, and if not it throws an exception.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator<= | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Comparison operator alike to the one above.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator> | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Comparison operator alike to the one above.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator>= | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Comparison operator alike to the one above.
difference_type internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator- | ( | const Iterator< BlockVectorType, OtherConstness > & | i | ) | const |
Return the distance between the two iterators, in elements.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator+ | ( | const difference_type & | d | ) | const |
Return an iterator which is the given number of elements in front of the present one.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator- | ( | const difference_type & | d | ) | const |
Return an iterator which is the given number of elements behind the present one.
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator+= | ( | const difference_type & | d | ) |
Move the iterator d
elements forward at once, and return the result.
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator-= | ( | const difference_type & | d | ) |
Move the iterator d
elements backward at once, and return the result.
|
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.
LinearAlgebra::distributed::BlockVector< Number >::BlockVector | ( | const BlockVector< Number > & | V | ) |
Copy-Constructor. Dimension set to that of V, all components are copied from V
|
explicit |
Copy constructor taking a BlockVector of another data type. This will fail if there is no conversion path from OtherNumber
to Number
. Note that you may lose accuracy when copying to a BlockVector with data elements with less accuracy.
Older versions of gcc did not honor the explicit
keyword on template constructors. In such cases, it is easy to accidentally write code that can be very inefficient, since the compiler starts performing hidden conversions. To avoid this, this function is disabled if we have detected a broken compiler during configuration.
LinearAlgebra::distributed::BlockVector< Number >::BlockVector | ( | const std::vector< size_type > & | block_sizes | ) |
Constructor. Set the number of blocks to block_sizes.size()
and initialize each block with block_sizes[i]
zero elements.
LinearAlgebra::distributed::BlockVector< Number >::BlockVector | ( | const std::vector< IndexSet > & | local_ranges, |
const std::vector< IndexSet > & | ghost_indices, | ||
const MPI_Comm | communicator | ||
) |
Construct a block vector with an IndexSet for the local range and ghost entries for each block.
LinearAlgebra::distributed::BlockVector< Number >::BlockVector | ( | const std::vector< IndexSet > & | local_ranges, |
const MPI_Comm | communicator | ||
) |
Same as above but the ghost indices are assumed to be empty.
|
overridevirtualdefault |
Destructor.
|
overridevirtual |
Copy operator: fill all components of the vector with the given scalar value.
BlockVector& LinearAlgebra::distributed::BlockVector< Number >::operator= | ( | const BlockVector< Number > & | V | ) |
Copy operator for arguments of the same type. Resize the present vector if necessary.
BlockVector& LinearAlgebra::distributed::BlockVector< Number >::operator= | ( | const BlockVector< Number2 > & | V | ) |
Copy operator for template arguments of different types. Resize the present vector if necessary.
BlockVector& LinearAlgebra::distributed::BlockVector< Number >::operator= | ( | const Vector< Number > & | V | ) |
Copy a regular vector into a block vector.
BlockVector<Number>& LinearAlgebra::distributed::BlockVector< Number >::operator= | ( | const PETScWrappers::MPI::BlockVector< Number > & | petsc_vec | ) |
Copy the content of a PETSc vector into the calling vector. This function assumes that the vectors layouts have already been initialized to match.
This operator is only available if deal.II was configured with PETSc.
BlockVector<Number>& LinearAlgebra::distributed::BlockVector< Number >::operator= | ( | const TrilinosWrappers::MPI::BlockVector< Number > & | trilinos_vec | ) |
Copy the content of a Trilinos vector into the calling vector. This function assumes that the vectors layouts have already been initialized to match.
This operator is only available if deal.II was configured with Trilinos.
void LinearAlgebra::distributed::BlockVector< Number >::reinit | ( | const size_type | num_blocks, |
const size_type | block_size = 0 , |
||
const bool | omit_zeroing_entries = false |
||
) |
Reinitialize the BlockVector to contain num_blocks
blocks of size block_size
each.
If the second argument is left at its default value, then the block vector allocates the specified number of blocks but leaves them at zero size. You then need to later reinitialize the individual blocks, and call collect_sizes() to update the block system's knowledge of its individual block's sizes.
If omit_zeroing_entries==false
, the vector is filled with zeros.
void LinearAlgebra::distributed::BlockVector< Number >::reinit | ( | const std::vector< size_type > & | N, |
const bool | omit_zeroing_entries = false |
||
) |
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 omit_zeroing_entries==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.
void LinearAlgebra::distributed::BlockVector< Number >::reinit | ( | const BlockVector< Number2 > & | V, |
const bool | omit_zeroing_entries = 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(), omit_zeroing_entries)
.
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.
|
overridevirtual |
This function copies the data that has accumulated in the data buffer for ghost indices to the owning processor. For the meaning of the argument operation
, see the entry on Compressing distributed vectors and matrices in the glossary.
There are two variants for this function. If called with argument VectorOperation::add
adds all the data accumulated in ghost elements to the respective elements on the owning processor and clears the ghost array afterwards. If called with argument VectorOperation::insert
, a set operation is performed. Since setting elements in a vector with ghost elements is ambiguous (as one can set both the element on the ghost site as well as the owning site), this operation makes the assumption that all data is set correctly on the owning processor. Upon call of compress(VectorOperation::insert), all ghost entries are therefore simply zeroed out (using zero_ghost_values()). In debug mode, a check is performed that makes sure that the data set is actually consistent between processors, i.e., whenever a non-zero ghost element is found, it is compared to the value on the owning processor and an exception is thrown if these elements do not agree.
void LinearAlgebra::distributed::BlockVector< Number >::update_ghost_values | ( | ) | const |
Fills the data field for ghost indices with the values stored in the respective positions of the owning processor. This function is needed before reading from ghosts. The function is const
even though ghost data is changed. This is needed to allow functions with a const
vector to perform the data exchange without creating temporaries.
void LinearAlgebra::distributed::BlockVector< Number >::zero_out_ghosts | ( | ) | const |
This method zeros the entries on ghost dofs, but does not touch locally owned DoFs.
After calling this method, read access to ghost elements of the vector is forbidden and an exception is thrown. Only write access to ghost elements is allowed in this state.
bool LinearAlgebra::distributed::BlockVector< Number >::has_ghost_elements | ( | ) | const |
Return if this Vector contains ghost elements.
void LinearAlgebra::distributed::BlockVector< Number >::add | ( | const std::vector< size_type > & | indices, |
const ::Vector< OtherNumber > & | values | ||
) |
This is a collective add operation that adds a whole set of values stored in values
to the vector components specified by indices
.
void LinearAlgebra::distributed::BlockVector< Number >::sadd | ( | const Number | s, |
const BlockVector< Number > & | V | ||
) |
Scaling and simple vector addition, i.e. *this = s*(*this)+V
.
|
overridevirtual |
Return whether the vector contains only elements with value zero. This function is mainly for internal consistency checks and should seldom be used when not in debug mode since it uses quite some time.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Compute the mean value of all the entries in the vector.
Implements LinearAlgebra::VectorSpaceVector< Number >.
real_type LinearAlgebra::distributed::BlockVector< Number >::lp_norm | ( | const real_type | p | ) | const |
\(l_p\)-norm of the vector. The pth root of the sum of the pth powers of the absolute values of the elements.
void LinearAlgebra::distributed::BlockVector< Number >::swap | ( | BlockVector< Number > & | v | ) |
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 analogous to 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.
|
overridevirtual |
Change the dimension to that of the vector V. The elements of V are not copied.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Multiply the entire vector by a fixed factor.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Divide the entire vector by a fixed factor.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Add the vector V
to the present one.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Subtract the vector V
from the present one.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Import all the elements present in the vector's IndexSet from the input vector V
. VectorOperation::values operation
is used to decide if the elements in V
should be added to the current vector or replace the current elements. The last parameter can be used if the same communication pattern is used multiple times. This can be used to improve performance.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the scalar product of two vectors.
Implements LinearAlgebra::VectorSpaceVector< Number >.
void LinearAlgebra::distributed::BlockVector< Number >::multivector_inner_product | ( | FullMatrixType & | matrix, |
const BlockVector< Number > & | V, | ||
const bool | symmetric = false |
||
) | const |
Calculate the scalar product between each block of this vector and V
and store the result in a full matrix matrix
. This function computes the result by forming \(A_{ij}=U_i \cdot V_j\) where \(U_i\) and \(V_j\) indicate the \(i\)th block (not element!) of \(U\) and the \(j\)th block of \(V\), respectively. If symmetric
is true
, it is assumed that inner product results in a square symmetric matrix and almost half of the scalar products can be avoided.
Obviously, this function can only be used if all blocks of both vectors are of the same size.
Number LinearAlgebra::distributed::BlockVector< Number >::multivector_inner_product_with_metric | ( | const FullMatrixType & | matrix, |
const BlockVector< Number > & | V, | ||
const bool | symmetric = false |
||
) | const |
Calculate the scalar product between each block of this vector and V
using a metric tensor matrix
. This function computes the result of \( \sum_{ij} A^{ij} U_i \cdot V_j\) where \(U_i\) and \(V_j\) indicate the \(i\)th block (not element) of \(U\) and the \(j\)th block of \(V\), respectively. If symmetric
is true
, it is assumed that \(U_i \cdot V_j\) and \(A^{ij}\) are symmetric matrices and almost half of the scalar products can be avoided.
Obviously, this function can only be used if all blocks of both vectors are of the same size.
void LinearAlgebra::distributed::BlockVector< Number >::mmult | ( | BlockVector< Number > & | V, |
const FullMatrixType & | matrix, | ||
const Number | s = Number(0.) , |
||
const Number | b = Number(1.) |
||
) | const |
Set each block of this vector as follows: \(V^i = s V^i + b \sum_{j} U_j A^{ji}\) where \(V^i\) and \(U_j\) indicate the \(i\)th block (not element) of \(V\) and the \(j\)th block of \(U\), respectively.
Obviously, this function can only be used if all blocks of both vectors are of the same size.
|
overridevirtual |
Add a
to all components. Note that a
is a scalar not a vector.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Simple addition of a multiple of a vector, i.e. *this += a*V
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Multiple addition of scaled vectors, i.e. *this += a*V+b*W
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
virtual |
A collective add operation: This function adds a whole set of values stored in values
to the vector components specified by indices
.
|
overridevirtual |
Scaling and simple addition of a multiple of a vector, i.e. *this = s*(*this)+a*V
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Scale each element of this vector by the corresponding element in the argument. This function is mostly meant to simulate multiplication (and immediate re-assignment) by a diagonal scaling matrix.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Assignment *this = a*V
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the l1 norm of the vector (i.e., the sum of the absolute values of all entries among all processors).
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the \(l_2\) norm of the vector (i.e., the square root of the sum of the square of all entries among all processors).
Implements LinearAlgebra::VectorSpaceVector< Number >.
real_type LinearAlgebra::distributed::BlockVector< Number >::norm_sqr | ( | ) | const |
Return the square of the \(l_2\) norm of the vector.
|
overridevirtual |
Return the maximum norm of the vector (i.e., the maximum absolute value among all entries and among all processors).
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Perform a combined operation of a vector addition and a subsequent inner product, returning the value of the inner product. In other words, the result of this function is the same as if the user called
The reason this function exists is that this operation involves less memory transfer than calling the two functions separately. This method only needs to load three vectors, this
, V
, W
, whereas calling separate methods means to load the calling vector this
twice. Since most vector operations are memory transfer limited, this reduces the time by 25% (or 50% if W
equals this
).
For complex-valued vectors, the scalar product in the second step is implemented as \(\left<v,w\right>=\sum_i v_i \bar{w_i}\).
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the global size of the vector, equal to the sum of the number of locally owned indices among all processors.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return an index set that describes which elements of this vector are owned by the current processor. As a consequence, the index sets returned on different processors if this is a distributed vector will form disjoint sets that add up to the complete index set. Obviously, if a vector is created on only one processor, then the result would satisfy
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Print the vector to the output stream out
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the memory consumption of this class in bytes.
Implements LinearAlgebra::VectorSpaceVector< Number >.
LinearAlgebra::distributed::Vector< Number, MemorySpace >::Vector | ( | ) |
Empty constructor.
LinearAlgebra::distributed::Vector< Number, MemorySpace >::Vector | ( | const Vector< Number, MemorySpace > & | in_vector | ) |
Copy constructor. Uses the parallel partitioning of in_vector
. It should be noted that this constructor automatically sets ghost values to zero. Call update_ghost_values()
directly following construction if a ghosted vector is required.
LinearAlgebra::distributed::Vector< Number, MemorySpace >::Vector | ( | const size_type | size | ) |
Construct a parallel vector of the given global size without any actual parallel distribution.
LinearAlgebra::distributed::Vector< Number, MemorySpace >::Vector | ( | const IndexSet & | local_range, |
const IndexSet & | ghost_indices, | ||
const MPI_Comm | communicator | ||
) |
Construct a parallel vector. The local range is specified by locally_owned_set
(note that this must be a contiguous interval, multiple intervals are not possible). The IndexSet ghost_indices
specifies ghost indices, i.e., indices which one might need to read data from or accumulate data from. It is allowed that the set of ghost indices also contains the local range, but it does not need to.
This function involves global communication, so it should only be called once for a given layout. Use the constructor with Vector<Number> argument to create additional vectors with the same parallel layout.
LinearAlgebra::distributed::Vector< Number, MemorySpace >::Vector | ( | const IndexSet & | local_range, |
const MPI_Comm | communicator | ||
) |
Same constructor as above but without any ghost indices.
LinearAlgebra::distributed::Vector< Number, MemorySpace >::Vector | ( | const std::shared_ptr< const Utilities::MPI::Partitioner > & | partitioner | ) |
Create the vector based on the parallel partitioning described in partitioner
. The input argument is a shared pointer, which store the partitioner data only once and share it between several vectors with the same layout.
|
overridevirtual |
Destructor.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::reinit | ( | const size_type | size, |
const bool | omit_zeroing_entries = false |
||
) |
Set the global size of the vector to size
without any actual parallel distribution.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::reinit | ( | const Vector< Number2, MemorySpace > & | in_vector, |
const bool | omit_zeroing_entries = false |
||
) |
Uses the parallel layout of the input vector in_vector
and allocates memory for this vector. Recommended initialization function when several vectors with the same layout should be created.
If the flag omit_zeroing_entries
is set to false, the memory will be initialized with zero, otherwise the memory will be untouched (and the user must make sure to fill it with reasonable data before using it).
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::reinit | ( | const IndexSet & | local_range, |
const IndexSet & | ghost_indices, | ||
const MPI_Comm | communicator | ||
) |
Initialize the vector. The local range is specified by locally_owned_set
(note that this must be a contiguous interval, multiple intervals are not possible). The IndexSet ghost_indices
specifies ghost indices, i.e., indices which one might need to read data from or accumulate data from. It is allowed that the set of ghost indices also contains the local range, but it does not need to.
This function involves global communication, so it should only be called once for a given layout. Use the reinit
function with Vector<Number> argument to create additional vectors with the same parallel layout.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::reinit | ( | const IndexSet & | local_range, |
const MPI_Comm | communicator | ||
) |
Same as above, but without ghost entries.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::reinit | ( | const std::shared_ptr< const Utilities::MPI::Partitioner > & | partitioner | ) |
Initialize the vector given to the parallel partitioning described in partitioner
. The input argument is a shared pointer, which store the partitioner data only once and share it between several vectors with the same layout.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::swap | ( | Vector< Number, MemorySpace > & | v | ) |
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.
This function is analogous to 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.
This function is virtual in order to allow for derived classes to handle memory separately.
Vector<Number, MemorySpace>& LinearAlgebra::distributed::Vector< Number, MemorySpace >::operator= | ( | const Vector< Number, MemorySpace > & | in_vector | ) |
Assigns the vector to the parallel partitioning of the input vector in_vector
, and copies all the data.
If one of the input vector or the calling vector (to the left of the assignment operator) had ghost elements set before this operation, the calling vector will have ghost values set. Otherwise, it will be in write mode. If the input vector does not have any ghost elements at all, the vector will also update its ghost values in analogy to the respective setting the Trilinos and PETSc vectors.
Vector<Number, MemorySpace>& LinearAlgebra::distributed::Vector< Number, MemorySpace >::operator= | ( | const Vector< Number2, MemorySpace > & | in_vector | ) |
Assigns the vector to the parallel partitioning of the input vector in_vector
, and copies all the data.
If one of the input vector or the calling vector (to the left of the assignment operator) had ghost elements set before this operation, the calling vector will have ghost values set. Otherwise, it will be in write mode. If the input vector does not have any ghost elements at all, the vector will also update its ghost values in analogy to the respective setting the Trilinos and PETSc vectors.
|
overridevirtual |
This function copies the data that has accumulated in the data buffer for ghost indices to the owning processor. For the meaning of the argument operation
, see the entry on Compressing distributed vectors and matrices in the glossary.
There are four variants for this function. If called with argument VectorOperation::add
adds all the data accumulated in ghost elements to the respective elements on the owning processor and clears the ghost array afterwards. If called with argument VectorOperation::insert
, a set operation is performed. Since setting elements in a vector with ghost elements is ambiguous (as one can set both the element on the ghost site as well as the owning site), this operation makes the assumption that all data is set correctly on the owning processor. Upon call of compress(VectorOperation::insert), all ghost entries are thus simply zeroed out (using zero_ghost_values()). In debug mode, a check is performed for whether the data set is actually consistent between processors, i.e., whenever a non-zero ghost element is found, it is compared to the value on the owning processor and an exception is thrown if these elements do not agree. If called with VectorOperation::min or VectorOperation::max, the minimum or maximum on all elements across the processors is set.
+inf
for VectorOperation::min, and -inf
for VectorOperation::max. If all values are initialized with values below zero and compress is called with VectorOperation::max two times subsequently, the maximal value after the second calculation will be zero. void LinearAlgebra::distributed::Vector< Number, MemorySpace >::update_ghost_values | ( | ) | const |
Fills the data field for ghost indices with the values stored in the respective positions of the owning processor. This function is needed before reading from ghosts. The function is const
even though ghost data is changed. This is needed to allow functions with a const
vector to perform the data exchange without creating temporaries.
After calling this method, write access to ghost elements of the vector is forbidden and an exception is thrown. Only read access to ghost elements is allowed in this state. Note that all subsequent operations on this vector, like global vector addition, etc., will also update the ghost values by a call to this method after the operation. However, global reduction operations like norms or the inner product will always ignore ghost elements in order to avoid counting the ghost data more than once. To allow writing to ghost elements again, call zero_out_ghosts().
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::compress_start | ( | const unsigned int | communication_channel = 0 , |
::VectorOperation::values | operation = VectorOperation::add |
||
) |
Initiates communication for the compress()
function with non- blocking communication. This function does not wait for the transfer to finish, in order to allow for other computations during the time it takes until all data arrives.
Before the data is actually exchanged, the function must be followed by a call to compress_finish()
.
In case this function is called for more than one vector before compress_finish()
is invoked, it is mandatory to specify a unique communication channel to each such call, in order to avoid several messages with the same ID that will corrupt this operation. Any communication channel less than 100 is a valid value (in particular, the range \([100, 200)\) is reserved for LinearAlgebra::distributed::BlockVector).
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::compress_finish | ( | ::VectorOperation::values | operation | ) |
For all requests that have been initiated in compress_start, wait for the communication to finish. Once it is finished, add or set the data (depending on the flag operation) to the respective positions in the owning processor, and clear the contents in the ghost data fields. The meaning of this argument is the same as in compress().
This function should be called exactly once per vector after calling compress_start, otherwise the result is undefined. In particular, it is not well-defined to call compress_start on the same vector again before compress_finished has been called. However, there is no warning to prevent this situation.
Must follow a call to the compress_start
function.
When the MemorySpace is CUDA and MPI is not CUDA-aware, data changed on the device after the call to compress_start will be lost.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::update_ghost_values_start | ( | const unsigned int | communication_channel = 0 | ) | const |
Initiates communication for the update_ghost_values()
function with non-blocking communication. This function does not wait for the transfer to finish, in order to allow for other computations during the time it takes until all data arrives.
Before the data is actually exchanged, the function must be followed by a call to update_ghost_values_finish()
.
In case this function is called for more than one vector before update_ghost_values_finish()
is invoked, it is mandatory to specify a unique communication channel to each such call, in order to avoid several messages with the same ID that will corrupt this operation. Any communication channel less than 100 is a valid value (in particular, the range \([100, 200)\) is reserved for LinearAlgebra::distributed::BlockVector).
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::update_ghost_values_finish | ( | ) | const |
For all requests that have been started in update_ghost_values_start, wait for the communication to finish.
Must follow a call to the update_ghost_values_start
function before reading data from ghost indices.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::zero_out_ghosts | ( | ) | const |
This method zeros the entries on ghost dofs, but does not touch locally owned DoFs.
After calling this method, read access to ghost elements of the vector is forbidden and an exception is thrown. Only write access to ghost elements is allowed in this state.
bool LinearAlgebra::distributed::Vector< Number, MemorySpace >::has_ghost_elements | ( | ) | const |
Return whether the vector currently is in a state where ghost values can be read or not. This is the same functionality as other parallel vectors have. If this method returns false, this only means that read-access to ghost elements is prohibited whereas write access is still possible (to those entries specified as ghosts during initialization), not that there are no ghost elements at all.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::copy_locally_owned_data_from | ( | const Vector< Number2, MemorySpace > & | src | ) |
This method copies the data in the locally owned range from another distributed vector src
into the calling vector. As opposed to operator= that also includes ghost entries, this operation ignores the ghost range. The only prerequisite is that the local range on the calling vector and the given vector src
are the same on all processors. It is explicitly allowed that the two vectors have different ghost elements that might or might not be related to each other.
Since no data exchange is performed, make sure that neither src
nor the calling vector have pending communications in order to obtain correct results.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::import | ( | const Vector< Number, MemorySpace2 > & | src, |
VectorOperation::values | operation | ||
) |
Import all the elements present in the distributed vector src
. VectorOperation::values operation
is used to decide if the elements in V
should be added to the current vector or replace the current elements. The main purpose of this function is to get data from one memory space, e.g. CUDA, to the other, e.g. the Host.
|
overridevirtual |
Change the dimension to that of the vector V. The elements of V are not copied.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Multiply the entire vector by a fixed factor.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Divide the entire vector by a fixed factor.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Add the vector V
to the present one.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Subtract the vector V
from the present one.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Import all the elements present in the vector's IndexSet from the input vector V
. VectorOperation::values operation
is used to decide if the elements in V
should be added to the current vector or replace the current elements. The last parameter can be used if the same communication pattern is used multiple times. This can be used to improve performance.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the scalar product of two vectors.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Add a
to all components. Note that a
is a scalar not a vector.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Simple addition of a multiple of a vector, i.e. *this += a*V
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Multiple addition of scaled vectors, i.e. *this += a*V+b*W
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
virtual |
A collective add operation: This function adds a whole set of values stored in values
to the vector components specified by indices
.
|
overridevirtual |
Scaling and simple addition of a multiple of a vector, i.e. *this = s*(*this)+a*V
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Scale each element of this vector by the corresponding element in the argument. This function is mostly meant to simulate multiplication (and immediate re-assignment) by a diagonal scaling matrix.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Assignment *this = a*V
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the l1 norm of the vector (i.e., the sum of the absolute values of all entries among all processors).
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the \(l_2\) norm of the vector (i.e., the square root of the sum of the square of all entries among all processors).
Implements LinearAlgebra::VectorSpaceVector< Number >.
real_type LinearAlgebra::distributed::Vector< Number, MemorySpace >::norm_sqr | ( | ) | const |
Return the square of the \(l_2\) norm of the vector.
|
overridevirtual |
Return the maximum norm of the vector (i.e., the maximum absolute value among all entries and among all processors).
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Perform a combined operation of a vector addition and a subsequent inner product, returning the value of the inner product. In other words, the result of this function is the same as if the user called
The reason this function exists is that this operation involves less memory transfer than calling the two functions separately. This method only needs to load three vectors, this
, V
, W
, whereas calling separate methods means to load the calling vector this
twice. Since most vector operations are memory transfer limited, this reduces the time by 25% (or 50% if W
equals this
).
For complex-valued vectors, the scalar product in the second step is implemented as \(\left<v,w\right>=\sum_i v_i \bar{w_i}\).
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the global size of the vector, equal to the sum of the number of locally owned indices among all processors.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return an index set that describes which elements of this vector are owned by the current processor. As a consequence, the index sets returned on different processors if this is a distributed vector will form disjoint sets that add up to the complete index set. Obviously, if a vector is created on only one processor, then the result would satisfy
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Print the vector to the output stream out
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the memory consumption of this class in bytes.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Sets all elements of the vector to the scalar s
. If the scalar is zero, also ghost elements are set to zero, otherwise they remain unchanged.
Implements LinearAlgebra::VectorSpaceVector< Number >.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::add | ( | const std::vector< size_type > & | indices, |
const ::Vector< OtherNumber > & | values | ||
) |
This is a collective add operation that adds a whole set of values stored in values
to the vector components specified by indices
.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::add | ( | const size_type | n_elements, |
const size_type * | indices, | ||
const OtherNumber * | values | ||
) |
Take an address where n_elements are stored contiguously and add them into the vector.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::sadd | ( | const Number | s, |
const Vector< Number, MemorySpace > & | V | ||
) |
Scaling and simple vector addition, i.e. *this = s*(*this)+V
.
size_type LinearAlgebra::distributed::Vector< Number, MemorySpace >::local_size | ( | ) | const |
Return the local size of the vector, i.e., the number of indices owned locally.
bool LinearAlgebra::distributed::Vector< Number, MemorySpace >::in_local_range | ( | const size_type | global_index | ) | const |
Return true if the given global index is in the local range of this processor.
iterator LinearAlgebra::distributed::Vector< Number, MemorySpace >::begin | ( | ) |
Make the Vector
class a bit like the vector<>
class of the C++ standard library by returning iterators to the start and end of the locally owned elements of this vector.
It holds that end() - begin() == local_size().
const_iterator LinearAlgebra::distributed::Vector< Number, MemorySpace >::begin | ( | ) | const |
Return constant iterator to the start of the locally owned elements of the vector.
iterator LinearAlgebra::distributed::Vector< Number, MemorySpace >::end | ( | ) |
Return an iterator pointing to the element past the end of the array of locally owned entries.
const_iterator LinearAlgebra::distributed::Vector< Number, MemorySpace >::end | ( | ) | const |
Return a constant iterator pointing to the element past the end of the array of the locally owned entries.
Number LinearAlgebra::distributed::Vector< Number, MemorySpace >::operator() | ( | const size_type | global_index | ) | const |
Read access to the data in the position corresponding to global_index
. The index must be either in the local range of the vector or be specified as a ghost index at construction.
Performance: O(1)
for locally owned elements that represent a contiguous range and O(log(nranges))
for ghost elements (quite fast, but slower than local_element()).
Number& LinearAlgebra::distributed::Vector< Number, MemorySpace >::operator() | ( | const size_type | global_index | ) |
Read and write access to the data in the position corresponding to global_index
. The index must be either in the local range of the vector or be specified as a ghost index at construction.
Performance: O(1)
for locally owned elements that represent a contiguous range and O(log(nranges))
for ghost elements (quite fast, but slower than local_element()).
Number LinearAlgebra::distributed::Vector< Number, MemorySpace >::operator[] | ( | const size_type | global_index | ) | const |
Read access to the data in the position corresponding to global_index
. The index must be either in the local range of the vector or be specified as a ghost index at construction.
This function does the same thing as operator().
Number& LinearAlgebra::distributed::Vector< Number, MemorySpace >::operator[] | ( | const size_type | global_index | ) |
Read and write access to the data in the position corresponding to global_index
. The index must be either in the local range of the vector or be specified as a ghost index at construction.
This function does the same thing as operator().
Number LinearAlgebra::distributed::Vector< Number, MemorySpace >::local_element | ( | const size_type | local_index | ) | const |
Read access to the data field specified by local_index
. Locally owned indices can be accessed with indices [0,local_size)
, and ghost indices with indices [local_size,local_size+ n_ghost_entries]
.
Performance: Direct array access (fast).
Number& LinearAlgebra::distributed::Vector< Number, MemorySpace >::local_element | ( | const size_type | local_index | ) |
Read and write access to the data field specified by local_index
. Locally owned indices can be accessed with indices [0,local_size)
, and ghost indices with indices [local_size,local_size+n_ghosts]
.
Performance: Direct array access (fast).
Number* LinearAlgebra::distributed::Vector< Number, MemorySpace >::get_values | ( | ) | const |
Return the pointer to the underlying raw array.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::extract_subvector_to | ( | const std::vector< size_type > & | indices, |
std::vector< OtherNumber > & | values | ||
) | const |
Instead of getting individual elements of a vector via operator(), this function allows getting a whole set of elements at once. The indices of the elements to be read are stated in the first argument, the corresponding values are returned in the second.
If the current vector is called v
, then this function is the equivalent to the code
indices
and values
arrays must be identical.void LinearAlgebra::distributed::Vector< Number, MemorySpace >::extract_subvector_to | ( | ForwardIterator | indices_begin, |
const ForwardIterator | indices_end, | ||
OutputIterator | values_begin | ||
) | const |
Instead of getting individual elements of a vector via operator(), this function allows getting a whole set of elements at once. In contrast to the previous function, this function obtains the indices of the elements by dereferencing all elements of the iterator range provided by the first two arguments, and puts the vector values into memory locations obtained by dereferencing a range of iterators starting at the location pointed to by the third argument.
If the current vector is called v
, then this function is the equivalent to the code
values_begin
as there are iterators between indices_begin
and indices_end
.
|
overridevirtual |
Return whether the vector contains only elements with value zero. This is a collective operation. This function is expensive, because potentially all elements have to be checked.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Compute the mean value of all the entries in the vector.
Implements LinearAlgebra::VectorSpaceVector< Number >.
real_type LinearAlgebra::distributed::Vector< Number, MemorySpace >::lp_norm | ( | const real_type | p | ) | const |
\(l_p\)-norm of the vector. The pth root of the sum of the pth powers of the absolute values of the elements.
const MPI_Comm& LinearAlgebra::distributed::Vector< Number, MemorySpace >::get_mpi_communicator | ( | ) | const |
Return a reference to the MPI communicator object in use with this vector.
const std::shared_ptr<const Utilities::MPI::Partitioner>& LinearAlgebra::distributed::Vector< Number, MemorySpace >::get_partitioner | ( | ) | const |
Return the MPI partitioner that describes the parallel layout of the vector. This object can be used to initialize another vector with the respective reinit() call, for additional queries regarding the parallel communication, or the compatibility of partitioners.
bool LinearAlgebra::distributed::Vector< Number, MemorySpace >::partitioners_are_compatible | ( | const Utilities::MPI::Partitioner & | part | ) | const |
Check whether the given partitioner is compatible with the partitioner used for this vector. Two partitioners are compatible if they have the same local size and the same ghost indices. They do not necessarily need to be the same data field of the shared pointer. This is a local operation only, i.e., if only some processors decide that the partitioning is not compatible, only these processors will return false
, whereas the other processors will return true
.
bool LinearAlgebra::distributed::Vector< Number, MemorySpace >::partitioners_are_globally_compatible | ( | const Utilities::MPI::Partitioner & | part | ) | const |
Check whether the given partitioner is compatible with the partitioner used for this vector. Two partitioners are compatible if they have the same local size and the same ghost indices. They do not necessarily need to be the same data field. As opposed to partitioners_are_compatible(), this method checks for compatibility among all processors and the method only returns true
if the partitioner is the same on all processors.
This method performs global communication, so make sure to use it only in a context where all processors call it the same number of times.
void LinearAlgebra::distributed::Vector< Number, MemorySpace >::set_ghost_state | ( | const bool | ghosted | ) | const |
Change the ghost state of this vector to ghosted
.
|
private |
Simple addition of a multiple of a vector, i.e. *this += a*V
without MPI communication.
|
private |
Scaling and simple addition of a multiple of a vector, i.e. *this = s*(*this)+a*V
without MPI communication.
|
private |
Local part of the inner product of two vectors.
|
private |
Local part of norm_sqr().
|
private |
Local part of mean_value().
|
private |
Local part of l1_norm().
|
private |
Local part of lp_norm().
|
private |
Local part of linfty_norm().
|
private |
Local part of the addition followed by an inner product of two vectors. The same applies for complex-valued vectors as for the add_and_dot() function.
|
private |
A helper function that clears the compress_requests and update_ghost_values_requests field. Used in reinit functions.
|
private |
A helper function that is used to resize the val array.
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
inlinestatic |
Definition at line 1845 of file la_parallel_vector.h.
|
inlinestatic |
Definition at line 1875 of file la_parallel_vector.h.
|
default |
Constructor. Create a vector of dimension zero.
Copy constructor. Sets the dimension to that of the given vector and copies all elements.
Definition at line 432 of file la_vector.h.
Constructor. Set dimension to n
and initialize all elements with zero.
The constructor is made explicit to avoid accident like this: v=0;
. Presumably, the user wants to set every element of the vector to zero, but instead, what happens is this call: v=Vector<Number>(0);
, i.e. the vector is replaced by one of length zero.
Definition at line 439 of file la_vector.h.
|
inline |
Initialize the vector with a given range of values pointed to by the iterators. This function exists in analogy to the std::vector
class.
Definition at line 447 of file la_vector.h.
|
overridevirtual |
Set the global size of the vector to size
. The stored elements have their index in [0,size).
If the flag omit_zeroing_entries
is set to false, the memory will be initialized with zero, otherwise the memory will be untouched (and the user must make sure to fill it with reasonable data before using it).
Reimplemented from LinearAlgebra::ReadWriteVector< Number >.
void LinearAlgebra::Vector< Number >::reinit | ( | const ReadWriteVector< Number2 > & | in_vector, |
const bool | omit_zeroing_entries = false |
||
) |
Uses the same IndexSet as the one of the input vector in_vector
and allocates memory for this vector.
If the flag omit_zeroing_entries
is set to false, the memory will be initialized with zero, otherwise the memory will be untouched (and the user must make sure to fill it with reasonable data before using it).
|
overridevirtual |
Initializes the vector. The indices are specified by locally_stored_indices
.
If the flag omit_zeroing_entries
is set to false, the memory will be initialized with zero, otherwise the memory will be untouched (and the user must make sure to fill it with reasonable data before using it). locally_stored_indices.
Reimplemented from LinearAlgebra::ReadWriteVector< Number >.
|
overridevirtual |
Change the dimension to that of the vector V. The elements of V are not copied.
Implements LinearAlgebra::VectorSpaceVector< Number >.
bool LinearAlgebra::Vector< Number >::has_ghost_elements | ( | ) | const |
Returns false
as this is a serial vector.
This functionality only needs to be called if using MPI based vectors and exists in other objects for compatibility.
Vector<Number>& LinearAlgebra::Vector< Number >::operator= | ( | const Vector< Number > & | in_vector | ) |
Copies the data of the input vector in_vector
.
Vector<Number>& LinearAlgebra::Vector< Number >::operator= | ( | const Vector< Number2 > & | in_vector | ) |
Copies the data of the input vector in_vector
.
|
overridevirtual |
Sets all elements of the vector to the scalar s
. This operation is only allowed if s
is equal to zero.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Multiply the entire vector by a fixed factor.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Divide the entire vector by a fixed factor.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Add the vector V
to the present one.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Subtract the vector V
from the present one.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the scalar product of two vectors.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
This function is not implemented and will throw an exception.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Add a
to all components. Note that a
is a scalar not a vector.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Simple addition of a multiple of a vector, i.e. *this += a*V
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Multiple addition of a multiple of a vector, i.e. *this += a*V+b*W
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Scaling and simple addition of a multiple of a vector, i.e. *this = s*(*this)+a*V
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Scale each element of this vector by the corresponding element in the argument. This function is mostly meant to simulate multiplication (and immediate re-assignment) by a diagonal scaling matrix.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Assignment *this = a*V
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return whether the vector contains only elements with value zero.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the mean value of all the entries of this vector.
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the l1 norm of the vector (i.e., the sum of the absolute values of all entries).
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the l2 norm of the vector (i.e., the square root of the sum of the square of all entries among all processors).
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Return the maximum norm of the vector (i.e., the maximum absolute value among all entries and among all processors).
Implements LinearAlgebra::VectorSpaceVector< Number >.
|
overridevirtual |
Perform a combined operation of a vector addition and a subsequent inner product, returning the value of the inner product. In other words, the result of this function is the same as if the user called
The reason this function exists is that this operation involves less memory transfer than calling the two functions separately. This method only needs to load three vectors, this
, V
, W
, whereas calling separate methods means to load the calling vector this
twice. Since most vector operations are memory transfer limited, this reduces the time by 25% (or 50% if W
equals this
).
For complex-valued vectors, the scalar product in the second step is implemented as \(\left<v,w\right>=\sum_i v_i \bar{w_i}\).
Implements LinearAlgebra::VectorSpaceVector< Number >.
Return the global size of the vector, equal to the sum of the number of locally owned indices among all processors.
Implements LinearAlgebra::VectorSpaceVector< Number >.
Definition at line 458 of file la_vector.h.
Return an index set that describes which elements of this vector are owned by the current processor. As a consequence, the index sets returned on different processors if this is a distributed vector will form disjoint sets that add up to the complete index set. Obviously, if a vector is created on only one processor, then the result would satisfy
Implements LinearAlgebra::VectorSpaceVector< Number >.
Definition at line 467 of file la_vector.h.
|
inlineoverridevirtual |
Print the vector to the output stream out
.
Implements LinearAlgebra::VectorSpaceVector< Number >.
Definition at line 476 of file la_vector.h.
void LinearAlgebra::Vector< Number >::print_as_numpy_array | ( | std::ostream & | out, |
const unsigned int | precision = 9 |
||
) | const |
void LinearAlgebra::Vector< Number >::block_write | ( | std::ostream & | out | ) | const |
Write the vector en bloc to a file. This is done in a binary mode, so the output is neither readable by humans nor (probably) by other computers using a different operating system or number format.
void LinearAlgebra::Vector< Number >::block_read | ( | std::istream & | in | ) |
Read a vector en block from a file. This is done using the inverse operations to the above function, so it is reasonably fast because the bitstream is not interpreted.
The vector is resized if necessary.
A primitive form of error checking is performed which will recognize the bluntest attempts to interpret some data as a vector stored bitwise to a file, but not more.
|
inlineoverridevirtual |
Return the memory consumption of this class in bytes.
Implements LinearAlgebra::VectorSpaceVector< Number >.
Definition at line 504 of file la_vector.h.
|
inlineprivate |
Serialize the data of this object using boost. This function is necessary to use boost::archive::text_iarchive and boost::archive::text_oarchive.
Definition at line 489 of file la_vector.h.
LinearAlgebra::ReadWriteVector< Number >::ReadWriteVector | ( | ) |
Empty constructor.
LinearAlgebra::ReadWriteVector< Number >::ReadWriteVector | ( | const ReadWriteVector< Number > & | in_vector | ) |
Copy constructor.
|
explicit |
Construct a vector given the size, the stored elements have their index in [0,size).
|
explicit |
Construct a vector whose stored elements indices are given by the IndexSet locally_stored_indices
.
|
overridedefault |
Destructor.
|
virtual |
Set the global size of the vector to size
. The stored elements have their index in [0,size).
If the flag omit_zeroing_entries
is set to false, the memory will be initialized with zero, otherwise the memory will be untouched (and the user must make sure to fill it with reasonable data before using it).
Reimplemented in LinearAlgebra::Vector< Number >.
void LinearAlgebra::ReadWriteVector< Number >::reinit | ( | const ReadWriteVector< Number2 > & | in_vector, |
const bool | omit_zeroing_entries = false |
||
) |
Uses the same IndexSet as the one of the input vector in_vector
and allocates memory for this vector.
If the flag omit_zeroing_entries
is set to false, the memory will be initialized with zero, otherwise the memory will be untouched (and the user must make sure to fill it with reasonable data before using it).
|
virtual |
Initializes the vector. The indices are specified by locally_stored_indices
.
If the flag omit_zeroing_entries
is set to false, the memory will be initialized with zero, otherwise the memory will be untouched (and the user must make sure to fill it with reasonable data before using it). locally_stored_indices.
Reimplemented in LinearAlgebra::Vector< Number >.
void LinearAlgebra::ReadWriteVector< Number >::reinit | ( | const TrilinosWrappers::MPI::Vector & | trilinos_vec | ) |
Initialize this ReadWriteVector by supplying access to all locally available entries in the given ghosted or non-ghosted vector.
trilinos_vec
.This function is mainly written for backwards-compatibility to get element access to a ghosted TrilinosWrappers::MPI::Vector inside the library.
void LinearAlgebra::ReadWriteVector< Number >::apply | ( | const Functor & | func | ) |
Apply the functor func
to each element of the vector. The functor should look like
void LinearAlgebra::ReadWriteVector< Number >::swap | ( | ReadWriteVector< Number > & | v | ) |
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.
This function is analogous to 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.
ReadWriteVector<Number>& LinearAlgebra::ReadWriteVector< Number >::operator= | ( | const ReadWriteVector< Number > & | in_vector | ) |
Copies the data and the IndexSet of the input vector in_vector
.
ReadWriteVector<Number>& LinearAlgebra::ReadWriteVector< Number >::operator= | ( | const ReadWriteVector< Number2 > & | in_vector | ) |
Copies the data and the IndexSet of the input vector in_vector
.
ReadWriteVector<Number>& LinearAlgebra::ReadWriteVector< Number >::operator= | ( | const Number | s | ) |
Sets all elements of the vector to the scalar s
. This operation is only allowed if s
is equal to zero.
void LinearAlgebra::ReadWriteVector< Number >::import | ( | const distributed::Vector< Number, MemorySpace > & | vec, |
VectorOperation::values | operation, | ||
const std::shared_ptr< const CommunicationPatternBase > & | communication_pattern = std::shared_ptr< const CommunicationPatternBase >() |
||
) |
Imports all the elements present in the vector's IndexSet from the input vector vec
. VectorOperation::values operation
is used to decide if the elements in V
should be added to the current vector or replace the current elements. The last parameter can be used if the same communication pattern is used multiple times. This can be used to improve performance.
void LinearAlgebra::ReadWriteVector< Number >::import | ( | const PETScWrappers::MPI::Vector & | petsc_vec, |
VectorOperation::values | operation, | ||
const std::shared_ptr< const CommunicationPatternBase > & | communication_pattern = std::shared_ptr< const CommunicationPatternBase >() |
||
) |
Imports all the elements present in the vector's IndexSet from the input vector petsc_vec
. VectorOperation::values operation
is used to decide if the elements in V
should be added to the current vector or replace the current elements. The last parameter can be used if the same communication pattern is used multiple times. This can be used to improve performance.
void LinearAlgebra::ReadWriteVector< Number >::import | ( | const TrilinosWrappers::MPI::Vector & | trilinos_vec, |
VectorOperation::values | operation, | ||
const std::shared_ptr< const CommunicationPatternBase > & | communication_pattern = std::shared_ptr< const CommunicationPatternBase >() |
||
) |
Imports all the elements present in the vector's IndexSet from the input vector trilinos_vec
. VectorOperation::values operation
is used to decide if the elements in V
should be added to the current vector or replace the current elements. The last parameter can be used if the same communication pattern is used multiple times. This can be used to improve performance.
trilinos_vec
is not allowed to have ghost entries. void LinearAlgebra::ReadWriteVector< Number >::import | ( | const TpetraWrappers::Vector< Number > & | tpetra_vec, |
VectorOperation::values | operation, | ||
const std::shared_ptr< const CommunicationPatternBase > & | communication_pattern = std::shared_ptr< const CommunicationPatternBase >() |
||
) |
Imports all the elements present in the vector's IndexSet from the input vector tpetra_vec
. VectorOperation::values operation
is used to decide if the elements in V
should be added to the current vector or replace the current elements. The last parameter can be used if the same communication pattern is used multiple times. This can be used to improve performance.
void LinearAlgebra::ReadWriteVector< Number >::import | ( | const EpetraWrappers::Vector & | epetra_vec, |
VectorOperation::values | operation, | ||
const std::shared_ptr< const CommunicationPatternBase > & | communication_pattern = std::shared_ptr< const CommunicationPatternBase >() |
||
) |
Imports all the elements present in the vector's IndexSet from the input vector epetra_vec
. VectorOperation::values operation
is used to decide if the elements in V
should be added to the current vector or replace the current elements. The last parameter can be used if the same communication pattern is used multiple times. This can be used to improve performance.
void LinearAlgebra::ReadWriteVector< Number >::import | ( | const CUDAWrappers::Vector< Number > & | cuda_vec, |
VectorOperation::values | operation, | ||
const std::shared_ptr< const CommunicationPatternBase > & | communication_pattern = std::shared_ptr< const CommunicationPatternBase >() |
||
) |
Import all the elements present in the vector's IndexSet from the input vector cuda_vec
. VectorOperation::values operation
is used to decide if the elements in V
should be added to the current vector or replace the current elements. The last parameter is not used.
size_type LinearAlgebra::ReadWriteVector< Number >::size | ( | ) | const |
The value returned by this function denotes the dimension of the vector spaces that are modeled by objects of this kind. However, objects of the current class do not actually stores all elements of vectors of this space but may, in fact store only a subset. The number of elements stored is returned by n_elements() and is smaller or equal to the number returned by the current function.
size_type LinearAlgebra::ReadWriteVector< Number >::n_elements | ( | ) | const |
This function returns the number of elements stored. It is smaller or equal to the dimension of the vector space that is modeled by an object of this kind. This dimension is return by size().
const IndexSet& LinearAlgebra::ReadWriteVector< Number >::get_stored_elements | ( | ) | const |
Return the IndexSet that represents the indices of the elements stored.
iterator LinearAlgebra::ReadWriteVector< Number >::begin | ( | ) |
Make the ReadWriteVector
class a bit like the vector<>
class of the C++ standard library by returning iterators to the start and end of the locally stored elements of this vector.
const_iterator LinearAlgebra::ReadWriteVector< Number >::begin | ( | ) | const |
Return constant iterator to the start of the locally stored elements of the vector.
iterator LinearAlgebra::ReadWriteVector< Number >::end | ( | ) |
Return an iterator pointing to the element past the end of the array of locally stored entries.
const_iterator LinearAlgebra::ReadWriteVector< Number >::end | ( | ) | const |
Return a constant iterator pointing to the element past the end of the array of the locally stored entries.
Number LinearAlgebra::ReadWriteVector< Number >::operator() | ( | const size_type | global_index | ) | const |
Read access to the data in the position corresponding to global_index
. An exception is thrown if global_index
is not stored by the current object.
Number& LinearAlgebra::ReadWriteVector< Number >::operator() | ( | const size_type | global_index | ) |
Read and write access to the data in the position corresponding to global_index
. An exception is thrown if global_index
is not stored by the current object.
Number LinearAlgebra::ReadWriteVector< Number >::operator[] | ( | const size_type | global_index | ) | const |
Read access to the data in the position corresponding to global_index
. An exception is thrown if global_index
is not stored by the current object.
This function does the same thing as operator().
Number& LinearAlgebra::ReadWriteVector< Number >::operator[] | ( | const size_type | global_index | ) |
Read and write access to the data in the position corresponding to global_index
. An exception is thrown if global_index
is not stored by the current object.
This function does the same thing as operator().
void LinearAlgebra::ReadWriteVector< Number >::extract_subvector_to | ( | const std::vector< size_type > & | indices, |
std::vector< Number2 > & | values | ||
) | const |
Instead of getting individual elements of a vector via operator(), this function allows getting a whole set of elements at once. The indices of the elements to be read are stated in the first argument, the corresponding values are returned in the second.
If the current vector is called v
, then this function is the equivalent to the code
indices
and values
arrays must be identical. void LinearAlgebra::ReadWriteVector< Number >::extract_subvector_to | ( | ForwardIterator | indices_begin, |
const ForwardIterator | indices_end, | ||
OutputIterator | values_begin | ||
) | const |
Instead of getting individual elements of a vector via operator(), this function allows getting a whole set of elements at once. In contrast to the previous function, this function obtains the indices of the elements by dereferencing all elements of the iterator range provided by the first two arguments, and puts the vector values into memory locations obtained by dereferencing a range of iterators starting at the location pointed to by the third argument.
If the current vector is called v
, then this function is the equivalent to the code
values_begin
as there are iterators between indices_begin
and indices_end
. Number LinearAlgebra::ReadWriteVector< Number >::local_element | ( | const size_type | local_index | ) | const |
Read access to the data field specified by local_index
. When you access elements in the order in which they are stored, it is necessary that you know in which they are stored. In other words, you need to know the map between the global indices of the elements this class stores, and the local indices into the contiguous array of these global elements. For this, see the general documentation of this class.
Performance: Direct array access (fast).
Number& LinearAlgebra::ReadWriteVector< Number >::local_element | ( | const size_type | local_index | ) |
Read and write access to the data field specified by local_index
. When you access elements in the order in which they are stored, it is necessary that you know in which they are stored. In other words, you need to know the map between the global indices of the elements this class stores, and the local indices into the contiguous array of these global elements. For this, see the general documentation of this class.
Performance: Direct array access (fast).
void LinearAlgebra::ReadWriteVector< Number >::add | ( | const std::vector< size_type > & | indices, |
const std::vector< Number2 > & | values | ||
) |
This function adds a whole set of values stored in values
to the vector components specified by indices
.
void LinearAlgebra::ReadWriteVector< Number >::add | ( | const std::vector< size_type > & | indices, |
const ReadWriteVector< Number2 > & | values | ||
) |
This function is similar to the previous one but takes a ReadWriteVector of values.
void LinearAlgebra::ReadWriteVector< Number >::add | ( | const size_type | n_elements, |
const size_type * | indices, | ||
const Number2 * | values | ||
) |
Take an address where n_elements
are stored contiguously and add them into the vector. Handles all cases which are not covered by the other two add()
functions above.
void LinearAlgebra::ReadWriteVector< Number >::print | ( | std::ostream & | out, |
const unsigned int | precision = 3 , |
||
const bool | scientific = true |
||
) | const |
Prints the vector to the output stream out
.
std::size_t LinearAlgebra::ReadWriteVector< Number >::memory_consumption | ( | ) | const |
Return the memory consumption of this class in bytes.
|
protected |
Import all the elements present in the vector's IndexSet from the input vector tpetra_vector
. This is an helper function and it should not be used directly.
|
protected |
Import all the elements present in the vector's IndexSet from the input vector multivector
. This is an helper function and it should not be used directly.
|
inlineprotected |
Return the local position of global_index
.
Definition at line 650 of file read_write_vector.h.
|
protected |
A helper function that is used to resize the val array.
|
protected |
Return a TpetraWrappers::CommunicationPattern and store it for future use.
|
protected |
Return a EpetraWrappers::CommunicationPattern and store it for future use.
LinearAlgebra::ReadWriteVector< Number >::FunctorTemplate< Functor >::FunctorTemplate | ( | ReadWriteVector< Number > & | parent, |
const Functor & | functor | ||
) |
Constructor. Take a functor and store a copy of it.
|
virtual |
Evaluate the element with the stored copy of the functor.
Constructor. Create a vector of dimension zero.
Copy constructor. Sets the dimension to that of the given vector, and copies all elements.
We would like to make this constructor explicit, but standard containers insist on using it implicitly.
Move constructor. Creates a new vector by stealing the internal data of the vector v
.
|
explicit |
Copy constructor taking a vector of another data type.
This constructor will fail to compile if there is no conversion path from OtherNumber
to Number
. You may lose accuracy when copying to a vector with data elements with less accuracy.
|
explicit |
Copy constructor taking an object of type std::initializer_list
. This constructor can be used to initialize a vector using a brace-enclosed list of numbers, such as in the following example:
This creates a vector of size 3, whose (double precision) elements have values 1.0, 2.0, and 3.0.
This constructor will fail to compile if there is no conversion path from OtherNumber
to Number
. You may lose accuracy when copying to a vector with data elements with less accuracy.
|
explicit |
Another copy constructor: copy the values from a PETSc vector class. This copy constructor is only available if PETSc was detected during configuration time.
Note that due to the communication model used in MPI, this operation can only succeed if all processes do it at the same time when v
is a distributed vector: It is not possible for only one process to obtain a copy of a parallel vector while the other jobs do something else.
|
explicit |
Another copy constructor: copy the values from a Trilinos wrapper vector. This copy constructor is only available if Trilinos was detected during configuration time.
v
(i.e. those given by v.get_mpi_communicator()
) do it at the same time. This means that unless you use a split MPI communicator then it is not normally possible for only one or a subset of processes to obtain a copy of a parallel vector while the other jobs do something else. In other words, calling this function is a 'collective operation' that needs to be executed by all MPI processes that jointly share v
. Constructor. Set dimension to n
and initialize all elements with zero.
The constructor is made explicit to avoid accidents like this: v=0;
. Presumably, the user wants to set every element of the vector to zero, but instead, what happens is this call: v=Vector<number>(0);
, i.e. the vector is replaced by one of length zero.
Vector< Number >::Vector | ( | const InputIterator | first, |
const InputIterator | last | ||
) |
Initialize the vector with a given range of values pointed to by the iterators. This function is there in analogy to the std::vector
class.
Destructor, deallocates memory. Made virtual to allow for derived classes to behave properly.
void Vector< Number >::compress | ( | ::VectorOperation::values | operation = ::VectorOperation::unknown | ) | const |
This function does nothing but exists for compatibility with the parallel vector classes.
For the parallel vector wrapper class, this function compresses the underlying representation of the vector, i.e. flushes the buffers of the vector object if it has any. This function is necessary after writing into a vector element-by-element and before anything else can be done on it.
However, for the implementation of this class, it is immaterial and thus an empty function.
|
virtual |
Change the dimension of the vector to N
. The reserved memory for this vector remains unchanged if possible, to make things faster; this may waste some memory, so keep this in mind. However, if N==0
all memory is freed, i.e. if you want to resize the vector and release the memory not needed, you have to first call reinit(0)
and then reinit(N)
. This cited behaviour is analogous to that of the standard library containers.
If omit_zeroing_entries
is false, the vector is filled by zeros. Otherwise, the elements are left an unspecified state.
This function is virtual in order to allow for derived classes to handle memory separately.
Same as above, but will preserve the values of vector upon resizing. If we new size is bigger, we will have
\[ \mathbf V \rightarrow \left( \begin{array}{c} \mathbf V \\ \mathbf 0 \end{array} \right) \]
whereas if the desired size is smaller, then
\[ \left( \begin{array}{c} \mathbf V_1 \\ \mathbf V_2 \end{array} \right) \rightarrow \mathbf V_1 \]
void Vector< Number >::apply_givens_rotation | ( | const std::array< Number, 3 > & | csr, |
const size_type | i, | ||
const size_type | k | ||
) |
Apply Givens rotation csr
(a triplet of cosine, sine and radius, see Utilities::LinearAlgebra::givens_rotation()) to the vector in the plane spanned by the i'th
and k'th
unit vectors.
void Vector< Number >::reinit | ( | const Vector< Number2 > & | V, |
const bool | omit_zeroing_entries = 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(), omit_zeroing_entries)
.
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.
This function is analogous to 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.
This function is virtual in order to allow for derived classes to handle memory separately.
Set all components of the vector to the given number s
.
Since the semantics of assigning a scalar to a vector are not immediately clear, this operator should really only be used if you want to set the entire vector to zero. This allows the intuitive notation v=0
. Assigning other values is deprecated and may be disallowed in the future.
Vector<Number>& Vector< Number >::operator= | ( | const Vector< Number > & | v | ) |
Copy the given vector. Resize the present vector if necessary.
|
defaultnoexcept |
Move the given vector. This operator replaces the present vector with the internal data of the vector v
and resets v
to the state it would have after being newly default-constructed.
Vector<Number>& Vector< Number >::operator= | ( | const Vector< Number2 > & | v | ) |
Copy the given vector. Resize the present vector if necessary.
Vector<Number>& Vector< Number >::operator= | ( | const BlockVector< Number > & | v | ) |
Copy operator for assigning a block vector to a regular vector.
Vector<Number>& Vector< Number >::operator= | ( | const PETScWrappers::VectorBase & | v | ) |
Another copy operator: copy the values from a PETSc wrapper vector class. This operator is only available if PETSc was detected during configuration time.
Note that due to the communication model used in MPI, this operation can only succeed if all processes do it at the same time when v
is a distributed vector: It is not possible for only one process to obtain a copy of a parallel vector while the other jobs do something else.
Vector<Number>& Vector< Number >::operator= | ( | const TrilinosWrappers::MPI::Vector< Number > & | v | ) |
Another copy operator: copy the values from a (sequential or parallel, depending on the underlying compiler) Trilinos wrapper vector class. This operator is only available if Trilinos was detected during configuration time.
v
(i.e. those given by v.get_mpi_communicator()
) do it at the same time. This means that unless you use a split MPI communicator then it is not normally possible for only one or a subset of processes to obtain a copy of a parallel vector while the other jobs do something else. In other words, calling this function is a 'collective operation' that needs to be executed by all MPI processes that jointly share v
. bool Vector< Number >::operator== | ( | const Vector< Number2 > & | v | ) | const |
Test for equality. This function assumes that the present vector and the one to compare with have the same size already, since comparing vectors of different sizes makes not much sense anyway.
bool Vector< Number >::operator!= | ( | const Vector< Number2 > & | v | ) | const |
Test for inequality. This function assumes that the present vector and the one to compare with have the same size already, since comparing vectors of different sizes makes not much sense anyway.
Number Vector< Number >::operator* | ( | const Vector< Number2 > & | V | ) | const |
Return the scalar product of two vectors. The return type is the underlying type of this
vector, so the return type and the accuracy with which it the result is computed depend on the order of the arguments of this vector.
For complex vectors, the scalar product is implemented as \(\left<v,w\right>=\sum_i v_i \bar{w_i}\).
Return the square of the \(l_2\)-norm.
Number Vector< Number >::mean_value | ( | ) | const |
Mean value of the elements of this vector.
\(l_1\)-norm of the vector. The sum of the absolute values.
\(l_2\)-norm of the vector. The square root of the sum of the squares of the elements.
\(l_p\)-norm of the vector. The pth root of the sum of the pth powers of the absolute values of the elements.
Maximum absolute value of the elements.
Number Vector< Number >::add_and_dot | ( | const Number | a, |
const Vector< Number > & | V, | ||
const Vector< Number > & | W | ||
) |
Performs a combined operation of a vector addition and a subsequent inner product, returning the value of the inner product. In other words, the result of this function is the same as if the user called
The reason this function exists is that this operation involves less memory transfer than calling the two functions separately. This method only needs to load three vectors, this
, V
, W
, whereas calling separate methods means to load the calling vector this
twice. Since most vector operations are memory transfer limited, this reduces the time by 25% (or 50% if W
equals this
).
For complex-valued vectors, the scalar product in the second step is implemented as \(\left<v,w\right>=\sum_i v_i \bar{w_i}\).
Return a pointer to the underlying data buffer.
const_pointer Vector< Number >::data | ( | ) | const |
Return a const pointer to the underlying data buffer.
Make the Vector
class a bit like the vector<>
class of the C++ standard library by returning iterators to the start and end of the elements of this vector.
const_iterator Vector< Number >::begin | ( | ) | const |
Return constant iterator to the start of the vectors.
Return an iterator pointing to the element past the end of the array.
const_iterator Vector< Number >::end | ( | ) | const |
Return a constant iterator pointing to the element past the end of the array.
Access the value of the ith
component.
Access the ith
component as a writeable reference.
Access the value of the ith
component.
Exactly the same as operator().
Access the ith
component as a writeable reference.
Exactly the same as operator().
void Vector< Number >::extract_subvector_to | ( | const std::vector< size_type > & | indices, |
std::vector< OtherNumber > & | values | ||
) | const |
Instead of getting individual elements of a vector via operator(), this function allows getting a whole set of elements at once. The indices of the elements to be read are stated in the first argument, the corresponding values are returned in the second.
If the current vector is called v
, then this function is the equivalent to the code
indices
and values
arrays must be identical. void Vector< Number >::extract_subvector_to | ( | ForwardIterator | indices_begin, |
const ForwardIterator | indices_end, | ||
OutputIterator | values_begin | ||
) | const |
Instead of getting individual elements of a vector via operator(), this function allows getting a whole set of elements at once. In contrast to the previous function, this function obtains the indices of the elements by dereferencing all elements of the iterator range provided by the first two arguments, and puts the vector values into memory locations obtained by dereferencing a range of iterators starting at the location pointed to by the third argument.
If the current vector is called v
, then this function is the equivalent to the code
values_begin
as there are iterators between indices_begin
and indices_end
. Vector<Number>& Vector< Number >::operator+= | ( | const Vector< Number > & | V | ) |
Add the given vector to the present one.
Vector<Number>& Vector< Number >::operator-= | ( | const Vector< Number > & | V | ) |
Subtract the given vector from the present one.
void Vector< Number >::add | ( | const std::vector< size_type > & | indices, |
const std::vector< OtherNumber > & | values | ||
) |
A collective add operation: This function adds a whole set of values stored in values
to the vector components specified by indices
.
void Vector< Number >::add | ( | const std::vector< size_type > & | indices, |
const Vector< OtherNumber > & | values | ||
) |
This is a second collective add operation. As a difference, this function takes a deal.II vector of values.
void Vector< Number >::add | ( | const size_type | n_elements, |
const size_type * | indices, | ||
const OtherNumber * | values | ||
) |
Take an address where n_elements
are stored contiguously and add them into the vector. Handles all cases which are not covered by the other two add()
functions above.
void Vector< Number >::add | ( | const Number | s | ) |
Addition of s
to all components. Note that s
is a scalar and not a vector.
void Vector< Number >::add | ( | const Number | a, |
const Vector< Number > & | V, | ||
const Number | b, | ||
const Vector< Number > & | W | ||
) |
Multiple addition of scaled vectors, i.e. *this += a*V+b*W
.
void Vector< Number >::add | ( | const Number | a, |
const Vector< Number > & | V | ||
) |
Simple addition of a multiple of a vector, i.e. *this += a*V
.
void Vector< Number >::sadd | ( | const Number | s, |
const Vector< Number > & | V | ||
) |
Scaling and simple vector addition, i.e. *this = s*(*this)+V
.
void Vector< Number >::sadd | ( | const Number | s, |
const Number | a, | ||
const Vector< Number > & | V | ||
) |
Scaling and simple addition, i.e. *this = s*(*this)+a*V
.
Scale each element of the vector by a constant value.
Scale each element of the vector by the inverse of the given value.
Scale each element of this vector by the corresponding element in the argument. This function is mostly meant to simulate multiplication (and immediate re-assignment) by a diagonal scaling matrix.
void Vector< Number >::scale | ( | const Vector< Number2 > & | scaling_factors | ) |
Scale each element of this vector by the corresponding element in the argument. This function is mostly meant to simulate multiplication (and immediate re-assignment) by a diagonal scaling matrix.
void Vector< Number >::equ | ( | const Number | a, |
const Vector< Number > & | u | ||
) |
Assignment *this = a*u
.
void Vector< Number >::equ | ( | const Number | a, |
const Vector< Number2 > & | u | ||
) |
Assignment *this = a*u
.
void Vector< Number >::update_ghost_values | ( | ) | const |
This function does nothing but exists for compatibility with the parallel
vector classes (e.g., LinearAlgebra::distributed::Vector class).
void Vector< Number >::print | ( | std::ostream & | out, |
const unsigned int | precision = 3 , |
||
const bool | scientific = true , |
||
const bool | across = true |
||
) | const |
Print to a stream. precision
denotes the desired precision with which values shall be printed, scientific
whether scientific notation shall be used. If across
is true
then the vector is printed in a line, while if false
then the elements are printed on a separate line each.
void Vector< Number >::block_write | ( | std::ostream & | out | ) | const |
Write the vector en bloc to a file. This is done in a binary mode, so the output is neither readable by humans nor (probably) by other computers using a different operating system or number format.
void Vector< Number >::block_read | ( | std::istream & | in | ) |
Read a vector en block from a file. This is done using the inverse operations to the above function, so it is reasonably fast because the bitstream is not interpreted.
The vector is resized if necessary.
A primitive form of error checking is performed which will recognize the bluntest attempts to interpret some data as a vector stored bitwise to a file, but not more.
void Vector< Number >::save | ( | Archive & | ar, |
const unsigned int | version | ||
) | const |
Write the data of this object to a stream for the purpose of serialization.
void Vector< Number >::load | ( | Archive & | ar, |
const unsigned int | version | ||
) |
Read the data of this object from a stream for the purpose of serialization.
void Vector< Number >::serialize | ( | Archive & | archive, |
const unsigned int | version | ||
) |
Write and read the data of this object from a stream for the purpose of serialization.
bool Vector< Number >::in_local_range | ( | const size_type | global_index | ) | const |
Return true if the given global index is in the local range of this processor. Since this is not a distributed vector the method always returns true.
Return an index set that describes which elements of this vector are owned by the current processor. Note that this index set does not include elements this vector may store locally as ghost elements but that are in fact owned by another processor. As a consequence, the index sets returned on different processors if this is a distributed vector will form disjoint sets that add up to the complete index set. Obviously, if a vector is created on only one processor, then the result would satisfy
Since the current data type does not support parallel data storage across different processors, the returned index set is the complete index set.
Return dimension of the vector.
Return whether the vector contains only elements with value zero. This function is mainly for internal consistency checks and should seldom be used when not in debug mode since it uses quite some time.
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).
The function obviously only makes sense if the template argument of this class is a real type. If it is a complex type, then an exception is thrown.
std::size_t Vector< Number >::memory_consumption | ( | ) | const |
Determine an estimate for the memory consumption (in bytes) of this object.
This function exists for compatibility with the parallel
vector classes (e.g., LinearAlgebra::distributed::Vector class). Always returns false since this implementation is serial.
|
private |
Convenience function used at the end of initialization or reinitialization. Resets (if necessary) the loop partitioner to the correct state, based on its current state and the length of the vector.
|
private |
Actual implementation of the reinit functions.
|
inline |
|
pure virtual |
Change the dimension to that of the vector V. The elements of V are not copied.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Sets all elements of the vector to the scalar s
. This operation is only allowed if s
is equal to zero.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Multiply the entire vector by a fixed factor.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Divide the entire vector by a fixed factor.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Add the vector V
to the present one.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Subtract the vector V
from the present one.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Import all the elements present in the vector's IndexSet from the input vector V
. VectorOperation::values operation
is used to decide if the elements in V
should be added to the current vector or replace the current elements. The last parameter can be used if the same communication pattern is used multiple times. This can be used to improve performance.
Implemented in LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::EpetraWrappers::Vector, LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::distributed::Vector< float >, and LinearAlgebra::distributed::Vector< double >.
|
pure virtual |
Return the scalar product of two vectors.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Add a
to all components. Note that a
is a scalar not a vector.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Simple addition of a multiple of a vector, i.e. *this += a*V
.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Multiple addition of scaled vectors, i.e. *this += a*V+b*W
.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Scaling and simple addition of a multiple of a vector, i.e. *this = s*(*this)+a*V
.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Scale each element of this vector by the corresponding element in the argument. This function is mostly meant to simulate multiplication (and immediate re-assignment) by a diagonal scaling matrix.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Assignment *this = a*V
.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
pure virtual |
Return whether the vector contains only elements with value zero.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< double >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, and LinearAlgebra::CUDAWrappers::Vector< Number >.
|
pure virtual |
Return the mean value of all the entries of this vector.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< double >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, and LinearAlgebra::CUDAWrappers::Vector< Number >.
|
pure virtual |
Return the l1 norm of the vector (i.e., the sum of the absolute values of all entries among all processors).
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< double >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, and LinearAlgebra::CUDAWrappers::Vector< Number >.
|
pure virtual |
Return the l2 norm of the vector (i.e., the square root of the sum of the square of all entries among all processors).
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< double >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, and LinearAlgebra::CUDAWrappers::Vector< Number >.
|
pure virtual |
Return the maximum norm of the vector (i.e., the maximum absolute value among all entries and among all processors).
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< double >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, and LinearAlgebra::TpetraWrappers::Vector< Number >.
|
pure virtual |
Perform a combined operation of a vector addition and a subsequent inner product, returning the value of the inner product. In other words, the result of this function is the same as if the user called
The reason this function exists is that this operation involves less memory transfer than calling the two functions separately. This method only needs to load three vectors, this
, V
, W
, whereas calling separate methods means to load the calling vector this
twice. Since most vector operations are memory transfer limited, this reduces the time by 25% (or 50% if W
equals this
).
For complex-valued vectors, the scalar product in the second step is implemented as \(\left<v,w\right>=\sum_i v_i \bar{w_i}\).
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::CUDAWrappers::Vector< Number >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< double >, and LinearAlgebra::EpetraWrappers::Vector.
|
inlinevirtual |
This function does nothing and only exists for backward compatibility.
Definition at line 228 of file vector_space_vector.h.
|
pure virtual |
Return the global size of the vector, equal to the sum of the number of locally owned indices among all processors.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< double >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, and LinearAlgebra::CUDAWrappers::Vector< Number >.
|
pure virtual |
Return an index set that describes which elements of this vector are owned by the current processor. As a consequence, the index sets returned on different processors if this is a distributed vector will form disjoint sets that add up to the complete index set. Obviously, if a vector is created on only one processor, then the result would satisfy
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< double >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, and LinearAlgebra::CUDAWrappers::Vector< Number >.
|
pure virtual |
Print the vector to the output stream out
.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< double >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::Vector< Number >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, LinearAlgebra::EpetraWrappers::Vector, and LinearAlgebra::CUDAWrappers::Vector< Number >.
|
pure virtual |
Return the memory consumption of this class in bytes.
Implemented in LinearAlgebra::distributed::Vector< Number, MemorySpace >, LinearAlgebra::distributed::Vector< double >, LinearAlgebra::distributed::Vector< float >, LinearAlgebra::distributed::BlockVector< Number >, LinearAlgebra::Vector< Number >, LinearAlgebra::TpetraWrappers::Vector< Number >, and LinearAlgebra::CUDAWrappers::Vector< Number >.
|
virtualdefault |
Destructor. Declared as virtual so that inheriting classes (which may manage their own memory) are destroyed correctly.
void LinearAlgebra::set_zero_mean_value | ( | VectorSpaceVector< Number > & | vector | ) |
Shift all entries of the vector by a constant factor so that the mean value of the vector becomes zero.
Definition at line 286 of file vector_space_vector.h.
|
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.
Definition at line 491 of file block_vector.h.
|
related |
|
static |
Attempt to perform an operation between two incompatible vector types.
|
static |
Exception
|
static |
Attempt to perform an operation between two incompatible vector types.
|
static |
Attempt to perform an operation not implemented on the device.
|
static |
Exception
|
static |
Exception
char IsBlockVector< VectorType >::yes_type::c[1] |
Definition at line 72 of file block_vector_base.h.
char IsBlockVector< VectorType >::no_type::c[2] |
Definition at line 76 of file block_vector_base.h.
|
static |
A statically computable value that indicates whether the template argument to this class is a block vector (in fact whether the type is derived from BlockVectorBase<T>).
Definition at line 100 of file block_vector_base.h.
|
staticconstexpr |
The chunks size to split communication in update_ghost_values() and compress() calls.
Most common MPI implementations will get slow when too many messages/requests are outstanding. Even when messages are small, say 1 kB only, we should collect enough data with communication_block_size
to cover typical infiniband latencies which are around a few microseconds. Sending 20 kB at a throughput of 5 GB/s takes 4 microseconds, so we should arrive at the bandwidth dominated regime then which is good enough.
Definition at line 101 of file la_parallel_block_vector.h.
|
private |
Shared pointer to store the parallel partitioning information. This information can be shared between several vectors that have the same partitioning.
Definition at line 1242 of file la_parallel_vector.h.
|
private |
The size that is currently allocated in the val array.
Definition at line 1247 of file la_parallel_vector.h.
|
private |
Underlying data structure storing the local elements of this vector.
Definition at line 1252 of file la_parallel_vector.h.
|
mutableprivate |
For parallel loops with TBB, this member variable stores the affinity information of loops.
Definition at line 1259 of file la_parallel_vector.h.
|
private |
Temporary storage that holds the data that is sent to this processor in compress()
or sent from this processor in update_ghost_values
.
Definition at line 1267 of file la_parallel_vector.h.
|
mutableprivate |
Stores whether the vector currently allows for reading ghost elements or not. Note that this is to ensure consistent ghost data and does not indicate whether the vector actually can store ghost elements. In particular, when assembling a vector we do not allow reading elements, only writing them.
Definition at line 1276 of file la_parallel_vector.h.
|
private |
A vector that collects all requests from compress()
operations. This class uses persistent MPI communicators, i.e., the communication channels are stored during successive calls to a given function. This reduces the overhead involved with setting up the MPI machinery, but it does not remove the need for a receive operation to be posted before the data can actually be sent.
Definition at line 1287 of file la_parallel_vector.h.
|
mutableprivate |
A vector that collects all requests from update_ghost_values()
operations. This class uses persistent MPI communicators.
Definition at line 1293 of file la_parallel_vector.h.
|
mutableprivate |
A lock that makes sure that the compress
and update_ghost_values
functions give reasonable results also when used with several threads.
Definition at line 1301 of file la_parallel_vector.h.
|
static |
Definition at line 1779 of file la_parallel_vector.h.
|
static |
Definition at line 1797 of file la_parallel_vector.h.
|
static |
Definition at line 1815 of file la_parallel_vector.h.
|
static |
Definition at line 1834 of file la_parallel_vector.h.
|
protected |
Indices of the elements stored.
Definition at line 687 of file read_write_vector.h.
|
protected |
IndexSet of the elements of the last imported vector;
Definition at line 692 of file read_write_vector.h.
|
protected |
CommunicationPattern for the communication between the source_stored_elements IndexSet and the current vector.
Definition at line 698 of file read_write_vector.h.
|
protected |
Pointer to the array of local elements of this vector.
Definition at line 703 of file read_write_vector.h.
|
mutableprotected |
For parallel loops with TBB, this member variable stores the affinity information of loops.
Definition at line 710 of file read_write_vector.h.
|
private |
Alias to the ReadWriteVector object that owns the FunctorTemplate.
Definition at line 741 of file read_write_vector.h.
|
private |
Copy of the functor.
Definition at line 746 of file read_write_vector.h.
|
private |
|
mutableprivate |
|
friend |
Typedef for the vector type used
Typedef for the vector type used.
Implementation of a parallel vector class. The design of this class is similar to the standard Vector class in deal.II, with the exception that storage is distributed with MPI.
The vector is designed for the following scheme of parallel partitioning:
[my_first_index,my_last_index)
. reinit (locally_owned, ghost_indices, communicator)
, and retained until the partitioning is changed. This allows for efficient parallel communication of indices. In particular, it stores the communication pattern, rather than having to compute it again for every communication. For more information on ghost vectors, see also the glossary entry on vectors with ghost elements. local_element()
. Locally owned indices are placed first, [0, local_size()), and then all ghost indices follow after them contiguously, [local_size(), local_size()+n_ghost_entries()). Functions related to parallel functionality:
compress()
goes through the data associated with ghost indices and communicates it to the owner process, which can then add it to the correct position. This can be used e.g. after having run an assembly routine involving ghosts that fill this vector. Note that the insert
mode of compress()
does not set the elements included in ghost entries but simply discards them, assuming that the owning processor has set them to the desired value already (See also the glossary entry on compress). update_ghost_values()
function imports the data from the owning processor to the ghost indices in order to provide read access to the data associated with ghosts. This vector can take two different states with respect to ghost elements:
operator= (0.)
), the vector does only allow writing into ghost elements but not reading from ghost elements. true
exactly when ghost elements have been updated and false
otherwise, irrespective of the actual number of ghost entries in the vector layout (for that information, use n_ghost_entries() instead). This vector uses the facilities of the class Vector<Number> for implementing the operations on the local range of the vector. In particular, it also inherits thread parallelism that splits most vector-vector operations into smaller chunks if the program uses multiple threads. This may or may not be desired when working also with MPI.
This vector class is based on two different number types for indexing. The so-called global index type encodes the overall size of the vector. Its type is types::global_dof_index. The largest possible value is 2^32-1
or approximately 4 billion in case 64 bit integers are disabled at configuration of deal.II (default case) or 2^64-1
or approximately 10^19
if 64 bit integers are enabled (see the glossary entry on When to use types::global_dof_index instead of unsigned int for further information).
The second relevant index type is the local index used within one MPI rank. As opposed to the global index, the implementation assumes 32-bit unsigned integers unconditionally. In other words, to actually use a vector with more than four billion entries, you need to use MPI with more than one rank (which in general is a safe assumption since four billion entries consume at least 16 GB of memory for floats or 32 GB of memory for doubles) and enable 64-bit indices. If more than 4 billion local elements are present, the implementation tries to detect that, which triggers an exception and aborts the code. Note, however, that the detection of overflow is tricky and the detection mechanism might fail in some circumstances. Therefore, it is strongly recommended to not rely on this class to automatically detect the unsupported case.
Definition at line 1318 of file la_parallel_vector.h.
|
friend |
Typedef for the block-vector type used
Typedef for the type used to describe vectors that consist of multiple blocks.
An implementation of block vectors based on distributed deal.II vectors. 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.
<float> and <double>
; others can be generated in application programs (see the section on Template instantiations in the manual).Definition at line 1322 of file la_parallel_vector.h.
|
friend |
Definition at line 421 of file la_vector.h.
Typedef for the vector type used
Typedef for the vector type used.
Implementation of a parallel vector class. The design of this class is similar to the standard Vector class in deal.II, with the exception that storage is distributed with MPI.
The vector is designed for the following scheme of parallel partitioning:
[my_first_index,my_last_index)
. reinit (locally_owned, ghost_indices, communicator)
, and retained until the partitioning is changed. This allows for efficient parallel communication of indices. In particular, it stores the communication pattern, rather than having to compute it again for every communication. For more information on ghost vectors, see also the glossary entry on vectors with ghost elements. local_element()
. Locally owned indices are placed first, [0, local_size()), and then all ghost indices follow after them contiguously, [local_size(), local_size()+n_ghost_entries()). Functions related to parallel functionality:
compress()
goes through the data associated with ghost indices and communicates it to the owner process, which can then add it to the correct position. This can be used e.g. after having run an assembly routine involving ghosts that fill this vector. Note that the insert
mode of compress()
does not set the elements included in ghost entries but simply discards them, assuming that the owning processor has set them to the desired value already (See also the glossary entry on compress). update_ghost_values()
function imports the data from the owning processor to the ghost indices in order to provide read access to the data associated with ghosts. This vector can take two different states with respect to ghost elements:
operator= (0.)
), the vector does only allow writing into ghost elements but not reading from ghost elements. true
exactly when ghost elements have been updated and false
otherwise, irrespective of the actual number of ghost entries in the vector layout (for that information, use n_ghost_entries() instead). This vector uses the facilities of the class Vector<Number> for implementing the operations on the local range of the vector. In particular, it also inherits thread parallelism that splits most vector-vector operations into smaller chunks if the program uses multiple threads. This may or may not be desired when working also with MPI.
This vector class is based on two different number types for indexing. The so-called global index type encodes the overall size of the vector. Its type is types::global_dof_index. The largest possible value is 2^32-1
or approximately 4 billion in case 64 bit integers are disabled at configuration of deal.II (default case) or 2^64-1
or approximately 10^19
if 64 bit integers are enabled (see the glossary entry on When to use types::global_dof_index instead of unsigned int for further information).
The second relevant index type is the local index used within one MPI rank. As opposed to the global index, the implementation assumes 32-bit unsigned integers unconditionally. In other words, to actually use a vector with more than four billion entries, you need to use MPI with more than one rank (which in general is a safe assumption since four billion entries consume at least 16 GB of memory for floats or 32 GB of memory for doubles) and enable 64-bit indices. If more than 4 billion local elements are present, the implementation tries to detect that, which triggers an exception and aborts the code. Note, however, that the detection of overflow is tricky and the detection mechanism might fail in some circumstances. Therefore, it is strongly recommended to not rely on this class to automatically detect the unsupported case.
Definition at line 425 of file la_vector.h.
Definition at line 714 of file read_write_vector.h.
Typedef for the vector type used
Typedef for the vector type used.
Implementation of a parallel vector class. The design of this class is similar to the standard Vector class in deal.II, with the exception that storage is distributed with MPI.
The vector is designed for the following scheme of parallel partitioning:
[my_first_index,my_last_index)
. reinit (locally_owned, ghost_indices, communicator)
, and retained until the partitioning is changed. This allows for efficient parallel communication of indices. In particular, it stores the communication pattern, rather than having to compute it again for every communication. For more information on ghost vectors, see also the glossary entry on vectors with ghost elements. local_element()
. Locally owned indices are placed first, [0, local_size()), and then all ghost indices follow after them contiguously, [local_size(), local_size()+n_ghost_entries()). Functions related to parallel functionality:
compress()
goes through the data associated with ghost indices and communicates it to the owner process, which can then add it to the correct position. This can be used e.g. after having run an assembly routine involving ghosts that fill this vector. Note that the insert
mode of compress()
does not set the elements included in ghost entries but simply discards them, assuming that the owning processor has set them to the desired value already (See also the glossary entry on compress). update_ghost_values()
function imports the data from the owning processor to the ghost indices in order to provide read access to the data associated with ghosts. This vector can take two different states with respect to ghost elements:
operator= (0.)
), the vector does only allow writing into ghost elements but not reading from ghost elements. true
exactly when ghost elements have been updated and false
otherwise, irrespective of the actual number of ghost entries in the vector layout (for that information, use n_ghost_entries() instead). This vector uses the facilities of the class Vector<Number> for implementing the operations on the local range of the vector. In particular, it also inherits thread parallelism that splits most vector-vector operations into smaller chunks if the program uses multiple threads. This may or may not be desired when working also with MPI.
This vector class is based on two different number types for indexing. The so-called global index type encodes the overall size of the vector. Its type is types::global_dof_index. The largest possible value is 2^32-1
or approximately 4 billion in case 64 bit integers are disabled at configuration of deal.II (default case) or 2^64-1
or approximately 10^19
if 64 bit integers are enabled (see the glossary entry on When to use types::global_dof_index instead of unsigned int for further information).
The second relevant index type is the local index used within one MPI rank. As opposed to the global index, the implementation assumes 32-bit unsigned integers unconditionally. In other words, to actually use a vector with more than four billion entries, you need to use MPI with more than one rank (which in general is a safe assumption since four billion entries consume at least 16 GB of memory for floats or 32 GB of memory for doubles) and enable 64-bit indices. If more than 4 billion local elements are present, the implementation tries to detect that, which triggers an exception and aborts the code. Note, however, that the detection of overflow is tricky and the detection mechanism might fail in some circumstances. Therefore, it is strongly recommended to not rely on this class to automatically detect the unsupported case.