]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Update the CellId class.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 18 Aug 2016 18:54:02 +0000 (12:54 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 19 Aug 2016 15:22:34 +0000 (09:22 -0600)
This basically just applies the style we use everywhere else to this class,
i.e., make the documentation more uniform, make some arguments 'const' or
a reference, move function definitions out of line, etc.

include/deal.II/grid/cell_id.h

index 347cf5cf8aaa3d7aea8abe5b28bd5da700bd1d03..8b88ee563a85644adbaad58fe7fe627ebe0ab18c 100644 (file)
@@ -57,18 +57,15 @@ class CellId
 {
 public:
   /**
-   * construct CellId with a given coarse_cell_index and list of child indices
+   * Construct a CellId object with a given @p coarse_cell_index and list of child indices.
    */
-  explicit CellId(unsigned int coarse_cell_id_, std::vector<unsigned char> id_)
-    : coarse_cell_id(coarse_cell_id_), id(id_)
-  {}
+  CellId(const unsigned int coarse_cell_id,
+         const std::vector<unsigned char> &child_indices);
 
   /**
-   * construct an empty CellId.
+   * Construct an invalid CellId.
    */
-  CellId()
-    : coarse_cell_id(static_cast<unsigned int>(-1))
-  {}
+  CellId();
 
   /**
    * Return a string representation of this CellId.
@@ -83,31 +80,49 @@ public:
   to_cell(const Triangulation<dim,spacedim> &tria) const;
 
   /**
-   * compare two CellIds
+   * Compare two CellId objects for equality.
    */
   bool operator== (const CellId &other) const;
 
   /**
-   * compare two CellIds
+   * Compare two CellIds for inequality.
    */
   bool operator!= (const CellId &other) const;
 
   /**
-   * compare two CellIds
+   * Compare two CellIds with regard to an ordering. The details of this
+   * ordering are unspecified except that the operation provides a
+   * total ordering among all cells.
    */
   bool operator<(const CellId &other) const;
 
-  friend std::istream &operator>> (std::istream &is, CellId &cid);
-  friend std::ostream &operator<< (std::ostream &os, const CellId &cid);
 private:
+  /**
+   * The number of the coarse cell within whose tree the cell
+   * represented by the current object is located.
+   */
   unsigned int coarse_cell_id;
+
+  /**
+   * A list of integers that denote which child to pick from one
+   * refinement level to the next, starting with the coarse cell,
+   * until we get to the cell represented by the current object.
+   */
   std::vector<unsigned char> id;
+
+  friend std::istream &operator>> (std::istream &is, CellId &cid);
+  friend std::ostream &operator<< (std::ostream &os, const CellId &cid);
 };
 
+
+
+
 /**
- * output CellId into a stream
+ * Write a CellId object into a stream.
  */
-inline std::ostream &operator<< (std::ostream &os, const CellId &cid)
+inline
+std::ostream &operator<< (std::ostream &os,
+                          const CellId &cid)
 {
   os << cid.coarse_cell_id << '_' << cid.id.size() << ':';
   for (unsigned int i=0; i<cid.id.size(); ++i)
@@ -115,10 +130,14 @@ inline std::ostream &operator<< (std::ostream &os, const CellId &cid)
   return os;
 }
 
+
+
 /**
- * read CellId from a stream
+ * Read a CellId object from a stream.
  */
-inline std::istream &operator>> (std::istream &is, CellId &cid)
+inline
+std::istream &operator>> (std::istream &is,
+                          CellId &cid)
 {
   unsigned int cellid;
   is >> cellid;
@@ -144,6 +163,24 @@ inline std::istream &operator>> (std::istream &is, CellId &cid)
   return is;
 }
 
+
+inline
+CellId::CellId(const unsigned int coarse_cell_id,
+               const std::vector<unsigned char> &id)
+  :
+  coarse_cell_id(coarse_cell_id),
+  id(id)
+{}
+
+
+inline
+CellId::CellId()
+  :
+  coarse_cell_id(static_cast<unsigned int>(-1))
+{}
+
+
+
 inline bool
 CellId::operator== (const CellId &other) const
 {
@@ -152,12 +189,16 @@ CellId::operator== (const CellId &other) const
   return id == other.id;
 }
 
+
+
 inline bool
 CellId::operator!= (const CellId &other) const
 {
   return !(*this == other);
 }
 
+
+
 inline
 bool CellId::operator<(const CellId &other) const
 {

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.