15#ifndef dealii_trilinos_epetra_vector_h
16#define dealii_trilinos_epetra_vector_h
21#ifdef DEAL_II_WITH_TRILINOS
32# include <Epetra_FEVector.h>
41 template <
typename Number>
51 namespace EpetraWrappers
95 VectorReference(
Vector &vector,
const size_type index);
101 VectorReference(
const VectorReference &) =
default;
114 const VectorReference &
115 operator=(
const VectorReference &r)
const;
121 operator=(
const VectorReference &r);
126 const VectorReference &
127 operator=(
const value_type &s)
const;
132 const VectorReference &
133 operator+=(
const value_type &s)
const;
138 const VectorReference &
139 operator-=(
const value_type &s)
const;
144 const VectorReference &
145 operator*=(
const value_type &s)
const;
150 const VectorReference &
151 operator/=(
const value_type &s)
const;
157 operator value_type()
const;
164 <<
"An error with error number " << arg1
165 <<
" occurred while calling a Trilinos function");
173 ExcAccessToNonLocalElement,
178 <<
"You are trying to access element " << arg1
179 <<
" of a distributed vector, but this element is not stored "
180 <<
"on the current processor. Note: There are " << arg2
181 <<
" elements stored "
182 <<
"on the current processor from within the range [" << arg3 <<
','
183 << arg4 <<
"] but Trilinos vectors need not store contiguous "
184 <<
"ranges on each processor, and not every element in "
185 <<
"this range may in fact be stored locally."
187 <<
"A common source for this kind of problem is that you "
188 <<
"are passing a 'fully distributed' vector into a function "
189 <<
"that needs read access to vector elements that correspond "
190 <<
"to degrees of freedom on ghost cells (or at least to "
191 <<
"'locally active' degrees of freedom that are not also "
192 <<
"'locally owned'). You need to pass a vector that has these "
193 <<
"elements as ghost entries.");
204 const size_type index;
208 friend class ::LinearAlgebra::EpetraWrappers::Vector;
269 const bool omit_zeroing_entries =
false);
276 reinit(
const Vector &V,
const bool omit_zeroing_entries =
false);
337 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
338 &communication_pattern = {});
348 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
349 &communication_pattern = {})
461 sadd(
const double s,
const double a,
const Vector &V);
563 size()
const override;
617 const Epetra_FEVector &
631 print(std::ostream &out,
632 const unsigned int precision = 3,
633 const bool scientific =
true,
634 const bool across =
true)
const;
664 <<
"An error with error number " << arg1
665 <<
" occurred while calling a Trilinos function");
702 inline VectorReference::VectorReference(
Vector &vector,
703 const size_type index)
710 inline const VectorReference &
711 VectorReference::operator=(
const VectorReference &r)
const
717 *
this =
static_cast<value_type
>(r);
724 inline VectorReference &
725 VectorReference::operator=(
const VectorReference &r)
728 *
this =
static_cast<value_type
>(r);
735 inline const VectorReference &
736 VectorReference::operator=(
const value_type &value)
const
738 (*vector.vector)[0][index] = value;
745 inline const VectorReference &
746 VectorReference::operator+=(
const value_type &value)
const
748 value_type new_value =
static_cast<value_type
>(*this) +
value;
749 (*vector.vector)[0][index] = new_value;
756 inline const VectorReference &
757 VectorReference::operator-=(
const value_type &value)
const
759 value_type new_value =
static_cast<value_type
>(*this) -
value;
760 (*vector.vector)[0][index] = new_value;
767 inline const VectorReference &
768 VectorReference::operator*=(
const value_type &value)
const
770 value_type new_value =
static_cast<value_type
>(*this) *
value;
771 (*vector.vector)[0][index] = new_value;
778 inline const VectorReference &
779 VectorReference::operator/=(
const value_type &value)
const
781 value_type new_value =
static_cast<value_type
>(*this) /
value;
782 (*vector.vector)[0][index] = new_value;
791 inline internal::VectorReference
794 return internal::VectorReference(*
this, index);
797 inline internal::VectorReference
800 return operator()(index);
806 return operator()(index);
::types::global_dof_index size_type
bool has_ghost_elements() const
Vector & operator-=(const Vector &V)
void equ(const double a, const Vector &V)
Vector & operator=(const Vector &V)
MPI_Comm get_mpi_communicator() const
void compress(const VectorOperation::values operation)
VectorTraits::value_type value_type
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
friend class internal::VectorReference
std::unique_ptr< Epetra_FEVector > vector
const Epetra_FEVector & trilinos_vector() const
void import_elements(const ReadWriteVector< double > &V, VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
void sadd(const double s, const double a, const Vector &V)
value_type operator()(const size_type index) const
Vector & operator/=(const double factor)
virtual size_type size() const override
reference operator[](const size_type index)
size_type locally_owned_size() const
::IndexSet locally_owned_elements() const
Vector & operator+=(const Vector &V)
virtual void extract_subvector_to(const ArrayView< const types::global_dof_index > &indices, ArrayView< double > &elements) const override
void scale(const Vector &scaling_factors)
void create_epetra_comm_pattern(const IndexSet &source_index_set, const MPI_Comm mpi_comm)
double mean_value() const
internal::VectorReference reference
Vector & operator*=(const double factor)
::IndexSet source_stored_elements
double operator*(const Vector &V) const
std::shared_ptr< const CommunicationPattern > epetra_comm_pattern
std::size_t memory_consumption() const
void reinit(const IndexSet ¶llel_partitioner, const MPI_Comm communicator, const bool omit_zeroing_entries=false)
reference operator()(const size_type index)
const internal::VectorReference const_reference
double linfty_norm() const
double add_and_dot(const double a, const Vector &V, const Vector &W)
bool has_ghost_elements() const
Number operator[](const size_type i) const
Number operator()(const size_type i) const
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcVectorTypeNotCompatible()
#define DeclException0(Exception0)
static ::ExceptionBase & ExcTrilinosError(int arg1)
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
static ::ExceptionBase & ExcDifferentParallelPartitioning()
#define DeclException1(Exception1, type1, outsequence)
unsigned int global_dof_index