]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add functions to the iterators to access the active_cell_index field.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 10 Apr 2015 21:17:35 +0000 (16:17 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 13 Apr 2015 00:10:17 +0000 (19:10 -0500)
include/deal.II/grid/tria_accessor.h
source/grid/tria_accessor.cc

index 1c0f4d12ee372530421e443ec94d61ba4ab842f5..36d9a27436961b04f18bb6a28c1b43eaeed26afd 100644 (file)
@@ -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.
    */
index 9d00889701fa17afcc763ec4fa3305fce6062b51..712d430468ff735b1a5ee3aab343044da1e57423 100644 (file)
@@ -1529,6 +1529,17 @@ CellAccessor<dim, spacedim>::set_direction_flag (const bool new_direction_flag)
 
 
 
+template <int dim, int spacedim>
+void
+CellAccessor<dim, spacedim>::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 <int dim, int spacedim>
 void
 CellAccessor<dim, spacedim>::set_parent (const unsigned int parent_index)
@@ -1555,6 +1566,18 @@ parent_index () const
 }
 
 
+
+template <int dim, int spacedim>
+unsigned int
+CellAccessor<dim, spacedim>::
+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 <int dim, int spacedim>
 TriaIterator<CellAccessor<dim,spacedim> >
 CellAccessor<dim, spacedim>::parent () 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.