]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
implement reading/writing IndexSet from file.
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 22 Jun 2010 21:58:56 +0000 (21:58 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 22 Jun 2010 21:58:56 +0000 (21:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@21272 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/index_set.h
deal.II/base/source/index_set.cc

index c427183c3799dbb167ed42dd60188a40a3fe6d11..3a3bfc07f4b40285e04fcfb1d43030a2c44c26a5 100644 (file)
@@ -250,6 +250,22 @@ class IndexSet
     template <class STREAM>
     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,
index 0c3d652822cf3e75b938ece8284a761bcebe38f7..3d1d4f8464751d850001e5ce375ae190468d7433 100644 (file)
@@ -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<Range>::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<numranges;++i)
+    {
+      in >> b >> e;
+      add_range(b,e);
+    }
+}
+
+
+
 void
 IndexSet::subtract_set (const IndexSet & other)
 {
@@ -299,6 +331,9 @@ void IndexSet::fill_index_vector(std::vector<unsigned int> & indices) const
 }
 
 
+
+
+
 #ifdef DEAL_II_USE_TRILINOS
 
 Epetra_Map

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.