]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Move TriaAccessor::parent_index to class CellAccessor since we keep this information...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 16 Mar 2014 01:18:41 +0000 (01:18 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 16 Mar 2014 01:18:41 +0000 (01:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@32659 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/dofs/dof_accessor.h
deal.II/include/deal.II/dofs/dof_accessor.templates.h
deal.II/include/deal.II/grid/tria_accessor.h
deal.II/include/deal.II/grid/tria_accessor.templates.h
deal.II/include/deal.II/grid/tria_levels.h
deal.II/source/grid/tria_accessor.cc

index 258320b307f3d879a76342555e322371da7ceef1..9a503c41dd28cd0938a1434ef3a792e037776405 100644 (file)
@@ -90,8 +90,7 @@ inconvenience this causes.
 
 
 <ol>
-
-  <li> Changed: the functionparser library bundled with deal.II got replaced
+  <li> Changed: The functionparser library bundled with deal.II got replaced
   by the muparser library.  
   <br>
   (Timo Heister, 2014/02/10)
@@ -149,6 +148,12 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li> Changed: Class TriaAccessor had a function parent_index(), but this function
+  could only work for cell accessors. The function has consequently been moved
+  to class CellAccessor.
+  <br>
+  (Wolfgang Bangerth, 2014/03/15)
+  </li>
 
   <li> Fixed: step-32 had a piece of code where we accessed an internal
   representation of how Trilinos vectors are actually stored. This is poor
index 1c56c862d52c3bd5b4e26377f1d6091d427203ec..b2ed4084f5ec4106e13c36a2a774dc9b5ab0ba75 100644 (file)
@@ -290,12 +290,6 @@ public:
    */
   static bool is_level_cell();
 
-  /**
-   * Return an iterator pointing to the the parent.
-   */
-  TriaIterator<DoFAccessor<structdim,DH, level_dof_access> >
-  parent () const;
-
   /**
    *  @name Accessing sub-objects
    */
@@ -826,12 +820,6 @@ public:
    */
   void copy_from (const TriaAccessorBase<0, 1, spacedim> &da);
 
-  /**
-   * Return an iterator pointing to the the parent.
-   */
-  TriaIterator<DoFAccessor<0,DH<1,spacedim>, level_dof_access> >
-  parent () const;
-
   /**
    *  @name Accessing sub-objects
    */
@@ -1259,9 +1247,13 @@ public:
    */
 
   /**
-   * Return the parent as a DoF cell iterator. This function is needed
-   * since the parent function of the base class returns a cell
-   * accessor without access to the DoF data.
+   * Return the parent of this cell as a DoF cell iterator.
+   * If the parent does not exist (i.e., if the object is at the coarsest level of
+   * the mesh hierarchy), an exception is generated.
+   *
+   * This function is needed
+   * since the parent function of the base class CellAccessor returns a triangulation
+   * cell accessor without access to the DoF data.
    */
   TriaIterator<DoFCellAccessor<DH, level_dof_access> >
   parent () const;
index ec4b9754424cfd9a6b481d92073d97418f8c6c09..42446a05c0d516235405b33551b0d3a9cb3a0308 100644 (file)
@@ -188,34 +188,6 @@ DoFAccessor<structdim,DH,level_dof_access>::child (const unsigned int i) const
 }
 
 
-template <int structdim, class DH, bool level_dof_access>
-inline
-TriaIterator<DoFAccessor<structdim,DH,level_dof_access> >
-DoFAccessor<structdim,DH,level_dof_access>::parent () const
-{
-  Assert (static_cast<unsigned int>(this->level()) < this->dof_handler->levels.size(),
-          ExcMessage ("DoFHandler not initialized"));
-  Assert (this->level () > 0,
-          ExcMessage ("Cell is at coarsest level."));
-
-  int previous_level;
-
-  if (DH::dimension==structdim)
-    previous_level = this->level () - 1;
-
-  else
-    previous_level = 0;
-
-  TriaIterator<DoFAccessor<structdim,DH,level_dof_access> > q (this->tria,
-                                                  previous_level,
-                                                  this->parent_index (),
-                                                  this->dof_handler);
-
-  return q;
-}
-
-
-
 namespace internal
 {
   namespace DoFAccessor
index a29335112ae7cb78896b1c332fed53a46bd9e9a2..7bf2018ff6d5154cf0563a63996b4a75d16d9d1a 100644 (file)
@@ -732,18 +732,6 @@ public:
    */
   bool used () const;
 
-  /**
-   *  Index of the parent.
-   *  The level of the parent is one
-   *  lower than that of the
-   *  present cell, if the parent
-   *  of a cell is accessed. If the
-   *  parent does not exist, -1 is
-   *  returned.
-   */
-  int parent_index () const;
-
-
   /**
    *  @name Accessing sub-objects
    */
@@ -1610,11 +1598,6 @@ private:
    */
   void clear_refinement_case () const;
 
-  /**
-   * Set the parent of a cell.
-   */
-  void set_parent (const unsigned int parent_index);
-
   /**
    *  Set the index of the ith
    *  child. Since the children
@@ -1887,12 +1870,6 @@ public:
    * @}
    */
 
-  /**
-   *  Index of the parent. You
-   *  can't do this for points.
-   */
-  static int parent_index ();
-
   /**
    *  @name Accessing sub-objects
    */
@@ -2836,12 +2813,22 @@ public:
    */
   bool direction_flag () const;
 
-
+  /**
+   *  Index of the parent of this cell.
+   *  The level of the parent is one
+   *  lower than that of the
+   *  present cell, if the parent
+   *  of a cell is accessed. If the
+   *  parent does not exist (i.e., if the object is at the coarsest level of
+   *  the mesh hierarchy), an exception is generated.
+   */
+  int parent_index () const;
 
   /**
    *  Return an iterator to the
-   *  parent. Throws an exception if this cell has no parent, i.e. has
-   *  level 0.
+   *  parent. If the
+   *  parent does not exist (i.e., if the object is at the coarsest level of
+   *  the mesh hierarchy), an exception is generated.
    */
   TriaIterator<CellAccessor<dim,spacedim> >
   parent () const;
@@ -3101,6 +3088,11 @@ protected:
 
 
 private:
+  /**
+   * Set the parent of a cell.
+   */
+  void set_parent (const unsigned int parent_index);
+
   /**
    * Set the orientation of this
    * cell.
index bdf5d52cabf5feb86adb87c4d28f752b0acdd743..19bb7ad61a3148733855692ed674fc1dcc00c4ec 100644 (file)
@@ -1366,20 +1366,6 @@ TriaAccessor<structdim, dim, spacedim>::clear_used_flag () const
 }
 
 
-template <int structdim, int dim, int spacedim>
-int
-TriaAccessor<structdim, dim, spacedim>::
-parent_index () const
-{
-  Assert (this->present_level > 0, TriaAccessorExceptions::ExcCellHasNoParent ());
-
-  // the parent of two consecutive cells
-  // is stored only once, since it is
-  // the same
-  return this->tria->levels[this->present_level]->parents[this->present_index / 2];
-}
-
-
 template <int structdim, int dim, int spacedim>
 int
 TriaAccessor<structdim, dim, spacedim>::
@@ -1638,18 +1624,6 @@ TriaAccessor<structdim, dim, spacedim>::set_children (const unsigned int i,
 
 
 
-template <int structdim, int dim, int spacedim>
-void
-TriaAccessor<structdim, dim, spacedim>::set_parent (const unsigned int parent_index)
-{
-  Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
-  Assert (this->present_level > 0, TriaAccessorExceptions::ExcCellHasNoParent ());
-  this->tria->levels[this->present_level]->parents[this->present_index / 2]
-    = parent_index;
-}
-
-
-
 template <int structdim, int dim, int spacedim>
 void
 TriaAccessor<structdim, dim, spacedim>::clear_children () const
@@ -2202,16 +2176,6 @@ TriaAccessor<0, 1, spacedim>::operator != (const TriaAccessor &t) const
 
 
 
-
-template <int spacedim>
-inline
-int
-TriaAccessor<0, 1, spacedim>::parent_index ()
-{
-  return -1;
-}
-
-
 template <int spacedim>
 inline
 unsigned int
index 1bdc99ab65f6cdd0a67534686d4765b8f9a57f83..90a107b544b302af4e6d07067be7b8fc552653cd 100644 (file)
@@ -39,7 +39,7 @@ namespace internal
      * In TriaLevel, all cell data is stored which is not dependent on the
      * dimension, e.g. a field to store the refinement flag for the cells
      * (what a cell actually is is declared elsewhere), etc. See also
-     * TriaObjects for non leveloriented data.
+     * TriaObjects for non level-oriented data.
      *
      * There is another field, which may fit in here, namely the
      * material data (for cells) or the boundary indicators (for faces),
@@ -154,6 +154,11 @@ namespace internal
        * One integer for every consecutive
        * pair of cells to store which
        * index their parent has.
+       *
+       * (We store this information once for each pair of cells since every
+       * refinement, isotropic or anisotropic, and in any space dimension,
+       * always creates children in multiples of two, so there is no need to
+       * store the parent index for every cell.)
        */
       std::vector<int> parents;
 
index 7bccde417aa64bde9689eca830128e504baae899..3050f7448d3f09a983f2c84932a328add5894f9c 100644 (file)
@@ -1398,6 +1398,32 @@ CellAccessor<dim, spacedim>::set_direction_flag (const bool new_direction_flag)
 
 
 
+template <int dim, int spacedim>
+void
+CellAccessor<dim, spacedim>::set_parent (const unsigned int parent_index)
+{
+  Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
+  Assert (this->present_level > 0, TriaAccessorExceptions::ExcCellHasNoParent ());
+  this->tria->levels[this->present_level]->parents[this->present_index / 2]
+    = parent_index;
+}
+
+
+
+template <int dim, int spacedim>
+int
+CellAccessor<dim, spacedim>::
+parent_index () const
+{
+  Assert (this->present_level > 0, TriaAccessorExceptions::ExcCellHasNoParent ());
+
+  // the parent of two consecutive cells
+  // is stored only once, since it is
+  // the same
+  return this->tria->levels[this->present_level]->parents[this->present_index / 2];
+}
+
+
 template <int dim, int spacedim>
 TriaIterator<CellAccessor<dim,spacedim> >
 CellAccessor<dim, spacedim>::parent () const
@@ -1405,7 +1431,7 @@ CellAccessor<dim, spacedim>::parent () const
   Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
   Assert (this->present_level > 0, TriaAccessorExceptions::ExcCellHasNoParent ());
   TriaIterator<CellAccessor<dim,spacedim> >
-  q (this->tria, this->present_level-1, this->parent_index ());
+  q (this->tria, this->present_level-1, parent_index ());
 
   return q;
 }

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.