Reference documentation for deal.II version GIT 05ffa62ef0 2022-11-26 15:30: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  {
84  template <typename Number>
85  class BlockVector : public BlockVectorBase<Vector<Number>>,
86  public VectorSpaceVector<Number>
87  {
88  public:
101  static constexpr unsigned int communication_block_size = 20;
102 
107 
111  using BlockType = typename BaseClass::BlockType;
112 
117  using real_type = typename BaseClass::real_type;
118  using pointer = typename BaseClass::pointer;
120  using reference = typename BaseClass::reference;
122  using size_type = typename BaseClass::size_type;
123  using iterator = typename BaseClass::iterator;
125 
141  explicit BlockVector(const size_type num_blocks = 0,
142  const size_type block_size = 0);
143 
149 
156  template <typename OtherNumber>
158 
163  BlockVector(const std::vector<size_type> &block_sizes);
164 
169  BlockVector(const std::vector<IndexSet> &local_ranges,
170  const std::vector<IndexSet> &ghost_indices,
171  const MPI_Comm & communicator);
172 
176  BlockVector(const std::vector<IndexSet> &local_ranges,
177  const MPI_Comm & communicator);
178 
187  virtual ~BlockVector() override = default;
188 
193  virtual BlockVector &
194  operator=(const value_type s) override;
195 
200  BlockVector &
202 
207  template <class Number2>
208  BlockVector &
210 
214  BlockVector &
216 
217 #ifdef DEAL_II_WITH_PETSC
227 #endif
228 
229 #ifdef DEAL_II_WITH_TRILINOS
240 #endif
241 
255  void
256  reinit(const size_type num_blocks,
257  const size_type block_size = 0,
258  const bool omit_zeroing_entries = false);
259 
279  void
280  reinit(const std::vector<size_type> &block_sizes,
281  const bool omit_zeroing_entries = false);
282 
297  template <typename Number2>
298  void
300  const bool omit_zeroing_entries = false);
301 
325  virtual void
326  compress(::VectorOperation::values operation) override;
327 
336  void
338 
349  DEAL_II_DEPRECATED void
351 
352 
361  void
363 
367  bool
369 
373  void
374  set_ghost_state(const bool ghosted) const;
375 
390  template <typename Number2>
391  void
393 
398  template <typename OtherNumber>
399  void
400  add(const std::vector<size_type> & indices,
401  const ::Vector<OtherNumber> &values);
402 
407  void
408  sadd(const Number s, const BlockVector<Number> &V);
409 
415  virtual bool
416  all_zero() const override;
417 
421  virtual Number
422  mean_value() const override;
423 
428  real_type
429  lp_norm(const real_type p) const;
430 
448  void
461  virtual void
463  const bool omit_zeroing_entries = false) override;
464 
468  virtual BlockVector<Number> &
469  operator*=(const Number factor) override;
470 
474  virtual BlockVector<Number> &
475  operator/=(const Number factor) override;
476 
480  virtual BlockVector<Number> &
482 
486  virtual BlockVector<Number> &
488 
497  virtual void
499  VectorOperation::values operation,
500  std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
501  communication_pattern = {}) override;
502 
506  virtual Number
507  operator*(const VectorSpaceVector<Number> &V) const override;
508 
525  template <typename FullMatrixType>
526  void
528  const BlockVector<Number> &V,
529  const bool symmetric = false) const;
530 
547  template <typename FullMatrixType>
548  Number
550  const BlockVector<Number> &V,
551  const bool symmetric = false) const;
552 
562  template <typename FullMatrixType>
563  void
565  const FullMatrixType &matrix,
566  const Number s = Number(0.),
567  const Number b = Number(1.)) const;
568 
572  virtual void
573  add(const Number a) override;
574 
578  virtual void
579  add(const Number a, const VectorSpaceVector<Number> &V) override;
580 
584  virtual void
585  add(const Number a,
587  const Number b,
588  const VectorSpaceVector<Number> &W) override;
589 
594  virtual void
595  add(const std::vector<size_type> &indices,
596  const std::vector<Number> & values);
597 
602  virtual void
603  sadd(const Number s,
604  const Number a,
605  const VectorSpaceVector<Number> &V) override;
606 
612  virtual void
613  scale(const VectorSpaceVector<Number> &scaling_factors) override;
614 
618  virtual void
619  equ(const Number a, const VectorSpaceVector<Number> &V) override;
620 
625  virtual real_type
626  l1_norm() const override;
627 
632  virtual real_type
633  l2_norm() const override;
634 
638  real_type
639  norm_sqr() const;
640 
645  virtual real_type
646  linfty_norm() const override;
647 
668  virtual Number
669  add_and_dot(const Number a,
671  const VectorSpaceVector<Number> &W) override;
672 
677  virtual size_type
678  size() const override;
679 
691  virtual ::IndexSet
692  locally_owned_elements() const override;
693 
697  virtual void
698  print(std::ostream & out,
699  const unsigned int precision = 3,
700  const bool scientific = true,
701  const bool across = true) const override;
702 
706  virtual std::size_t
707  memory_consumption() const override;
721 
727  };
728 
731  } // end of namespace distributed
732 
733 } // end of namespace LinearAlgebra
734 
735 
743 template <typename Number>
744 inline void
747 {
748  u.swap(v);
749 }
750 
751 
756 template <typename Number>
758  : std::false_type
759 {};
760 
761 
763 
764 #ifdef DEAL_II_MSVC
765 # include <deal.II/lac/la_parallel_block_vector.templates.h>
766 #endif
767 
768 #endif
::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
void swap(LinearAlgebra::distributed::BlockVector< Number > &u, LinearAlgebra::distributed::BlockVector< Number > &v)
BlockVector & operator=(const BlockVector &V)
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
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
#define DEAL_II_DEPRECATED
Definition: config.h:164
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:458
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:459
static ::ExceptionBase & ExcIteratorRangeDoesNotMatchVectorSize()
#define DeclException0(Exception0)
Definition: exceptions.h:464
static ::ExceptionBase & ExcVectorTypeNotCompatible()
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)