]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
fix bug in IndexSet
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 31 Jul 2013 13:34:45 +0000 (13:34 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 31 Jul 2013 13:34:45 +0000 (13:34 +0000)
git-svn-id: https://svn.dealii.org/trunk@30192 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/base/index_set.cc
tests/base/index_set_readwrite_03.cc [new file with mode: 0644]
tests/base/index_set_readwrite_03/cmp/generic [new file with mode: 0644]

index bf373ddd5f163c3eee3a3da8e37a1236aeea9810..ce4b5bcfb716dfd71bc2f57b696fc20017fc77df 100644 (file)
@@ -271,6 +271,8 @@ IndexSet::block_read(std::istream &in)
   if (n_ranges)
     in.read(reinterpret_cast<char *>(&*ranges.begin()),
             ranges.size() * sizeof(Range));
+
+  do_compress(); // needed so that largest_range can be recomputed
 }
 
 
diff --git a/tests/base/index_set_readwrite_03.cc b/tests/base/index_set_readwrite_03.cc
new file mode 100644 (file)
index 0000000..4ddef58
--- /dev/null
@@ -0,0 +1,67 @@
+// ---------------------------------------------------------------------
+// $Id: index_set_readwrite_02.cc 30045 2013-07-18 19:18:00Z maier $
+//
+// Copyright (C) 2010 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+// document a bug in IndexSet::block_read() and block_write(),
+// because largest_range was not serialized/reset.
+
+#include "../tests.h"
+#include <iomanip>
+#include <iomanip>
+#include <fstream>
+#include <cmath>
+#include <cstdio>
+#include <stdlib.h>
+
+#include <deal.II/base/index_set.h>
+
+
+void test ()
+{
+  IndexSet is1(250);
+  is1.add_range(125,200);
+  is1.add_range(0,75);
+
+  {
+    std::ofstream out("index_set_readwrite_03/a.idxset");
+    is1.block_write(out);
+  }
+
+  IndexSet is2;
+  std::ifstream in("index_set_readwrite_03/a.idxset");
+  is2.block_read(in);
+
+  Assert(is1 == is2, ExcInternalError());
+
+  deallog << is1.is_element(4) << " " << is2.is_element(4) << std::endl;
+  
+  deallog << "OK" << std::endl;
+
+  std::remove ("index_set_readwrite_03/a.idxset");
+}
+
+
+
+
+int main()
+{
+  std::ofstream logfile("index_set_readwrite_03/output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test ();
+}
diff --git a/tests/base/index_set_readwrite_03/cmp/generic b/tests/base/index_set_readwrite_03/cmp/generic
new file mode 100644 (file)
index 0000000..5530e5d
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::1 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.