![]() |
deal.II version GIT relicensing-6809-ge913b9bb34 2026-09-25 17:20:01+00:00
|
#include <deal.II/lac/trilinos_tpetra_vector.h>
This class implements a wrapper to the Trilinos distributed vector class Tpetra::Vector. This class requires Trilinos to be compiled with MPI support.
Moreover, this class takes an optional template argument for the memory space used. By default, all memory is allocated on the CPU.
Definition at line 290 of file trilinos_tpetra_vector.h.
Public Types | |
| using | value_type = Number |
| using | real_type = typename numbers::NumberTraits< Number >::real_type |
| using | size_type = types::global_dof_index |
| using | reference = internal::VectorReference< Number, MemorySpace > |
| using | const_reference = const internal::VectorReference< Number, MemorySpace > |
Public Member Functions | |
| template<class Archive > | |
| void | serialize (Archive &ar, const unsigned int version) |
1: Basic Object-handling | |
| Vector () | |
| Vector (const Vector &V) | |
| Vector (const Teuchos::RCP< TpetraTypes::VectorType< Number, MemorySpace > > V) | |
| Vector (const IndexSet ¶llel_partitioner, const MPI_Comm communicator=MPI_COMM_WORLD) | |
| Vector (const IndexSet &locally_owned_entries, const IndexSet &ghost_entries, const MPI_Comm communicator, const bool vector_writable=false) | |
| void | clear () |
| void | reinit (const IndexSet ¶llel_partitioner, const MPI_Comm communicator=MPI_COMM_WORLD, const bool omit_zeroing_entries=false) |
| void | reinit (const IndexSet &locally_owned_entries, const IndexSet &locally_relevant_or_ghost_entries, const MPI_Comm communicator=MPI_COMM_WORLD, const bool vector_writable=false) |
| void | reinit (const Vector< Number, MemorySpace > &V, const bool omit_zeroing_entries=false) |
| virtual void | swap (Vector &v) noexcept |
| virtual void | extract_subvector_to (const ArrayView< const types::global_dof_index > &indices, const ArrayView< Number > &elements) const override |
| Vector & | operator= (const Vector &V) |
| template<typename OtherNumber > | |
| Vector & | operator= (const ::Vector< OtherNumber > &V) |
| Vector & | operator= (const Number s) |
| void | import_elements (const ReadWriteVector< Number > &V, VectorOperation::values operation, const Teuchos::RCP< const Utilities::MPI::CommunicationPatternBase > &communication_pattern) |
| void | import_elements (const ReadWriteVector< Number > &V, VectorOperation::values operation) |
2: Data-Access | |
| reference | operator() (const size_type index) |
| Number | operator() (const size_type index) const |
| reference | operator[] (const size_type index) |
| Number | operator[] (const size_type index) const |
3: Modification of vectors | |
| Vector & | operator*= (const Number factor) |
| Vector & | operator/= (const Number factor) |
| Vector & | operator+= (const Vector< Number, MemorySpace > &V) |
| Vector & | operator-= (const Vector< Number, MemorySpace > &V) |
| Number | operator* (const Vector< Number, MemorySpace > &V) const |
| void | add (const Number a) |
| void | add (const Vector< Number, MemorySpace > &V, const bool allow_different_maps=false) |
| void | add (const Number a, const Vector< Number, MemorySpace > &V) |
| void | add (const Number a, const Vector< Number, MemorySpace > &V, const Number b, const Vector< Number, MemorySpace > &W) |
| void | add (const std::vector< size_type > &indices, const std::vector< Number > &values) |
| void | add (const std::vector< size_type > &indices, const ::Vector< Number > &values) |
| void | add (const size_type n_elements, const size_type *indices, const Number *values) |
| void | sadd (const Number s, const Number a, const Vector< Number, MemorySpace > &V) |
| void | sadd (const Number s, const Vector< Number, MemorySpace > &V) |
| void | set (const size_type n_elements, const size_type *indices, const Number *values) |
| void | set (const std::vector< size_type > &indices, const std::vector< Number > &values) |
| void | scale (const Vector< Number, MemorySpace > &scaling_factors) |
| void | equ (const Number a, const Vector< Number, MemorySpace > &V) |
| bool | all_zero () const |
| bool | is_non_negative () const |
4: Scalar products, norms and related operations | |
| Number | mean_value () const |
| Number | min () const |
| Number | max () const |
| real_type | l1_norm () const |
| real_type | l2_norm () const |
| real_type | lp_norm (const real_type p) const |
| real_type | linfty_norm () const |
| real_type | norm_sqr () const |
| Number | add_and_dot (const Number a, const Vector< Number, MemorySpace > &V, const Vector< Number, MemorySpace > &W) |
5: Scalar products, norms and related operations | |
| bool | has_ghost_elements () const |
| bool | operator== (const Vector< Number, MemorySpace > &v) const |
| bool | operator!= (const Vector< Number, MemorySpace > &v) const |
| virtual size_type | size () const override |
| size_type | locally_owned_size () const |
| std::pair< size_type, size_type > | local_range () const |
| bool | in_local_range (const size_type index) const |
| bool | is_compressed () const |
| MPI_Comm | get_mpi_communicator () const |
| ::IndexSet | locally_owned_elements () const |
6: Mixed stuff | |
| void | compress (const VectorOperation::values operation) |
| void | update_ghost_values () const |
| const TpetraTypes::VectorType< Number, MemorySpace > & | trilinos_vector () const |
| TpetraTypes::VectorType< Number, MemorySpace > & | trilinos_vector () |
| const TpetraTypes::MapType< MemorySpace > & | trilinos_partitioner () const |
| Teuchos::RCP< const TpetraTypes::VectorType< Number, MemorySpace > > | trilinos_rcp () const |
| Teuchos::RCP< TpetraTypes::VectorType< Number, MemorySpace > > | trilinos_rcp () |
| void | print (std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const |
| std::size_t | memory_consumption () const |
| MPI_Comm | mpi_comm () const |
Querying the observer pointers an object has. | |
| unsigned int | n_subscriptions () const |
| template<typename StreamType > | |
| void | list_subscribers (StreamType &stream) const |
| void | list_subscribers () const |
Static Public Member Functions | |
| static ::ExceptionBase & | ExcDifferentParallelPartitioning () |
| static ::ExceptionBase & | ExcVectorTypeNotCompatible () |
| static ::ExceptionBase & | ExcAccessToNonLocalElement (size_type arg1, size_type arg2, size_type arg3, size_type arg4) |
| static ::ExceptionBase & | ExcMissingIndexSet () |
| static ::ExceptionBase & | ExcTrilinosError (int arg1) |
| static ::ExceptionBase & | ExcInUse (int arg1, std::string arg2, std::string arg3) |
| static ::ExceptionBase & | ExcNoSubscriber (std::string arg1, std::string arg2) |
Private Types | |
| using | dual_view_type = typename TpetraTypes::VectorType< Number, MemorySpace >::dual_view_type |
| using | host_view_type = typename dual_view_type::t_host |
| using | array_view_type = Kokkos::Subview< host_view_type, std::remove_const_t< decltype(Kokkos::ALL)>, unsigned > |
Private Member Functions | |
| void | create_tpetra_comm_pattern (const IndexSet &source_index_set, const MPI_Comm mpi_comm) |
EnableObserverPointer functionality | |
Classes derived from EnableObserverPointer provide a facility to subscribe to this object. This is mostly used by the ObserverPointer class. | |
| void | subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
| void | unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const |
| void | check_no_subscribers () const noexcept |
Private Attributes | |
| bool | compressed |
| bool | has_ghost |
| VectorOperation::values | last_action |
| Teuchos::RCP< TpetraTypes::VectorType< Number, MemorySpace > > | vector |
| Teuchos::RCP< TpetraTypes::VectorType< Number, MemorySpace > > | nonlocal_vector |
| ::IndexSet | source_stored_elements |
| ::IndexSet | local_entries |
| std::vector< types::global_dof_index > | nonlocal_cached_indices |
| std::vector< Number > | nonlocal_cached_values |
| std::optional< array_view_type > | vector_1d_view |
| std::optional< array_view_type > | nonlocal_vector_1d_view |
| std::mutex | mutex |
| Teuchos::RCP< const TpetraWrappers::CommunicationPattern< MemorySpace > > | tpetra_comm_pattern |
| std::atomic< unsigned int > | counter |
| std::map< std::string, unsigned int > | counter_map |
| std::vector< std::atomic< bool > * > | validity_pointers |
| const std::type_info * | object_info |
Friends | |
| class | internal::VectorReference< Number, MemorySpace > |
| using LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::value_type = Number |
Declare some of the standard types used in all containers.
Definition at line 296 of file trilinos_tpetra_vector.h.
| using LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::real_type = typename numbers::NumberTraits<Number>::real_type |
Definition at line 297 of file trilinos_tpetra_vector.h.
| using LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::size_type = types::global_dof_index |
Definition at line 298 of file trilinos_tpetra_vector.h.
| using LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::reference = internal::VectorReference<Number, MemorySpace> |
Definition at line 299 of file trilinos_tpetra_vector.h.
| using LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::const_reference = const internal::VectorReference<Number, MemorySpace> |
Definition at line 300 of file trilinos_tpetra_vector.h.
|
private |
Definition at line 1141 of file trilinos_tpetra_vector.h.
|
private |
Definition at line 1143 of file trilinos_tpetra_vector.h.
|
private |
Definition at line 1145 of file trilinos_tpetra_vector.h.
| LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::Vector | ( | ) |
Default constructor that generates an empty (zero size) vector. The function reinit() will have to give the vector the correct size and distribution among processes in case of an MPI run.
| LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::Vector | ( | const Vector< Number, MemorySpace > & | V | ) |
Copy constructor. Sets the dimension and the partitioning to that of the given vector and copies all elements.
| LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::Vector | ( | const Teuchos::RCP< TpetraTypes::VectorType< Number, MemorySpace > > | V | ) |
Copy constructor from Teuchos::RCP<Tpetra::Vector>.
|
explicit |
TODO: This is not used 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.
|
explicit |
In addition to just specifying one index set as in all the other methods above, this method allows to supply an additional set of ghost entries.
Depending on whether the locally_relevant_or_ghost_entries argument uniquely subdivides elements among processors or not, the resulting vector may or may not have ghost elements. See the general documentation of this class for more information.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::clear | ( | ) |
Release all memory and return to a state just like after having called the default constructor.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::reinit | ( | const IndexSet & | parallel_partitioner, |
| const MPI_Comm | communicator = MPI_COMM_WORLD, |
||
| 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 zeros (false) or left in an undetermined state (true).
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::reinit | ( | const IndexSet & | locally_owned_entries, |
| const IndexSet & | locally_relevant_or_ghost_entries, | ||
| const MPI_Comm | communicator = MPI_COMM_WORLD, |
||
| const bool | vector_writable = false |
||
| ) |
Reinit functionality. This function destroys the old vector content and generates a new one based on the input partitioning. In addition to just specifying one index set as in all the other methods above, this method allows to supply an additional set of ghost entries.
Depending on whether the locally_relevant_or_ghost_entries argument uniquely subdivides elements among processors or not, the resulting vector may or may not have ghost elements. See the general documentation of this class for more information.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::reinit | ( | const Vector< Number, MemorySpace > & | V, |
| const bool | omit_zeroing_entries = false |
||
| ) |
Change the dimension to that of the vector V. The elements of V are not copied.
|
virtualnoexcept |
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.
|
overridevirtual |
Extract a range of elements all at once.
Implements ReadVector< Number >.
| Vector & LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::operator= | ( | const Vector< Number, MemorySpace > & | V | ) |
Copy function. This function takes a Vector and copies all the elements. The Vector will have the same parallel distribution as V.
The semantics of this operator are complex. If the two vectors have the same size, and if either the left or right hand side vector of the assignment (i.e., either the input vector on the right hand side, or the calling vector to the left of the assignment operator) currently has ghost elements, then the left hand side vector will also have ghost values and will consequently be a read-only vector (see also the glossary entry on the issue). Otherwise, the left hand vector will be a writable vector after this operation. These semantics facilitate having a vector with ghost elements on the left hand side of the assignment, and a vector without ghost elements on the right hand side, with the resulting left hand side vector having the correct values in both its locally owned and its ghost elements.
On the other hand, if the left hand side vector does not have the correct size yet, or is perhaps an entirely uninitialized vector, then the assignment is simply a copy operation in the usual sense: In that case, if the right hand side has no ghost elements (i.e., is a completely distributed vector), then the left hand side will have no ghost elements either. And if the right hand side has ghost elements (and is consequently read-only), then the left hand side will have these same properties after the operation.
| Vector & LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::operator= | ( | const ::Vector< OtherNumber > & | V | ) |
| Vector & LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::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.
Because this operation modifies the vector, it is only allowed to call this function on vectors that have no ghost entries. However, as a special case, assigning zero to the entire vector by writing v=0; where v is a variable of the current type is allowed as we interpret it as equivalent to creating a new, zero-initialized vector. See vectors with ghost elements for more on writing into vectors with ghost elements.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::import_elements | ( | const ReadWriteVector< Number > & | V, |
| VectorOperation::values | operation, | ||
| const Teuchos::RCP< const Utilities::MPI::CommunicationPatternBase > & | communication_pattern | ||
| ) |
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.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::import_elements | ( | const ReadWriteVector< Number > & | V, |
| VectorOperation::values | operation | ||
| ) |
|
inline |
Provide access to a given element, both read and write.
When using a vector distributed with MPI, this operation only makes sense for elements that are actually present on the calling processor. Otherwise, an exception is thrown.
Definition at line 1557 of file trilinos_tpetra_vector.h.
| Number LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::operator() | ( | const size_type | index | ) | const |
Provide read-only access to an element.
When using a vector distributed with MPI, this operation only makes sense for elements that are actually present on the calling processor. Otherwise, an exception is thrown.
|
inline |
Provide access to a given element, both read and write.
Exactly the same as operator().
Definition at line 1564 of file trilinos_tpetra_vector.h.
|
inline |
Provide read-only access to an element.
Exactly the same as operator().
Definition at line 1571 of file trilinos_tpetra_vector.h.
| Vector & LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::operator*= | ( | const Number | factor | ) |
Multiply the entire vector by a fixed factor.
| Vector & LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::operator/= | ( | const Number | factor | ) |
Divide the entire vector by a fixed factor.
| Vector & LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::operator+= | ( | const Vector< Number, MemorySpace > & | V | ) |
Add the vector V to the present one.
| Vector & LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::operator-= | ( | const Vector< Number, MemorySpace > & | V | ) |
Subtract the vector V from the present one.
| Number LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::operator* | ( | const Vector< Number, MemorySpace > & | V | ) | const |
Return the scalar product of two vectors. The vectors need to have the same layout.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::add | ( | const Number | a | ) |
Add a to all components. Note that is a scalar not a vector.
|
inline |
Simple vector addition, equal to the operator+=.
Though, if the second argument allow_different_maps is set, then it is possible to add data from a vector that uses a different map, i.e., a vector whose elements are split across processors differently. This may include vectors with ghost elements, for example. In general, however, adding vectors with a different element-to-processor map requires communicating data among processors and, consequently, is a slower operation than when using vectors using the same map.
Definition at line 1252 of file trilinos_tpetra_vector.h.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::add | ( | const Number | a, |
| const Vector< Number, MemorySpace > & | V | ||
| ) |
Simple addition of a multiple of a vector, i.e. *this += a*V. The vectors need to have the same layout.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::add | ( | const Number | a, |
| const Vector< Number, MemorySpace > & | V, | ||
| const Number | b, | ||
| const Vector< Number, MemorySpace > & | W | ||
| ) |
Multiple addition of multiple of a vector, i.e. *this> += a*V+b*W. The vectors need to have the same layout.
|
inline |
A collective add operation: This function adds a whole set of values stored in values to the vector components specified by indices.
Definition at line 1263 of file trilinos_tpetra_vector.h.
|
inline |
This is a second collective add operation. As a difference, this function takes a deal.II vector of values.
Definition at line 1277 of file trilinos_tpetra_vector.h.
|
inline |
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.
Definition at line 1292 of file trilinos_tpetra_vector.h.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::sadd | ( | const Number | s, |
| const Number | a, | ||
| const Vector< Number, MemorySpace > & | V | ||
| ) |
Scaling and simple addition of a multiple of a vector, i.e. this = s(*this)+a*V.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::sadd | ( | const Number | s, |
| const Vector< Number, MemorySpace > & | V | ||
| ) |
Scaling and simple vector addition, i.e. this = s(*this) + V.
|
inline |
A collective set operation: instead of setting individual elements of a vector, this function allows to set a whole set of elements at once. It is assumed that the elements to be set are located in contiguous memory.
Definition at line 1430 of file trilinos_tpetra_vector.h.
|
inline |
A collective set operation: instead of setting individual elements of a vector, this function allows to set a whole set of elements at once. The indices of the elements to be set are stated in the first argument, the corresponding values in the second.
Definition at line 1419 of file trilinos_tpetra_vector.h.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::scale | ( | const Vector< Number, MemorySpace > & | 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. The vectors need to have the same layout.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::equ | ( | const Number | a, |
| const Vector< Number, MemorySpace > & | V | ||
| ) |
Assignment *this = a*V.
| bool LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::all_zero | ( | ) | const |
Return whether the vector contains only elements with value zero.
| bool LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::is_non_negative | ( | ) | const |
Return true if the vector has no negative entries, i.e. all entries are zero or positive. This function is used, for example, to check whether refinement indicators are really all positive (or zero).
| Number LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::mean_value | ( | ) | const |
Return the mean value of the element of this vector.
| Number LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::min | ( | ) | const |
Compute the minimal value of the elements of this vector.
| Number LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::max | ( | ) | const |
Compute the maximal value of the elements of this vector.
| real_type LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::l1_norm | ( | ) | const |
Return the l1 norm of the vector (i.e., the sum of the absolute values of all entries among all processors).
| real_type LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::l2_norm | ( | ) | const |
Return the l2 norm of the vector (i.e., the square root of the sum of the square of all entries among all processors).
| real_type LinearAlgebra::TpetraWrappers::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.
| real_type LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::linfty_norm | ( | ) | const |
Return the maximum norm of the vector (i.e., the maximum absolute value among all entries and among all processors).
| real_type LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::norm_sqr | ( | ) | const |
Return the square of the l2-norm.
| Number LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::add_and_dot | ( | const Number | a, |
| const Vector< Number, MemorySpace > & | V, | ||
| const Vector< Number, MemorySpace > & | 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).
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}\).
|
inline |
Return whether the vector has ghost elements or not.
Definition at line 1214 of file trilinos_tpetra_vector.h.
| bool LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::operator== | ( | const Vector< Number, MemorySpace > & | 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 LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::operator!= | ( | const Vector< Number, MemorySpace > & | 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.
|
overridevirtual |
Return the global size of the vector, equal to the sum of the number of locally owned indices among all processors.
Implements ReadVector< Number >.
| size_type LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::locally_owned_size | ( | ) | const |
Return the local size of the vector, i.e., the number of indices owned locally.
| std::pair< size_type, size_type > LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::local_range | ( | ) | const |
Return a pair of indices indicating which elements of this vector are stored locally. The first number is the index of the first element stored, the second the index of the one past the last one that is stored locally. If this is a sequential vector, then the result will be the pair (0,N), otherwise it will be a pair (i,i+n), where n is the number of elements stored on this processor and i is the first element of the vector stored on this processor, corresponding to the half open interval \([i,i+n)\).
The range includes ghost entries and does not require knowledge of which entries are locally owned. If no entries are stored on this processor, the returned pair is (0,0).
| bool LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::in_local_range | ( | const size_type | index | ) | const |
Return whether index is in the local range or not, see also local_range().
|
inline |
Return the state of the vector, i.e., whether compress() needs to be called after an operation requiring data exchange. A call to compress() is also needed when the method set() or add() has been called.
Definition at line 1223 of file trilinos_tpetra_vector.h.
| MPI_Comm LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::get_mpi_communicator | ( | ) | const |
Return the underlying MPI communicator.
| ::IndexSet LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::locally_owned_elements | ( | ) | const |
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
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::compress | ( | const VectorOperation::values | operation | ) |
Compress the underlying representation of the Trilinos object, i.e. flush 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.
| operation | The compress mode (Add or Insert) in case the vector has not been written to since the last time this function was called. The argument is ignored if the vector has been added or written to since the last time compress() was called. |
See Compressing distributed objects for more information.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::update_ghost_values | ( | ) | const |
This function only exists for compatibility with the LinearAlgebra::distributed::Vector class and does nothing: this class implements ghost value updates in a different way that is a better fit with the underlying Trilinos vector object.
| const TpetraTypes::VectorType< Number, MemorySpace > & LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::trilinos_vector | ( | ) | const |
Return a const reference to the underlying Trilinos Tpetra::Vector class.
| TpetraTypes::VectorType< Number, MemorySpace > & LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::trilinos_vector | ( | ) |
Return a (modifiable) reference to the underlying Trilinos Tpetra::Vector class.
| const TpetraTypes::MapType< MemorySpace > & LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::trilinos_partitioner | ( | ) | const |
Return a const reference to the underlying Trilinos Tpetra::Map that sets the parallel partitioning of the vector.
| Teuchos::RCP< const TpetraTypes::VectorType< Number, MemorySpace > > LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::trilinos_rcp | ( | ) | const |
Return a const Teuchos::RCP to the underlying Trilinos Tpetra::Vector class.
| Teuchos::RCP< TpetraTypes::VectorType< Number, MemorySpace > > LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::trilinos_rcp | ( | ) |
Return a (modifiable) Teuchos::RCP to the underlying Trilinos Tpetra::Vector class.
| void LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::print | ( | std::ostream & | out, |
| const unsigned int | precision = 3, |
||
| const bool | scientific = true, |
||
| const bool | across = true |
||
| ) | const |
Prints the vector to the output stream out.
| std::size_t LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::memory_consumption | ( | ) | const |
Return the memory consumption of this class in bytes.
| MPI_Comm LinearAlgebra::TpetraWrappers::Vector< Number, MemorySpace >::mpi_comm | ( | ) | const |
Return the mpi communicator
|
private |
Create the CommunicationPattern for the communication between the IndexSet source_index_set and the current vector based on the communicator mpi_comm.
|
inlineinherited |
Return the present number of subscriptions to this object. This allows to use this class for reference counted lifetime determination where the last one to unsubscribe also deletes the object.
Definition at line 318 of file enable_observer_pointer.h.
|
inlineinherited |
List the subscribers to the input stream.
Definition at line 335 of file enable_observer_pointer.h.
|
inherited |
List the subscribers to deallog.
Definition at line 200 of file enable_observer_pointer.cc.
|
inlineinherited |
Read or write the data of this object to or from a stream for the purpose of serialization using the BOOST serialization library.
This function does not actually serialize any of the member variables of this class. The reason is that what this class stores is only who subscribes to this object, but who does so at the time of storing the contents of this object does not necessarily have anything to do with who subscribes to the object when it is restored. Consequently, we do not want to overwrite the subscribers at the time of restoring, and then there is no reason to write the subscribers out in the first place.
Definition at line 327 of file enable_observer_pointer.h.
|
privateinherited |
Subscribes a user of the object by storing the pointer validity. The subscriber may be identified by text supplied as identifier.
Definition at line 136 of file enable_observer_pointer.cc.
|
privateinherited |
Unsubscribes a user from the object.
identifier and the validity pointer must be the same as the one supplied to subscribe(). Definition at line 154 of file enable_observer_pointer.cc.
|
privatenoexceptinherited |
Check that there are no objects subscribing to this object. If this check passes then it is safe to destroy the current object. It this check fails then this function will either abort or print an error message to deallog (by using the AssertNothrow mechanism), but will not throw an exception.
Definition at line 58 of file enable_observer_pointer.cc.
|
friend |
Definition at line 1194 of file trilinos_tpetra_vector.h.
|
private |
A boolean variable to hold information on whether the vector is compressed or not.
Definition at line 1098 of file trilinos_tpetra_vector.h.
|
private |
Store whether the vector has ghost elements or not.
If the vector has no ghost elements, it can only access and modify entries included in the locally owned index set. And if the vector has ghost elements it can access and modify entries included in the locally relevant index set.
Definition at line 1108 of file trilinos_tpetra_vector.h.
|
private |
The operation that was last performed on the elements of the vector. The reset state is represented by VectorOperation::unknown, which means no element-wise modification has been done locally since creation or the last call to compress().
Definition at line 1116 of file trilinos_tpetra_vector.h.
|
private |
Teuchos::RCP to the actual Tpetra vector object.
Definition at line 1121 of file trilinos_tpetra_vector.h.
|
private |
A vector object in Trilinos to be used for collecting the non-local elements if the vector was constructed with an additional IndexSet describing ghost elements.
Definition at line 1129 of file trilinos_tpetra_vector.h.
|
private |
IndexSet of the elements of the last imported vector.
Definition at line 1134 of file trilinos_tpetra_vector.h.
|
private |
IndexSet of the local owned elements.
Definition at line 1139 of file trilinos_tpetra_vector.h.
|
private |
Indices of the non-local elements that are cached and will be communicated to their owners upon calling compress(). Note, that these indices are not the set of entries in nonlocal_vector. Rather it enables a cache for fully distributed vectors to allow writing into entries that are not locally owned (i.e. it supports cases where the size of the non-local vector is not known at the time this vector is constructed).
Definition at line 1159 of file trilinos_tpetra_vector.h.
|
private |
Values of the non-local cached elements specified in nonlocal_cached_indices.
Definition at line 1165 of file trilinos_tpetra_vector.h.
|
mutableprivate |
To avoid creating new views during element-wise access, store a view to the vector.
Definition at line 1171 of file trilinos_tpetra_vector.h.
|
mutableprivate |
To avoid creating new views during element-wise access, store a view to the nonlocal vector.
Definition at line 1177 of file trilinos_tpetra_vector.h.
|
mutableprivate |
A lock that ensures thread-safety for relevant functions. In particular, any function accessing reference counted pointers of the trilinos vector needs to be guarded unless Trilinos is compiled using -D Trilinos_ENABLE_THREAD_SAFE=ON or -D Teuchos_ENABLE_THREAD_SAFE=ON.
Definition at line 1187 of file trilinos_tpetra_vector.h.
|
private |
CommunicationPattern for the communication between the source_stored_elements IndexSet and the current vector.
Definition at line 1194 of file trilinos_tpetra_vector.h.
|
mutableprivateinherited |
Store the number of objects which subscribed to this object. Initially, this number is zero, and upon destruction it shall be zero again (i.e. all objects which subscribed should have unsubscribed again).
The creator (and owner) of an object is counted in the map below if HE manages to supply identification.
We use the mutable keyword in order to allow subscription to constant objects also.
This counter may be read from and written to concurrently in multithreaded code: hence we use the std::atomic class template.
Definition at line 212 of file enable_observer_pointer.h.
|
mutableprivateinherited |
In this map, we count subscriptions for each different identification string supplied to subscribe().
Definition at line 218 of file enable_observer_pointer.h.
|
mutableprivateinherited |
In this vector, we store pointers to the validity bool in the ObserverPointer objects that subscribe to this class.
Definition at line 224 of file enable_observer_pointer.h.
|
mutableprivateinherited |
Pointer to the typeinfo object of this object, from which we can later deduce the class name. Since this information on the derived class is neither available in the destructor, nor in the constructor, we obtain it in between and store it here.
Definition at line 232 of file enable_observer_pointer.h.