]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix a problem in the ConstraintMatrix.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 15 Aug 2008 15:53:03 +0000 (15:53 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 15 Aug 2008 15:53:03 +0000 (15:53 +0000)
git-svn-id: https://svn.dealii.org/trunk@16562 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/dofs/dof_constraints.cc
deal.II/doc/news/changes.h

index 95376bcb6b295df21038456e7f9fc9b5a2feb170..c0b7e1a09afc13c5102b5419f3db3afae413c0c0 100644 (file)
@@ -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; i<constrained_line->entries.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; i<constrained_line->entries.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; i<constrained_line->entries.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; i<constrained_line->entries.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
index e120d7205045b641762447f92e4057ff7d06164d..2524636708e5296405c25231db38ad0af0f5694f 100644 (file)
@@ -234,6 +234,16 @@ inconvenience this causes.
 <h3>deal.II</h3>
 
 <ol>
+  <li>
+  <p>
+  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.
+  <br>
+  (WB 2008/08/15)
+  </p>
+
   <li>
   <p>
   New: It is now possible to get the inverse of the Jacobian

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.