]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
One more testcase in the same direction.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 23 Jan 2008 16:40:04 +0000 (16:40 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 23 Jan 2008 16:40:04 +0000 (16:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@15649 0785d39b-7218-0410-832d-ea1e28bc413d

tests/deal.II/constraints_zero_condense.cc [new file with mode: 0644]
tests/deal.II/constraints_zero_condense/cmp/generic [new file with mode: 0644]

diff --git a/tests/deal.II/constraints_zero_condense.cc b/tests/deal.II/constraints_zero_condense.cc
new file mode 100644 (file)
index 0000000..3a1e303
--- /dev/null
@@ -0,0 +1,78 @@
+//----------------------------  constraints_zero_condense.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_condense.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 check that if
+// we condense a matrix with this then the right thing happens
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <dofs/dof_constraints.h>
+#include <lac/sparse_matrix.h>
+
+#include <fstream>
+
+
+void test ()
+{
+
+                                  // constrain each dof to zero. this
+                                  // should yield a diagonal matrix
+  ConstraintMatrix cm;
+
+  for (unsigned int i=0; i<5; ++i)
+    cm.add_line (i);
+  cm.close ();
+  
+                                  // completely fill a 5x5 matrix
+                                  // with some values
+  SparsityPattern sp (5,5,5);
+  for (unsigned int i=0; i<5; ++i)
+    for (unsigned int j=0; j<5; ++j)
+      sp.add(i,j);
+  sp.compress ();
+  
+  SparseMatrix<double> m(sp);
+  for (unsigned int i=0; i<5; ++i)
+    for (unsigned int j=0; j<5; ++j)
+      m.set(i,j, i+j+2);
+
+                                  // now condense it
+  cm.condense (m);
+
+                                  // and print it
+  for (unsigned int i=0; i<5; ++i)
+    {
+      for (unsigned int j=0; j<5; ++j)
+       deallog << m(i,j) << ' ';
+      deallog << std::endl;
+    }
+}
+
+
+int main ()
+{
+  std::ofstream logfile("constraints_zero_condense/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_condense/cmp/generic b/tests/deal.II/constraints_zero_condense/cmp/generic
new file mode 100644 (file)
index 0000000..e808e1b
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL::6.0 0 0 0 0 
+DEAL::0 6.0 0 0 0 
+DEAL::0 0 6.0 0 0 
+DEAL::0 0 0 6.0 0 
+DEAL::0 0 0 0 6.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.