Reference documentation for deal.II version Git 05e4468 2017-09-21 10:18:23 +0200
constraint_matrix.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2017 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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii_constraint_matrix_h
18 #define dealii_constraint_matrix_h
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/exceptions.h>
22 #include <deal.II/base/index_set.h>
23 #include <deal.II/base/subscriptor.h>
24 #include <deal.II/base/template_constraints.h>
25 
26 #include <deal.II/lac/vector.h>
27 #include <deal.II/lac/vector_element_access.h>
28 
29 #include <boost/range/iterator_range.hpp>
30 
31 #include <vector>
32 #include <set>
33 #include <utility>
34 
35 
36 DEAL_II_NAMESPACE_OPEN
37 
38 template <int dim, class T> class Table;
39 template <typename> class FullMatrix;
40 class SparsityPattern;
44 template <typename number> class SparseMatrix;
45 template <typename number> class BlockSparseMatrix;
46 
47 namespace internals
48 {
49  class GlobalRowsFromLocal;
50 }
51 
52 
53 //TODO[WB]: We should have a function of the kind
54 // ConstraintMatrix::add_constraint (const size_type constrained_dof,
55 // const std::vector<std::pair<size_type, double> > &entries,
56 // const double inhomogeneity = 0);
57 // rather than building up constraints piecemeal through add_line/add_entry
58 // etc. This would also eliminate the possibility of accidentally changing
59 // existing constraints into something pointless, see the discussion on the
60 // mailing list on "Tiny bug in interpolate_boundary_values" in Sept. 2010.
61 
138 {
139 public:
144 
151  {
157 
164 
171  };
172 
190  explicit ConstraintMatrix (const IndexSet &local_constraints = IndexSet());
191 
195  explicit ConstraintMatrix (const ConstraintMatrix &constraint_matrix);
196 
200  ConstraintMatrix (ConstraintMatrix &&constraint_matrix) = default;
201 
211  ConstraintMatrix &operator= (const ConstraintMatrix &) = delete;
212 
216  ConstraintMatrix &operator= (ConstraintMatrix &&constraint_matrix) = default;
217 
224  void copy_from (const ConstraintMatrix &other);
225 
232  void reinit (const IndexSet &local_constraints = IndexSet());
233 
240  bool can_store_line (const size_type line_index) const;
241 
248  const IndexSet &get_local_lines() const;
249 
269  void add_selected_constraints (const ConstraintMatrix &constraints_in,
270  const IndexSet &filter);
271 
281  void add_line (const size_type line);
282 
295  void add_lines (const std::vector<bool> &lines);
296 
309  void add_lines (const std::set<size_type> &lines);
310 
323  void add_lines (const IndexSet &lines);
324 
336  void add_entry (const size_type line,
337  const size_type column,
338  const double value);
339 
345  void add_entries (const size_type line,
346  const std::vector<std::pair<size_type,double> > &col_val_pairs);
347 
354  void set_inhomogeneity (const size_type line,
355  const double value);
356 
377  void close ();
378 
403  void merge (const ConstraintMatrix &other_constraints,
404  const MergeConflictBehavior merge_conflict_behavior = no_conflicts_allowed,
405  const bool allow_different_local_lines = false);
406 
419  void shift (const size_type offset);
420 
428  void clear ();
429 
443  size_type n_constraints () const;
444 
454  bool is_constrained (const size_type index) const;
455 
467  bool is_identity_constrained (const size_type index) const;
468 
475  bool are_identity_constrained (const size_type index1,
476  const size_type index2) const;
477 
488  size_type max_constraint_indirections () const;
489 
494  bool is_inhomogeneously_constrained (const size_type index) const;
495 
501  bool has_inhomogeneities () const;
502 
507  const std::vector<std::pair<size_type,double> > *
508  get_constraint_entries (const size_type line) const;
509 
514  double get_inhomogeneity (const size_type line) const;
515 
536  void print (std::ostream &out) const;
537 
550  void write_dot (std::ostream &) const;
551 
556  std::size_t memory_consumption () const;
557 
564  void resolve_indices(std::vector<types::global_dof_index> &indices) const;
565 
593  void condense (SparsityPattern &sparsity) const;
594 
598  void condense (BlockSparsityPattern &sparsity) const;
599 
604  void condense (DynamicSparsityPattern &sparsity) const;
605 
610  void condense (BlockDynamicSparsityPattern &sparsity) const;
611 
619  template <typename number>
620  void condense (SparseMatrix<number> &matrix) const;
621 
625  template <typename number>
626  void condense (BlockSparseMatrix<number> &matrix) const;
627 
639  template <class VectorType>
640  void condense (VectorType &vec) const;
641 
648  template <class VectorType>
649  void condense (const VectorType &vec_ghosted,
650  VectorType &output) const;
651 
664  template <typename number, class VectorType>
665  void condense (SparseMatrix<number> &matrix,
666  VectorType &vector) const;
667 
672  template <typename number, class BlockVectorType>
673  void condense (BlockSparseMatrix<number> &matrix,
674  BlockVectorType &vector) const;
675 
682  template <class VectorType>
683  void set_zero (VectorType &vec) const;
684 
736  template <class InVector, class OutVector>
737  void
738  distribute_local_to_global (const InVector &local_vector,
739  const std::vector<size_type> &local_dof_indices,
740  OutVector &global_vector) const;
741 
785  template <typename VectorType, typename LocalType>
786  void
787  distribute_local_to_global (const Vector<LocalType> &local_vector,
788  const std::vector<size_type> &local_dof_indices,
789  VectorType &global_vector,
790  const FullMatrix<LocalType> &local_matrix) const;
791 
809  template <typename VectorType, typename LocalType>
810  void
811  distribute_local_to_global (const Vector<LocalType> &local_vector,
812  const std::vector<size_type> &local_dof_indices_row,
813  const std::vector<size_type> &local_dof_indices_col,
814  VectorType &global_vector,
815  const FullMatrix<LocalType> &local_matrix,
816  bool diagonal = false) const;
817 
821  template <class VectorType>
822  void
823  distribute_local_to_global (const size_type index,
824  const double value,
825  VectorType &global_vector) const;
826 
855  template <typename ForwardIteratorVec, typename ForwardIteratorInd,
856  class VectorType>
857  void
858  distribute_local_to_global (ForwardIteratorVec local_vector_begin,
859  ForwardIteratorVec local_vector_end,
860  ForwardIteratorInd local_indices_begin,
861  VectorType &global_vector) const;
862 
910  template <typename MatrixType>
911  void
913  const std::vector<size_type> &local_dof_indices,
914  MatrixType &global_matrix) const;
915 
943  template <typename MatrixType>
944  void
946  const std::vector<size_type> &row_indices,
947  const std::vector<size_type> &col_indices,
948  MatrixType &global_matrix) const;
949 
966  template <typename MatrixType>
967  void
969  const std::vector<size_type> &row_indices,
970  const ConstraintMatrix &column_constraint_matrix,
971  const std::vector<size_type> &column_indices,
972  MatrixType &global_matrix) const;
973 
990  template <typename MatrixType, typename VectorType>
991  void
993  const Vector<typename VectorType::value_type> &local_vector,
994  const std::vector<size_type> &local_dof_indices,
995  MatrixType &global_matrix,
996  VectorType &global_vector,
997  bool use_inhomogeneities_for_rhs = false) const;
998 
1052  template <typename SparsityPatternType>
1053  void
1054  add_entries_local_to_global (const std::vector<size_type> &local_dof_indices,
1055  SparsityPatternType &sparsity_pattern,
1056  const bool keep_constrained_entries = true,
1057  const Table<2,bool> &dof_mask = default_empty_table) const;
1058 
1062  template <typename SparsityPatternType>
1063  void
1064  add_entries_local_to_global (const std::vector<size_type> &row_indices,
1065  const std::vector<size_type> &col_indices,
1066  SparsityPatternType &sparsity_pattern,
1067  const bool keep_constrained_entries = true,
1068  const Table<2,bool> &dof_mask = default_empty_table) const;
1069 
1089  template <typename ForwardIteratorVec, typename ForwardIteratorInd,
1090  class VectorType>
1091  void
1092  get_dof_values (const VectorType &global_vector,
1093  ForwardIteratorInd local_indices_begin,
1094  ForwardIteratorVec local_vector_begin,
1095  ForwardIteratorVec local_vector_end) const;
1096 
1118  template <class VectorType>
1119  void distribute (VectorType &vec) const;
1120 
1131  {
1136  typedef std::vector<std::pair<size_type,double> > Entries;
1137 
1143  size_type index;
1144 
1152  Entries entries;
1153 
1158 
1166  bool operator < (const ConstraintLine &) const;
1167 
1173  bool operator == (const ConstraintLine &) const;
1174 
1179  std::size_t memory_consumption () const;
1180  };
1181 
1182 
1186  typedef std::vector<ConstraintLine>::const_iterator const_iterator;
1187 
1188 
1192  typedef boost::iterator_range<const_iterator> LineRange;
1193 
1194 
1203  const LineRange get_lines() const;
1204 
1205 
1224  size_type,
1225  << "The specified line " << arg1
1226  << " does not exist.");
1233  size_type, size_type, double, double,
1234  << "The entry for the indices " << arg1 << " and "
1235  << arg2 << " already exists, but the values "
1236  << arg3 << " (old) and " << arg4 << " (new) differ "
1237  << "by " << (arg4-arg3) << ".");
1244  int, int,
1245  << "You tried to constrain DoF " << arg1
1246  << " to DoF " << arg2
1247  << ", but that one is also constrained. This is not allowed!");
1254  size_type,
1255  << "Degree of freedom " << arg1
1256  << " is constrained from both object in a merge operation.");
1263  size_type,
1264  << "In the given argument a degree of freedom is constrained "
1265  << "to another DoF with number " << arg1
1266  << ", which however is constrained by this object. This is not"
1267  << " allowed.");
1274  size_type,
1275  << "The index set given to this constraint matrix indicates "
1276  << "constraints for degree of freedom " << arg1
1277  << " should not be stored by this object, but a constraint "
1278  << "is being added.");
1279 
1286  size_type,
1287  size_type,
1288  << "The index set given to this constraint matrix indicates "
1289  << "constraints using degree of freedom " << arg2
1290  << " should not be stored by this object, but a constraint "
1291  << "for degree of freedom " << arg1 <<" uses it.");
1292 
1299  int, int,
1300  << "While distributing the constraint for DoF "
1301  << arg1 << ", it turns out that one of the processors "
1302  << "who own the " << arg2
1303  << " degrees of freedom that x_" << arg1
1304  << " is constrained against does not know about "
1305  << "the constraint on x_" << arg1
1306  << ". Did you not initialize the ConstraintMatrix "
1307  << "with the appropriate locally_relevant set so "
1308  << "that every processor who owns a DoF that constrains "
1309  << "another DoF also knows about this constraint?");
1310 
1311 private:
1312 
1324  std::vector<ConstraintLine> lines;
1325 
1358  std::vector<size_type> lines_cache;
1359 
1366 
1370  bool sorted;
1371 
1376  size_type calculate_line_index (const size_type line) const;
1377 
1382  static bool check_zero_weight (const std::pair<size_type, double> &p);
1383 
1389 
1394  template <typename MatrixType, typename VectorType>
1395  void
1397  const Vector<typename VectorType::value_type> &local_vector,
1398  const std::vector<size_type> &local_dof_indices,
1399  MatrixType &global_matrix,
1400  VectorType &global_vector,
1401  bool use_inhomogeneities_for_rhs,
1402  std::integral_constant<bool, false>) const;
1403 
1408  template <typename MatrixType, typename VectorType>
1409  void
1411  const Vector<typename VectorType::value_type> &local_vector,
1412  const std::vector<size_type> &local_dof_indices,
1413  MatrixType &global_matrix,
1414  VectorType &global_vector,
1415  bool use_inhomogeneities_for_rhs,
1416  std::integral_constant<bool, true>) const;
1417 
1422  template <typename SparsityPatternType>
1423  void
1424  add_entries_local_to_global (const std::vector<size_type> &local_dof_indices,
1425  SparsityPatternType &sparsity_pattern,
1426  const bool keep_constrained_entries,
1427  const Table<2,bool> &dof_mask,
1428  std::integral_constant<bool, false>) const;
1429 
1434  template <typename SparsityPatternType>
1435  void
1436  add_entries_local_to_global (const std::vector<size_type> &local_dof_indices,
1437  SparsityPatternType &sparsity_pattern,
1438  const bool keep_constrained_entries,
1439  const Table<2,bool> &dof_mask,
1440  std::integral_constant<bool, true>) const;
1441 
1449  void
1450  make_sorted_row_list (const std::vector<size_type> &local_dof_indices,
1451  internals::GlobalRowsFromLocal &global_rows) const;
1452 
1460  void
1461  make_sorted_row_list (const std::vector<size_type> &local_dof_indices,
1462  std::vector<size_type> &active_dofs) const;
1463 
1467  template <typename LocalType>
1468  LocalType
1469  resolve_vector_entry (const size_type i,
1470  const internals::GlobalRowsFromLocal &global_rows,
1471  const Vector<LocalType> &local_vector,
1472  const std::vector<size_type> &local_dof_indices,
1473  const FullMatrix<LocalType> &local_matrix) const;
1474 };
1475 
1476 
1477 
1478 /* ---------------- template and inline functions ----------------- */
1479 
1480 inline
1482  :
1483  lines (),
1484  local_lines (local_constraints),
1485  sorted (false)
1486 {
1487  // make sure the IndexSet is compressed. Otherwise this can lead to crashes
1488  // that are hard to find (only happen in release mode).
1489  // see tests/mpi/constraint_matrix_crash_01
1491 }
1492 
1493 
1494 
1495 inline
1497  :
1498  Subscriptor (),
1499  lines (constraint_matrix.lines),
1500  lines_cache (constraint_matrix.lines_cache),
1501  local_lines (constraint_matrix.local_lines),
1502  sorted (constraint_matrix.sorted)
1503 {}
1504 
1505 
1506 inline
1507 void
1508 ConstraintMatrix::add_line (const size_type line)
1509 {
1510  Assert (sorted==false, ExcMatrixIsClosed());
1511 
1512  // the following can happen when we compute with distributed meshes and dof
1513  // handlers and we constrain a degree of freedom whose number we don't have
1514  // locally. if we don't abort here the program will try to allocate several
1515  // terabytes of memory to resize the various arrays below :-)
1517  ExcInternalError());
1518  const size_type line_index = calculate_line_index (line);
1519 
1520  // check whether line already exists; it may, in which case we can just quit
1521  if (is_constrained(line))
1522  return;
1523 
1524  // if necessary enlarge vector of existing entries for cache
1525  if (line_index >= lines_cache.size())
1526  lines_cache.resize (std::max(2*static_cast<size_type>(lines_cache.size()),
1527  line_index+1),
1529 
1530  // push a new line to the end of the list
1531  lines.emplace_back ();
1532  lines.back().index = line;
1533  lines.back().inhomogeneity = 0.;
1534  lines_cache[line_index] = lines.size()-1;
1535 }
1536 
1537 
1538 
1539 inline
1540 void
1541 ConstraintMatrix::add_entry (const size_type line,
1542  const size_type column,
1543  const double value)
1544 {
1545  Assert (sorted==false, ExcMatrixIsClosed());
1546  Assert (line != column,
1547  ExcMessage ("Can't constrain a degree of freedom to itself"));
1548 
1549  // Ensure that the current line is present in the cache:
1550  const size_type line_index = calculate_line_index(line);
1551  Assert (line_index < lines_cache.size(),
1552  ExcMessage("The current ConstraintMatrix does not contain the line "
1553  "for the current entry. Call ConstraintMatrix::add_line "
1554  "before calling this function."));
1555 
1556  // if in debug mode, check whether an entry for this column already exists
1557  // and if it's the same as the one entered at present
1558  //
1559  // in any case: exit the function if an entry for this column already
1560  // exists, since we don't want to enter it twice
1562  ExcInternalError());
1563  Assert (!local_lines.size() || local_lines.is_element(column),
1564  ExcColumnNotStoredHere(line, column));
1565  ConstraintLine *line_ptr = &lines[lines_cache[line_index]];
1566  Assert (line_ptr->index == line, ExcInternalError());
1567  for (ConstraintLine::Entries::const_iterator
1568  p=line_ptr->entries.begin();
1569  p != line_ptr->entries.end(); ++p)
1570  if (p->first == column)
1571  {
1572  Assert (std::fabs(p->second - value) < 1.e-14,
1573  ExcEntryAlreadyExists(line, column, p->second, value));
1574  return;
1575  }
1576 
1577  line_ptr->entries.emplace_back (column, value);
1578 }
1579 
1580 
1581 
1582 inline
1583 void
1585  const double value)
1586 {
1587  const size_type line_index = calculate_line_index(line);
1588  Assert( line_index < lines_cache.size() &&
1589  lines_cache[line_index] != numbers::invalid_size_type,
1590  ExcMessage("call add_line() before calling set_inhomogeneity()"));
1591  Assert(lines_cache[line_index] < lines.size(), ExcInternalError());
1592  ConstraintLine *line_ptr = &lines[lines_cache[line_index]];
1593  line_ptr->inhomogeneity = value;
1594 }
1595 
1596 
1597 
1598 inline
1601 {
1602  return lines.size();
1603 }
1604 
1605 
1606 
1607 inline
1608 bool
1609 ConstraintMatrix::is_constrained (const size_type index) const
1610 {
1611  const size_type line_index = calculate_line_index(index);
1612  return ((line_index < lines_cache.size())
1613  &&
1614  (lines_cache[line_index] != numbers::invalid_size_type));
1615 }
1616 
1617 
1618 
1619 inline
1620 bool
1622 {
1623  // check whether the entry is constrained. could use is_constrained, but
1624  // that means computing the line index twice
1625  const size_type line_index = calculate_line_index(index);
1626  if (line_index >= lines_cache.size() ||
1627  lines_cache[line_index] == numbers::invalid_size_type)
1628  return false;
1629  else
1630  {
1631  Assert(lines_cache[line_index] < lines.size(), ExcInternalError());
1632  return !(lines[lines_cache[line_index]].inhomogeneity == 0);
1633  }
1634 }
1635 
1636 
1637 
1638 inline
1639 const std::vector<std::pair<types::global_dof_index,double> > *
1640 ConstraintMatrix::get_constraint_entries (const size_type line) const
1641 {
1642  // check whether the entry is constrained. could use is_constrained, but
1643  // that means computing the line index twice
1644  const size_type line_index = calculate_line_index(line);
1645  if (line_index >= lines_cache.size() ||
1646  lines_cache[line_index] == numbers::invalid_size_type)
1647  return nullptr;
1648  else
1649  return &lines[lines_cache[line_index]].entries;
1650 }
1651 
1652 
1653 
1654 inline
1655 double
1656 ConstraintMatrix::get_inhomogeneity (const size_type line) const
1657 {
1658  // check whether the entry is constrained. could use is_constrained, but
1659  // that means computing the line index twice
1660  const size_type line_index = calculate_line_index(line);
1661  if (line_index >= lines_cache.size() ||
1662  lines_cache[line_index] == numbers::invalid_size_type)
1663  return 0;
1664  else
1665  return lines[lines_cache[line_index]].inhomogeneity;
1666 }
1667 
1668 
1669 
1671 ConstraintMatrix::calculate_line_index (const size_type line) const
1672 {
1673  //IndexSet is unused (serial case)
1674  if (!local_lines.size())
1675  return line;
1676 
1678  ExcRowNotStoredHere(line));
1679 
1680  return local_lines.index_within_set(line);
1681 }
1682 
1683 
1684 
1685 inline bool
1686 ConstraintMatrix::can_store_line (size_type line_index) const
1687 {
1688  return !local_lines.size() || local_lines.is_element(line_index);
1689 }
1690 
1691 
1692 
1693 inline
1694 const IndexSet &
1696 {
1697  return local_lines;
1698 }
1699 
1700 
1701 
1702 template <class VectorType>
1703 inline
1705  const size_type index,
1706  const double value,
1707  VectorType &global_vector) const
1708 {
1709  Assert (lines.empty() || sorted == true, ExcMatrixNotClosed());
1710 
1711  if (is_constrained(index) == false)
1712  global_vector(index) += value;
1713  else
1714  {
1715  const ConstraintLine &position =
1717  for (size_type j=0; j<position.entries.size(); ++j)
1718  global_vector(position.entries[j].first)
1719  += value * position.entries[j].second;
1720  }
1721 }
1722 
1723 
1724 template <typename ForwardIteratorVec, typename ForwardIteratorInd,
1725  class VectorType>
1726 inline
1728  ForwardIteratorVec local_vector_begin,
1729  ForwardIteratorVec local_vector_end,
1730  ForwardIteratorInd local_indices_begin,
1731  VectorType &global_vector) const
1732 {
1733  Assert (lines.empty() || sorted == true, ExcMatrixNotClosed());
1734  for ( ; local_vector_begin != local_vector_end;
1735  ++local_vector_begin, ++local_indices_begin)
1736  {
1737  if (is_constrained(*local_indices_begin) == false)
1738  internal::ElementAccess<VectorType>::add(*local_vector_begin,
1739  *local_indices_begin, global_vector);
1740  else
1741  {
1742  const ConstraintLine &position =
1743  lines[lines_cache[calculate_line_index(*local_indices_begin)]];
1744  for (size_type j=0; j<position.entries.size(); ++j)
1745  internal::ElementAccess<VectorType>::add(*local_vector_begin *
1746  position.entries[j].second, position.entries[j].first,
1747  global_vector);
1748  }
1749  }
1750 }
1751 
1752 
1753 template <class InVector, class OutVector>
1754 inline
1755 void
1757  const InVector &local_vector,
1758  const std::vector<size_type> &local_dof_indices,
1759  OutVector &global_vector) const
1760 {
1761  Assert (local_vector.size() == local_dof_indices.size(),
1762  ExcDimensionMismatch(local_vector.size(), local_dof_indices.size()));
1763  distribute_local_to_global (local_vector.begin(), local_vector.end(),
1764  local_dof_indices.begin(), global_vector);
1765 }
1766 
1767 
1768 
1769 template <typename ForwardIteratorVec, typename ForwardIteratorInd,
1770  class VectorType>
1771 inline
1772 void ConstraintMatrix::get_dof_values (const VectorType &global_vector,
1773  ForwardIteratorInd local_indices_begin,
1774  ForwardIteratorVec local_vector_begin,
1775  ForwardIteratorVec local_vector_end) const
1776 {
1777  Assert (lines.empty() || sorted == true, ExcMatrixNotClosed());
1778  for ( ; local_vector_begin != local_vector_end;
1779  ++local_vector_begin, ++local_indices_begin)
1780  {
1781  if (is_constrained(*local_indices_begin) == false)
1782  *local_vector_begin = global_vector(*local_indices_begin);
1783  else
1784  {
1785  const ConstraintLine &position =
1786  lines[lines_cache[calculate_line_index(*local_indices_begin)]];
1787  typename VectorType::value_type value = position.inhomogeneity;
1788  for (size_type j=0; j<position.entries.size(); ++j)
1789  value += (global_vector(position.entries[j].first) *
1790  position.entries[j].second);
1791  *local_vector_begin = value;
1792  }
1793  }
1794 }
1795 
1796 
1797 template <typename MatrixType> class BlockMatrixBase;
1798 template <typename SparsityPatternType> class BlockSparsityPatternBase;
1799 template <typename number> class BlockSparseMatrixEZ;
1800 
1819 template <typename MatrixType>
1821 {
1822 private:
1823  struct yes_type
1824  {
1825  char c[1];
1826  };
1827  struct no_type
1828  {
1829  char c[2];
1830  };
1831 
1837  template <typename T>
1838  static yes_type check_for_block_matrix (const BlockMatrixBase<T> *);
1839 
1844  template <typename T>
1845  static yes_type check_for_block_matrix (const BlockSparsityPatternBase<T> *);
1846 
1851  template <typename T>
1852  static yes_type check_for_block_matrix (const BlockSparseMatrixEZ<T> *);
1853 
1858  static no_type check_for_block_matrix (...);
1859 
1860 public:
1866  static const bool value = (sizeof(check_for_block_matrix
1867  ((MatrixType *)nullptr))
1868  ==
1869  sizeof(yes_type));
1870 };
1871 
1872 
1873 // instantiation of the static member
1874 template <typename MatrixType>
1876 
1877 
1878 template <typename MatrixType>
1879 inline
1880 void
1883  const std::vector<size_type> &local_dof_indices,
1884  MatrixType &global_matrix) const
1885 {
1886  // create a dummy and hand on to the function actually implementing this
1887  // feature in the cm.templates.h file.
1889  distribute_local_to_global (local_matrix, dummy, local_dof_indices,
1890  global_matrix, dummy, false,
1891  std::integral_constant<bool, IsBlockMatrix<MatrixType>::value>());
1892 }
1893 
1894 
1895 
1896 
1897 template <typename MatrixType, typename VectorType>
1898 inline
1899 void
1902  const Vector<typename VectorType::value_type> &local_vector,
1903  const std::vector<size_type> &local_dof_indices,
1904  MatrixType &global_matrix,
1905  VectorType &global_vector,
1906  bool use_inhomogeneities_for_rhs) const
1907 {
1908  // enter the internal function with the respective block information set,
1909  // the actual implementation follows in the cm.templates.h file.
1910  distribute_local_to_global (local_matrix, local_vector, local_dof_indices,
1911  global_matrix, global_vector, use_inhomogeneities_for_rhs,
1912  std::integral_constant<bool, IsBlockMatrix<MatrixType>::value>());
1913 }
1914 
1915 
1916 
1917 
1918 template <typename SparsityPatternType>
1919 inline
1920 void
1922 add_entries_local_to_global (const std::vector<size_type> &local_dof_indices,
1923  SparsityPatternType &sparsity_pattern,
1924  const bool keep_constrained_entries,
1925  const Table<2,bool> &dof_mask) const
1926 {
1927  // enter the internal function with the respective block information set,
1928  // the actual implementation follows in the cm.templates.h file.
1929  add_entries_local_to_global (local_dof_indices, sparsity_pattern,
1930  keep_constrained_entries, dof_mask,
1931  std::integral_constant<bool, IsBlockMatrix<SparsityPatternType>::value>());
1932 }
1933 
1934 
1935 DEAL_II_NAMESPACE_CLOSE
1936 
1937 #endif
const types::global_dof_index invalid_size_type
Definition: types.h:182
double get_inhomogeneity(const size_type line) const
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:605
std::vector< size_type > lines_cache
static::ExceptionBase & ExcDoFIsConstrainedFromBothObjects(size_type arg1)
static::ExceptionBase & ExcEntryAlreadyExists(size_type arg1, size_type arg2, double arg3, double arg4)
std::vector< ConstraintLine >::const_iterator const_iterator
void merge(const ConstraintMatrix &other_constraints, const MergeConflictBehavior merge_conflict_behavior=no_conflicts_allowed, const bool allow_different_local_lines=false)
bool can_store_line(const size_type line_index) const
bool is_constrained(const size_type index) const
static bool check_zero_weight(const std::pair< size_type, double > &p)
void condense(SparsityPattern &sparsity) const
boost::iterator_range< const_iterator > LineRange
const std::vector< std::pair< size_type, double > > * get_constraint_entries(const size_type line) const
LocalType resolve_vector_entry(const size_type i, const internals::GlobalRowsFromLocal &global_rows, const Vector< LocalType > &local_vector, const std::vector< size_type > &local_dof_indices, const FullMatrix< LocalType > &local_matrix) const
void add_entries(const size_type line, const std::vector< std::pair< size_type, double > > &col_val_pairs)
const IndexSet & get_local_lines() const
void distribute(VectorType &vec) const
bool has_inhomogeneities() const
static::ExceptionBase & ExcDoFIsConstrainedToConstrainedDoF(size_type arg1)
static const bool value
void print(std::ostream &out) const
types::global_dof_index size_type
size_type size() const
Definition: index_set.h:1553
static yes_type check_for_block_matrix(const BlockMatrixBase< T > *)
std::vector< std::pair< size_type, double > > Entries
size_type max_constraint_indirections() const
bool are_identity_constrained(const size_type index1, const size_type index2) const
static::ExceptionBase & ExcLineInexistant(size_type arg1)
Definition: mpi.h:57
void add_line(const size_type line)
void write_dot(std::ostream &) const
void distribute_local_to_global(const InVector &local_vector, const std::vector< size_type > &local_dof_indices, OutVector &global_vector) const
static::ExceptionBase & ExcMessage(std::string arg1)
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:593
void add_entry(const size_type line, const size_type column, const double value)
unsigned int global_dof_index
Definition: types.h:88
ConstraintMatrix & operator=(const ConstraintMatrix &)=delete
#define Assert(cond, exc)
Definition: exceptions.h:337
static::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
static::ExceptionBase & ExcColumnNotStoredHere(size_type arg1, size_type arg2)
ConstraintMatrix(const IndexSet &local_constraints=IndexSet())
bool operator<(const ConstraintLine &) const
bool is_inhomogeneously_constrained(const size_type index) const
#define DeclException0(Exception0)
Definition: exceptions.h:570
bool operator==(const ConstraintLine &) const
static const Table< 2, bool > default_empty_table
void compress() const
Definition: index_set.h:1562
size_type calculate_line_index(const size_type line) const
void add_lines(const std::vector< bool > &lines)
static::ExceptionBase & ExcIncorrectConstraint(int arg1, int arg2)
static::ExceptionBase & ExcMatrixNotClosed()
static::ExceptionBase & ExcDoFConstrainedToConstrainedDoF(int arg1, int arg2)
std::size_t memory_consumption() const
std::size_t memory_consumption() const
void copy_from(const ConstraintMatrix &other)
void shift(const size_type offset)
void set_zero(VectorType &vec) const
void resolve_indices(std::vector< types::global_dof_index > &indices) const
size_type n_constraints() const
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
Definition: exceptions.h:629
const LineRange get_lines() const
size_type index_within_set(const size_type global_index) const
Definition: index_set.h:1789
static::ExceptionBase & ExcRowNotStoredHere(size_type arg1)
bool is_element(const size_type index) const
Definition: index_set.h:1623
Definition: table.h:33
void reinit(const IndexSet &local_constraints=IndexSet())
void add_selected_constraints(const ConstraintMatrix &constraints_in, const IndexSet &filter)
void set_inhomogeneity(const size_type line, const double value)
void add_entries_local_to_global(const std::vector< size_type > &local_dof_indices, SparsityPatternType &sparsity_pattern, const bool keep_constrained_entries=true, const Table< 2, bool > &dof_mask=default_empty_table) const
std::vector< ConstraintLine > lines
void make_sorted_row_list(const std::vector< size_type > &local_dof_indices, internals::GlobalRowsFromLocal &global_rows) const
void get_dof_values(const VectorType &global_vector, ForwardIteratorInd local_indices_begin, ForwardIteratorVec local_vector_begin, ForwardIteratorVec local_vector_end) const
static::ExceptionBase & ExcMatrixIsClosed()
static::ExceptionBase & ExcInternalError()
bool is_identity_constrained(const size_type index) const