From 7ffe7676a0cea1db2a3b791815d96405cc4dcf88 Mon Sep 17 00:00:00 2001 From: bangerth Date: Fri, 15 Aug 2008 15:53:03 +0000 Subject: [PATCH] Fix a problem in the ConstraintMatrix. git-svn-id: https://svn.dealii.org/trunk@16562 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/source/dofs/dof_constraints.cc | 110 ++++++++++++------ deal.II/doc/news/changes.h | 10 ++ 2 files changed, 85 insertions(+), 35 deletions(-) diff --git a/deal.II/deal.II/source/dofs/dof_constraints.cc b/deal.II/deal.II/source/dofs/dof_constraints.cc index 95376bcb6b..c0b7e1a09a 100644 --- a/deal.II/deal.II/source/dofs/dof_constraints.cc +++ b/deal.II/deal.II/source/dofs/dof_constraints.cc @@ -207,19 +207,9 @@ void ConstraintMatrix::close () // constrained: chained_constraint_replaced = true; - // replace - // it by its - // expansion; we do - // that by - // overwriting the - // entry by the first - // entry of the - // expansion and - // adding the - // remaining ones to - // the end, where we - // will later process - // them once more + // look up the chain + // of constraints for + // this entry const unsigned int dof_index = line->entries[entry].first; const double weight = line->entries[entry].second; @@ -239,28 +229,73 @@ void ConstraintMatrix::close () constrained_line = std::lower_bound (lines.begin(), lines.end(), test_line); - Assert (constrained_line->entries.size() > 0, - ExcInternalError()); - - for (unsigned int i=0; ientries.size(); ++i) - Assert (dof_index != constrained_line->entries[i].first, - ExcMessage ("Cycle in constraints detected!")); - - // replace first - // entry, then tack - // the rest to the - // end of the list - line->entries[entry] = - std::make_pair (constrained_line->entries[0].first, - constrained_line->entries[0].second * - weight); - - for (unsigned int i=1; ientries.size(); ++i) - line->entries - .push_back (std::make_pair (constrained_line->entries[i].first, - constrained_line->entries[i].second * - weight)); + // now we have to + // replace an entry + // by its + // expansion. we do + // that by + // overwriting the + // entry by the first + // entry of the + // expansion and + // adding the + // remaining ones to + // the end, where we + // will later process + // them once more + // + // we can of course + // only do that if + // the DoF that we + // are currently + // handle is + // constrained by a + // linear combination + // of other dofs: + if (constrained_line->entries.size() > 0) + { + for (unsigned int i=0; ientries.size(); ++i) + Assert (dof_index != constrained_line->entries[i].first, + ExcMessage ("Cycle in constraints detected!")); + + // replace first + // entry, then tack + // the rest to the + // end of the list + line->entries[entry] = + std::make_pair (constrained_line->entries[0].first, + constrained_line->entries[0].second * + weight); + + for (unsigned int i=1; ientries.size(); ++i) + line->entries + .push_back (std::make_pair (constrained_line->entries[i].first, + constrained_line->entries[i].second * + weight)); + } + else + // the DoF that we + // encountered is + // not constrained + // by a linear + // combination of + // other dofs but + // is equal to zero + // (i.e. its chain + // of entries is + // empty). in that + // case, we can't + // just overwrite + // the current + // entry, but we + // have to actually + // eliminate it + { + line->entries.erase (line->entries.begin()+entry); + } + + // now that we're // here, do not // increase index by @@ -270,7 +305,12 @@ void ConstraintMatrix::close () // entry because we // have replaced the // present entry by - // another one + // another one, or + // because we have + // deleted it and + // shifted all + // following ones one + // forward } else // entry not further diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index e120d72050..2524636708 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -234,6 +234,16 @@ inconvenience this causes.

deal.II

    +
  1. +

    + Fixed: Using the ConstraintMatrix class, when a degree of freedom was + constrained against another DoF, and that other DoF was constrained to + be equal to zero (i.e. the trivial linear combination of a third set of + degrees of freedom), an exception resulted. This is now fixed. +
    + (WB 2008/08/15) +

    +
  2. New: It is now possible to get the inverse of the Jacobian -- 2.39.5