]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
additional sanity checks in ConstraintMatrix in debug mode.
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Aug 2011 18:30:31 +0000 (18:30 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Aug 2011 18:30:31 +0000 (18:30 +0000)
git-svn-id: https://svn.dealii.org/trunk@24181 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/constraint_matrix.h

index 14140084e7025f0351ae166622a9f4d74c7701c1..3de3362880360581df62aed2d5c9582f3b7ddb8b 100644 (file)
@@ -365,6 +365,8 @@ class ConstraintMatrix : public Subscriptor
                                      * constraint line <i>i</i>, according
                                      * to the discussion in the general
                                      * class description.
+                                     * Note: the line needs to be added with
+                                     * one of the add_line() calls first.
                                      */
     void set_inhomogeneity (const unsigned int line,
                            const double       value);
@@ -1857,7 +1859,12 @@ void
 ConstraintMatrix::set_inhomogeneity (const unsigned int line,
                                     const double       value)
 {
-  ConstraintLine* line_ptr = &lines[lines_cache[calculate_line_index(line)]];
+  const unsigned int line_index = calculate_line_index(line);
+  Assert( line_index < lines_cache.size() &&
+      lines_cache[line_index] != numbers::invalid_unsigned_int, 
+      ExcMessage("call add_line() before calling set_inhomogeneity()"));
+  Assert(lines_cache[line_index] < lines.size(), ExcInternalError());
+  ConstraintLine* line_ptr = &lines[lines_cache[line_index]];
   line_ptr->inhomogeneity = value;
 }
 

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.