]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Merge tests from branch_distributed_grids.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 7 Jun 2010 21:26:44 +0000 (21:26 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 7 Jun 2010 21:26:44 +0000 (21:26 +0000)
git-svn-id: https://svn.dealii.org/trunk@21171 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/index_set_15.cc [new file with mode: 0644]
tests/base/index_set_15/cmp/generic [new file with mode: 0644]
tests/base/index_set_16.cc [new file with mode: 0644]
tests/base/index_set_16/cmp/generic [new file with mode: 0644]

diff --git a/tests/base/index_set_15.cc b/tests/base/index_set_15.cc
new file mode 100644 (file)
index 0000000..5b68ab5
--- /dev/null
@@ -0,0 +1,85 @@
+//-----------------------------------------------------------------------------
+//    $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::subtract_set
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <stdlib.h>
+
+#include <base/index_set.h>
+
+
+void test ()
+{
+  IndexSet is1 (100);
+  IndexSet is2 (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());
+      is2.add_index (rand() % is2.size());
+    }
+
+  IndexSet is3 = is1;
+  is3.subtract_set(is2);
+
+  deallog << "Set sizes: "
+         << is1.n_elements() << ' '
+         << is2.n_elements() << ' '
+         << is3.n_elements() << std::endl;
+
+  is1.print(deallog);
+  is2.print(deallog);
+  is3.print(deallog);
+  
+  
+  
+  for (unsigned int i=0; i<is3.size(); ++i)
+    {
+      Assert ((is1.is_element(i) && !is2.is_element(i))
+             ==
+             is3.is_element(i),
+             ExcInternalError());
+    }
+
+  IndexSet empty(100);
+  is3 = is1;
+  is3.subtract_set(empty);
+  
+  Assert (is3 == is1, ExcInternalError());
+
+  is3.subtract_set(is1);
+  Assert (is3 == empty, ExcInternalError());
+  
+  deallog << "OK" << std::endl;
+}
+
+
+
+
+int main()
+{
+  std::ofstream logfile("index_set_15/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test ();
+}
diff --git a/tests/base/index_set_15/cmp/generic b/tests/base/index_set_15/cmp/generic
new file mode 100644 (file)
index 0000000..b91d6f4
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Set sizes: 61 56 31
+DEAL::{1, 3, [5,6], [8,9], 11, [13,15], [17,19], [21,22], 24, [26,29], [31,32], 34, 36, [39,41], [43,44], 46, 49, 52, 54, 56, 59, [62,65], 67, [69,70], 72, [76,77], 79, [81,84], [86,88], [90,91], [93,98]}
+DEAL::{[0,2], 5, 8, 12, [14,15], 17, 19, 21, [23,30], [35,37], 39, [41,42], 45, [49,51], 53, [55,60], [64,65], [67,68], [70,71], 73, 75, 78, [80,81], [83,84], 86, [88,89], [91,92], 95, 99}
+DEAL::{3, 6, 9, 11, 13, 18, 22, [31,32], 34, 40, [43,44], 46, 52, 54, [62,63], 69, 72, [76,77], 79, 82, 87, 90, [93,94], [96,98]}
+DEAL::OK
diff --git a/tests/base/index_set_16.cc b/tests/base/index_set_16.cc
new file mode 100644 (file)
index 0000000..0070e23
--- /dev/null
@@ -0,0 +1,70 @@
+
+//-----------------------------------------------------------------------------
+//    $Id: index_set_15.cc 20519 2010-02-08 10:23:05Z heister $
+//    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::subtract_set further
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <stdlib.h>
+
+#include <base/index_set.h>
+
+
+void test ()
+{
+  IndexSet is1 (100);
+  IndexSet is2 (100);
+
+  is1.add_range(0,10);
+  is1.add_range(20,100);
+  
+  is2.add_range(0,50);
+//  is2.add_range(10,15);
+  
+  IndexSet is3 = is1;
+  is3.subtract_set(is2);
+  
+  is1.print(deallog);
+  is2.print(deallog);
+  is3.print(deallog);  
+  
+  for (unsigned int i=0; i<is3.size(); ++i)
+    {
+      Assert ((is1.is_element(i) && !is2.is_element(i))
+             ==
+             is3.is_element(i),
+             ExcInternalError());
+    }
+
+  deallog << is3.index_within_set(51) << std::endl;
+  Assert(is3.index_within_set(51)==1, ExcInternalError());
+  
+  deallog << "OK" << std::endl;
+}
+
+
+
+
+int main()
+{
+  std::ofstream logfile("index_set_16/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test ();
+}
diff --git a/tests/base/index_set_16/cmp/generic b/tests/base/index_set_16/cmp/generic
new file mode 100644 (file)
index 0000000..ee7de75
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::{[0,9], [20,99]}
+DEAL::{[0,49]}
+DEAL::{[50,99]}
+DEAL::1
+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.