18#ifdef DEAL_II_WITH_PETSC
35 VectorReference::operator PetscScalar()
const
60 const PetscScalar *ptr;
66 if (index >=
static_cast<size_type
>(begin) &&
67 index <
static_cast<size_type
>(end))
70 value = *(ptr + index - begin);
75 Assert(vector.ghost_indices.is_element(index),
77 "You are trying to access an element of a vector "
78 "that is neither a locally owned element nor a "
79 "ghost element of the vector."));
81 vector.ghost_indices.index_within_set(index);
84 value = *(ptr +
ghostidx + end - begin);
106 AssertThrow((index >=
static_cast<size_type
>(begin)) &&
107 (index <
static_cast<size_type
>(end)),
110 const PetscScalar *ptr;
114 value = *(ptr + index - begin);
134 , ghost_indices(v.ghost_indices)
188 template <
typename Iterator,
typename OutType>
189 class ConvertingIterator
194 using difference_type =
195 typename std::iterator_traits<Iterator>::difference_type;
199 using iterator_category = std::forward_iterator_tag;
201 ConvertingIterator(
const Iterator &iterator)
208 return static_cast<OutType>(std::real(*m_iterator));
221 ConvertingIterator
old = *
this;
229 return this->m_iterator ==
other.m_iterator;
235 return this->m_iterator !=
other.m_iterator;
280 Assert(
static_cast<PetscInt
>(
static_cast<PetscScalar
>(
314 [](PetscScalar left, PetscScalar right) {
315 return static_cast<PetscInt
>(std::real(left)) <
316 static_cast<PetscInt
>(std::real(right));
463 std::pair<VectorBase::size_type, VectorBase::size_type>
471 return std::make_pair(begin, end);
478 const std::vector<PetscScalar> &values)
480 Assert(indices.size() == values.size(),
481 ExcMessage(
"Function called with arguments of different sizes"));
489 const std::vector<PetscScalar> &values)
491 Assert(indices.size() == values.size(),
492 ExcMessage(
"Function called with arguments of different sizes"));
502 Assert(indices.size() == values.size(),
503 ExcMessage(
"Function called with arguments of different sizes"));
512 const PetscScalar *values)
557# ifdef DEAL_II_WITH_MPI
573 ExcMessage(
"Error: not all processors agree on the last "
574 "VectorOperation before this compress() call."));
582 "Missing compress() or calling with wrong VectorOperation argument."));
630 return sum /
static_cast<PetscReal
>(
size());
639 PetscScalar mean = 0;
647 const PetscScalar *
eptr = ptr + (
size() / 4) * 4;
714 const PetscScalar *
eptr = ptr + (
size() / 4) * 4;
812 template <
typename T>
821 template <
typename T>
827 "whether it is non-negative."))
return true;
885 const PetscScalar factor = 1. / a;
954 const PetscScalar weights[2] = {a, b};
1037 const unsigned int precision,
1038 const bool scientific,
1045 const PetscScalar *val;
1051 const std::ios::fmtflags
old_flags = out.flags();
1052 const unsigned int old_precision = out.precision(precision);
1054 out.precision(precision);
1056 out.setf(std::ios::scientific, std::ios::floatfield);
1058 out.setf(std::ios::fixed, std::ios::floatfield);
1062 out << val[i] <<
' ';
1065 out << val[i] << std::endl;
1095 VectorBase::operator
const Vec &()
const
1111 std::size_t mem =
sizeof(Vec) +
sizeof(
last_action) +
1133 const PetscScalar *values,
1147 if (n_elements != 0)
1150 reinterpret_cast<const PetscInt *
>(indices);
bool operator!=(const AlignedVector< T > &lhs, const AlignedVector< T > &rhs)
bool operator==(const AlignedVector< T > &lhs, const AlignedVector< T > &rhs)
size_type n_elements() const
void set_size(const size_type size)
void add_indices(const ForwardIterator &begin, const ForwardIterator &end)
real_type lp_norm(const real_type p) const
real_type l1_norm() const
VectorBase & operator+=(const VectorBase &V)
PetscScalar mean_value() const
void determine_ghost_indices()
size_type local_size() const
VectorOperation::values last_action
PetscScalar operator*(const VectorBase &vec) const
bool operator==(const VectorBase &v) const
VectorBase & operator*=(const PetscScalar factor)
VectorBase & operator-=(const VectorBase &V)
bool operator!=(const VectorBase &v) const
std::size_t memory_consumption() const
VectorBase & operator/=(const PetscScalar factor)
bool is_non_negative() const
MPI_Comm get_mpi_communicator() const
void scale(const VectorBase &scaling_factors)
std::pair< size_type, size_type > local_range() const
void sadd(const PetscScalar s, const VectorBase &V)
real_type norm_sqr() const
void compress(const VectorOperation::values operation)
void set(const std::vector< size_type > &indices, const std::vector< PetscScalar > &values)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
PetscScalar add_and_dot(const PetscScalar a, const VectorBase &V, const VectorBase &W)
virtual ~VectorBase() override
real_type linfty_norm() const
void add(const std::vector< size_type > &indices, const std::vector< PetscScalar > &values)
void write_ascii(const PetscViewerFormat format=PETSC_VIEWER_DEFAULT)
bool has_ghost_elements() const
size_type locally_owned_size() const
void equ(const PetscScalar a, const VectorBase &V)
void do_set_add_operation(const size_type n_elements, const size_type *indices, const PetscScalar *values, const bool add_values)
VectorBase & operator=(const VectorBase &)
real_type l2_norm() const
std::enable_if_t< std::is_floating_point< T >::value &&std::is_floating_point< U >::value, typename ProductType< std::complex< T >, std::complex< U > >::type > operator*(const std::complex< T > &left, const std::complex< U > &right)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcGhostsPresent()
#define Assert(cond, exc)
#define AssertIsFinite(number)
#define AssertThrowMPI(error_code)
#define AssertNothrow(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
std::enable_if_t< std::is_fundamental< T >::value, std::size_t > memory_consumption(const T &t)
bool is_non_negative(const T &t)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
SynchronousIterators< Iterators > operator++(SynchronousIterators< Iterators > &a)