From 0729c37faa5ec363768fb5f5d429310972719224 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 23 Jan 2008 16:28:37 +0000 Subject: [PATCH] Fix the case of constraints of the form x[i]=0 which simply weren't written at all. git-svn-id: https://svn.dealii.org/trunk@15647 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/source/dofs/dof_constraints.cc | 43 ++++++++---- deal.II/doc/news/changes.h | 9 ++- tests/deal.II/constraint_graph_zero.cc | 59 +++++++++++++++++ .../deal.II/constraint_graph_zero/cmp/generic | 6 ++ tests/deal.II/constraints_zero.cc | 59 +++++++++++++++++ tests/deal.II/constraints_zero/cmp/generic | 4 ++ tests/deal.II/constraints_zero_merge.cc | 66 +++++++++++++++++++ .../constraints_zero_merge/cmp/generic | 10 +++ 8 files changed, 244 insertions(+), 12 deletions(-) create mode 100644 tests/deal.II/constraint_graph_zero.cc create mode 100644 tests/deal.II/constraint_graph_zero/cmp/generic create mode 100644 tests/deal.II/constraints_zero.cc create mode 100644 tests/deal.II/constraints_zero/cmp/generic create mode 100644 tests/deal.II/constraints_zero_merge.cc create mode 100644 tests/deal.II/constraints_zero_merge/cmp/generic diff --git a/deal.II/deal.II/source/dofs/dof_constraints.cc b/deal.II/deal.II/source/dofs/dof_constraints.cc index 7f0bbaca52..95376bcb6b 100644 --- a/deal.II/deal.II/source/dofs/dof_constraints.cc +++ b/deal.II/deal.II/source/dofs/dof_constraints.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 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 @@ -1599,11 +1599,27 @@ unsigned int ConstraintMatrix::max_constraint_indirections () const void ConstraintMatrix::print (std::ostream &out) const { for (unsigned int i=0; i!=lines.size(); ++i) - for (unsigned int j=0; j!=lines[i].entries.size(); ++j) - out << " " << lines[i].line - << " " << lines[i].entries[j].first - << ": " << lines[i].entries[j].second << std::endl; - + { + // output the list of + // constraints as pairs of dofs + // and their weights + if (lines[i].entries.size() > 0) + for (unsigned int j=0; j" << lines[i].entries[j].first - << "; // weight: " - << lines[i].entries[j].second - << "\n"; + // same concept as in the + // previous function + if (lines[i].entries.size() > 0) + for (unsigned int j=0; j" << lines[i].entries[j].first + << "; // weight: " + << lines[i].entries[j].second + << "\n"; + else + out << " " << lines[i].line << "\n"; } out << "}" << std::endl; } diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index c88708614c..5cd975c516 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -232,13 +232,20 @@ constraints individually.
    +
  1. Fixed: Neither ConstraintMatrix::print nor ConstraintMatrix::write_dot + produced any output for constraints of the form $x_i=0$, i.e. where the right + hand side is a trivial linear combination of other degrees of freedom. This + is now fixed. +
    + (WB 2008/01/23) +

  2. +
  3. Improved: GridGenerator::subdivided_hyper_rectangle now also colorizes cells according to the octant they are in.
    (GK 2007/12/20)

  4. -
  5. New: The DataOut, DataOutRotation, DataOutStack, and DataOutFaces can now deal with vector-valued data if the functions in DataOutBase that write in a particular graphical output format can deal with it. diff --git a/tests/deal.II/constraint_graph_zero.cc b/tests/deal.II/constraint_graph_zero.cc new file mode 100644 index 0000000000..42785391e6 --- /dev/null +++ b/tests/deal.II/constraint_graph_zero.cc @@ -0,0 +1,59 @@ +//---------------------------- constraint_graph_zero.cc --------------------------- +// $Id$ +// 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. +// +//---------------------------- constraint_graph_zero.cc --------------------------- + + +// generate constraints for a case where there are nodes that have a +// constraint x[i]=0, i.e. where the right hand side is a trivial +// linear combination of other degrees of freedom. then write this as +// a DOT graph. +// +// we used to get this case wrong (we simply forgot to output this +// node). + + +#include "../tests.h" +#include +#include + +#include + + +void test () +{ + + ConstraintMatrix cm; + + // a "regular" constraint + cm.add_line (1); + cm.add_entry (1, 2, 42.); + + // a "singular" constraint + cm.add_line (4); + + cm.write_dot (deallog.get_file_stream()); +} + + +int main () +{ + std::ofstream logfile("constraint_graph_zero/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/deal.II/constraint_graph_zero/cmp/generic b/tests/deal.II/constraint_graph_zero/cmp/generic new file mode 100644 index 0000000000..da48f067e4 --- /dev/null +++ b/tests/deal.II/constraint_graph_zero/cmp/generic @@ -0,0 +1,6 @@ + +digraph constraints { + 1->2; // weight: 42. + 4 +} +DEAL::OK diff --git a/tests/deal.II/constraints_zero.cc b/tests/deal.II/constraints_zero.cc new file mode 100644 index 0000000000..efda48faf8 --- /dev/null +++ b/tests/deal.II/constraints_zero.cc @@ -0,0 +1,59 @@ +//---------------------------- constraints_zero.cc --------------------------- +// $Id$ +// 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 --------------------------- + + +// generate the constraints for a case where there are nodes that have +// a constraint x[i]=0, i.e. where the right hand side is a trivial +// linear combination of other degrees of freedom. then print this set +// of constraints. +// +// we used to get this case wrong (we simply forgot to output this +// node). + + +#include "../tests.h" +#include +#include + +#include + + +void test () +{ + + ConstraintMatrix cm; + + // a "regular" constraint + cm.add_line (1); + cm.add_entry (1, 2, 42.); + + // a "singular" constraint + cm.add_line (4); + + cm.print (deallog.get_file_stream()); +} + + +int main () +{ + std::ofstream logfile("constraints_zero/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/deal.II/constraints_zero/cmp/generic b/tests/deal.II/constraints_zero/cmp/generic new file mode 100644 index 0000000000..0be5392c8f --- /dev/null +++ b/tests/deal.II/constraints_zero/cmp/generic @@ -0,0 +1,4 @@ + + 1 2: 42. + 4 = 0 +DEAL::OK diff --git a/tests/deal.II/constraints_zero_merge.cc b/tests/deal.II/constraints_zero_merge.cc new file mode 100644 index 0000000000..a0fe8a4667 --- /dev/null +++ b/tests/deal.II/constraints_zero_merge.cc @@ -0,0 +1,66 @@ +//---------------------------- constraints_zero_merge.cc --------------------------- +// $Id$ +// 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_merge.cc --------------------------- + + +// generate the constraints for a case where there are nodes that have +// a constraint x[i]=0, i.e. where the right hand side is a trivial +// linear combination of other degrees of freedom. then merge two such +// constraint matrices + + +#include "../tests.h" +#include +#include + +#include + + +void test () +{ + + ConstraintMatrix cm1, cm2; + + // a "regular" and a singular + // constraint to each of the + // constraint matrices + cm1.add_line (1); + cm1.add_entry (1, 2, 42.); + cm1.add_line (4); + + cm2.add_line (11); + cm2.add_entry (11, 22, 42.); + cm2.add_line (14); + + cm2.merge (cm1); + + deallog << "CM1" << std::endl; + cm1.print (deallog.get_file_stream()); + + deallog << "CM2" << std::endl; + cm2.print (deallog.get_file_stream()); +} + + +int main () +{ + std::ofstream logfile("constraints_zero_merge/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/deal.II/constraints_zero_merge/cmp/generic b/tests/deal.II/constraints_zero_merge/cmp/generic new file mode 100644 index 0000000000..7a08a27bbd --- /dev/null +++ b/tests/deal.II/constraints_zero_merge/cmp/generic @@ -0,0 +1,10 @@ + +DEAL::CM1 + 1 2: 42. + 4 = 0 +DEAL::CM2 + 11 22: 42. + 14 = 0 + 1 2: 42. + 4 = 0 +DEAL::OK -- 2.39.5