From 2079ddd1d0fe8e11f0b46a1b626db91e7b34f20f Mon Sep 17 00:00:00 2001 From: heister Date: Wed, 31 Jul 2013 13:34:45 +0000 Subject: [PATCH] fix bug in IndexSet git-svn-id: https://svn.dealii.org/trunk@30192 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/base/index_set.cc | 2 + tests/base/index_set_readwrite_03.cc | 67 +++++++++++++++++++ tests/base/index_set_readwrite_03/cmp/generic | 3 + 3 files changed, 72 insertions(+) create mode 100644 tests/base/index_set_readwrite_03.cc create mode 100644 tests/base/index_set_readwrite_03/cmp/generic diff --git a/deal.II/source/base/index_set.cc b/deal.II/source/base/index_set.cc index bf373ddd5f..ce4b5bcfb7 100644 --- a/deal.II/source/base/index_set.cc +++ b/deal.II/source/base/index_set.cc @@ -271,6 +271,8 @@ IndexSet::block_read(std::istream &in) if (n_ranges) in.read(reinterpret_cast(&*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 index 0000000000..4ddef5888c --- /dev/null +++ b/tests/base/index_set_readwrite_03.cc @@ -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 +#include +#include +#include +#include +#include + +#include + + +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 index 0000000000..5530e5d5d2 --- /dev/null +++ b/tests/base/index_set_readwrite_03/cmp/generic @@ -0,0 +1,3 @@ + +DEAL::1 1 +DEAL::OK -- 2.39.5