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_vector.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2011 - 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_vector_h
17#define dealii_la_parallel_vector_h
18
19#include <deal.II/base/config.h>
20
29
33
34#include <iomanip>
35#include <memory>
36
38
39// Forward declarations
40#ifndef DOXYGEN
41namespace LinearAlgebra
42{
46 namespace distributed
47 {
48 template <typename>
49 class BlockVector;
50 }
51
52 template <typename>
53 class ReadWriteVector;
54} // namespace LinearAlgebra
55
56# ifdef DEAL_II_WITH_PETSC
57namespace PETScWrappers
58{
59 namespace MPI
60 {
61 class Vector;
62 }
63} // namespace PETScWrappers
64# endif
65
66# ifdef DEAL_II_WITH_TRILINOS
67namespace TrilinosWrappers
68{
69 namespace MPI
70 {
71 class Vector;
72 }
73} // namespace TrilinosWrappers
74# endif
75#endif
76
77namespace LinearAlgebra
78{
79 namespace distributed
80 {
249 template <typename Number, typename MemorySpace = MemorySpace::Host>
251 public Subscriptor
252 {
253 public:
255 using value_type = Number;
257 using const_pointer = const value_type *;
259 using const_iterator = const value_type *;
264
265 static_assert(
266 std::is_same<MemorySpace, ::MemorySpace::Host>::value ||
267 std::is_same<MemorySpace, ::MemorySpace::Default>::value,
268 "MemorySpace should be Host or Default");
269
278
286
294 Vector(Vector<Number, MemorySpace> &&in_vector); // NOLINT
295
301
318 Vector(const IndexSet &local_range,
319 const IndexSet &ghost_indices,
320 const MPI_Comm communicator);
321
325 Vector(const IndexSet &local_range, const MPI_Comm communicator);
326
334 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner);
335
339 virtual ~Vector() override;
340
345 void
346 reinit(const size_type size, const bool omit_zeroing_entries = false);
347
358 template <typename Number2>
359 void
361 const bool omit_zeroing_entries = false);
362
379 void
380 reinit(const IndexSet &local_range,
381 const IndexSet &ghost_indices,
382 const MPI_Comm communicator);
383
387 void
388 reinit(const IndexSet &local_range, const MPI_Comm communicator);
389
402 void
404 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
405 const MPI_Comm comm_sm = MPI_COMM_SELF);
406
413 void
415 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
416 const bool make_ghosted,
417 const MPI_Comm &comm_sm = MPI_COMM_SELF);
418
438 void
440 const types::global_dof_index ghost_size,
441 const MPI_Comm comm,
442 const MPI_Comm comm_sm = MPI_COMM_SELF);
443
456 void
458
467
481
493 template <typename Number2>
496
538 virtual void
540
562 void
564
582 void
583 compress_start(const unsigned int communication_channel = 0,
585
604 void
606
624 void
626 const unsigned int communication_channel = 0) const;
627
628
636 void
638
651
660 void
662
674 bool
676
691 template <typename Number2>
692 void
694
705 template <typename MemorySpace2>
706 void
708 VectorOperation::values operation);
709
713 template <typename MemorySpace2>
714 DEAL_II_DEPRECATED_EARLY void
716 VectorOperation::values operation)
717 {
718 import_elements(src, operation);
719 }
720
732 virtual void
734 const bool omit_zeroing_entries = false) override;
735
740 operator*=(const Number factor) override;
741
746 operator/=(const Number factor) override;
747
753
759
771 virtual void
774 VectorOperation::values operation,
775 std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
776 communication_pattern = {}) override;
777
781 DEAL_II_DEPRECATED_EARLY virtual void
783 VectorOperation::values operation,
784 std::shared_ptr<const Utilities::MPI::CommunicationPatternBase>
785 communication_pattern = {}) override
786 {
787 import_elements(V, operation, communication_pattern);
788 }
789
793 virtual Number
794 operator*(const VectorSpaceVector<Number> &V) const override;
795
799 virtual void
800 add(const Number a) override;
801
805 virtual void
806 add(const Number a, const VectorSpaceVector<Number> &V) override;
807
811 virtual void
812 add(const Number a,
814 const Number b,
815 const VectorSpaceVector<Number> &W) override;
816
821 virtual void
822 add(const std::vector<size_type> &indices,
823 const std::vector<Number> & values);
824
829 virtual void
830 sadd(const Number s,
831 const Number a,
832 const VectorSpaceVector<Number> &V) override;
833
839 virtual void
840 scale(const VectorSpaceVector<Number> &scaling_factors) override;
841
845 virtual void
846 equ(const Number a, const VectorSpaceVector<Number> &V) override;
847
852 virtual real_type
853 l1_norm() const override;
854
859 virtual real_type
860 l2_norm() const override;
861
866 norm_sqr() const;
867
872 virtual real_type
873 linfty_norm() const override;
874
895 virtual Number
896 add_and_dot(const Number a,
898 const VectorSpaceVector<Number> &W) override;
899
904 virtual size_type
905 size() const override;
906
918 virtual ::IndexSet
919 locally_owned_elements() const override;
920
924 virtual void
925 print(std::ostream & out,
926 const unsigned int precision = 3,
927 const bool scientific = true,
928 const bool across = true) const override;
929
933 virtual std::size_t
934 memory_consumption() const override;
948 operator=(const Number s) override;
949
954 template <typename OtherNumber>
955 void
956 add(const std::vector<size_type> & indices,
957 const ::Vector<OtherNumber> &values);
958
963 template <typename OtherNumber>
964 void
965 add(const size_type n_elements,
966 const size_type * indices,
967 const OtherNumber *values);
968
973 void
974 sadd(const Number s, const Vector<Number, MemorySpace> &V);
975
992 local_size() const;
993
1000
1005 bool
1006 in_local_range(const size_type global_index) const;
1007
1018 iterator
1020
1029 begin() const;
1030
1038 iterator
1040
1049 end() const;
1050
1060 Number
1061 operator()(const size_type global_index) const;
1062
1072 Number &
1073 operator()(const size_type global_index);
1074
1082 Number
1083 operator[](const size_type global_index) const;
1091 Number &
1092 operator[](const size_type global_index);
1093
1102 Number
1103 local_element(const size_type local_index) const;
1104
1113 Number &
1114 local_element(const size_type local_index);
1115
1122 Number *
1123 get_values() const;
1124
1142 template <typename OtherNumber>
1143 void
1144 extract_subvector_to(const std::vector<size_type> &indices,
1145 std::vector<OtherNumber> & values) const;
1146
1174 template <typename ForwardIterator, typename OutputIterator>
1175 void
1176 extract_subvector_to(ForwardIterator indices_begin,
1177 const ForwardIterator indices_end,
1178 OutputIterator values_begin) const;
1184 virtual bool
1185 all_zero() const override;
1186
1190 virtual Number
1191 mean_value() const override;
1192
1197 real_type
1198 lp_norm(const real_type p) const;
1209 MPI_Comm
1211
1218 const std::shared_ptr<const Utilities::MPI::Partitioner> &
1220
1230 bool
1232 const Utilities::MPI::Partitioner &part) const;
1233
1247 bool
1249 const Utilities::MPI::Partitioner &part) const;
1250
1254 void
1255 set_ghost_state(const bool ghosted) const;
1256
1261 const std::vector<ArrayView<const Number>> &
1263
1272
1277 Number,
1278 Number,
1279 unsigned int,
1280 << "Called compress(VectorOperation::insert), but"
1281 << " the element received from a remote processor, value "
1282 << std::setprecision(16) << arg1
1283 << ", does not match with the value "
1284 << std::setprecision(16) << arg2
1285 << " on the owner processor " << arg3);
1286
1292 size_type,
1293 size_type,
1294 size_type,
1295 size_type,
1296 << "You tried to access element " << arg1
1297 << " of a distributed vector, but this element is not "
1298 << "stored on the current processor. Note: The range of "
1299 << "locally owned elements is [" << arg2 << ',' << arg3
1300 << "], and there are " << arg4 << " ghost elements "
1301 << "that this vector can access."
1302 << "\n\n"
1303 << "A common source for this kind of problem is that you "
1304 << "are passing a 'fully distributed' vector into a function "
1305 << "that needs read access to vector elements that correspond "
1306 << "to degrees of freedom on ghost cells (or at least to "
1307 << "'locally active' degrees of freedom that are not also "
1308 << "'locally owned'). You need to pass a vector that has these "
1309 << "elements as ghost entries.");
1310
1311 private:
1316 void
1317 add_local(const Number a, const VectorSpaceVector<Number> &V);
1318
1323 void
1324 sadd_local(const Number s,
1325 const Number a,
1326 const VectorSpaceVector<Number> &V);
1327
1331 template <typename Number2>
1332 Number
1334
1338 real_type
1340
1344 Number
1346
1350 real_type
1352
1356 real_type
1357 lp_norm_local(const real_type p) const;
1358
1362 real_type
1364
1370 Number
1371 add_and_dot_local(const Number a,
1374
1380 std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
1381
1386
1390 mutable ::MemorySpace::MemorySpaceData<Number, MemorySpace> data;
1391
1396 mutable std::shared_ptr<::parallel::internal::TBBPartitioner>
1398
1403 mutable ::MemorySpace::MemorySpaceData<Number, MemorySpace>
1405
1413 mutable bool vector_is_ghosted;
1414
1415#ifdef DEAL_II_WITH_MPI
1424 std::vector<MPI_Request> compress_requests;
1425
1430 mutable std::vector<MPI_Request> update_ghost_values_requests;
1431#endif
1432
1438 mutable std::mutex mutex;
1439
1446
1451 void
1453
1457 void
1458 resize_val(const size_type new_allocated_size,
1459 const MPI_Comm comm_sm = MPI_COMM_SELF);
1460
1461 // Make all other vector types friends.
1462 template <typename Number2, typename MemorySpace2>
1463 friend class Vector;
1464
1465 // Make BlockVector type friends.
1466 template <typename Number2>
1467 friend class BlockVector;
1468 };
1472 /*-------------------- Inline functions ---------------------------------*/
1473
1474#ifndef DOXYGEN
1475
1476 template <typename Number, typename MemorySpace>
1477 inline bool
1479 {
1480 return vector_is_ghosted;
1481 }
1482
1483
1484
1485 template <typename Number, typename MemorySpace>
1488 {
1489 return partitioner->size();
1490 }
1491
1492
1493
1494 template <typename Number, typename MemorySpace>
1497 {
1498 return locally_owned_size();
1499 }
1500
1501
1502
1503 template <typename Number, typename MemorySpace>
1506 {
1507 return partitioner->locally_owned_size();
1508 }
1509
1510
1511
1512 template <typename Number, typename MemorySpace>
1513 inline bool
1515 const size_type global_index) const
1516 {
1517 return partitioner->in_local_range(global_index);
1518 }
1519
1520
1521
1522 template <typename Number, typename MemorySpace>
1523 inline IndexSet
1525 {
1526 IndexSet is(size());
1527
1528 is.add_range(partitioner->local_range().first,
1529 partitioner->local_range().second);
1530
1531 return is;
1532 }
1533
1534
1535
1536 template <typename Number, typename MemorySpace>
1539 {
1540 return data.values.data();
1541 }
1542
1543
1544
1545 template <typename Number, typename MemorySpace>
1548 {
1549 return data.values.data();
1550 }
1551
1552
1553
1554 template <typename Number, typename MemorySpace>
1557 {
1558 return data.values.data() + partitioner->locally_owned_size();
1559 }
1560
1561
1562
1563 template <typename Number, typename MemorySpace>
1566 {
1567 return data.values.data() + partitioner->locally_owned_size();
1568 }
1569
1570
1571
1572 template <typename Number, typename MemorySpace>
1573 const std::vector<ArrayView<const Number>> &
1575 {
1576 return data.values_sm;
1577 }
1578
1579
1580
1581 template <typename Number, typename MemorySpace>
1582 inline Number
1583 Vector<Number, MemorySpace>::operator()(const size_type global_index) const
1584 {
1585 Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1586 ExcMessage(
1587 "This function is only implemented for the Host memory space"));
1588 Assert(
1589 partitioner->in_local_range(global_index) ||
1590 partitioner->ghost_indices().is_element(global_index),
1591 ExcAccessToNonLocalElement(global_index,
1592 partitioner->local_range().first,
1593 partitioner->local_range().second == 0 ?
1594 0 :
1595 (partitioner->local_range().second - 1),
1596 partitioner->ghost_indices().n_elements()));
1597 // do not allow reading a vector which is not in ghost mode
1598 Assert(partitioner->in_local_range(global_index) ||
1599 vector_is_ghosted == true,
1600 ExcMessage("You tried to read a ghost element of this vector, "
1601 "but it has not imported its ghost values."));
1602 return data.values[partitioner->global_to_local(global_index)];
1603 }
1604
1605
1606
1607 template <typename Number, typename MemorySpace>
1608 inline Number &
1609 Vector<Number, MemorySpace>::operator()(const size_type global_index)
1610 {
1611 Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1612 ExcMessage(
1613 "This function is only implemented for the Host memory space"));
1614 Assert(
1615 partitioner->in_local_range(global_index) ||
1616 partitioner->ghost_indices().is_element(global_index),
1617 ExcAccessToNonLocalElement(global_index,
1618 partitioner->local_range().first,
1619 partitioner->local_range().second == 0 ?
1620 0 :
1621 (partitioner->local_range().second - 1),
1622 partitioner->ghost_indices().n_elements()));
1623 // we would like to prevent reading ghosts from a vector that does not
1624 // have them imported, but this is not possible because we might be in a
1625 // part of the code where the vector has enabled ghosts but is non-const
1626 // (then, the compiler picks this method according to the C++ rule book
1627 // even if a human would pick the const method when this subsequent use
1628 // is just a read)
1629 return data.values[partitioner->global_to_local(global_index)];
1630 }
1631
1632
1633
1634 template <typename Number, typename MemorySpace>
1635 inline Number
1636 Vector<Number, MemorySpace>::operator[](const size_type global_index) const
1637 {
1638 return operator()(global_index);
1639 }
1640
1641
1642
1643 template <typename Number, typename MemorySpace>
1644 inline Number &
1645 Vector<Number, MemorySpace>::operator[](const size_type global_index)
1646 {
1647 return operator()(global_index);
1648 }
1649
1650
1651
1652 template <typename Number, typename MemorySpace>
1653 inline Number
1655 const size_type local_index) const
1656 {
1657 Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1658 ExcMessage(
1659 "This function is only implemented for the Host memory space"));
1660 AssertIndexRange(local_index,
1661 partitioner->locally_owned_size() +
1662 partitioner->n_ghost_indices());
1663 // do not allow reading a vector which is not in ghost mode
1664 Assert(local_index < locally_owned_size() || vector_is_ghosted == true,
1665 ExcMessage("You tried to read a ghost element of this vector, "
1666 "but it has not imported its ghost values."));
1667
1668 return data.values[local_index];
1669 }
1670
1671
1672
1673 template <typename Number, typename MemorySpace>
1674 inline Number &
1675 Vector<Number, MemorySpace>::local_element(const size_type local_index)
1676 {
1677 Assert((std::is_same<MemorySpace, ::MemorySpace::Host>::value),
1678 ExcMessage(
1679 "This function is only implemented for the Host memory space"));
1680
1681 AssertIndexRange(local_index,
1682 partitioner->locally_owned_size() +
1683 partitioner->n_ghost_indices());
1684
1685 return data.values[local_index];
1686 }
1687
1688
1689
1690 template <typename Number, typename MemorySpace>
1691 inline Number *
1693 {
1694 return data.values.data();
1695 }
1696
1697
1698
1699 template <typename Number, typename MemorySpace>
1700 template <typename OtherNumber>
1701 inline void
1703 const std::vector<size_type> &indices,
1704 std::vector<OtherNumber> & values) const
1705 {
1706 for (size_type i = 0; i < indices.size(); ++i)
1707 values[i] = operator()(indices[i]);
1708 }
1709
1710
1711
1712 template <typename Number, typename MemorySpace>
1713 template <typename ForwardIterator, typename OutputIterator>
1714 inline void
1716 ForwardIterator indices_begin,
1717 const ForwardIterator indices_end,
1718 OutputIterator values_begin) const
1719 {
1720 while (indices_begin != indices_end)
1721 {
1722 *values_begin = operator()(*indices_begin);
1723 indices_begin++;
1724 values_begin++;
1725 }
1726 }
1727
1728
1729
1730 template <typename Number, typename MemorySpace>
1731 template <typename OtherNumber>
1732 inline void
1734 const std::vector<size_type> & indices,
1735 const ::Vector<OtherNumber> &values)
1736 {
1737 AssertDimension(indices.size(), values.size());
1738 for (size_type i = 0; i < indices.size(); ++i)
1739 {
1740 Assert(
1741 numbers::is_finite(values[i]),
1742 ExcMessage(
1743 "The given value is not finite but either infinite or Not A Number (NaN)"));
1744 this->operator()(indices[i]) += values(i);
1745 }
1746 }
1747
1748
1749
1750 template <typename Number, typename MemorySpace>
1751 template <typename OtherNumber>
1752 inline void
1753 Vector<Number, MemorySpace>::add(const size_type n_elements,
1754 const size_type * indices,
1755 const OtherNumber *values)
1756 {
1757 for (size_type i = 0; i < n_elements; ++i, ++indices, ++values)
1758 {
1759 Assert(
1760 numbers::is_finite(*values),
1761 ExcMessage(
1762 "The given value is not finite but either infinite or Not A Number (NaN)"));
1763 this->operator()(*indices) += *values;
1764 }
1765 }
1766
1767
1768
1769 template <typename Number, typename MemorySpace>
1770 inline MPI_Comm
1772 {
1773 return partitioner->get_mpi_communicator();
1774 }
1775
1776
1777
1778 template <typename Number, typename MemorySpace>
1779 inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
1781 {
1782 return partitioner;
1783 }
1784
1785
1786
1787 template <typename Number, typename MemorySpace>
1788 inline void
1789 Vector<Number, MemorySpace>::set_ghost_state(const bool ghosted) const
1790 {
1791 vector_is_ghosted = ghosted;
1792 }
1793
1794#endif
1795
1796 } // namespace distributed
1797} // namespace LinearAlgebra
1798
1799
1807template <typename Number, typename MemorySpace>
1808inline void
1811{
1812 u.swap(v);
1813}
1814
1815
1819template <typename Number, typename MemorySpace>
1820struct is_serial_vector<LinearAlgebra::distributed::Vector<Number, MemorySpace>>
1821 : std::false_type
1822{};
1823
1824
1825
1826namespace internal
1827{
1828 namespace LinearOperatorImplementation
1829 {
1830 template <typename>
1831 class ReinitHelper;
1832
1837 template <typename Number>
1838 class ReinitHelper<LinearAlgebra::distributed::Vector<Number>>
1839 {
1840 public:
1841 // A helper type-trait that leverage SFINAE to figure out if type T has
1842 // void T::get_mpi_communicator()
1843 template <typename T>
1845 decltype(std::declval<T>().get_mpi_communicator());
1846
1847 template <typename T>
1848 static constexpr bool has_get_mpi_communicator =
1849 is_supported_operation<get_mpi_communicator_t, T>;
1850
1851 // A helper type-trait that leverage SFINAE to figure out if type T has
1852 // void T::locally_owned_domain_indices()
1853 template <typename T>
1855 decltype(std::declval<T>().locally_owned_domain_indices());
1856
1857 template <typename T>
1858 static constexpr bool has_locally_owned_domain_indices =
1859 is_supported_operation<locally_owned_domain_indices_t, T>;
1860
1861 // A helper type-trait that leverage SFINAE to figure out if type T has
1862 // void T::locally_owned_range_indices()
1863 template <typename T>
1865 decltype(std::declval<T>().locally_owned_range_indices());
1866
1867 template <typename T>
1868 static constexpr bool has_locally_owned_range_indices =
1869 is_supported_operation<locally_owned_range_indices_t, T>;
1870
1871 // A helper type-trait that leverage SFINAE to figure out if type T has
1872 // void T::initialize_dof_vector(VectorType v)
1873 template <typename T>
1875 decltype(std::declval<T>().initialize_dof_vector(
1877
1878 template <typename T>
1879 static constexpr bool has_initialize_dof_vector =
1880 is_supported_operation<initialize_dof_vector_t, T>;
1881
1882 // Used for (Trilinos/PETSc)Wrappers::SparseMatrix
1883 template <typename MatrixType,
1884#if !defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1900
1885 std::enable_if_t<has_get_mpi_communicator<MatrixType> &&
1886 has_locally_owned_domain_indices<MatrixType>,
1887#else
1888 // workaround for Intel 18
1889 std::enable_if_t<
1890 is_supported_operation<get_mpi_communicator_t, MatrixType> &&
1892 MatrixType>,
1893#endif
1894 MatrixType> * = nullptr>
1895 static void
1896 reinit_domain_vector(MatrixType & mat,
1898 bool /*omit_zeroing_entries*/)
1899 {
1900 vec.reinit(mat.locally_owned_domain_indices(),
1901 mat.get_mpi_communicator());
1902 }
1903
1904 // Used for MatrixFree and DiagonalMatrix
1905 template <typename MatrixType,
1906#if !defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1900
1907 std::enable_if_t<has_initialize_dof_vector<MatrixType>,
1908#else
1909 // workaround for Intel 18
1910 std::enable_if_t<
1911 is_supported_operation<initialize_dof_vector_t, MatrixType>,
1912#endif
1913 MatrixType> * = nullptr>
1914 static void
1915 reinit_domain_vector(MatrixType & mat,
1917 bool omit_zeroing_entries)
1918 {
1919 mat.initialize_dof_vector(vec);
1920 if (!omit_zeroing_entries)
1921 vec = Number();
1922 }
1923
1924 // Used for (Trilinos/PETSc)Wrappers::SparseMatrix
1925 template <typename MatrixType,
1926#if !defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1900
1927 std::enable_if_t<has_get_mpi_communicator<MatrixType> &&
1928 has_locally_owned_range_indices<MatrixType>,
1929#else
1930 // workaround for Intel 18
1931 std::enable_if_t<
1932 is_supported_operation<get_mpi_communicator_t, MatrixType> &&
1933 is_supported_operation<locally_owned_range_indices_t,
1934 MatrixType>,
1935#endif
1936 MatrixType> * = nullptr>
1937 static void
1938 reinit_range_vector(MatrixType & mat,
1940 bool /*omit_zeroing_entries*/)
1941 {
1942 vec.reinit(mat.locally_owned_range_indices(),
1943 mat.get_mpi_communicator());
1944 }
1945
1946 // Used for MatrixFree and DiagonalMatrix
1947 template <typename MatrixType,
1948#if !defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1900
1949 std::enable_if_t<has_initialize_dof_vector<MatrixType>,
1950#else
1951 // workaround for Intel 18
1952 std::enable_if_t<
1953 is_supported_operation<initialize_dof_vector_t, MatrixType>,
1954#endif
1955 MatrixType> * = nullptr>
1956 static void
1957 reinit_range_vector(MatrixType & mat,
1959 bool omit_zeroing_entries)
1960 {
1961 mat.initialize_dof_vector(vec);
1962 if (!omit_zeroing_entries)
1963 vec = Number();
1964 }
1965 };
1966
1967 } // namespace LinearOperatorImplementation
1968} /* namespace internal */
1969
1970
1972
1973#endif
Number & operator()(const size_type global_index)
virtual real_type l1_norm() const override
bool partitioners_are_compatible(const Utilities::MPI::Partitioner &part) const
virtual Vector< Number, MemorySpace > & operator*=(const Number factor) override
Number local_element(const size_type local_index) const
void reinit(const IndexSet &local_range, const MPI_Comm communicator)
Number add_and_dot_local(const Number a, const Vector< Number, MemorySpace > &V, const Vector< Number, MemorySpace > &W)
void compress_finish(VectorOperation::values operation)
virtual void add(const Number a, const VectorSpaceVector< Number > &V, const Number b, const VectorSpaceVector< Number > &W) override
mutable ::MemorySpace::MemorySpaceData< Number, MemorySpace > import_data
void swap(Vector< Number, MemorySpace > &v)
virtual real_type linfty_norm() const override
mutable ::MemorySpace::MemorySpaceData< Number, MemorySpace > data
Vector< Number, MemorySpace > & operator=(Vector< Number, MemorySpace > &&in_vector)
typename numbers::NumberTraits< Number >::real_type real_type
const_iterator end() const
Vector(const IndexSet &local_range, const MPI_Comm communicator)
Vector(const size_type size)
Vector(Vector< Number, MemorySpace > &&in_vector)
size_type locally_owned_size() const
void reinit(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner, const MPI_Comm comm_sm=MPI_COMM_SELF)
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner
void add(const size_type n_elements, const size_type *indices, const OtherNumber *values)
virtual void equ(const Number a, const VectorSpaceVector< Number > &V) override
void sadd(const Number s, const Vector< Number, MemorySpace > &V)
Vector< Number, MemorySpace > & operator=(const Vector< Number, MemorySpace > &in_vector)
void reinit(const IndexSet &local_range, const IndexSet &ghost_indices, const MPI_Comm communicator)
virtual std::size_t memory_consumption() const override
Number operator[](const size_type global_index) const
virtual bool all_zero() const override
Vector(const Vector< Number, MemorySpace > &in_vector)
virtual Number mean_value() const override
void set_ghost_state(const bool ghosted) const
virtual Vector< Number, MemorySpace > & operator=(const Number s) override
Vector(const IndexSet &local_range, const IndexSet &ghost_indices, const MPI_Comm communicator)
void add(const std::vector< size_type > &indices, const ::Vector< OtherNumber > &values)
void import_elements(const Vector< Number, MemorySpace2 > &src, VectorOperation::values operation)
virtual void reinit(const VectorSpaceVector< Number > &V, const bool omit_zeroing_entries=false) override
Number & operator[](const size_type global_index)
virtual Number operator*(const VectorSpaceVector< Number > &V) const override
virtual void add(const std::vector< size_type > &indices, const std::vector< Number > &values)
void reinit(const Vector< Number2, MemorySpace > &in_vector, const bool omit_zeroing_entries=false)
real_type lp_norm(const real_type p) const
bool partitioners_are_globally_compatible(const Utilities::MPI::Partitioner &part) const
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_partitioner() const
virtual size_type size() const override
virtual Vector< Number, MemorySpace > & operator-=(const VectorSpaceVector< Number > &V) override
void add_local(const Number a, const VectorSpaceVector< Number > &V)
std::shared_ptr<::parallel::internal::TBBPartitioner > thread_loop_partitioner
virtual void sadd(const Number s, const Number a, const VectorSpaceVector< Number > &V) override
virtual void scale(const VectorSpaceVector< Number > &scaling_factors) override
virtual void print(std::ostream &out, const unsigned int precision=3, const bool scientific=true, const bool across=true) const override
const std::vector< ArrayView< const Number > > & shared_vector_data() const
void update_ghost_values_start(const unsigned int communication_channel=0) const
void copy_locally_owned_data_from(const Vector< Number2, MemorySpace > &src)
Vector< Number, MemorySpace > & operator=(const Vector< Number2, MemorySpace > &in_vector)
virtual void add(const Number a, const VectorSpaceVector< Number > &V) override
virtual void compress(VectorOperation::values operation) override
virtual Vector< Number, MemorySpace > & operator/=(const Number factor) override
virtual void add(const Number a) override
Number operator()(const size_type global_index) const
virtual Vector< Number, MemorySpace > & operator+=(const VectorSpaceVector< Number > &V) override
real_type lp_norm_local(const real_type p) const
void sadd_local(const Number s, const Number a, const VectorSpaceVector< Number > &V)
void reinit(const size_type size, const bool omit_zeroing_entries=false)
void extract_subvector_to(const std::vector< size_type > &indices, std::vector< OtherNumber > &values) const
void compress_start(const unsigned int communication_channel=0, VectorOperation::values operation=VectorOperation::add)
std::vector< MPI_Request > update_ghost_values_requests
const_iterator begin() const
std::vector< MPI_Request > compress_requests
bool in_local_range(const size_type global_index) const
void extract_subvector_to(ForwardIterator indices_begin, const ForwardIterator indices_end, OutputIterator values_begin) const
Number inner_product_local(const Vector< Number2, MemorySpace > &V) const
Number & local_element(const size_type local_index)
void reinit(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner, const bool make_ghosted, const MPI_Comm &comm_sm=MPI_COMM_SELF)
virtual Number add_and_dot(const Number a, const VectorSpaceVector< Number > &V, const VectorSpaceVector< Number > &W) override
void resize_val(const size_type new_allocated_size, const MPI_Comm comm_sm=MPI_COMM_SELF)
virtual real_type l2_norm() const override
virtual void import_elements(const LinearAlgebra::ReadWriteVector< Number > &V, VectorOperation::values operation, std::shared_ptr< const Utilities::MPI::CommunicationPatternBase > communication_pattern={}) override
void reinit(const types::global_dof_index local_size, const types::global_dof_index ghost_size, const MPI_Comm comm, const MPI_Comm comm_sm=MPI_COMM_SELF)
Vector(const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner)
virtual ::IndexSet locally_owned_elements() const override
void swap(LinearAlgebra::distributed::Vector< Number, MemorySpace > &u, LinearAlgebra::distributed::Vector< Number, MemorySpace > &v)
const value_type * const_iterator
Definition vector.h:132
value_type * iterator
Definition vector.h:131
decltype(std::declval< T >().initialize_dof_vector(std::declval< LinearAlgebra::distributed::Vector< Number > & >())) initialize_dof_vector_t
static void reinit_range_vector(MatrixType &mat, LinearAlgebra::distributed::Vector< Number > &vec, bool)
static void reinit_range_vector(MatrixType &mat, LinearAlgebra::distributed::Vector< Number > &vec, bool omit_zeroing_entries)
static void reinit_domain_vector(MatrixType &mat, LinearAlgebra::distributed::Vector< Number > &vec, bool omit_zeroing_entries)
static void reinit_domain_vector(MatrixType &mat, LinearAlgebra::distributed::Vector< Number > &vec, bool)
#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
Point< 2 > second
Definition grid_out.cc:4616
static ::ExceptionBase & ExcAccessToNonLocalElement(size_type arg1, size_type arg2, size_type arg3, size_type arg4)
#define DeclException0(Exception0)
Definition exceptions.h:465
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
Definition exceptions.h:579
static ::ExceptionBase & ExcVectorTypeNotCompatible()
static ::ExceptionBase & ExcNonMatchingElements(Number arg1, Number arg2, unsigned int arg3)
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition exceptions.h:556
static ::ExceptionBase & ExcMessage(std::string arg1)
constexpr bool is_supported_operation
bool is_finite(const double x)
Definition numbers.h:538
unsigned int global_dof_index
Definition types.h:82
const MPI_Comm comm