From: heister Date: Wed, 31 Jul 2013 13:34:45 +0000 (+0000) Subject: fix bug in IndexSet X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2079ddd1d0fe8e11f0b46a1b626db91e7b34f20f;p=dealii-svn.git fix bug in IndexSet git-svn-id: https://svn.dealii.org/trunk@30192 0785d39b-7218-0410-832d-ea1e28bc413d --- 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