Reference documentation for deal.II version 9.5.0
\(\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\}}\)
Loading...
Searching...
No Matches
la_parallel_block_vector.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 1999 - 2023 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
39namespace PETScWrappers
40{
41 namespace MPI
42 {
43 class BlockVector;
44 }
45} // namespace PETScWrappers
46# endif
47
48# ifdef DEAL_II_WITH_TRILINOS
49namespace TrilinosWrappers
50{
51 namespace MPI
52 {
53 class BlockVector;
54 }
55} // namespace TrilinosWrappers
56# endif
57#endif
58
59namespace 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
112
118 using pointer = typename BaseClass::pointer;
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
191 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
192 & partitioners,
193 const MPI_Comm &comm_sm = MPI_COMM_SELF);
194
203 virtual ~BlockVector() override = default;
204
209 virtual BlockVector &
210 operator=(const value_type s) override;
211
218
223 template <class Number2>
226
232
233#ifdef DEAL_II_WITH_PETSC
243#endif
244
245#ifdef DEAL_II_WITH_TRILINOS
256#endif
257
271 void
272 reinit(const size_type num_blocks,
273 const size_type block_size = 0,
274 const bool omit_zeroing_entries = false);
275
295 void
296 reinit(const std::vector<size_type> &block_sizes,
297 const bool omit_zeroing_entries = false);
298
313 template <typename Number2>
314 void
316 const bool omit_zeroing_entries = false);
317
335 void
336 reinit(const std::vector<IndexSet> &local_ranges,
337 const std::vector<IndexSet> &ghost_indices,
338 const MPI_Comm communicator);
339
343 void
344 reinit(const std::vector<IndexSet> &local_ranges,
345 const MPI_Comm communicator);
346
360 void
362 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
363 & partitioners,
364 const MPI_Comm &comm_sm = MPI_COMM_SELF);
365
372 void
374 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
375 & partitioners,
376 const bool make_ghosted,
377 const MPI_Comm &comm_sm = MPI_COMM_SELF);
378
402 virtual void
404
413 void
415
428
429
438 void
440
444 bool
446
450 void
451 set_ghost_state(const bool ghosted) const;
452
467 template <typename Number2>
468 void
470
475 template <typename OtherNumber>
476 void
477 add(const std::vector<size_type> & indices,
478 const ::Vector<OtherNumber> &values);
479
484 void
485 sadd(const Number s, const BlockVector<Number> &V);
486
492 virtual bool
493 all_zero() const override;
494
498 virtual Number
499 mean_value() const override;
500
506 lp_norm(const real_type p) const;
507
525 void
538 virtual void
540 const bool omit_zeroing_entries = false) override;
541
545 virtual BlockVector<Number> &
546 operator*=(const Number factor) override;
547
551 virtual BlockVector<Number> &
552 operator/=(const Number factor) override;
553
557 virtual BlockVector<Number> &
559
563 virtual BlockVector<Number> &
565
574 virtual void
577 VectorOperation::values operation,
578 std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
579 communication_pattern = {}) override;
580
584 DEAL_II_DEPRECATED_EARLY virtual void
586 VectorOperation::values operation,
587 std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
588 communication_pattern = {}) override
589 {
590 import_elements(V, operation, communication_pattern);
591 }
592
596 virtual Number
597 operator*(const VectorSpaceVector<Number> &V) const override;
598
615 template <typename FullMatrixType>
616 void
617 multivector_inner_product(FullMatrixType & matrix,
618 const BlockVector<Number> &V,
619 const bool symmetric = false) const;
620
637 template <typename FullMatrixType>
638 Number
639 multivector_inner_product_with_metric(const FullMatrixType & matrix,
640 const BlockVector<Number> &V,
641 const bool symmetric = false) const;
642
652 template <typename FullMatrixType>
653 void
655 const FullMatrixType &matrix,
656 const Number s = Number(0.),
657 const Number b = Number(1.)) const;
658
662 virtual void
663 add(const Number a) override;
664
668 virtual void
669 add(const Number a, const VectorSpaceVector<Number> &V) override;
670
674 virtual void
675 add(const Number a,
677 const Number b,
678 const VectorSpaceVector<Number> &W) override;
679
684 virtual void
685 add(const std::vector<size_type> &indices,
686 const std::vector<Number> & values);
687
692 virtual void
693 sadd(const Number s,
694 const Number a,
695 const VectorSpaceVector<Number> &V) override;
696
702 virtual void
703 scale(const VectorSpaceVector<Number> &scaling_factors) override;
704
708 virtual void
709 equ(const Number a, const VectorSpaceVector<Number> &V) override;
710
715 virtual real_type
716 l1_norm() const override;
717
722 virtual real_type
723 l2_norm() const override;
724
729 norm_sqr() const;
730
735 virtual real_type
736 linfty_norm() const override;
737
758 virtual Number
759 add_and_dot(const Number a,
761 const VectorSpaceVector<Number> &W) override;
762
767 virtual size_type
768 size() const override;
769
781 virtual ::IndexSet
782 locally_owned_elements() const override;
783
787 virtual void
788 print(std::ostream & out,
789 const unsigned int precision = 3,
790 const bool scientific = true,
791 const bool across = true) const override;
792
796 virtual std::size_t
797 memory_consumption() const override;
811
817 };
818
821 } // end of namespace distributed
822
823} // end of namespace LinearAlgebra
824
825
833template <typename Number>
834inline void
837{
838 u.swap(v);
839}
840
841
846template <typename Number>
847struct is_serial_vector<LinearAlgebra::distributed::BlockVector<Number>>
848 : std::false_type
849{};
850
851
853
854#ifdef DEAL_II_MSVC
855# include <deal.II/lac/la_parallel_block_vector.templates.h>
856#endif
857
858#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)
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 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)
void reinit(const std::vector< IndexSet > &local_ranges, const MPI_Comm communicator)
virtual void reinit(const VectorSpaceVector< Number > &V, const bool omit_zeroing_entries=false) override
virtual ::IndexSet locally_owned_elements() const override
static constexpr unsigned int communication_block_size
void reinit(const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &partitioners, const bool make_ghosted, const MPI_Comm &comm_sm=MPI_COMM_SELF)
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
virtual BlockVector< Number > & operator/=(const Number factor) override
BlockVector(const std::vector< size_type > &block_sizes)
virtual BlockVector< Number > & operator-=(const VectorSpaceVector< Number > &V) override
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
BlockVector< Number > & operator=(const TrilinosWrappers::MPI::BlockVector &trilinos_vec)
BlockVector< Number > & operator=(const PETScWrappers::MPI::BlockVector &petsc_vec)
virtual bool all_zero() const override
void set_ghost_state(const bool ghosted) const
void add(const std::vector< size_type > &indices, const ::Vector< OtherNumber > &values)
BlockVector & operator=(const Vector< Number > &V)
virtual real_type l2_norm() const override
BlockVector(const std::vector< IndexSet > &local_ranges, const MPI_Comm communicator)
virtual Number operator*(const VectorSpaceVector< Number > &V) const override
void reinit(const std::vector< IndexSet > &local_ranges, const std::vector< IndexSet > &ghost_indices, const MPI_Comm communicator)
Number multivector_inner_product_with_metric(const FullMatrixType &matrix, const BlockVector< Number > &V, const bool symmetric=false) const
virtual BlockVector< Number > & operator+=(const VectorSpaceVector< Number > &V) override
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
virtual BlockVector & operator=(const value_type s) override
BlockVector & operator=(const BlockVector< Number2 > &V)
void reinit(const BlockVector< Number2 > &V, const bool omit_zeroing_entries=false)
BlockVector & operator=(const BlockVector &V)
virtual void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const override
void reinit(const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &partitioners, const MPI_Comm &comm_sm=MPI_COMM_SELF)
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
virtual void import_elements(const LinearAlgebra::ReadWriteVector< Number > &V, VectorOperation::values operation, std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > communication_pattern={}) 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
BlockVector(const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &partitioners, const MPI_Comm &comm_sm=MPI_COMM_SELF)
typename BaseClass::const_pointer const_pointer
typename BaseClass::const_iterator const_iterator
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
virtual void compress(VectorOperation::values operation) override
#define DEAL_II_DEPRECATED
Definition config.h:172
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
#define DeclException0(Exception0)
Definition exceptions.h:465
static ::ExceptionBase & ExcVectorTypeNotCompatible()
static ::ExceptionBase & ExcIteratorRangeDoesNotMatchVectorSize()