]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Test function n_intervals, get_view and fill_index_vector in IndexSet.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 26 Aug 2010 09:48:24 +0000 (09:48 +0000)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Thu, 26 Aug 2010 09:48:24 +0000 (09:48 +0000)
git-svn-id: https://svn.dealii.org/trunk@21718 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/index_set_17.cc [new file with mode: 0644]
tests/base/index_set_17/cmp/generic [new file with mode: 0644]
tests/base/index_set_18.cc [new file with mode: 0644]
tests/base/index_set_18/cmp/generic [new file with mode: 0644]
tests/base/index_set_19.cc [new file with mode: 0644]
tests/base/index_set_19/cmp/generic [new file with mode: 0644]

diff --git a/tests/base/index_set_17.cc b/tests/base/index_set_17.cc
new file mode 100644 (file)
index 0000000..fbe797d
--- /dev/null
@@ -0,0 +1,59 @@
+//-----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2010 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 IndexSet::n_intervals
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <stdlib.h>
+
+#include <base/index_set.h>
+
+
+void test ()
+{
+  IndexSet is1 (100);
+
+                                  // randomly add 90 elements to each
+                                  // set, some of which may be
+                                  // repetitions of previous ones
+  for (unsigned int i=0; i<9*is1.size()/10; ++i)
+    {
+      is1.add_index (rand() % is1.size());
+    }
+
+  is1.compress();
+
+  deallog << "Number of intervals: "
+         << is1.n_intervals() << std::endl;
+
+  is1.print(deallog);
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+
+int main()
+{
+  std::ofstream logfile("index_set_17/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test ();
+}
diff --git a/tests/base/index_set_17/cmp/generic b/tests/base/index_set_17/cmp/generic
new file mode 100644 (file)
index 0000000..c4cf6c7
--- /dev/null
@@ -0,0 +1,4 @@
+
+DEAL::Number of intervals: 24
+DEAL::{[2,3], 5, 8, 11, [13,15], 19, [21,27], [29,30], [34,37], 40, [42,43], [45,46], [49,51], 54, [56,59], [62,64], [67,70], [72,73], [76,78], [80,84], [86,88], [90,93], [95,96], [98,99]}
+DEAL::OK
diff --git a/tests/base/index_set_18.cc b/tests/base/index_set_18.cc
new file mode 100644 (file)
index 0000000..69d5d1a
--- /dev/null
@@ -0,0 +1,59 @@
+//-----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2010 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 IndexSet::get_view
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <stdlib.h>
+
+#include <base/index_set.h>
+
+
+void test ()
+{
+  IndexSet is1 (100);
+
+                                  // randomly add 90 elements to each
+                                  // set, some of which may be
+                                  // repetitions of previous ones
+  for (unsigned int i=0; i<9*is1.size()/10; ++i)
+    is1.add_index (rand() % is1.size());
+
+  is1.compress();
+
+  IndexSet is2 = is1.get_view (20, 50);
+
+  deallog << "Original index set: " << std::endl;
+  is1.print(deallog);
+  deallog << "View of index set between 20 and 50: " << std::endl;
+  is2.print(deallog);
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+
+int main()
+{
+  std::ofstream logfile("index_set_18/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test ();
+}
diff --git a/tests/base/index_set_18/cmp/generic b/tests/base/index_set_18/cmp/generic
new file mode 100644 (file)
index 0000000..d7c72c7
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Original index set: 
+DEAL::{[2,3], 5, 8, 11, [13,15], 19, [21,27], [29,30], [34,37], 40, [42,43], [45,46], [49,51], 54, [56,59], [62,64], [67,70], [72,73], [76,78], [80,84], [86,88], [90,93], [95,96], [98,99]}
+DEAL::View of index set between 20 and 50: 
+DEAL::{[1,7], [9,10], [14,17], 20, [22,23], [25,26], 29}
+DEAL::OK
diff --git a/tests/base/index_set_19.cc b/tests/base/index_set_19.cc
new file mode 100644 (file)
index 0000000..5ce5e1d
--- /dev/null
@@ -0,0 +1,64 @@
+//-----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2010 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 IndexSet::fill_index_vector
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <stdlib.h>
+
+#include <base/index_set.h>
+
+
+void test ()
+{
+  IndexSet is1 (100);
+
+                                  // randomly add 90 elements to each
+                                  // set, some of which may be
+                                  // repetitions of previous ones
+  for (unsigned int i=0; i<9*is1.size()/10; ++i)
+    is1.add_index (rand() % is1.size());
+
+  std::vector<unsigned int> indices;
+  is1.fill_index_vector (indices);
+
+  deallog << "Original index set: " << std::endl;
+  is1.print(deallog);
+
+  deallog << "List of indices: " << std::endl;
+  for (unsigned int i=0; i<indices.size(); i++)
+    deallog << indices[i] << ' ';
+  deallog << std::endl;
+
+  for (unsigned int i=0; i<indices.size(); i++)
+    Assert(is1.index_within_set(indices[i])==i, ExcInternalError());
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+
+int main()
+{
+  std::ofstream logfile("index_set_19/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test ();
+}
diff --git a/tests/base/index_set_19/cmp/generic b/tests/base/index_set_19/cmp/generic
new file mode 100644 (file)
index 0000000..642df6f
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Original index set: 
+DEAL::{[2,3], 5, 8, 11, [13,15], 19, [21,27], [29,30], [34,37], 40, [42,43], [45,46], [49,51], 54, [56,59], [62,64], [67,70], [72,73], [76,78], [80,84], [86,88], [90,93], [95,96], [98,99]}
+DEAL::List of indices: 
+DEAL::2 3 5 8 11 13 14 15 19 21 22 23 24 25 26 27 29 30 34 35 36 37 40 42 43 45 46 49 50 51 54 56 57 58 59 62 63 64 67 68 69 70 72 73 76 77 78 80 81 82 83 84 86 87 88 90 91 92 93 95 96 98 99 
+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.