]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement indexing also for non-contiguous ranges.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 15 Oct 2009 22:57:57 +0000 (22:57 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 15 Oct 2009 22:57:57 +0000 (22:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@19898 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/index_set_10.cc
tests/base/index_set_12.cc [new file with mode: 0644]
tests/base/index_set_12/cmp/generic [new file with mode: 0644]

index 7c41499cdc2498721c03d715bece033c184e67cb..ea9279d515eb1bbaa17863451a96388a27624a6f 100644 (file)
@@ -11,7 +11,7 @@
 //
 //-----------------------------------------------------------------------------
 
-// test indexing in IndexSet variables
+// test indexing in IndexSet variables for a contiguous range
 
 #include "../tests.h"
 #include <iomanip>
diff --git a/tests/base/index_set_12.cc b/tests/base/index_set_12.cc
new file mode 100644 (file)
index 0000000..08ad27b
--- /dev/null
@@ -0,0 +1,66 @@
+//-----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2009 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.
+//
+//-----------------------------------------------------------------------------
+
+// test indexing in IndexSet variables for a non-contiguous range
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+
+#include <base/index_set.h>
+
+
+void test ()
+{
+  IndexSet index_set (20);
+
+  index_set.add_index (2);
+  index_set.add_index (3);
+  index_set.add_index (4);
+
+  index_set.add_index (6);
+  index_set.add_index (7);
+
+  index_set.compress ();
+
+  index_set.add_index (9);
+
+  for (unsigned int i=0; i<index_set.n_elements(); ++i)
+    {
+      deallog << index_set.nth_index_in_set(i)
+             << std::endl;
+      Assert (index_set.index_within_set(index_set.nth_index_in_set(i)) == i,
+             ExcInternalError());
+    }
+  deallog << "OK" << std::endl;
+
+  for (unsigned int i=0; i<index_set.size(); ++i)
+    if (index_set.is_element (i))
+      deallog << i << ' ' << index_set.index_within_set(i)
+             << std::endl;
+}
+
+
+
+
+int main()
+{
+  std::ofstream logfile("index_set_12/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test ();
+}
diff --git a/tests/base/index_set_12/cmp/generic b/tests/base/index_set_12/cmp/generic
new file mode 100644 (file)
index 0000000..99fa7a6
--- /dev/null
@@ -0,0 +1,14 @@
+
+DEAL::2
+DEAL::3
+DEAL::4
+DEAL::6
+DEAL::7
+DEAL::9
+DEAL::OK
+DEAL::2 0
+DEAL::3 1
+DEAL::4 2
+DEAL::6 3
+DEAL::7 4
+DEAL::9 5

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.