]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix the case of constraints of the form x[i]=0 which simply weren't written at all.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 23 Jan 2008 16:28:37 +0000 (16:28 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 23 Jan 2008 16:28:37 +0000 (16:28 +0000)
git-svn-id: https://svn.dealii.org/trunk@15647 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/dofs/dof_constraints.cc
deal.II/doc/news/changes.h
tests/deal.II/constraint_graph_zero.cc [new file with mode: 0644]
tests/deal.II/constraint_graph_zero/cmp/generic [new file with mode: 0644]
tests/deal.II/constraints_zero.cc [new file with mode: 0644]
tests/deal.II/constraints_zero/cmp/generic [new file with mode: 0644]
tests/deal.II/constraints_zero_merge.cc [new file with mode: 0644]
tests/deal.II/constraints_zero_merge/cmp/generic [new file with mode: 0644]

index 7f0bbaca5276457fb408ae4c14cc1d99bf1f03ab..95376bcb6b295df21038456e7f9fc9b5a2feb170 100644 (file)
@@ -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.size(); ++j)
+         out << "    " << lines[i].line
+             << " " << lines[i].entries[j].first
+             << ":  " << lines[i].entries[j].second << "\n";
+      else
+                                        // but also output something
+                                        // if the constraint simply
+                                        // reads x[13]=0, i.e. where
+                                        // the right hand side is not
+                                        // a linear combination of
+                                        // other dofs
+       out << "    " << lines[i].line
+           << " = 0"
+           << "\n";
+    }
+  
   AssertThrow (out, ExcIO());
 }
 
@@ -1616,11 +1632,16 @@ ConstraintMatrix::write_dot (std::ostream &out) const
       << std::endl;
   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
-           << "; // 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.size(); ++j)
+         out << "  " << lines[i].line << "->" << lines[i].entries[j].first
+             << "; // weight: "
+             << lines[i].entries[j].second
+             << "\n";
+      else
+       out << "  " << lines[i].line << "\n";
     }
   out << "}" << std::endl;
 }
index c88708614c5c5b3dcc28dd5c9e24347e5c248951..5cd975c5163579450176d629c2375fd694013fa3 100644 (file)
@@ -232,13 +232,20 @@ constraints individually.
 
 <ol> 
 
+  <li> <p>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.
+  <br>
+  (WB 2008/01/23)
+  </p></li>
+
   <li> <p>Improved: GridGenerator::subdivided_hyper_rectangle now also colorizes
   cells according to the octant they are in.
   <br>
   (GK 2007/12/20)
   </p></li>
 
-
   <li> <p>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 (file)
index 0000000..4278539
--- /dev/null
@@ -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 <base/logstream.h>
+#include <dofs/dof_constraints.h>
+
+#include <fstream>
+
+
+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 (file)
index 0000000..da48f06
--- /dev/null
@@ -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 (file)
index 0000000..efda48f
--- /dev/null
@@ -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 <base/logstream.h>
+#include <dofs/dof_constraints.h>
+
+#include <fstream>
+
+
+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 (file)
index 0000000..0be5392
--- /dev/null
@@ -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 (file)
index 0000000..a0fe8a4
--- /dev/null
@@ -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 <base/logstream.h>
+#include <dofs/dof_constraints.h>
+
+#include <fstream>
+
+
+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 (file)
index 0000000..7a08a27
--- /dev/null
@@ -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

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.