From: Wolfgang Bangerth Date: Sat, 17 Aug 2013 01:14:52 +0000 (+0000) Subject: Provide ConstraintMatrix::are_identity_constrained() X-Git-Tag: v8.1.0~1048 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14d612601da96dec5d9bb8133846c12dfb6d326d;p=dealii.git Provide ConstraintMatrix::are_identity_constrained() git-svn-id: https://svn.dealii.org/trunk@30326 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index d247f75c4b..93d16b5ed8 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -56,6 +56,20 @@ inconvenience this causes.

Specific improvements

    +
  1. + Fixed: Under some circumstances (see http://code.google.com/p/dealii/issues/detail?id=82) + the DoFTools::make_periodicity_constraints() function could create cycles in + the ConstraintMatrix object. This is now fixed. +
    + (David Emerson, Wolfgang Bangerth, 2013/08/16) +
  2. + +
  3. + New: There is now a function ConstraintMatrix::are_identity_constrained(). +
    + (Wolfgang Bangerth, 2013/08/16) +
  4. +
  5. New: TableHandler::write_text() now also supports output in org-mode (http://orgmode.org/) format via a new entry in the diff --git a/deal.II/include/deal.II/lac/constraint_matrix.h b/deal.II/include/deal.II/lac/constraint_matrix.h index 8237b943d9..6c623eef0e 100644 --- a/deal.II/include/deal.II/lac/constraint_matrix.h +++ b/deal.II/include/deal.II/lac/constraint_matrix.h @@ -548,6 +548,15 @@ public: */ bool is_identity_constrained (const size_type index) const; + /** + * Return whether the two given degrees of freedom are linked by an + * equality constraint that either constrains index1 to be so that + * index1=index2 or constrains index2 so that + * index2=index1. + */ + bool are_identity_constrained (const size_type index1, + const size_type index2) const; + /** * Return the maximum number of other * dofs that one dof is constrained diff --git a/deal.II/source/lac/constraint_matrix.cc b/deal.II/source/lac/constraint_matrix.cc index 099e3703d6..79f46bad9c 100644 --- a/deal.II/source/lac/constraint_matrix.cc +++ b/deal.II/source/lac/constraint_matrix.cc @@ -1542,6 +1542,36 @@ bool ConstraintMatrix::is_identity_constrained (const size_type index) const } +bool ConstraintMatrix::are_identity_constrained (const size_type index1, + const size_type index2) const +{ + if (is_constrained(index1) == true) + { + const ConstraintLine &p = lines[lines_cache[calculate_line_index(index1)]]; + Assert (p.line == index1, ExcInternalError()); + + // return if an entry for this line was found and if it has only one + // entry equal to 1.0 and that one is index2 + return ((p.entries.size() == 1) && + (p.entries[0].first == index2) && + (p.entries[0].second == 1.0)); + } + else if (is_constrained(index2) == true) + { + const ConstraintLine &p = lines[lines_cache[calculate_line_index(index2)]]; + Assert (p.line == index2, ExcInternalError()); + + // return if an entry for this line was found and if it has only one + // entry equal to 1.0 and that one is index1 + return ((p.entries.size() == 1) && + (p.entries[0].first == index1) && + (p.entries[0].second == 1.0)); + } + else + return false; +} + + ConstraintMatrix::size_type ConstraintMatrix::max_constraint_indirections () const