Reference documentation for deal.II version GIT 6da2e5d553 2022-07-01 18:55:02+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
la_parallel_block_vector.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2022 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_la_parallel_block_vector_h
17 #define dealii_la_parallel_block_vector_h
18 
19 
20 #include <deal.II/base/config.h>
21 
23 
29 
30 #include <cstdio>
31 #include <vector>
32 
34 
35 
36 // Forward declarations
37 #ifndef DOXYGEN
38 # ifdef DEAL_II_WITH_PETSC
39 namespace PETScWrappers
40 {
41  namespace MPI
42  {
43  class BlockVector;
44  }
45 } // namespace PETScWrappers
46 # endif
47 
48 # ifdef DEAL_II_WITH_TRILINOS
49 namespace TrilinosWrappers
50 {
51  namespace MPI
52  {
53  class BlockVector;
54  }
55 } // namespace TrilinosWrappers
56 # endif
57 #endif
58 
59 namespace LinearAlgebra
60 {
61  namespace distributed
62  {
83  template <typename Number>
84  class BlockVector : public BlockVectorBase<Vector<Number>>,
85  public VectorSpaceVector<Number>
86  {
87  public:
100  static constexpr unsigned int communication_block_size = 20;
101 
106 
110  using BlockType = typename BaseClass::BlockType;
111 
116  using real_type = typename BaseClass::real_type;
117  using pointer = typename BaseClass::pointer;
119  using reference = typename BaseClass::reference;
121  using size_type = typename BaseClass::size_type;
122  using iterator = typename BaseClass::iterator;
124 
129 
140  explicit BlockVector(const size_type num_blocks = 0,
141  const size_type block_size = 0);
142 
148 
155  template <typename OtherNumber>
157 
162  BlockVector(const std::vector<size_type> &block_sizes);
163 
168  BlockVector(const std::vector<IndexSet> &local_ranges,
169  const std::vector<IndexSet> &ghost_indices,
170  const MPI_Comm & communicator);
171 
175  BlockVector(const std::vector<IndexSet> &local_ranges,
176  const MPI_Comm & communicator);
177 
186  virtual ~BlockVector() override = default;
187 
192  virtual BlockVector &
193  operator=(const value_type s) override;
194 
199  BlockVector &
201 
206  template <class Number2>
207  BlockVector &
209 
213  BlockVector &
215 
216 #ifdef DEAL_II_WITH_PETSC
226 #endif
227 
228 #ifdef DEAL_II_WITH_TRILINOS
239 #endif
240 
254  void
255  reinit(const size_type num_blocks,
256  const size_type block_size = 0,
257  const bool omit_zeroing_entries = false);
258 
278  void
279  reinit(const std::vector<size_type> &block_sizes,
280  const bool omit_zeroing_entries = false);
281 
296  template <typename Number2>
297  void
299  const bool omit_zeroing_entries = false);
300 
324  virtual void
325  compress(::VectorOperation::values operation) override;
326 
335  void
337 
348  DEAL_II_DEPRECATED void
350 
351 
360  void
362 
366  bool
368 
372  void
373  set_ghost_state(const bool ghosted) const;
374 
389  template <typename Number2>
390  void
392 
397  template <typename OtherNumber>
398  void
399  add(const std::vector<size_type> & indices,
400  const ::Vector<OtherNumber> &values);
401 
406  void
407  sadd(const Number s, const BlockVector<Number> &V);
408 
414  virtual bool
415  all_zero() const override;
416 
420  virtual Number
421  mean_value() const override;
422 
427  real_type
428  lp_norm(const real_type p) const;
429 
447  void
450 
455 
460  virtual void
462  const bool omit_zeroing_entries = false) override;
463 
467  virtual BlockVector<Number> &
468  operator*=(const Number factor) override;
469 
473  virtual BlockVector<Number> &
474  operator/=(const Number factor) override;
475 
479  virtual BlockVector<Number> &
481 
485  virtual BlockVector<Number> &
487 
496  virtual void
498  VectorOperation::values operation,
499  std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
500  communication_pattern = {}) override;
501 
505  virtual Number
506  operator*(const VectorSpaceVector<Number> &V) const override;
507 
524  template <typename FullMatrixType>
525  void
527  const BlockVector<Number> &V,
528  const bool symmetric = false) const;
529 
546  template <typename FullMatrixType>
547  Number
549  const BlockVector<Number> &V,
550  const bool symmetric = false) const;
551 
561  template <typename FullMatrixType>
562  void
564  const FullMatrixType &matrix,
565  const Number s = Number(0.),
566  const Number b = Number(1.)) const;
567 
571  virtual void
572  add(const Number a) override;
573 
577  virtual void
578  add(const Number a, const VectorSpaceVector<Number> &V) override;
579 
583  virtual void
584  add(const Number a,
586  const Number b,
587  const VectorSpaceVector<Number> &W) override;
588 
593  virtual void
594  add(const std::vector<size_type> &indices,
595  const std::vector<Number> & values);
596 
601  virtual void
602  sadd(const Number s,
603  const Number a,
604  const VectorSpaceVector<Number> &V) override;
605 
611  virtual void
612  scale(const VectorSpaceVector<Number> &scaling_factors) override;
613 
617  virtual void
618  equ(const Number a, const VectorSpaceVector<Number> &V) override;
619 
624  virtual real_type
625  l1_norm() const override;
626 
631  virtual real_type
632  l2_norm() const override;
633 
637  real_type
638  norm_sqr() const;
639 
644  virtual real_type
645  linfty_norm() const override;
646 
667  virtual Number
668  add_and_dot(const Number a,
670  const VectorSpaceVector<Number> &W) override;
671 
676  virtual size_type
677  size() const override;
678 
690  virtual ::IndexSet
691  locally_owned_elements() const override;
692 
696  virtual void
697  print(std::ostream & out,
698  const unsigned int precision = 3,
699  const bool scientific = true,
700  const bool across = true) const override;
701 
705  virtual std::size_t
706  memory_consumption() const override;
708 
720 
726  };
727 
730  } // end of namespace distributed
731 
732 } // end of namespace LinearAlgebra
733 
734 
742 template <typename Number>
743 inline void
746 {
747  u.swap(v);
748 }
749 
750 
755 template <typename Number>
757  : std::false_type
758 {};
759 
760 
762 
763 #ifdef DEAL_II_MSVC
764 # include <deal.II/lac/la_parallel_block_vector.templates.h>
765 #endif
766 
767 #endif
void swap(LinearAlgebra::distributed::BlockVector< Number > &u, LinearAlgebra::distributed::BlockVector< Number > &v)
#define DEAL_II_DEPRECATED
Definition: config.h:164
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
#define DeclException0(Exception0)
Definition: exceptions.h:464
::internal::BlockVectorIterators::Iterator< BlockVectorBase, false > iterator
typename BlockType::const_reference const_reference
typename BlockType::value_type value_type
::internal::BlockVectorIterators::Iterator< BlockVectorBase, true > const_iterator
typename BlockType::reference reference
typename BlockType::real_type real_type
BlockVector & operator=(const BlockVector &V)
static ::ExceptionBase & ExcIteratorRangeDoesNotMatchVectorSize()
BlockVector & operator=(const Vector< Number > &V)
virtual real_type linfty_norm() const override
void swap(BlockVector< Number > &v)
BlockVector(const size_type num_blocks=0, const size_type block_size=0)
virtual BlockVector & operator=(const value_type s) override
virtual real_type l1_norm() const override
virtual void add(const Number a, const VectorSpaceVector< Number > &V, const Number b, const VectorSpaceVector< Number > &W) override
virtual void add(const std::vector< size_type > &indices, const std::vector< Number > &values)
BlockVector< Number > & operator=(const TrilinosWrappers::MPI::BlockVector &trilinos_vec)
virtual void reinit(const VectorSpaceVector< Number > &V, const bool omit_zeroing_entries=false) override
virtual ::IndexSet locally_owned_elements() const override
virtual BlockVector< Number > & operator+=(const VectorSpaceVector< Number > &V) override
static constexpr unsigned int communication_block_size
virtual BlockVector< Number > & operator/=(const Number factor) override
virtual BlockVector< Number > & operator-=(const VectorSpaceVector< Number > &V) override
virtual ~BlockVector() override=default
virtual void sadd(const Number s, const Number a, const VectorSpaceVector< Number > &V) override
virtual BlockVector< Number > & operator*=(const Number factor) override
static ::ExceptionBase & ExcVectorTypeNotCompatible()
BlockVector & operator=(const BlockVector< Number2 > &V)
BlockVector(const std::vector< size_type > &block_sizes)
virtual void scale(const VectorSpaceVector< Number > &scaling_factors) override
BlockVector(const BlockVector< OtherNumber > &v)
BlockVector(const BlockVector< Number > &V)
void reinit(const size_type num_blocks, const size_type block_size=0, const bool omit_zeroing_entries=false)
virtual std::size_t memory_consumption() const override
virtual Number mean_value() const override
virtual bool all_zero() const override
virtual void compress(::VectorOperation::values operation) override
void set_ghost_state(const bool ghosted) const
void add(const std::vector< size_type > &indices, const ::Vector< OtherNumber > &values)
virtual real_type l2_norm() const override
virtual Number operator*(const VectorSpaceVector< Number > &V) const override
Number multivector_inner_product_with_metric(const FullMatrixType &matrix, const BlockVector< Number > &V, const bool symmetric=false) const
BlockVector< Number > & operator=(const PETScWrappers::MPI::BlockVector &petsc_vec)
virtual void add(const Number a, const VectorSpaceVector< Number > &V) override
typename BaseClass::const_reference const_reference
real_type lp_norm(const real_type p) const
void reinit(const BlockVector< Number2 > &V, const bool omit_zeroing_entries=false)
virtual void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const override
void sadd(const Number s, const BlockVector< Number > &V)
void copy_locally_owned_data_from(const BlockVector< Number2 > &src)
virtual void add(const Number a) override
BlockVector(const std::vector< IndexSet > &local_ranges, const std::vector< IndexSet > &ghost_indices, const MPI_Comm &communicator)
virtual void equ(const Number a, const VectorSpaceVector< Number > &V) override
typename BaseClass::const_pointer const_pointer
typename BaseClass::const_iterator const_iterator
BlockVector(const std::vector< IndexSet > &local_ranges, const MPI_Comm &communicator)
void multivector_inner_product(FullMatrixType &matrix, const BlockVector< Number > &V, const bool symmetric=false) const
void mmult(BlockVector< Number > &V, const FullMatrixType &matrix, const Number s=Number(0.), const Number b=Number(1.)) const
void reinit(const std::vector< size_type > &block_sizes, const bool omit_zeroing_entries=false)
virtual Number add_and_dot(const Number a, const VectorSpaceVector< Number > &V, const VectorSpaceVector< Number > &W) override
virtual size_type size() const override
constexpr int block_size
Definition: cuda_size.h:29
@ matrix
Contents is actually a matrix.
@ symmetric
Matrix is symmetric.
static const char V
BlockVector< double > BlockVector
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)