15#ifndef dealii_vector_h
16#define dealii_vector_h
31#include <boost/serialization/split_member.hpp>
34#include <initializer_list>
43# ifdef DEAL_II_WITH_PETSC
50# ifdef DEAL_II_WITH_TRILINOS
60# ifdef DEAL_II_TRILINOS_WITH_TPETRA
63 namespace TpetraWrappers
65 template <
typename Number,
typename MemorySpace>
71template <
typename number>
118template <
typename Number>
130 std::is_arithmetic_v<typename numbers::NumberTraits<Number>::real_type>,
131 "The Vector class only supports basic numeric types. In particular, it "
132 "does not support automatically differentiated numbers.");
192 template <
typename OtherNumber>
210 template <
typename OtherNumber>
211 explicit Vector(
const std::initializer_list<OtherNumber> &v);
213#ifdef DEAL_II_WITH_PETSC
228#ifdef DEAL_II_WITH_TRILINOS
246#ifdef DEAL_II_TRILINOS_WITH_TPETRA
261 template <
typename OtherNumber,
typename MemorySpace>
281 template <
typename InputIterator>
369 template <
typename Number2>
425 template <
typename Number2>
435#ifdef DEAL_II_WITH_PETSC
452#ifdef DEAL_II_WITH_TRILINOS
472#ifdef DEAL_II_TRILINOS_WITH_TPETRA
488 template <
typename OtherNumber,
typename MemorySpace>
499 template <
typename Number2>
508 template <
typename Number2>
533 template <
typename Number2>
712 template <
typename OtherNumber>
715 std::vector<OtherNumber> &values)
const;
751 template <
typename ForwardIterator,
typename OutputIterator>
754 const ForwardIterator indices_end,
755 OutputIterator values_begin)
const;
784 template <
typename OtherNumber>
786 add(
const std::vector<size_type> &indices,
787 const std::vector<OtherNumber> &values);
793 template <
typename OtherNumber>
802 template <
typename OtherNumber>
806 const OtherNumber *values);
883 template <
typename Number2>
898 template <
typename Number2>
923 const unsigned int precision = 3,
924 const bool scientific =
true,
925 const bool across =
true)
const;
954 template <
class Archive>
956 save(Archive &ar,
const unsigned int version)
const;
963 template <
class Archive>
965 load(Archive &ar,
const unsigned int version);
973 template <
class Archive>
975 serialize(Archive &archive,
const unsigned int version);
979 BOOST_SERIALIZATION_SPLIT_MEMBER()
1096 const bool omit_zeroing_entries,
1097 const bool reset_partitioner);
1103 mutable std::shared_ptr<parallel::internal::TBBPartitioner>
1107 template <
typename Number2>
1126template <
typename Number>
1137template <
typename Number>
1138template <
typename OtherNumber>
1145template <
typename Number>
1146template <
typename InputIterator>
1157template <
typename Number>
1168template <
typename Number>
1172 return values.size();
1177template <
typename Number>
1181 return values.size();
1186template <
typename Number>
1195template <
typename Number>
1199 return values.data();
1204template <
typename Number>
1208 return values.data();
1213template <
typename Number>
1217 return values.begin();
1222template <
typename Number>
1226 return values.begin();
1231template <
typename Number>
1235 return values.end();
1240template <
typename Number>
1244 return values.end();
1249template <
typename Number>
1259template <
typename Number>
1269template <
typename Number>
1278template <
typename Number>
1287template <
typename Number>
1288template <
typename OtherNumber>
1291 std::vector<OtherNumber> &values)
const
1293 for (size_type i = 0; i < indices.size(); ++i)
1294 values[i] =
operator()(indices[i]);
1299template <
typename Number>
1300template <
typename ForwardIterator,
typename OutputIterator>
1303 const ForwardIterator indices_end,
1304 OutputIterator values_begin)
const
1306 while (indices_begin != indices_end)
1316template <
typename Number>
1329template <
typename Number>
1330template <
typename OtherNumber>
1333 const std::vector<OtherNumber> &values)
1335 Assert(indices.size() == values.size(),
1337 add(indices.size(), indices.data(), values.data());
1342template <
typename Number>
1343template <
typename OtherNumber>
1348 Assert(indices.size() == values.size(),
1350 add(indices.size(), indices.data(), values.values.begin());
1355template <
typename Number>
1356template <
typename OtherNumber>
1359 const size_type *indices,
1360 const OtherNumber *values)
1362 for (size_type i = 0; i < n_indices; ++i)
1368 "The given value is not finite but either infinite or Not A Number (NaN)"));
1370 this->values[indices[i]] += values[i];
1376template <
typename Number>
1377template <
typename Number2>
1381 return !(*
this == v);
1386template <
typename Number>
1393template <
typename Number>
1402template <
typename Number>
1409template <
typename Number>
1416template <
typename Number>
1417template <
typename Number2>
1420 const bool omit_zeroing_entries)
1424 if (!omit_zeroing_entries ||
size() != v.
size())
1436template <
typename Number>
1446template <
typename Number>
1447template <
class Archive>
1458template <
typename Number>
1459template <
class Archive>
1485template <
typename Number>
1500template <
typename number>
1501inline std::ostream &
1509 out << v(v.
size() - 1);
1524template <
typename Number>
Vector< Number > & operator=(const PETScWrappers::VectorBase &v)
typename numbers::NumberTraits< Number >::real_type real_type
Number & operator[](const size_type i)
void extract_subvector_to(ForwardIterator indices_begin, const ForwardIterator indices_end, OutputIterator values_begin) const
bool operator!=(const Vector< Number2 > &v) const
const value_type * const_pointer
void scale(const Vector< Number2 > &scaling_factors)
bool has_ghost_elements() const
void add(const std::vector< size_type > &indices, const std::vector< OtherNumber > &values)
void add(const Number a, const Vector< Number > &V, const Number b, const Vector< Number > &W)
Vector(const TrilinosWrappers::MPI::Vector &v)
Number & operator()(const size_type i)
Vector< Number > & operator=(const TrilinosWrappers::MPI::Vector &v)
bool in_local_range(const size_type global_index) const
Vector< Number > & operator=(const Number s)
Number operator*(const Vector< Number2 > &V) const
const_pointer data() const
void do_reinit(const size_type new_size, const bool omit_zeroing_entries, const bool reset_partitioner)
Vector< Number > & operator=(const BlockVector< Number > &v)
void sadd(const Number s, const Number a, const Vector< Number > &V)
Vector(const size_type n)
Vector< Number > & operator=(Vector< Number > &&v) noexcept=default
const value_type * const_iterator
void block_write(std::ostream &out) const
Number mean_value() const
Number add_and_dot(const Number a, const Vector< Number > &V, const Vector< Number > &W)
void load(Archive &ar, const unsigned int version)
const value_type & const_reference
void reinit(const Vector< Number2 > &V, const bool omit_zeroing_entries=false)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
Vector(const Vector< Number > &v)
std::shared_ptr< parallel::internal::TBBPartitioner > thread_loop_partitioner
void block_read(std::istream &in)
Number operator[](const size_type i) const
Vector< Number > & operator*=(const Number factor)
virtual size_type size() const override
void equ(const Number a, const Vector< Number > &u)
void zero_out_ghost_values() const
void serialize(Archive &archive, const unsigned int version)
Vector(const PETScWrappers::VectorBase &v)
real_type lp_norm(const real_type p) const
const_iterator begin() const
void sadd(const Number s, const Vector< Number > &V)
bool operator==(const Vector< Number2 > &v) const
Vector(const LinearAlgebra::TpetraWrappers::Vector< OtherNumber, MemorySpace > &v)
real_type l2_norm() const
void grow_or_shrink(const size_type N)
virtual ~Vector() override=default
Vector(const Vector< OtherNumber > &v)
void save(Archive &ar, const unsigned int version) const
real_type linfty_norm() const
Vector< Number > & operator=(const Vector< Number > &v)
Vector< Number > & operator+=(const Vector< Number > &V)
void scale(const Vector< Number > &scaling_factors)
virtual void extract_subvector_to(const ArrayView< const types::global_dof_index > &indices, ArrayView< Number > &elements) const override
void maybe_reset_thread_partitioner()
IndexSet locally_owned_elements() const
real_type norm_sqr() const
void add(const Number a, const Vector< Number > &V)
AlignedVector< Number > values
void equ(const Number a, const Vector< Number2 > &u)
Vector< Number > & operator=(const Vector< Number2 > &v)
void apply_givens_rotation(const std::array< Number, 3 > &csr, const size_type i, const size_type k)
const_iterator end() const
Vector(Vector< Number > &&v) noexcept=default
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
void add(const size_type n_elements, const size_type *indices, const OtherNumber *values)
size_type locally_owned_size() const
Number operator()(const size_type i) const
virtual void swap(Vector< Number > &v) noexcept
void compress(VectorOperation::values operation=VectorOperation::unknown) const
bool is_non_negative() const
Vector< Number > & operator-=(const Vector< Number > &V)
Vector< Number > & operator=(const LinearAlgebra::TpetraWrappers::Vector< OtherNumber, MemorySpace > &v)
void extract_subvector_to(const std::vector< size_type > &indices, std::vector< OtherNumber > &values) const
void update_ghost_values() const
std::size_t memory_consumption() const
real_type l1_norm() const
void add(const std::vector< size_type > &indices, const Vector< OtherNumber > &values)
Vector(const InputIterator first, const InputIterator last)
Vector(const std::initializer_list< OtherNumber > &v)
Vector< Number > & operator/=(const Number factor)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcZero()
static ::ExceptionBase & ExcEmptyObject()
#define Assert(cond, exc)
#define AssertIsFinite(number)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
std::ostream & operator<<(std::ostream &out, const Vector< number > &v)
void swap(Vector< Number > &u, Vector< Number > &v) noexcept
bool is_finite(const double x)
unsigned int global_dof_index