]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Better document what happens when in/outputting CellId objects. 2987/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 18 Aug 2016 21:07:07 +0000 (15:07 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 19 Aug 2016 15:22:36 +0000 (09:22 -0600)
include/deal.II/grid/cell_id.h

index 11e092454a6aeb3b59c056fa76fced53eac85a51..a4bce635b75e86705ef9c56d83607761d989902a 100644 (file)
@@ -126,7 +126,11 @@ std::ostream &operator<< (std::ostream &os,
 {
   os << cid.coarse_cell_id << '_' << cid.child_indices.size() << ':';
   for (unsigned int i=0; i<cid.child_indices.size(); ++i)
-    os << static_cast<int>(cid.child_indices[i]);
+    // write the child indices. because they are between 0 and 2^dim-1, they all
+    // just have one digit, so we could write them as integers. it's
+    // probably clearer to write them as one-digit characters starting
+    // at '0'
+    os << static_cast<unsigned char>(cid.child_indices[i] + '0');
   return os;
 }
 
@@ -157,6 +161,8 @@ std::istream &operator>> (std::istream &is,
   cid.child_indices.clear();
   for (unsigned int i=0; i<idsize; ++i)
     {
+      // read the one-digit child index (as an integer number) and
+      // convert it back into unsigned char
       is >> value;
       cid.child_indices.push_back(value-'0');
     }

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.