From e4c188a8457e33579c4b91287d701edc624af919 Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 28 Feb 2000 16:29:39 +0000 Subject: [PATCH] Add a safety check whether constrained nodes are constrained to other constraints, which is not allowed. git-svn-id: https://svn.dealii.org/trunk@2502 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/include/dofs/dof_constraints.h | 11 +++++- .../deal.II/source/dofs/dof_constraints.cc | 34 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_constraints.h b/deal.II/deal.II/include/dofs/dof_constraints.h index 98ecb50dd1..cae4cac49f 100644 --- a/deal.II/deal.II/include/dofs/dof_constraints.h +++ b/deal.II/deal.II/include/dofs/dof_constraints.h @@ -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 diff --git a/deal.II/deal.II/source/dofs/dof_constraints.cc b/deal.II/deal.II/source/dofs/dof_constraints.cc index 2b9e6178f8..0c259e9811 100644 --- a/deal.II/deal.II/source/dofs/dof_constraints.cc +++ b/deal.II/deal.II/source/dofs/dof_constraints.cc @@ -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(), 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::const_iterator line=lines.begin(); + line!=lines.end(); ++line) + for (vector >::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 >() }; + const vector::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; }; -- 2.39.5