From fb34df1a98869013344c4904d87e7ff91a005583 Mon Sep 17 00:00:00 2001 From: heister Date: Tue, 22 Jun 2010 21:58:56 +0000 Subject: [PATCH] implement reading/writing IndexSet from file. git-svn-id: https://svn.dealii.org/trunk@21272 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/index_set.h | 16 ++++++++++++ deal.II/base/source/index_set.cc | 35 +++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/deal.II/base/include/base/index_set.h b/deal.II/base/include/base/index_set.h index c427183c37..3a3bfc07f4 100644 --- a/deal.II/base/include/base/index_set.h +++ b/deal.II/base/include/base/index_set.h @@ -250,6 +250,22 @@ class IndexSet template void print(STREAM &out) const; + /** + * Writes the IndexSet into a text based + * file format, that can be read in again + * using the read() function. + */ + void write(std::ostream & out) const; + + /** + * Constructs the IndexSet from a text + * based representation given by the + * stream @param in written by the + * write() function. + */ + void read(std::istream & in); + + #ifdef DEAL_II_USE_TRILINOS /** * Given an MPI communicator, diff --git a/deal.II/base/source/index_set.cc b/deal.II/base/source/index_set.cc index 0c3d652822..3d1d4f8464 100644 --- a/deal.II/base/source/index_set.cc +++ b/deal.II/base/source/index_set.cc @@ -201,6 +201,38 @@ IndexSet::get_view (const unsigned int begin, } + +void +IndexSet::write(std::ostream & out) const +{ + compress(); + out << size() << " "; + out << ranges.size() << std::endl; + std::vector::const_iterator r = ranges.begin(); + for ( ;r!=ranges.end(); ++r) + { + out << r->begin << " " << r->end << std::endl; + } +} + + + +void +IndexSet::read(std::istream & in) +{ + unsigned int s, numranges, b, e; + in >> s >> numranges; + ranges.clear(); + set_size(s); + for (unsigned int i=0;i> b >> e; + add_range(b,e); + } +} + + + void IndexSet::subtract_set (const IndexSet & other) { @@ -299,6 +331,9 @@ void IndexSet::fill_index_vector(std::vector & indices) const } + + + #ifdef DEAL_II_USE_TRILINOS Epetra_Map -- 2.39.5