From 7fcd24df853752c69d8da077d7615982f2a9b634 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 18 Aug 2016 12:54:02 -0600 Subject: [PATCH] Update the CellId class. 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 | 75 ++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/include/deal.II/grid/cell_id.h b/include/deal.II/grid/cell_id.h index 347cf5cf8a..8b88ee563a 100644 --- a/include/deal.II/grid/cell_id.h +++ b/include/deal.II/grid/cell_id.h @@ -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 id_) - : coarse_cell_id(coarse_cell_id_), id(id_) - {} + CellId(const unsigned int coarse_cell_id, + const std::vector &child_indices); /** - * construct an empty CellId. + * Construct an invalid CellId. */ - CellId() - : coarse_cell_id(static_cast(-1)) - {} + CellId(); /** * Return a string representation of this CellId. @@ -83,31 +80,49 @@ public: to_cell(const Triangulation &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 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> (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 &id) + : + coarse_cell_id(coarse_cell_id), + id(id) +{} + + +inline +CellId::CellId() + : + coarse_cell_id(static_cast(-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 { -- 2.39.5