From: Wolfgang Bangerth Date: Fri, 10 Apr 2015 21:17:35 +0000 (-0500) Subject: Add functions to the iterators to access the active_cell_index field. X-Git-Tag: v8.3.0-rc1~274^2~13 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dc2e1dc5ab39f118d71d37fcfae99a967b56fe4a;p=dealii.git Add functions to the iterators to access the active_cell_index field. --- diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index 1c0f4d12ee..36d9a27436 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -2450,7 +2450,21 @@ public: bool direction_flag () const; /** - * Index of the parent of this cell within the level of the triangulation to + * Return the how many-th active cell the current cell is (assuming + * the current cell is indeed active). This is useful, for example, + * if you are accessing the elements of a vector with as many + * entries as there are active cells. Such vectors are used for + * estimating the error on each cell of a triangulation, for + * specifying refinement criteria passed to the functions in + * GridRefinement, and for generating cell-wise output. + * + * The function throws an exception if the current cell is not + * active. + */ + unsigned int active_cell_index () const; + + /** + * Return the index of the parent of this cell within the level of the triangulation to * which the parent cell belongs. The level of the parent is of course one * lower than that of the present cell. If the parent does not exist (i.e., * if the object is at the coarsest level of the mesh hierarchy), an @@ -2655,6 +2669,11 @@ protected: private: + /** + * Set the active cell index of a cell. This is done at the end of refinement. + */ + void set_active_cell_index (const unsigned int active_cell_index); + /** * Set the parent of a cell. */ diff --git a/source/grid/tria_accessor.cc b/source/grid/tria_accessor.cc index 9d00889701..712d430468 100644 --- a/source/grid/tria_accessor.cc +++ b/source/grid/tria_accessor.cc @@ -1529,6 +1529,17 @@ CellAccessor::set_direction_flag (const bool new_direction_flag) +template +void +CellAccessor::set_active_cell_index (const unsigned int active_cell_index) +{ + Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed()); + this->tria->levels[this->present_level]->active_cell_indices[this->present_index] + = active_cell_index; +} + + + template void CellAccessor::set_parent (const unsigned int parent_index) @@ -1555,6 +1566,18 @@ parent_index () const } + +template +unsigned int +CellAccessor:: +active_cell_index () const +{ + Assert (this->has_children()==false, TriaAccessorExceptions::ExcCellNotActive()); + return this->tria->levels[this->present_level]->active_cell_indices[this->present_index]; +} + + + template TriaIterator > CellAccessor::parent () const