Reference documentation for deal.II version 9.4.1
Searching...
No Matches
LinearAlgebra::EpetraWrappers::Vector Class Reference

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

Inheritance diagram for LinearAlgebra::EpetraWrappers::Vector:
[legend]

Public Types

using value_type = double

using size_type = types::global_dof_index

using real_type = typename numbers::NumberTraits< double >::real_type

Public Member Functions

Vector ()

Vector (const Vector &V)

Vector (const IndexSet &parallel_partitioner, const MPI_Comm &communicator)

void reinit (const IndexSet &parallel_partitioner, const MPI_Comm &communicator, const bool omit_zeroing_entries=false)

virtual void reinit (const VectorSpaceVector< double > &V, const bool omit_zeroing_entries=false) override

Vectoroperator= (const Vector &V)

virtual Vectoroperator= (const double s) override

virtual void import (const ReadWriteVector< double > &V, VectorOperation::values operation, std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > communication_pattern={}) override

virtual Vectoroperator*= (const double factor) override

virtual Vectoroperator/= (const double factor) override

virtual Vectoroperator+= (const VectorSpaceVector< double > &V) override

virtual Vectoroperator-= (const VectorSpaceVector< double > &V) override

virtual double operator* (const VectorSpaceVector< double > &V) const override

virtual void add (const double a) override

virtual void add (const double a, const VectorSpaceVector< double > &V) override

virtual void add (const double a, const VectorSpaceVector< double > &V, const double b, const VectorSpaceVector< double > &W) override

virtual void sadd (const double s, const double a, const VectorSpaceVector< double > &V) override

virtual void scale (const VectorSpaceVector< double > &scaling_factors) override

virtual void equ (const double a, const VectorSpaceVector< double > &V) override

virtual bool all_zero () const override

virtual double mean_value () const override

virtual double l1_norm () const override

virtual double l2_norm () const override

virtual double linfty_norm () const override

virtual double add_and_dot (const double a, const VectorSpaceVector< double > &V, const VectorSpaceVector< double > &W) override

bool has_ghost_elements () const

virtual size_type size () const override

size_type locally_owned_size () const

MPI_Comm get_mpi_communicator () const

virtual ::IndexSet locally_owned_elements () const override

const Epetra_FEVector & trilinos_vector () const

Epetra_FEVector & trilinos_vector ()

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

virtual std::size_t memory_consumption () const override

virtual void compress (VectorOperation::values)

Static Public Member Functions

static ::ExceptionBaseExcDifferentParallelPartitioning ()

static ::ExceptionBaseExcVectorTypeNotCompatible ()

static ::ExceptionBaseExcTrilinosError (int arg1)

Private Member Functions

void create_epetra_comm_pattern (const IndexSet &source_index_set, const MPI_Comm &mpi_comm)

Private Attributes

std::unique_ptr< Epetra_FEVector > vector

::IndexSet source_stored_elements

std::shared_ptr< const CommunicationPatternepetra_comm_pattern

Subscriptor functionality

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

std::atomic< unsigned intcounter

std::map< std::string, unsigned intcounter_map

std::vector< std::atomic< bool > * > validity_pointers

const std::type_info * object_info

void subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const

void unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const

unsigned int n_subscriptions () const

template<typename StreamType >
void list_subscribers (StreamType &stream) const

void list_subscribers () const

template<class Archive >
void serialize (Archive &ar, const unsigned int version)

static ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)

static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)

void check_no_subscribers () const noexcept

using map_value_type = decltype(counter_map)::value_type

using map_iterator = decltype(counter_map)::iterator

static std::mutex mutex

Detailed Description

This class implements a wrapper to the Trilinos distributed vector class Epetra_FEVector. This class is derived from the LinearAlgebra::VectorSpaceVector class. Note however that Epetra only works with Number = double. This class requires Trilinos to be compiled with MPI support.

Definition at line 64 of file trilinos_epetra_vector.h.

◆ value_type

 using LinearAlgebra::VectorSpaceVector< double >::value_type = double
inherited

Definition at line 58 of file vector_space_vector.h.

◆ size_type

 using LinearAlgebra::VectorSpaceVector< double >::size_type = types::global_dof_index
inherited

Definition at line 59 of file vector_space_vector.h.

◆ real_type

 using LinearAlgebra::VectorSpaceVector< double >::real_type = typename numbers::NumberTraits::real_type
inherited

Definition at line 60 of file vector_space_vector.h.

◆ Vector() [1/3]

 Vector< Number >::Vector ( )

Constructor. Create a vector of dimension zero.

Definition at line 39 of file trilinos_epetra_vector.cc.

◆ Vector() [2/3]

 Vector< Number >::Vector ( const Vector & V )

Copy constructor. Sets the dimension and the partitioning to that of the given vector and copies all elements.

Definition at line 47 of file trilinos_epetra_vector.cc.

◆ Vector() [3/3]

 Vector< Number >::Vector ( const IndexSet & parallel_partitioner, const MPI_Comm & communicator )
explicit

This constructor takes an IndexSet that defines how to distribute the individual components among the MPI processors. Since it also includes information about the size of the vector, this is all we need to generate a parallel vector.

Definition at line 54 of file trilinos_epetra_vector.cc.

◆ reinit() [1/2]

 void Vector< Number >::reinit ( const IndexSet & parallel_partitioner, const MPI_Comm & communicator, const bool omit_zeroing_entries = false )

Reinit functionality. This function destroys the old vector content and generates a new one based on the input partitioning. The flag omit_zeroing_entries determines whether the vector should be filled with zero (false) or left untouched (true).

Definition at line 64 of file trilinos_epetra_vector.cc.

◆ reinit() [2/2]

 void Vector< Number >::reinit ( const VectorSpaceVector< double > & V, const bool omit_zeroing_entries = false )
overridevirtual

Change the dimension to that of the vector V. The elements of V are not copied.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 83 of file trilinos_epetra_vector.cc.

◆ operator=() [1/2]

 Vector & Vector< Number >::operator= ( const Vector & V )

Copy function. This function takes a Vector and copies all the elements. The Vector will have the same parallel distribution as V.

Definition at line 101 of file trilinos_epetra_vector.cc.

◆ operator=() [2/2]

 Vector & Vector< Number >::operator= ( const double s )
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< double >.

Definition at line 131 of file trilinos_epetra_vector.cc.

◆ import()

 void Vector< Number >::import ( const ReadWriteVector< double > & V, VectorOperation::values operation, std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > communication_pattern = {} )
overridevirtual

Imports 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< double >.

Definition at line 145 of file trilinos_epetra_vector.cc.

◆ operator*=()

 Vector & Vector< Number >::operator*= ( const double factor )
overridevirtual

Multiply the entire vector by a fixed factor.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 201 of file trilinos_epetra_vector.cc.

◆ operator/=()

 Vector & Vector< Number >::operator/= ( const double factor )
overridevirtual

Divide the entire vector by a fixed factor.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 212 of file trilinos_epetra_vector.cc.

◆ operator+=()

 Vector & Vector< Number >::operator+= ( const VectorSpaceVector< double > & V )
overridevirtual

Add the vector V to the present one.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 224 of file trilinos_epetra_vector.cc.

◆ operator-=()

 Vector & Vector< Number >::operator-= ( const VectorSpaceVector< double > & V )
overridevirtual

Subtract the vector V from the present one.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 276 of file trilinos_epetra_vector.cc.

◆ operator*()

 double Vector< Number >::operator* ( const VectorSpaceVector< double > & V ) const
overridevirtual

Return the scalar product of two vectors. The vectors need to have the same layout.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 286 of file trilinos_epetra_vector.cc.

 void Vector< Number >::add ( const double a )
overridevirtual

Add a to all components. Note that is a scalar not a vector.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 310 of file trilinos_epetra_vector.cc.

 void Vector< Number >::add ( const double a, const VectorSpaceVector< double > & V )
overridevirtual

Simple addition of a multiple of a vector, i.e. *this += a*V. The vectors need to have the same layout.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 321 of file trilinos_epetra_vector.cc.

 void Vector< Number >::add ( const double a, const VectorSpaceVector< double > & V, const double b, const VectorSpaceVector< double > & W )
overridevirtual

Multiple addition of multiple of a vector, i.e. *this> += a*V+b*W. The vectors need to have the same layout.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 341 of file trilinos_epetra_vector.cc.

 void Vector< Number >::sadd ( const double s, const double a, const VectorSpaceVector< double > & V )
overridevirtual

Scaling and simple addition of a multiple of a vector, i.e. this = s(*this)+a*V.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 373 of file trilinos_epetra_vector.cc.

◆ scale()

 void Vector< Number >::scale ( const VectorSpaceVector< double > & scaling_factors )
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. The vectors need to have the same layout.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 392 of file trilinos_epetra_vector.cc.

◆ equ()

 void Vector< Number >::equ ( const double a, const VectorSpaceVector< double > & V )
overridevirtual

Assignment *this = a*V.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 415 of file trilinos_epetra_vector.cc.

◆ all_zero()

 bool Vector< Number >::all_zero ( ) const
overridevirtual

Return whether the vector contains only elements with value zero.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 438 of file trilinos_epetra_vector.cc.

◆ mean_value()

 double Vector< Number >::mean_value ( ) const
overridevirtual

Return the mean value of the element of this vector.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 467 of file trilinos_epetra_vector.cc.

◆ l1_norm()

 double Vector< Number >::l1_norm ( ) const
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< double >.

Definition at line 481 of file trilinos_epetra_vector.cc.

◆ l2_norm()

 double Vector< Number >::l2_norm ( ) const
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< double >.

Definition at line 494 of file trilinos_epetra_vector.cc.

◆ linfty_norm()

 double Vector< Number >::linfty_norm ( ) const
overridevirtual

Return the maximum norm of the vector (i.e., the maximum absolute value among all entries and among all processors).

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 507 of file trilinos_epetra_vector.cc.

 double Vector< Number >::add_and_dot ( const double a, const VectorSpaceVector< double > & V, const VectorSpaceVector< double > & W )
overridevirtual

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

return_value = *this * W;
virtual void add(const double a) override

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

The vectors need to have the same layout.

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

Definition at line 520 of file trilinos_epetra_vector.cc.

◆ has_ghost_elements()

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

This function always returns false and is present only for backward compatibility.

Definition at line 394 of file trilinos_epetra_vector.h.

◆ size()

 Vector::size_type Vector< Number >::size ( ) const
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< double >.

Definition at line 532 of file trilinos_epetra_vector.cc.

◆ locally_owned_size()

 Vector::size_type Vector< Number >::locally_owned_size ( ) const

Return the local size of the vector, i.e., the number of indices owned locally.

Definition at line 544 of file trilinos_epetra_vector.cc.

◆ get_mpi_communicator()

 MPI_Comm Vector< Number >::get_mpi_communicator ( ) const

Return the MPI communicator object in use with this object.

Definition at line 552 of file trilinos_epetra_vector.cc.

◆ locally_owned_elements()

 IndexSet Vector< Number >::locally_owned_elements ( ) const
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

vec.locally_owned_elements() == complete_index_set(vec.size())
IndexSet complete_index_set(const IndexSet::size_type N)
Definition: index_set.h:1014

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 563 of file trilinos_epetra_vector.cc.

◆ trilinos_vector() [1/2]

 const Epetra_FEVector & Vector< Number >::trilinos_vector ( ) const

Return a const reference to the underlying Trilinos Epetra_FEVector class.

Definition at line 597 of file trilinos_epetra_vector.cc.

◆ trilinos_vector() [2/2]

 Epetra_FEVector & Vector< Number >::trilinos_vector ( )

Return a (modifiable) reference to the underlying Trilinos Epetra_FEVector class.

Definition at line 605 of file trilinos_epetra_vector.cc.

◆ print()

 void Vector< Number >::print ( std::ostream & out, const unsigned int precision = 3, const bool scientific = true, const bool across = true ) const
overridevirtual

Prints the vector to the output stream out.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 613 of file trilinos_epetra_vector.cc.

◆ memory_consumption()

 std::size_t Vector< Number >::memory_consumption ( ) const
overridevirtual

Return the memory consumption of this class in bytes.

Implements LinearAlgebra::VectorSpaceVector< double >.

Definition at line 651 of file trilinos_epetra_vector.cc.

◆ create_epetra_comm_pattern()

 void Vector< Number >::create_epetra_comm_pattern ( const IndexSet & source_index_set, const MPI_Comm & mpi_comm )
private

Create the CommunicationPattern for the communication between the IndexSet source_index_set and the current vector based on the communicator mpi_comm.

Definition at line 661 of file trilinos_epetra_vector.cc.

◆ compress()

 virtual void LinearAlgebra::VectorSpaceVector< double >::compress ( VectorOperation::values )
inlinevirtualinherited

This function does nothing and only exists for backward compatibility.

Definition at line 226 of file vector_space_vector.h.

◆ vector

 std::unique_ptr LinearAlgebra::EpetraWrappers::Vector::vector
private

Pointer to the actual Epetra vector object.

Definition at line 378 of file trilinos_epetra_vector.h.

◆ source_stored_elements

 ::IndexSet LinearAlgebra::EpetraWrappers::Vector::source_stored_elements
private

IndexSet of the elements of the last imported vector.

Definition at line 383 of file trilinos_epetra_vector.h.

◆ epetra_comm_pattern

 std::shared_ptr LinearAlgebra::EpetraWrappers::Vector::epetra_comm_pattern
private

CommunicationPattern for the communication between the source_stored_elements IndexSet and the current vector.

Definition at line 389 of file trilinos_epetra_vector.h.

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