Reference documentation for deal.II version GIT relicensing-384-g4769914377 2024-04-13 09:00: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\}}\)
Loading...
Searching...
No Matches
la_parallel_block_vector.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2016 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_la_parallel_block_vector_h
16#define dealii_la_parallel_block_vector_h
17
18
19#include <deal.II/base/config.h>
20
22
28
29#include <cstdio>
30#include <vector>
31
33
34
35// Forward declarations
36#ifndef DOXYGEN
37# ifdef DEAL_II_WITH_PETSC
38namespace PETScWrappers
39{
40 namespace MPI
41 {
42 class BlockVector;
43 }
44} // namespace PETScWrappers
45# endif
46
47# ifdef DEAL_II_WITH_TRILINOS
48namespace TrilinosWrappers
49{
50 namespace MPI
51 {
52 class BlockVector;
53 }
54} // namespace TrilinosWrappers
55# endif
56#endif
57
58namespace LinearAlgebra
59{
60 namespace distributed
61 {
83 template <typename Number>
84 class BlockVector : public BlockVectorBase<Vector<Number>>
85 {
86 public:
99 static constexpr unsigned int communication_block_size = 20;
100
105
110
116 using pointer = typename BaseClass::pointer;
123
139 explicit BlockVector(const size_type num_blocks = 0,
140 const size_type block_size = 0);
141
147
154 template <typename OtherNumber>
156
161 BlockVector(const std::vector<size_type> &block_sizes);
162
167 BlockVector(const std::vector<IndexSet> &local_ranges,
168 const std::vector<IndexSet> &ghost_indices,
169 const MPI_Comm communicator);
170
174 BlockVector(const std::vector<IndexSet> &local_ranges,
175 const MPI_Comm communicator);
176
189 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
190 &partitioners,
191 const MPI_Comm &comm_sm = MPI_COMM_SELF);
192
201 ~BlockVector() = default;
202
209
216
221 template <class Number2>
224
230
231#ifdef DEAL_II_WITH_PETSC
241#endif
242
243#ifdef DEAL_II_WITH_TRILINOS
254#endif
255
269 void
270 reinit(const size_type num_blocks,
271 const size_type block_size = 0,
272 const bool omit_zeroing_entries = false);
273
293 void
294 reinit(const std::vector<size_type> &block_sizes,
295 const bool omit_zeroing_entries = false);
296
311 template <typename Number2>
312 void
314 const bool omit_zeroing_entries = false);
315
333 void
334 reinit(const std::vector<IndexSet> &local_ranges,
335 const std::vector<IndexSet> &ghost_indices,
336 const MPI_Comm communicator);
337
341 void
342 reinit(const std::vector<IndexSet> &local_ranges,
343 const MPI_Comm communicator);
344
358 void
360 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
361 &partitioners,
362 const MPI_Comm &comm_sm = MPI_COMM_SELF);
363
370 void
372 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
373 &partitioners,
374 const bool make_ghosted,
375 const MPI_Comm &comm_sm = MPI_COMM_SELF);
376
400 void
402
411 void
413
422 void
424
428 bool
430
434 void
435 set_ghost_state(const bool ghosted) const;
436
451 template <typename Number2>
452 void
454
459 template <typename OtherNumber>
460 void
461 add(const std::vector<size_type> &indices,
462 const ::Vector<OtherNumber> &values);
463
468 void
469 sadd(const Number s, const BlockVector<Number> &V);
470
476 bool
477 all_zero() const;
478
482 Number
483 mean_value() const;
484
490 lp_norm(const real_type p) const;
491
509 void
522 operator*=(const Number factor);
523
528 operator/=(const Number factor);
529
535
541
550 void
553 const VectorOperation::values operation,
554 const std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
555 &communication_pattern = {});
556
562 VectorOperation::values operation,
563 std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
564 communication_pattern = {})
565 {
566 import_elements(V, operation, communication_pattern);
567 }
568
572 Number
574
591 template <typename FullMatrixType>
592 void
593 multivector_inner_product(FullMatrixType &matrix,
594 const BlockVector<Number> &V,
595 const bool symmetric = false) const;
596
613 template <typename FullMatrixType>
614 Number
615 multivector_inner_product_with_metric(const FullMatrixType &matrix,
616 const BlockVector<Number> &V,
617 const bool symmetric = false) const;
618
628 template <typename FullMatrixType>
629 void
631 const FullMatrixType &matrix,
632 const Number s = Number(0.),
633 const Number b = Number(1.)) const;
634
638 void
639 add(const Number a);
640
644 void
645 add(const Number a, const BlockVector<Number> &V);
646
650 void
651 add(const Number a,
652 const BlockVector<Number> &V,
653 const Number b,
654 const BlockVector<Number> &W);
655
660 void
661 add(const std::vector<size_type> &indices,
662 const std::vector<Number> &values);
663
668 void
669 sadd(const Number s, const Number a, const BlockVector<Number> &V);
670
676 void
677 scale(const BlockVector<Number> &scaling_factors);
678
682 void
683 equ(const Number a, const BlockVector<Number> &V);
684
690 l1_norm() const;
691
697 l2_norm() const;
698
703 norm_sqr() const;
704
710 linfty_norm() const;
711
732 Number
733 add_and_dot(const Number a,
734 const BlockVector<Number> &V,
735 const BlockVector<Number> &W);
736
741 virtual size_type
742 size() const override;
743
757
761 void
762 print(std::ostream &out,
763 const unsigned int precision = 3,
764 const bool scientific = true,
765 const bool across = true) const;
766
770 std::size_t
785
791 };
792
795 } // end of namespace distributed
796
797} // end of namespace LinearAlgebra
798
799
807template <typename Number>
808inline void
814
815
820template <typename Number>
821struct is_serial_vector<LinearAlgebra::distributed::BlockVector<Number>>
822 : std::false_type
823{};
824
825
827
828#ifdef DEAL_II_MSVC
829# include <deal.II/lac/la_parallel_block_vector.templates.h>
830#endif
831
832#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< Number > & operator-=(const BlockVector< Number > &V)
void swap(BlockVector< Number > &v)
Number operator*(const BlockVector< Number > &V) const
BlockVector(const size_type num_blocks=0, const size_type block_size=0)
void add(const std::vector< size_type > &indices, const std::vector< Number > &values)
void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const
void reinit(const std::vector< IndexSet > &local_ranges, const MPI_Comm communicator)
void sadd(const Number s, const Number a, const BlockVector< Number > &V)
static constexpr unsigned int communication_block_size
void add(const Number a, const BlockVector< Number > &V, const Number b, const BlockVector< Number > &W)
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)
BlockVector(const std::vector< size_type > &block_sizes)
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)
BlockVector< Number > & operator=(const TrilinosWrappers::MPI::BlockVector &trilinos_vec)
BlockVector< Number > & operator=(const PETScWrappers::MPI::BlockVector &petsc_vec)
BlockVector< Number > & operator/=(const Number factor)
void set_ghost_state(const bool ghosted) const
void add(const Number a, const BlockVector< Number > &V)
void add(const std::vector< size_type > &indices, const ::Vector< OtherNumber > &values)
BlockVector & operator=(const Vector< Number > &V)
BlockVector< Number > & operator*=(const Number factor)
BlockVector(const std::vector< IndexSet > &local_ranges, const MPI_Comm communicator)
void scale(const BlockVector< Number > &scaling_factors)
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
typename BaseClass::const_reference const_reference
real_type lp_norm(const real_type p) const
BlockVector & operator=(const BlockVector< Number2 > &V)
void reinit(const BlockVector< Number2 > &V, const bool omit_zeroing_entries=false)
BlockVector & operator=(const BlockVector &V)
void reinit(const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &partitioners, const MPI_Comm &comm_sm=MPI_COMM_SELF)
Number add_and_dot(const Number a, const BlockVector< Number > &V, const BlockVector< Number > &W)
void equ(const Number a, const BlockVector< Number > &V)
void sadd(const Number s, const BlockVector< Number > &V)
void copy_locally_owned_data_from(const BlockVector< Number2 > &src)
BlockVector(const std::vector< IndexSet > &local_ranges, const std::vector< IndexSet > &ghost_indices, const MPI_Comm communicator)
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)
void compress(VectorOperation::values operation)
void import_elements(const LinearAlgebra::ReadWriteVector< Number > &V, const VectorOperation::values operation, const std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > &communication_pattern={})
BlockVector< Number > & operator+=(const BlockVector< Number > &V)
BlockVector & operator=(const value_type s)
virtual size_type size() const override
#define DEAL_II_DEPRECATED
Definition config.h:207
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
#define DeclException0(Exception0)
Definition exceptions.h:471
static ::ExceptionBase & ExcVectorTypeNotCompatible()
static ::ExceptionBase & ExcIteratorRangeDoesNotMatchVectorSize()