Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
constraint_matrix.h
1 // ---------------------------------------------------------------------
2 // @f$Id: constraint_matrix.h 31932 2013-12-08 02:15:54Z heister @f$
3 //
4 // Copyright (C) 1998 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 
18 #ifndef __deal2__constraint_matrix_h
19 #define __deal2__constraint_matrix_h
20 
21 #include <deal.II/base/config.h>
23 #include <deal.II/base/index_set.h>
24 #include <deal.II/base/subscriptor.h>
25 #include <deal.II/base/template_constraints.h>
26 #include <deal.II/base/thread_local_storage.h>
27 
28 #include <deal.II/lac/vector.h>
29 
30 #include <vector>
31 #include <map>
32 #include <set>
33 #include <utility>
34 #include <complex>
35 
36 #include <boost/scoped_ptr.hpp>
37 
38 
40 
41 template<int dim, class T> class Table;
42 template <typename> class FullMatrix;
43 class SparsityPattern;
51 template <typename number> class SparseMatrix;
52 template <typename number> class BlockSparseMatrix;
53 class BlockIndices;
54 template <typename MatrixType> struct IsBlockMatrix;
55 
56 namespace internals
57 {
58  class GlobalRowsFromLocal;
59 }
60 
61 
62 //TODO[WB]: We should have a function of the kind
63 // ConstraintMatrix::add_constraint (const size_type constrained_dof,
64 // const std::vector<std::pair<size_type, double> > &entries,
65 // const double inhomogeneity = 0);
66 // rather than building up constraints piecemeal through add_line/add_entry
67 // etc. This would also eliminate the possibility of accidentally changing
68 // existing constraints into something pointless, see the discussion on the
69 // mailing list on "Tiny bug in interpolate_boundary_values" in Sept. 2010.
70 
146 {
147 public:
152 
159  {
165 
172 
179  };
180 
189  ConstraintMatrix (const IndexSet &local_constraints = IndexSet());
190 
194  ConstraintMatrix (const ConstraintMatrix &constraint_matrix);
195 
202  void reinit (const IndexSet &local_constraints = IndexSet());
203 
210  bool can_store_line (const size_type line_index) const;
211 
218  const IndexSet &get_local_lines() const;
219 
239  void add_selected_constraints (const ConstraintMatrix &constraints_in,
240  const IndexSet &filter);
241 
251  void add_line (const size_type line);
252 
266  void add_lines (const std::vector<bool> &lines);
267 
281  void add_lines (const std::set<size_type> &lines);
282 
296  void add_lines (const IndexSet &lines);
297 
309  void add_entry (const size_type line,
310  const size_type column,
311  const double value);
312 
318  void add_entries (const size_type line,
319  const std::vector<std::pair<size_type,double> > &col_val_pairs);
320 
327  void set_inhomogeneity (const size_type line,
328  const double value);
329 
350  void close ();
351 
368  void merge (const ConstraintMatrix &other_constraints,
369  const MergeConflictBehavior merge_conflict_behavior = no_conflicts_allowed);
370 
382  void shift (const size_type offset);
383 
391  void clear ();
392 
406  size_type n_constraints () const;
407 
417  bool is_constrained (const size_type index) const;
418 
430  bool is_identity_constrained (const size_type index) const;
431 
438  bool are_identity_constrained (const size_type index1,
439  const size_type index2) const;
440 
451  size_type max_constraint_indirections () const;
452 
457  bool is_inhomogeneously_constrained (const size_type index) const;
458 
464  bool has_inhomogeneities () const;
465 
470  const std::vector<std::pair<size_type,double> > *
471  get_constraint_entries (const size_type line) const;
472 
477  double get_inhomogeneity (const size_type line) const;
478 
487  void print (std::ostream &) const;
488 
501  void write_dot (std::ostream &) const;
502 
507  std::size_t memory_consumption () const;
508 
515  void resolve_indices(std::vector<types::global_dof_index> &indices) const;
516 
538  void condense (const SparsityPattern &uncondensed,
539  SparsityPattern &condensed) const;
540 
541 
552  void condense (SparsityPattern &sparsity) const;
553 
557  void condense (BlockSparsityPattern &sparsity) const;
558 
573  void condense (CompressedSparsityPattern &sparsity) const;
574 
579  void condense (CompressedSetSparsityPattern &sparsity) const;
580 
585  void condense (CompressedSimpleSparsityPattern &sparsity) const;
586 
600  void condense (BlockCompressedSparsityPattern &sparsity) const;
601 
606  void condense (BlockCompressedSetSparsityPattern &sparsity) const;
607 
612  void condense (BlockCompressedSimpleSparsityPattern &sparsity) const;
613 
614 
626  template<typename number>
627  void condense (const SparseMatrix<number> &uncondensed,
628  SparseMatrix<number> &condensed) const DEAL_II_DEPRECATED;
629 
635  template<typename number>
636  void condense (SparseMatrix<number> &matrix) const;
637 
641  template <typename number>
642  void condense (BlockSparseMatrix<number> &matrix) const;
643 
660  template <class VectorType>
661  void condense (const VectorType &uncondensed,
662  VectorType &condensed) const DEAL_II_DEPRECATED;
663 
673  template <class VectorType>
674  void condense (VectorType &vec) const;
675 
689  template<typename number, class VectorType>
690  void condense (const SparseMatrix<number> &uncondensed_matrix,
691  const VectorType &uncondensed_vector,
692  SparseMatrix<number> &condensed_matrix,
693  VectorType &condensed_vector) const DEAL_II_DEPRECATED;
694 
700  template<typename number, class VectorType>
701  void condense (SparseMatrix<number> &matrix,
702  VectorType &vector) const;
703 
708  template <typename number, class BlockVectorType>
709  void condense (BlockSparseMatrix<number> &matrix,
710  BlockVectorType &vector) const;
711 
718  template <class VectorType>
719  void set_zero (VectorType &vec) const;
720 
766  template <class InVector, class OutVector>
767  void
768  distribute_local_to_global (const InVector &local_vector,
769  const std::vector<size_type> &local_dof_indices,
770  OutVector &global_vector) const;
771 
815  template <typename VectorType>
816  void
817  distribute_local_to_global (const Vector<double> &local_vector,
818  const std::vector<size_type> &local_dof_indices,
819  VectorType &global_vector,
820  const FullMatrix<double> &local_matrix) const;
821 
825  template <class VectorType>
826  void
827  distribute_local_to_global (const size_type index,
828  const double value,
829  VectorType &global_vector) const;
830 
859  template <typename ForwardIteratorVec, typename ForwardIteratorInd,
860  class VectorType>
861  void
862  distribute_local_to_global (ForwardIteratorVec local_vector_begin,
863  ForwardIteratorVec local_vector_end,
864  ForwardIteratorInd local_indices_begin,
865  VectorType &global_vector) const;
866 
908  template <typename MatrixType>
909  void
910  distribute_local_to_global (const FullMatrix<double> &local_matrix,
911  const std::vector<size_type> &local_dof_indices,
912  MatrixType &global_matrix) const;
913 
917  template <typename MatrixType>
918  void
919  distribute_local_to_global (const FullMatrix<double> &local_matrix,
920  const std::vector<size_type> &row_indices,
921  const std::vector<size_type> &col_indices,
922  MatrixType &global_matrix) const;
923 
939  template <typename MatrixType, typename VectorType>
940  void
941  distribute_local_to_global (const FullMatrix<double> &local_matrix,
942  const Vector<double> &local_vector,
943  const std::vector<size_type> &local_dof_indices,
944  MatrixType &global_matrix,
945  VectorType &global_vector,
946  bool use_inhomogeneities_for_rhs = false) const;
947 
1000  template <typename SparsityType>
1001  void
1002  add_entries_local_to_global (const std::vector<size_type> &local_dof_indices,
1003  SparsityType &sparsity_pattern,
1004  const bool keep_constrained_entries = true,
1005  const Table<2,bool> &dof_mask = default_empty_table) const;
1006 
1010  template <typename SparsityType>
1011  void
1012  add_entries_local_to_global (const std::vector<size_type> &row_indices,
1013  const std::vector<size_type> &col_indices,
1014  SparsityType &sparsity_pattern,
1015  const bool keep_constrained_entries = true,
1016  const Table<2,bool> &dof_mask = default_empty_table) const;
1017 
1037  template <typename ForwardIteratorVec, typename ForwardIteratorInd,
1038  class VectorType>
1039  void
1040  get_dof_values (const VectorType &global_vector,
1041  ForwardIteratorInd local_indices_begin,
1042  ForwardIteratorVec local_vector_begin,
1043  ForwardIteratorVec local_vector_end) const;
1044 
1066  template <class VectorType>
1067  void distribute (const VectorType &condensed,
1068  VectorType &uncondensed) const;
1069 
1079  template <class VectorType>
1080  void distribute (VectorType &vec) const;
1081 
1091  DeclException0 (ExcMatrixIsClosed);
1097  DeclException0 (ExcMatrixNotClosed);
1103  DeclException1 (ExcLineInexistant,
1104  size_type,
1105  << "The specified line " << arg1
1106  << " does not exist.");
1112  DeclException4 (ExcEntryAlreadyExists,
1113  size_type, size_type, double, double,
1114  << "The entry for the indices " << arg1 << " and "
1115  << arg2 << " already exists, but the values "
1116  << arg3 << " (old) and " << arg4 << " (new) differ "
1117  << "by " << (arg4-arg3) << ".");
1123  DeclException2 (ExcDoFConstrainedToConstrainedDoF,
1124  int, int,
1125  << "You tried to constrain DoF " << arg1
1126  << " to DoF " << arg2
1127  << ", but that one is also constrained. This is not allowed!");
1133  DeclException1 (ExcDoFIsConstrainedFromBothObjects,
1134  size_type,
1135  << "Degree of freedom " << arg1
1136  << " is constrained from both object in a merge operation.");
1142  DeclException1 (ExcDoFIsConstrainedToConstrainedDoF,
1143  size_type,
1144  << "In the given argument a degree of freedom is constrained "
1145  << "to another DoF with number " << arg1
1146  << ", which however is constrained by this object. This is not"
1147  << " allowed.");
1153  DeclException1 (ExcRowNotStoredHere,
1154  size_type,
1155  << "The index set given to this constraint matrix indicates "
1156  << "constraints for degree of freedom " << arg1
1157  << " should not be stored by this object, but a constraint "
1158  << "is being added.");
1159 
1165  DeclException2 (ExcIncorrectConstraint,
1166  int, int,
1167  << "While distributing the constraint for DoF "
1168  << arg1 << ", it turns out that one of the processors "
1169  << "who own the " << arg2
1170  << " degrees of freedom that x_" << arg1
1171  << " is constrained against does not know about "
1172  << "the constraint on x_" << arg1
1173  << ". Did you not initialize the ConstraintMatrix "
1174  << "with the appropriate locally_relevant set so "
1175  << "that every processor who owns a DoF that constrains "
1176  << "another DoF also knows about this constraint?");
1177 
1178 private:
1179 
1184  {
1189  typedef std::vector<std::pair<size_type,double> > Entries;
1190 
1195  size_type line;
1196 
1204  Entries entries;
1205 
1210 
1218  bool operator < (const ConstraintLine &) const;
1219 
1225  bool operator == (const ConstraintLine &) const;
1226 
1231  std::size_t memory_consumption () const;
1232  };
1233 
1245  std::vector<ConstraintLine> lines;
1246 
1279  std::vector<size_type> lines_cache;
1280 
1287 
1291  bool sorted;
1292 
1297  size_type calculate_line_index (const size_type line) const;
1298 
1303  static bool check_zero_weight (const std::pair<size_type, double> &p);
1304 
1310 
1315  template <typename MatrixType, typename VectorType>
1316  void
1317  distribute_local_to_global (const FullMatrix<double> &local_matrix,
1318  const Vector<double> &local_vector,
1319  const std::vector<size_type> &local_dof_indices,
1320  MatrixType &global_matrix,
1321  VectorType &global_vector,
1322  bool use_inhomogeneities_for_rhs,
1324 
1329  template <typename MatrixType, typename VectorType>
1330  void
1331  distribute_local_to_global (const FullMatrix<double> &local_matrix,
1332  const Vector<double> &local_vector,
1333  const std::vector<size_type> &local_dof_indices,
1334  MatrixType &global_matrix,
1335  VectorType &global_vector,
1336  bool use_inhomogeneities_for_rhs,
1338 
1343  template <typename SparsityType>
1344  void
1345  add_entries_local_to_global (const std::vector<size_type> &local_dof_indices,
1346  SparsityType &sparsity_pattern,
1347  const bool keep_constrained_entries,
1348  const Table<2,bool> &dof_mask,
1350 
1355  template <typename SparsityType>
1356  void
1357  add_entries_local_to_global (const std::vector<size_type> &local_dof_indices,
1358  SparsityType &sparsity_pattern,
1359  const bool keep_constrained_entries,
1360  const Table<2,bool> &dof_mask,
1362 
1370  void
1371  make_sorted_row_list (const std::vector<size_type> &local_dof_indices,
1372  internals::GlobalRowsFromLocal &global_rows) const;
1373 
1381  void
1382  make_sorted_row_list (const std::vector<size_type> &local_dof_indices,
1383  std::vector<size_type> &active_dofs) const;
1384 
1388  double
1389  resolve_vector_entry (const size_type i,
1390  const internals::GlobalRowsFromLocal &global_rows,
1391  const Vector<double> &local_vector,
1392  const std::vector<size_type> &local_dof_indices,
1393  const FullMatrix<double> &local_matrix) const;
1394 };
1395 
1396 
1397 
1398 /* ---------------- template and inline functions ----------------- */
1399 
1400 inline
1402  :
1403  lines (),
1404  local_lines (local_constraints),
1405  sorted (false)
1406 {
1407  // make sure the IndexSet is compressed. Otherwise this can lead to crashes
1408  // that are hard to find (only happen in release mode).
1409  // see tests/mpi/constraint_matrix_crash_01
1411 }
1412 
1413 
1414 
1415 inline
1417  :
1418  Subscriptor (),
1419  lines (constraint_matrix.lines),
1420  lines_cache (constraint_matrix.lines_cache),
1421  local_lines (constraint_matrix.local_lines),
1422  sorted (constraint_matrix.sorted)
1423 {}
1424 
1425 
1426 inline
1427 void
1428 ConstraintMatrix::add_line (const size_type line)
1429 {
1430  Assert (sorted==false, ExcMatrixIsClosed());
1431 
1432  // the following can happen when we compute with distributed meshes and dof
1433  // handlers and we constrain a degree of freedom whose number we don't have
1434  // locally. if we don't abort here the program will try to allocate several
1435  // terabytes of memory to resize the various arrays below :-)
1437  ExcInternalError());
1438  const size_type line_index = calculate_line_index (line);
1439 
1440  // check whether line already exists; it may, in which case we can just quit
1441  if (is_constrained(line))
1442  return;
1443 
1444  // if necessary enlarge vector of existing entries for cache
1445  if (line_index >= lines_cache.size())
1446  lines_cache.resize (std::max(2*static_cast<size_type>(lines_cache.size()),
1447  line_index+1),
1449 
1450  // push a new line to the end of the list
1451  lines.push_back (ConstraintLine());
1452  lines.back().line = line;
1453  lines.back().inhomogeneity = 0.;
1454  lines_cache[line_index] = lines.size()-1;
1455 }
1456 
1457 
1458 
1459 inline
1460 void
1461 ConstraintMatrix::add_entry (const size_type line,
1462  const size_type column,
1463  const double value)
1464 {
1465  Assert (sorted==false, ExcMatrixIsClosed());
1466  Assert (line != column,
1467  ExcMessage ("Can't constrain a degree of freedom to itself"));
1468 
1469  // if in debug mode, check whether an entry for this column already exists
1470  // and if it's the same as the one entered at present
1471  //
1472  // in any case: exit the function if an entry for this column already
1473  // exists, since we don't want to enter it twice
1475  ExcInternalError());
1477  Assert (line_ptr->line == line, ExcInternalError());
1478  for (ConstraintLine::Entries::const_iterator
1479  p=line_ptr->entries.begin();
1480  p != line_ptr->entries.end(); ++p)
1481  if (p->first == column)
1482  {
1483  Assert (std::fabs(p->second - value) < 1.e-14,
1484  ExcEntryAlreadyExists(line, column, p->second, value));
1485  return;
1486  }
1487 
1488  line_ptr->entries.push_back (std::make_pair(column,value));
1489 }
1490 
1491 
1492 
1493 inline
1494 void
1496  const double value)
1497 {
1498  const size_type line_index = calculate_line_index(line);
1499  Assert( line_index < lines_cache.size() &&
1500  lines_cache[line_index] != numbers::invalid_size_type,
1501  ExcMessage("call add_line() before calling set_inhomogeneity()"));
1502  Assert(lines_cache[line_index] < lines.size(), ExcInternalError());
1503  ConstraintLine *line_ptr = &lines[lines_cache[line_index]];
1504  line_ptr->inhomogeneity = value;
1505 }
1506 
1507 
1508 
1509 inline
1512 {
1513  return lines.size();
1514 }
1515 
1516 
1517 
1518 inline
1519 bool
1520 ConstraintMatrix::is_constrained (const size_type index) const
1521 {
1522  const size_type line_index = calculate_line_index(index);
1523  return ((line_index < lines_cache.size())
1524  &&
1525  (lines_cache[line_index] != numbers::invalid_size_type));
1526 }
1527 
1528 
1529 
1530 inline
1531 bool
1533 {
1534  // check whether the entry is constrained. could use is_constrained, but
1535  // that means computing the line index twice
1536  const size_type line_index = calculate_line_index(index);
1537  if (line_index >= lines_cache.size() ||
1538  lines_cache[line_index] == numbers::invalid_size_type)
1539  return false;
1540  else
1541  {
1542  Assert(lines_cache[line_index] < lines.size(), ExcInternalError());
1543  return !(lines[lines_cache[line_index]].inhomogeneity == 0);
1544  }
1545 }
1546 
1547 
1548 
1549 inline
1550 const std::vector<std::pair<types::global_dof_index,double> > *
1551 ConstraintMatrix::get_constraint_entries (const size_type line) const
1552 {
1553  // check whether the entry is constrained. could use is_constrained, but
1554  // that means computing the line index twice
1555  const size_type line_index = calculate_line_index(line);
1556  if (line_index >= lines_cache.size() ||
1557  lines_cache[line_index] == numbers::invalid_size_type)
1558  return 0;
1559  else
1560  return &lines[lines_cache[line_index]].entries;
1561 }
1562 
1563 
1564 
1565 inline
1566 double
1567 ConstraintMatrix::get_inhomogeneity (const size_type line) const
1568 {
1569  // check whether the entry is constrained. could use is_constrained, but
1570  // that means computing the line index twice
1571  const size_type line_index = calculate_line_index(line);
1572  if (line_index >= lines_cache.size() ||
1573  lines_cache[line_index] == numbers::invalid_size_type)
1574  return 0;
1575  else
1576  return lines[lines_cache[line_index]].inhomogeneity;
1577 }
1578 
1579 
1580 
1582 ConstraintMatrix::calculate_line_index (const size_type line) const
1583 {
1584  //IndexSet is unused (serial case)
1585  if (!local_lines.size())
1586  return line;
1587 
1589  ExcRowNotStoredHere(line));
1590 
1591  return local_lines.index_within_set(line);
1592 }
1593 
1594 
1595 
1596 inline bool
1597 ConstraintMatrix::can_store_line (size_type line_index) const
1598 {
1599  return !local_lines.size() || local_lines.is_element(line_index);
1600 }
1601 
1602 
1603 
1604 inline
1605 const IndexSet &
1607 {
1608  return local_lines;
1609 }
1610 
1611 
1612 
1613 template <class VectorType>
1614 inline
1616  const size_type index,
1617  const double value,
1618  VectorType &global_vector) const
1619 {
1620  Assert (lines.empty() || sorted == true, ExcMatrixNotClosed());
1621 
1622  if (is_constrained(index) == false)
1623  global_vector(index) += value;
1624  else
1625  {
1626  const ConstraintLine &position =
1628  for (size_type j=0; j<position.entries.size(); ++j)
1629  global_vector(position.entries[j].first)
1630  += value * position.entries[j].second;
1631  }
1632 }
1633 
1634 
1635 template <typename ForwardIteratorVec, typename ForwardIteratorInd,
1636  class VectorType>
1637 inline
1639  ForwardIteratorVec local_vector_begin,
1640  ForwardIteratorVec local_vector_end,
1641  ForwardIteratorInd local_indices_begin,
1642  VectorType &global_vector) const
1643 {
1644  Assert (lines.empty() || sorted == true, ExcMatrixNotClosed());
1645  for ( ; local_vector_begin != local_vector_end;
1646  ++local_vector_begin, ++local_indices_begin)
1647  {
1648  if (is_constrained(*local_indices_begin) == false)
1649  global_vector(*local_indices_begin) += *local_vector_begin;
1650  else
1651  {
1652  const ConstraintLine &position =
1653  lines[lines_cache[calculate_line_index(*local_indices_begin)]];
1654  for (size_type j=0; j<position.entries.size(); ++j)
1655  global_vector(position.entries[j].first)
1656  += *local_vector_begin * position.entries[j].second;
1657  }
1658  }
1659 }
1660 
1661 
1662 template <class InVector, class OutVector>
1663 inline
1664 void
1666  const InVector &local_vector,
1667  const std::vector<size_type> &local_dof_indices,
1668  OutVector &global_vector) const
1669 {
1670  Assert (local_vector.size() == local_dof_indices.size(),
1671  ExcDimensionMismatch(local_vector.size(), local_dof_indices.size()));
1672  distribute_local_to_global (local_vector.begin(), local_vector.end(),
1673  local_dof_indices.begin(), global_vector);
1674 }
1675 
1676 
1677 
1678 template <typename ForwardIteratorVec, typename ForwardIteratorInd,
1679  class VectorType>
1680 inline
1681 void ConstraintMatrix::get_dof_values (const VectorType &global_vector,
1682  ForwardIteratorInd local_indices_begin,
1683  ForwardIteratorVec local_vector_begin,
1684  ForwardIteratorVec local_vector_end) const
1685 {
1686  Assert (lines.empty() || sorted == true, ExcMatrixNotClosed());
1687  for ( ; local_vector_begin != local_vector_end;
1688  ++local_vector_begin, ++local_indices_begin)
1689  {
1690  if (is_constrained(*local_indices_begin) == false)
1691  *local_vector_begin = global_vector(*local_indices_begin);
1692  else
1693  {
1694  const ConstraintLine &position =
1695  lines[lines_cache[calculate_line_index(*local_indices_begin)]];
1696  typename VectorType::value_type value = position.inhomogeneity;
1697  for (size_type j=0; j<position.entries.size(); ++j)
1698  value += (global_vector(position.entries[j].first) *
1699  position.entries[j].second);
1700  *local_vector_begin = value;
1701  }
1702  }
1703 }
1704 
1705 
1706 
1707 template <typename MatrixType>
1708 inline
1709 void
1712  const std::vector<size_type> &local_dof_indices,
1713  MatrixType &global_matrix) const
1714 {
1715  // create a dummy and hand on to the function actually implementing this
1716  // feature in the cm.templates.h file.
1717  Vector<double> dummy(0);
1718  distribute_local_to_global (local_matrix, dummy, local_dof_indices,
1719  global_matrix, dummy, false,
1721 }
1722 
1723 
1724 
1725 template <typename MatrixType, typename VectorType>
1726 inline
1727 void
1730  const Vector<double> &local_vector,
1731  const std::vector<size_type> &local_dof_indices,
1732  MatrixType &global_matrix,
1733  VectorType &global_vector,
1734  bool use_inhomogeneities_for_rhs) const
1735 {
1736  // enter the internal function with the respective block information set,
1737  // the actual implementation follows in the cm.templates.h file.
1738  distribute_local_to_global (local_matrix, local_vector, local_dof_indices,
1739  global_matrix, global_vector, use_inhomogeneities_for_rhs,
1741 }
1742 
1743 
1744 
1745 template <typename SparsityType>
1746 inline
1747 void
1749 add_entries_local_to_global (const std::vector<size_type> &local_dof_indices,
1750  SparsityType &sparsity_pattern,
1751  const bool keep_constrained_entries,
1752  const Table<2,bool> &dof_mask) const
1753 {
1754  // enter the internal function with the respective block information set,
1755  // the actual implementation follows in the cm.templates.h file.
1756  add_entries_local_to_global (local_dof_indices, sparsity_pattern,
1757  keep_constrained_entries, dof_mask,
1759 }
1760 
1761 
1762 DEAL_II_NAMESPACE_CLOSE
1763 
1764 #endif
const types::global_dof_index invalid_size_type
Definition: types.h:211
double get_inhomogeneity(const size_type line) const
types::global_dof_index index_within_set(const types::global_dof_index global_index) const
Definition: index_set.h:970
std::vector< size_type > lines_cache
bool can_store_line(const size_type line_index) const
bool is_constrained(const size_type index) const
types::global_dof_index size() const
Definition: index_set.h:685
const std::vector< std::pair< size_type, double > > * get_constraint_entries(const size_type line) const
::ExceptionBase & ExcMessage(std::string arg1)
Auxiliary class aiding in the handling of block structures like in BlockVector or FESystem...
Definition: block_indices.h:55
void add_entries(const size_type line, const std::vector< std::pair< size_type, double > > &col_val_pairs)
const IndexSet & get_local_lines() const
size_type max_constraint_indirections() const
bool has_inhomogeneities() const
static const Table< 2, bool > default_empty_table
types::global_dof_index size_type
DeclException1(ExcLineInexistant, size_type,<< "The specified line "<< arg1<< " does not exist.")
std::vector< std::pair< size_type, double > > Entries
bool are_identity_constrained(const size_type index1, const size_type index2) const
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
DeclException0(ExcMatrixIsClosed)
void add_entry(const size_type line, const size_type column, const double value)
unsigned int global_dof_index
Definition: types.h:100
#define Assert(cond, exc)
Definition: exceptions.h:299
void condense(const SparsityPattern &uncondensed, SparsityPattern &condensed) const
ConstraintMatrix(const IndexSet &local_constraints=IndexSet())
bool operator<(const ConstraintLine &) const
bool is_inhomogeneously_constrained(const size_type index) const
bool operator==(const ConstraintLine &) const
void add_entries_local_to_global(const std::vector< size_type > &local_dof_indices, SparsityType &sparsity_pattern, const bool keep_constrained_entries=true, const Table< 2, bool > &dof_mask=default_empty_table) const
BlockCompressedSparsityPattern CompressedBlockSparsityPattern DEAL_II_DEPRECATED
void compress() const
Definition: index_set.h:694
size_type calculate_line_index(const size_type line) const
DeclException4(ExcEntryAlreadyExists, size_type, size_type, double, double,<< "The entry for the indices "<< arg1<< " and "<< arg2<< " already exists, but the values "<< arg3<< " (old) and "<< arg4<< " (new) differ "<< "by "<< (arg4-arg3)<< ".")
void add_lines(const std::vector< bool > &lines)
static bool check_zero_weight(const std::pair< size_type, double > &p)
void print(std::ostream &) const
std::size_t memory_consumption() const
void merge(const ConstraintMatrix &other_constraints, const MergeConflictBehavior merge_conflict_behavior=no_conflicts_allowed)
std::size_t memory_consumption() const
DeclException2(ExcDoFConstrainedToConstrainedDoF, int, int,<< "You tried to constrain DoF "<< arg1<< " to DoF "<< arg2<< ", but that one is also constrained. This is not allowed!")
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
void distribute(const VectorType &condensed, VectorType &uncondensed) const
::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
void reinit(const IndexSet &local_constraints=IndexSet())
Definition: table.h:33
void add_selected_constraints(const ConstraintMatrix &constraints_in, const IndexSet &filter)
void set_inhomogeneity(const size_type line, const double value)
std::vector< ConstraintLine > lines
::ExceptionBase & ExcInternalError()
void make_sorted_row_list(const std::vector< size_type > &local_dof_indices, internals::GlobalRowsFromLocal &global_rows) const
bool is_element(const types::global_dof_index index) const
Definition: index_set.h:811
double resolve_vector_entry(const size_type i, const internals::GlobalRowsFromLocal &global_rows, const Vector< double > &local_vector, const std::vector< size_type > &local_dof_indices, const FullMatrix< double > &local_matrix) const
void get_dof_values(const VectorType &global_vector, ForwardIteratorInd local_indices_begin, ForwardIteratorVec local_vector_begin, ForwardIteratorVec local_vector_end) const
bool is_identity_constrained(const size_type index) const