]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Take over Timo's patches 23221-23224 from mainline. Branch-7-0
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 20 Jan 2011 13:50:09 +0000 (13:50 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 20 Jan 2011 13:50:09 +0000 (13:50 +0000)
git-svn-id: https://svn.dealii.org/branches/releases/Branch-7-0@23225 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/constraint_matrix.h
tests/lac/constraints_01.cc [new file with mode: 0644]
tests/lac/constraints_01/cmp/generic [new file with mode: 0644]
tests/lac/constraints_01/is.23 [new file with mode: 0644]

index 859398db9692f83ea120f65d206c0c4d7de1b1f9..4a272f2a6307dc46bc5cc94caf79436baaf541c3 100644 (file)
@@ -1875,12 +1875,14 @@ ConstraintMatrix::is_inhomogeneously_constrained (const unsigned int index) cons
                                // constrained. could use is_constrained, but
                                // that means computing the line index twice
   const unsigned int line_index = calculate_line_index(index);
-  if (line_index > lines_cache.size() ||
-      lines_cache[line_index] == numbers::invalid_unsigned_int ||
-      lines[lines_cache[line_index]].inhomogeneity == 0)
+  if (line_index >= lines_cache.size() ||
+      lines_cache[line_index] == numbers::invalid_unsigned_int)
     return false;
   else
-    return true;
+    {
+      Assert(lines_cache[line_index] < lines.size(), ExcInternalError());
+      return !(lines[lines_cache[line_index]].inhomogeneity == 0);
+    }
 }
 
 
@@ -1893,7 +1895,7 @@ ConstraintMatrix::get_constraint_entries (unsigned int line) const
                                // constrained. could use is_constrained, but
                                // that means computing the line index twice
   const unsigned int line_index = calculate_line_index(line);
-  if (line_index > lines_cache.size() ||
+  if (line_index >= lines_cache.size() ||
       lines_cache[line_index] == numbers::invalid_unsigned_int)
     return 0;
   else
@@ -1910,7 +1912,7 @@ ConstraintMatrix::get_inhomogeneity (unsigned int line) const
                                // constrained. could use is_constrained, but
                                // that means computing the line index twice
   const unsigned int line_index = calculate_line_index(line);
-  if (line_index > lines_cache.size() ||
+  if (line_index >= lines_cache.size() ||
       lines_cache[line_index] == numbers::invalid_unsigned_int)
     return 0;
   else
diff --git a/tests/lac/constraints_01.cc b/tests/lac/constraints_01.cc
new file mode 100644 (file)
index 0000000..ca96e08
--- /dev/null
@@ -0,0 +1,68 @@
+//----------------------------  constraints_zero.cc  ---------------------------
+//    $Id: constraints_zero.cc 18471 2009-03-10 13:20:31Z kronbichler $
+//    Version: $Name$ 
+//
+//    Copyright (C) 2005, 2006, 2007, 2008 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  constraints_zero.cc  ---------------------------
+
+
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/constraint_matrix.h>
+
+#include <fstream>
+
+// bug in ConstraintMatrix
+
+//index=18466 line_index=652 lines_cache[line_index]=919940456 lines.size()=21
+
+void test ()
+{
+  IndexSet rel;
+  std::ifstream f("constraints_01/is.23");
+  rel.read(f);
+  
+  ConstraintMatrix cm;
+  cm.clear();
+  cm.reinit(rel);
+
+  unsigned int inhoms[]={
+8385, 8386, 8391, 17886, 17892, 17895, 18066, 18069, 18072, 18075, 18086, 18089, 18092, 18095, 18138, 18141, 18144, 18147, 18158, 18161, 18164
+  };
+
+  for (unsigned int i=0;i<sizeof(inhoms) / sizeof(inhoms[0]);++i)
+    {
+      deallog << inhoms[i] << std::endl;
+      cm.add_line(inhoms[i]);
+      cm.set_inhomogeneity(inhoms[i],1.0);
+    }  
+  
+  cm.print (deallog.get_file_stream());
+
+  bool is = cm.is_inhomogeneously_constrained(18466);
+  deallog << "constraint 18466 inhom? " << is << std::endl;  
+  Assert(!is, ExcInternalError());
+}
+
+
+int main ()
+{
+  std::ofstream logfile("constraints_01/output");
+  logfile.precision(2);
+  
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);  
+
+  test ();
+  
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/lac/constraints_01/cmp/generic b/tests/lac/constraints_01/cmp/generic
new file mode 100644 (file)
index 0000000..0d1a044
--- /dev/null
@@ -0,0 +1,45 @@
+
+DEAL::8385
+DEAL::8386
+DEAL::8391
+DEAL::17886
+DEAL::17892
+DEAL::17895
+DEAL::18066
+DEAL::18069
+DEAL::18072
+DEAL::18075
+DEAL::18086
+DEAL::18089
+DEAL::18092
+DEAL::18095
+DEAL::18138
+DEAL::18141
+DEAL::18144
+DEAL::18147
+DEAL::18158
+DEAL::18161
+DEAL::18164
+    8385 = 1.0
+    8386 = 1.0
+    8391 = 1.0
+    17886 = 1.0
+    17892 = 1.0
+    17895 = 1.0
+    18066 = 1.0
+    18069 = 1.0
+    18072 = 1.0
+    18075 = 1.0
+    18086 = 1.0
+    18089 = 1.0
+    18092 = 1.0
+    18095 = 1.0
+    18138 = 1.0
+    18141 = 1.0
+    18144 = 1.0
+    18147 = 1.0
+    18158 = 1.0
+    18161 = 1.0
+    18164 = 1.0
+DEAL::constraint 18466 inhom? 0
+DEAL::OK
diff --git a/tests/lac/constraints_01/is.23 b/tests/lac/constraints_01/is.23
new file mode 100644 (file)
index 0000000..6019e0b
--- /dev/null
@@ -0,0 +1,68 @@
+49920 67
+8385 8394
+8400 8406
+8430 8436
+8440 8446
+8538 8544
+8548 8554
+8574 8580
+8584 8590
+8946 8952
+8956 8962
+8982 8988
+8992 8998
+9082 9088
+9092 9098
+9118 9124
+9128 9134
+10497 10503
+16994 16995
+16998 16999
+17000 17001
+17002 17004
+17006 17010
+17618 17620
+17622 17628
+17630 17634
+17650 17652
+17654 17660
+17662 17666
+17746 17748
+17750 17756
+17758 17762
+17778 17780
+17782 17788
+17790 17794
+17886 17889
+17892 17900
+17902 17906
+17922 17924
+17926 17932
+17934 17938
+17970 17971
+17972 17973
+17974 17975
+17976 17977
+17978 17987
+17988 17989
+17990 17991
+17992 17993
+17994 18002
+18018 18020
+18022 18028
+18030 18035
+18036 18037
+18038 18039
+18040 18041
+18042 18053
+18054 18817
+19169 19171
+19173 19177
+19873 19881
+19889 19897
+19937 19945
+19953 19961
+20129 20137
+20145 20153
+20193 20201
+20209 20215

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.