From 19a6d5adfd4742ecb11997919986ad7073910b15 Mon Sep 17 00:00:00 2001 From: bangerth Date: Thu, 20 Jan 2011 13:50:09 +0000 Subject: [PATCH] Take over Timo's patches 23221-23224 from mainline. git-svn-id: https://svn.dealii.org/branches/releases/Branch-7-0@23225 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/deal.II/lac/constraint_matrix.h | 14 ++-- tests/lac/constraints_01.cc | 68 +++++++++++++++++++ tests/lac/constraints_01/cmp/generic | 45 ++++++++++++ tests/lac/constraints_01/is.23 | 68 +++++++++++++++++++ 4 files changed, 189 insertions(+), 6 deletions(-) create mode 100644 tests/lac/constraints_01.cc create mode 100644 tests/lac/constraints_01/cmp/generic create mode 100644 tests/lac/constraints_01/is.23 diff --git a/deal.II/include/deal.II/lac/constraint_matrix.h b/deal.II/include/deal.II/lac/constraint_matrix.h index 859398db96..4a272f2a63 100644 --- a/deal.II/include/deal.II/lac/constraint_matrix.h +++ b/deal.II/include/deal.II/lac/constraint_matrix.h @@ -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 index 0000000000..ca96e08904 --- /dev/null +++ b/tests/lac/constraints_01.cc @@ -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 +#include + +#include + +// 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