]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a safety check whether constrained nodes are constrained to other
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 28 Feb 2000 16:29:39 +0000 (16:29 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 28 Feb 2000 16:29:39 +0000 (16:29 +0000)
constraints, which is not allowed.

git-svn-id: https://svn.dealii.org/trunk@2502 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/dofs/dof_constraints.h
deal.II/deal.II/source/dofs/dof_constraints.cc

index 98ecb50dd12a0e9b2d6a91f481fd7f85a9f3ee89..cae4cac49f3ed5f1d798f2f3e13fb29213544597 100644 (file)
@@ -332,6 +332,14 @@ class ConstraintMatrix : public Subscriptor
                    << "The entry for the indices " << arg1 << " and "
                    << arg2 << " already exists, but the values "
                    << arg3 << " (old) and " << arg4 << " (new) differ.");
+                                    /**
+                                     * Exception
+                                     */
+    DeclException2 (ExcDoFConstrainedToConstrainedDoF,
+                   int, int,
+                   << "You tried to constrain DoF " << arg1
+                   << " to DoF " << arg2
+                   << ", but that one is also constrained. This is not allowed!");
     
   private:
 
@@ -339,7 +347,8 @@ class ConstraintMatrix : public Subscriptor
                                      * This class represents one line of a
                                      * constraint matrix.
                                      */
-    struct ConstraintLine {
+    struct ConstraintLine
+    {
                                         /**
                                          * Number of this line. Since only very
                                          * few lines are stored, we can not
index 2b9e6178f89a612051fb5bc02413be9fda1d49c4..0c259e981174b9e9c10852c0eeee7d00021a9cd0 100644 (file)
@@ -98,7 +98,14 @@ void ConstraintMatrix::close () {
                                   endl = lines.end();
   for (; line!=endl; ++line)
     {
-                                      // first remove zero entries
+                                      // first remove zero
+                                      // entries. that would mean
+                                      // that in the linear
+                                      // constraint for a node,
+                                      // x_i = ax_1 + bx_2 + ...,
+                                      // another node times 0
+                                      // appears. obviously,
+                                      // 0*something can be omitted
       line->entries.erase (remove_if (line->entries.begin(),
                                      line->entries.end(),
                                      compose1 (bind2nd (equal_to<double>(), 0),
@@ -111,6 +118,31 @@ void ConstraintMatrix::close () {
   
                                   // sort the lines
   sort (lines.begin(), lines.end());
+
+#ifdef DEBUG
+                                  // if in debug mode: check that no
+                                  // dof is constraint to another dof
+                                  // that is also constrained
+  for (vector<ConstraintLine>::const_iterator line=lines.begin();
+       line!=lines.end(); ++line)
+    for (vector<pair<unsigned int,double> >::const_iterator entry=line->entries.begin();
+        entry!=line->entries.end(); ++entry)
+      {
+                                        // make sure that
+                                        // entry->first is not the
+                                        // index of a line itself
+       const ConstraintLine test_line = { entry->first,
+                                          vector<pair<unsigned int,double> >() };
+       const vector<ConstraintLine>::const_iterator
+         test_line_position = lower_bound (lines.begin(),
+                                           lines.end(),
+                                           test_line);
+       Assert ((test_line_position == lines.end())
+               ||
+               (test_line_position->line != entry->first),
+               ExcDoFConstrainedToConstrainedDoF(line->line, entry->first));
+      };
+#endif
   
   sorted = true;
 };

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.