15#ifndef dealii_trilinos_epetra_vector_h
16#define dealii_trilinos_epetra_vector_h
21#ifdef DEAL_II_WITH_TRILINOS
31# include <Epetra_FEVector.h>
40 template <
typename Number>
41 class ReadWriteVector;
50 namespace EpetraWrappers
94 VectorReference(
Vector &vector,
const size_type index);
100 VectorReference(
const VectorReference &) =
default;
113 const VectorReference &
114 operator=(
const VectorReference &r)
const;
120 operator=(
const VectorReference &r);
125 const VectorReference &
126 operator=(
const value_type &s)
const;
131 const VectorReference &
132 operator+=(
const value_type &s)
const;
137 const VectorReference &
138 operator-=(
const value_type &s)
const;
143 const VectorReference &
144 operator*=(
const value_type &s)
const;
149 const VectorReference &
150 operator/=(
const value_type &s)
const;
156 operator value_type()
const;
163 <<
"An error with error number " << arg1
164 <<
" occurred while calling a Trilinos function");
172 ExcAccessToNonLocalElement,
177 <<
"You are trying to access element " << arg1
178 <<
" of a distributed vector, but this element is not stored "
179 <<
"on the current processor. Note: There are " << arg2
180 <<
" elements stored "
181 <<
"on the current processor from within the range [" << arg3 <<
','
182 << arg4 <<
"] but Trilinos vectors need not store contiguous "
183 <<
"ranges on each processor, and not every element in "
184 <<
"this range may in fact be stored locally."
186 <<
"A common source for this kind of problem is that you "
187 <<
"are passing a 'fully distributed' vector into a function "
188 <<
"that needs read access to vector elements that correspond "
189 <<
"to degrees of freedom on ghost cells (or at least to "
190 <<
"'locally active' degrees of freedom that are not also "
191 <<
"'locally owned'). You need to pass a vector that has these "
192 <<
"elements as ghost entries.");
203 const size_type index;
207 friend class ::LinearAlgebra::EpetraWrappers::Vector;
335 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
346 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
459 sadd(
const double s,
const double a,
const Vector &V);
561 size()
const override;
615 const Epetra_FEVector &
629 print(std::ostream &out,
630 const unsigned int precision = 3,
631 const bool scientific =
true,
632 const bool across =
true)
const;
662 <<
"An error with error number " <<
arg1
663 <<
" occurred while calling a Trilinos function");
700 inline VectorReference::VectorReference(
Vector &vector,
701 const size_type index)
708 inline const VectorReference &
709 VectorReference::operator=(
const VectorReference &r)
const
715 *
this =
static_cast<value_type
>(r);
722 inline VectorReference &
723 VectorReference::operator=(
const VectorReference &r)
726 *
this =
static_cast<value_type
>(r);
733 inline const VectorReference &
734 VectorReference::operator=(
const value_type &value)
const
736 (*vector.vector)[0][index] = value;
743 inline const VectorReference &
744 VectorReference::operator+=(
const value_type &value)
const
746 value_type new_value =
static_cast<value_type
>(*this) +
value;
747 (*vector.vector)[0][index] = new_value;
754 inline const VectorReference &
755 VectorReference::operator-=(
const value_type &value)
const
757 value_type new_value =
static_cast<value_type
>(*this) -
value;
758 (*vector.vector)[0][index] = new_value;
765 inline const VectorReference &
766 VectorReference::operator*=(
const value_type &value)
const
768 value_type new_value =
static_cast<value_type
>(*this) *
value;
769 (*vector.vector)[0][index] = new_value;
776 inline const VectorReference &
777 VectorReference::operator/=(
const value_type &value)
const
779 value_type new_value =
static_cast<value_type
>(*this) /
value;
780 (*vector.vector)[0][index] = new_value;
789 inline internal::VectorReference
792 return internal::VectorReference(*
this, index);
795 inline internal::VectorReference
798 return operator()(index);
804 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
VectorTraits::size_type size_type
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)
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)
virtual void extract_subvector_to(const ArrayView< const types::global_dof_index > &indices, const ArrayView< double > &elements) const override
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