]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
New tests.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 19 Jun 2004 19:18:47 +0000 (19:18 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 19 Jun 2004 19:18:47 +0000 (19:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@9432 0785d39b-7218-0410-832d-ea1e28bc413d

tests/bits/Makefile
tests/bits/compressed_sparsity_pattern_01.cc [new file with mode: 0644]
tests/bits/compressed_sparsity_pattern_02.cc [new file with mode: 0644]
tests/bits/compressed_sparsity_pattern_03.cc [new file with mode: 0644]
tests/bits/compressed_sparsity_pattern_04.cc [new file with mode: 0644]
tests/bits/compressed_sparsity_pattern_05.cc [new file with mode: 0644]
tests/bits/compressed_sparsity_pattern_06.cc [new file with mode: 0644]
tests/bits/compressed_sparsity_pattern_07.cc [new file with mode: 0644]
tests/bits/compressed_sparsity_pattern_08.cc [new file with mode: 0644]
tests/bits/compressed_sparsity_pattern_09.cc [new file with mode: 0644]

index e7978acc21eb0f7f439e533fe12b8abffab61376..df99da89ef244e5d129633b1a68b766294a40d30 100644 (file)
@@ -60,7 +60,8 @@ tests_x = anna_? \
          apply_boundary_values_* \
          error_estimator_* \
          cylinder_shell_* \
-         grid_in_*
+         grid_in_* \
+         compressed_sparsity_pattern_*
 
 # tests for the hp branch:
 #        fe_collection_*
diff --git a/tests/bits/compressed_sparsity_pattern_01.cc b/tests/bits/compressed_sparsity_pattern_01.cc
new file mode 100644 (file)
index 0000000..4cd673e
--- /dev/null
@@ -0,0 +1,52 @@
+//----------------------------  compressed_sparsity_pattern_01.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 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.
+//
+//----------------------------  compressed_sparsity_pattern_01.cc  ---------------------------
+
+
+// check CompressedSparsityPattern::n_nonzero_elements. test n_rows() and
+// n_cols() in passing
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/compressed_sparsity_pattern.h>
+#include <iostream>
+#include <fstream>
+
+
+void test ()
+{
+                                   // set up a sparsity pattern. since
+                                   // CompressedSparsityPatterns are most
+                                   // often used for 3d, use a rather large
+                                   // number of entries per row
+  const unsigned int N = 1000;
+  CompressedSparsityPattern csp (N,N);
+  for (unsigned int i=0; i<N; ++i)
+    for (unsigned int j=0; j<40; ++j)
+      csp.add (i, (i+(i+1)*(j*j+i))%N);
+
+  Assert (csp.n_rows() == N, ExcInternalError());
+  Assert (csp.n_cols() == N, ExcInternalError());
+  deallog << csp.n_nonzero_elements () << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("compressed_sparsity_pattern_01.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test ();
+  return 0;
+}
diff --git a/tests/bits/compressed_sparsity_pattern_02.cc b/tests/bits/compressed_sparsity_pattern_02.cc
new file mode 100644 (file)
index 0000000..ea1701b
--- /dev/null
@@ -0,0 +1,49 @@
+//----------------------------  compressed_sparsity_pattern_02.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 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.
+//
+//----------------------------  compressed_sparsity_pattern_02.cc  ---------------------------
+
+
+// check CompressedSparsityPattern::bandwidth
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/compressed_sparsity_pattern.h>
+#include <iostream>
+#include <fstream>
+
+
+void test ()
+{
+                                   // set up a sparsity pattern. since
+                                   // CompressedSparsityPatterns are most
+                                   // often used for 3d, use a rather large
+                                   // number of entries per row
+  const unsigned int N = 1000;
+  CompressedSparsityPattern csp (N,N);
+  for (unsigned int i=0; i<N; ++i)
+    for (unsigned int j=0; j<40; ++j)
+      csp.add (i, (i+(i+1)*(j*j+i))%N);
+
+  deallog << csp.bandwidth () << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("compressed_sparsity_pattern_02.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test ();
+  return 0;
+}
diff --git a/tests/bits/compressed_sparsity_pattern_03.cc b/tests/bits/compressed_sparsity_pattern_03.cc
new file mode 100644 (file)
index 0000000..8da37aa
--- /dev/null
@@ -0,0 +1,50 @@
+//----------------------------  compressed_sparsity_pattern_03.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 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.
+//
+//----------------------------  compressed_sparsity_pattern_03.cc  ---------------------------
+
+
+// check CompressedSparsityPattern::row_length
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/compressed_sparsity_pattern.h>
+#include <iostream>
+#include <fstream>
+
+
+void test ()
+{
+                                   // set up a sparsity pattern. since
+                                   // CompressedSparsityPatterns are most
+                                   // often used for 3d, use a rather large
+                                   // number of entries per row
+  const unsigned int N = 1000;
+  CompressedSparsityPattern csp (N,N);
+  for (unsigned int i=0; i<N; ++i)
+    for (unsigned int j=0; j<40; ++j)
+      csp.add (i, (i+(i+1)*(j*j+i))%N);
+
+  for (unsigned int i=0; i<N; ++i)
+    deallog << i << ' ' << csp.row_length (i) << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("compressed_sparsity_pattern_03.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test ();
+  return 0;
+}
diff --git a/tests/bits/compressed_sparsity_pattern_04.cc b/tests/bits/compressed_sparsity_pattern_04.cc
new file mode 100644 (file)
index 0000000..cdef247
--- /dev/null
@@ -0,0 +1,50 @@
+//----------------------------  compressed_sparsity_pattern_04.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 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.
+//
+//----------------------------  compressed_sparsity_pattern_04.cc  ---------------------------
+
+
+// check CompressedSparsityPattern::column_number. since we create quite some
+// output here, choose smaller number of rows and entries than in the other
+// tests
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/compressed_sparsity_pattern.h>
+#include <iostream>
+#include <fstream>
+
+
+void test ()
+{
+  const unsigned int N = 100;
+  CompressedSparsityPattern csp (N,N);
+  for (unsigned int i=0; i<N; ++i)
+    for (unsigned int j=0; j<10; ++j)
+      csp.add (i, (i+(i+1)*(j*j+i))%N);
+
+  for (unsigned int i=0; i<N; ++i)
+    for (unsigned int j=0; j<csp.row_length (i); ++j)
+      deallog << i << ' ' << j << ' ' << csp.column_number (i,j)
+              << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("compressed_sparsity_pattern_04.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test ();
+  return 0;
+}
diff --git a/tests/bits/compressed_sparsity_pattern_05.cc b/tests/bits/compressed_sparsity_pattern_05.cc
new file mode 100644 (file)
index 0000000..62b3576
--- /dev/null
@@ -0,0 +1,51 @@
+//----------------------------  compressed_sparsity_pattern_05.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 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.
+//
+//----------------------------  compressed_sparsity_pattern_05.cc  ---------------------------
+
+
+// check CompressedSparsityPattern::symmetrize. since we create quite some
+// output here, choose smaller number of rows and entries than in the other
+// tests
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/compressed_sparsity_pattern.h>
+#include <iostream>
+#include <fstream>
+
+
+void test ()
+{
+  const unsigned int N = 100;
+  CompressedSparsityPattern csp (N,N);
+  for (unsigned int i=0; i<N; ++i)
+    for (unsigned int j=0; j<10; ++j)
+      csp.add (i, (i+(i+1)*(j*j+i))%N);
+  csp.symmetrize ();
+
+  for (unsigned int i=0; i<N; ++i)
+    for (unsigned int j=0; j<csp.row_length (i); ++j)
+      deallog << i << ' ' << j << ' ' << csp.column_number (i,j)
+              << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("compressed_sparsity_pattern_05.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test ();
+  return 0;
+}
diff --git a/tests/bits/compressed_sparsity_pattern_06.cc b/tests/bits/compressed_sparsity_pattern_06.cc
new file mode 100644 (file)
index 0000000..ed2a2e1
--- /dev/null
@@ -0,0 +1,50 @@
+//----------------------------  compressed_sparsity_pattern_06.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 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.
+//
+//----------------------------  compressed_sparsity_pattern_06.cc  ---------------------------
+
+
+// check CompressedSparsityPattern::print_gnuplot. since we create quite some
+// output here, choose smaller number of rows and entries than in the other
+// tests
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/compressed_sparsity_pattern.h>
+#include <iostream>
+#include <fstream>
+
+
+std::ofstream logfile("compressed_sparsity_pattern_06.output");
+
+void test ()
+{
+  const unsigned int N = 100;
+  CompressedSparsityPattern csp (N,N);
+  for (unsigned int i=0; i<N; ++i)
+    for (unsigned int j=0; j<10; ++j)
+      csp.add (i, (i+(i+1)*(j*j+i))%N);
+  csp.symmetrize ();
+
+  csp.print_gnuplot (logfile);
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main () 
+{
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test ();
+  return 0;
+}
diff --git a/tests/bits/compressed_sparsity_pattern_07.cc b/tests/bits/compressed_sparsity_pattern_07.cc
new file mode 100644 (file)
index 0000000..c03b474
--- /dev/null
@@ -0,0 +1,54 @@
+//----------------------------  compressed_sparsity_pattern_07.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 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.
+//
+//----------------------------  compressed_sparsity_pattern_07.cc  ---------------------------
+
+
+// check CompressedSparsityPattern::exists. since we create quite some
+// output here, choose smaller number of rows and entries than in the other
+// tests
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/compressed_sparsity_pattern.h>
+#include <iostream>
+#include <fstream>
+
+
+void test ()
+{
+  const unsigned int N = 100;
+  CompressedSparsityPattern csp (N,N);
+  for (unsigned int i=0; i<N; ++i)
+    for (unsigned int j=0; j<10; ++j)
+      csp.add (i, (i+(i+1)*(j*j+i))%N);
+  csp.symmetrize ();
+
+  for (unsigned int i=0; i<N; ++i)
+    {
+      deallog << i << ' ';
+      for (unsigned int j=0; j<N; ++j)
+        deallog << (csp.exists(i,j) ? 'x' : ' ');
+      deallog << std::endl;
+    }
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("compressed_sparsity_pattern_07.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test ();
+  return 0;
+}
diff --git a/tests/bits/compressed_sparsity_pattern_08.cc b/tests/bits/compressed_sparsity_pattern_08.cc
new file mode 100644 (file)
index 0000000..4e6a725
--- /dev/null
@@ -0,0 +1,49 @@
+//----------------------------  compressed_sparsity_pattern_08.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 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.
+//
+//----------------------------  compressed_sparsity_pattern_08.cc  ---------------------------
+
+
+// check CompressedSparsityPattern::max_entries_per_row
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/compressed_sparsity_pattern.h>
+#include <iostream>
+#include <fstream>
+
+
+void test ()
+{
+                                   // set up a sparsity pattern. since
+                                   // CompressedSparsityPatterns are most
+                                   // often used for 3d, use a rather large
+                                   // number of entries per row
+  const unsigned int N = 1000;
+  CompressedSparsityPattern csp (N,N);
+  for (unsigned int i=0; i<N; ++i)
+    for (unsigned int j=0; j<40; ++j)
+      csp.add (i, (i+(i+1)*(j*j+i))%N);
+
+  deallog << ' ' << csp.max_entries_per_row () << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("compressed_sparsity_pattern_08.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test ();
+  return 0;
+}
diff --git a/tests/bits/compressed_sparsity_pattern_09.cc b/tests/bits/compressed_sparsity_pattern_09.cc
new file mode 100644 (file)
index 0000000..697476b
--- /dev/null
@@ -0,0 +1,46 @@
+//----------------------------  compressed_sparsity_pattern_09.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004 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.
+//
+//----------------------------  compressed_sparsity_pattern_09.cc  ---------------------------
+
+
+// check CompressedSparsityPattern::empty
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/compressed_sparsity_pattern.h>
+#include <iostream>
+#include <fstream>
+
+
+void test ()
+{
+  const unsigned int N = 1000;
+  CompressedSparsityPattern csp;
+  Assert (csp.empty() == true, ExcInternalError());
+
+  csp.reinit (N, N);
+  Assert (csp.empty() == false, ExcInternalError());
+  
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main () 
+{
+  std::ofstream logfile("compressed_sparsity_pattern_09.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  test ();
+  return 0;
+}

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.