]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Split the TriaAccessor class into two, one that handles cells and one that handles...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 Mar 2007 20:45:49 +0000 (20:45 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 5 Mar 2007 20:45:49 +0000 (20:45 +0000)
git-svn-id: https://svn.dealii.org/trunk@14521 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/dofs/dof_accessor.templates.h
deal.II/deal.II/include/grid/tria.h
deal.II/deal.II/include/grid/tria_accessor.h
deal.II/deal.II/include/grid/tria_accessor.templates.h
deal.II/deal.II/include/grid/tria_iterator_selector.h
deal.II/deal.II/source/grid/tria_accessor.cc
deal.II/deal.II/source/multigrid/mg_dof_accessor.cc

index d4f3a92c30a6fe9e4d216dd122efd5a77807bf92..a72e369f591fa93ba334451cbad34104bde27267 100644 (file)
@@ -127,12 +127,12 @@ inline
 TriaIterator<DH::dimension,DoFObjectAccessor<structdim,DH> >
 DoFAccessor<structdim,DH>::child (const unsigned int i) const
 {
-  Assert (static_cast<unsigned int>(this->present_level) < this->dof_handler->levels.size(),
+  Assert (static_cast<unsigned int>(this->level()) < this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
 
   int next_level;
   if (DH::dimension==structdim)
-    next_level = this->present_level+1;
+    next_level = this->level()+1;
   else
     next_level = 0;
   
@@ -192,7 +192,7 @@ DoFAccessor<dim,DH>::dof_index (const unsigned int i,
 {
                                   // access the respective DoF 
   return this->dof_handler
-    ->template get_dof_index<dim> (this->present_level,
+    ->template get_dof_index<dim> (this->level(),
                                   this->present_index,
                                   fe_index,
                                   i);
@@ -209,7 +209,7 @@ DoFAccessor<dim,DH>::set_dof_index (const unsigned int i,
 {
                                   // access the respective DoF
   this->dof_handler
-    ->template set_dof_index<dim> (this->present_level,
+    ->template set_dof_index<dim> (this->level(),
                                   this->present_index,
                                   fe_index,
                                   i,
@@ -225,7 +225,7 @@ DoFAccessor<dim,DH>::n_active_fe_indices () const
 {
                                   // access the respective DoF
   return this->dof_handler
-    ->template n_active_fe_indices<dim> (this->present_level,
+    ->template n_active_fe_indices<dim> (this->level(),
                                         this->present_index);
 }
 
@@ -238,7 +238,7 @@ DoFAccessor<dim,DH>::nth_active_fe_index (const unsigned int n) const
 {
                                   // access the respective DoF
   return this->dof_handler
-    ->template nth_active_fe_index<dim> (this->present_level,
+    ->template nth_active_fe_index<dim> (this->level(),
                                         this->present_index,
                                         n);
 }
@@ -252,7 +252,7 @@ DoFAccessor<dim,DH>::fe_index_is_active (const unsigned int fe_index) const
 {
                                   // access the respective DoF
   return this->dof_handler
-    ->template fe_index_is_active<dim> (this->present_level,
+    ->template fe_index_is_active<dim> (this->level(),
                                        this->present_index,
                                        fe_index);
 }
@@ -365,7 +365,7 @@ void
 DoFObjectAccessor<1,DH>::get_dof_indices (std::vector<unsigned int> &dof_indices,
                                          const unsigned int         fe_index) const
 {
-  Assert (static_cast<unsigned int>(this->present_level) < this->dof_handler->levels.size(),
+  Assert (static_cast<unsigned int>(this->level()) < this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
 
   Assert (this->dof_handler != 0, typename BaseClass::ExcInvalidObject());
@@ -425,7 +425,7 @@ TriaIterator<DH::dimension,DoFObjectAccessor<1,DH> >
 DoFObjectAccessor<2,DH>::line (const unsigned int i) const
 {
   Assert (i<4, ExcIndexRange (i, 0, 4));
-  Assert (static_cast<unsigned int>(this->present_level) < this->dof_handler->levels.size(),
+  Assert (static_cast<unsigned int>(this->level()) < this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
 
   return TriaIterator<dim,DoFObjectAccessor<1,DH> >
@@ -471,7 +471,7 @@ DoFObjectAccessor<2,DH>::get_dof_indices (std::vector<unsigned int> &dof_indices
           4*this->dof_handler->get_fe()[fe_index].dofs_per_vertex),
          ExcInternalError());
          
-  Assert (static_cast<unsigned int>(this->present_level) < this->dof_handler->levels.size(),
+  Assert (static_cast<unsigned int>(this->level()) < this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
   
   const unsigned int dofs_per_vertex = this->dof_handler->get_fe()[fe_index].dofs_per_vertex,
@@ -567,7 +567,7 @@ DoFObjectAccessor<3,DH>::get_dof_indices (std::vector<unsigned int> &dof_indices
                                 6*this->dof_handler->get_fe()[fe_index].dofs_per_quad +
                                 this->dof_handler->get_fe()[fe_index].dofs_per_hex),
          typename BaseClass::ExcVectorDoesNotMatch());
-  Assert (static_cast<unsigned int>(this->present_level) < this->dof_handler->levels.size(),
+  Assert (static_cast<unsigned int>(this->level()) < this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
 
                                   // this function really only makes
@@ -587,7 +587,7 @@ DoFObjectAccessor<3,DH>::get_dof_indices (std::vector<unsigned int> &dof_indices
           8*this->dof_handler->get_fe()[fe_index].dofs_per_vertex),
          ExcInternalError());
 
-  Assert (static_cast<unsigned int>(this->present_level) < this->dof_handler->levels.size(),
+  Assert (static_cast<unsigned int>(this->level()) < this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
   
   const unsigned int dofs_per_vertex = this->dof_handler->get_fe()[fe_index].dofs_per_vertex,
@@ -680,7 +680,7 @@ TriaIterator<DH::dimension,DoFCellAccessor<DH> >
 DoFCellAccessor<DH>::child (const unsigned int i) const
 {
   TriaIterator<dim,DoFCellAccessor<DH> > q (this->tria,
-                                           this->present_level+1,
+                                           this->level()+1,
                                            this->child_index (i),
                                            this->dof_handler);
   
@@ -742,7 +742,7 @@ get_dof_indices (std::vector<unsigned int> &dof_indices) const
           this->get_fe().dofs_per_vertex * GeometryInfo<1>::vertices_per_cell),
          ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
   
-  unsigned int *cache = &this->dof_handler->levels[this->present_level]
+  unsigned int *cache = &this->dof_handler->levels[this->level()]
                        ->cell_dof_indices_cache[this->present_index * this->get_fe().dofs_per_cell]; 
   for (unsigned int i=0; i<this->get_fe().dofs_per_cell; ++i, ++cache)
     dof_indices[i] = *cache;
@@ -780,7 +780,7 @@ get_dof_indices (std::vector<unsigned int> &dof_indices) const
           this->get_fe().dofs_per_vertex * GeometryInfo<2>::vertices_per_cell),
          ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
   
-  unsigned int *cache = &this->dof_handler->levels[this->present_level]
+  unsigned int *cache = &this->dof_handler->levels[this->level()]
                        ->cell_dof_indices_cache[this->present_index * this->get_fe().dofs_per_cell]; 
   for (unsigned int i=0; i<this->get_fe().dofs_per_cell; ++i, ++cache)
     dof_indices[i] = *cache;
@@ -819,7 +819,7 @@ get_dof_indices (std::vector<unsigned int> &dof_indices) const
           this->get_fe().dofs_per_vertex * GeometryInfo<3>::vertices_per_cell),
          ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
   
-  unsigned int *cache = &this->dof_handler->levels[this->present_level]
+  unsigned int *cache = &this->dof_handler->levels[this->level()]
                        ->cell_dof_indices_cache[this->present_index * this->get_fe().dofs_per_cell]; 
   for (unsigned int i=0; i<this->get_fe().dofs_per_cell; ++i, ++cache)
     dof_indices[i] = *cache;
@@ -907,13 +907,13 @@ inline
 unsigned int
 DoFCellAccessor<hp::DoFHandler<1> >::active_fe_index () const
 {
-  Assert (static_cast<unsigned int>(this->present_level) < this->dof_handler->levels.size(),
+  Assert (static_cast<unsigned int>(this->level()) < this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
   Assert (static_cast<std::vector<unsigned int>::size_type>(this->present_index) <
-         this->dof_handler->levels[this->present_level]->active_fe_indices.size (),
+         this->dof_handler->levels[this->level()]->active_fe_indices.size (),
          ExcIndexRange (this->present_index, 0,
-                        this->dof_handler->levels[this->present_level]->active_fe_indices.size ()));
-  return this->dof_handler->levels[this->present_level]
+                        this->dof_handler->levels[this->level()]->active_fe_indices.size ()));
+  return this->dof_handler->levels[this->level()]
     ->active_fe_indices[this->present_index];
 }
 
@@ -924,13 +924,13 @@ inline
 unsigned int
 DoFCellAccessor<hp::DoFHandler<2> >::active_fe_index () const
 {
-  Assert (static_cast<unsigned int>(this->present_level) < this->dof_handler->levels.size(),
+  Assert (static_cast<unsigned int>(this->level()) < this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
   Assert (static_cast<std::vector<unsigned int>::size_type>(this->present_index) <
-         this->dof_handler->levels[this->present_level]->active_fe_indices.size (),
+         this->dof_handler->levels[this->level()]->active_fe_indices.size (),
          ExcIndexRange (this->present_index, 0,
-                        this->dof_handler->levels[this->present_level]->active_fe_indices.size ()));
-  return this->dof_handler->levels[this->present_level]
+                        this->dof_handler->levels[this->level()]->active_fe_indices.size ()));
+  return this->dof_handler->levels[this->level()]
     ->active_fe_indices[this->present_index];
 }
 
@@ -941,13 +941,13 @@ inline
 unsigned int
 DoFCellAccessor<hp::DoFHandler<3> >::active_fe_index () const
 {
-  Assert (static_cast<unsigned int>(this->present_level) < this->dof_handler->levels.size(),
+  Assert (static_cast<unsigned int>(this->level()) < this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
   Assert (static_cast<std::vector<unsigned int>::size_type>(this->present_index) <
-         this->dof_handler->levels[this->present_level]->active_fe_indices.size (),
+         this->dof_handler->levels[this->level()]->active_fe_indices.size (),
          ExcIndexRange (this->present_index, 0,
-                        this->dof_handler->levels[this->present_level]->active_fe_indices.size ()));
-  return this->dof_handler->levels[this->present_level]
+                        this->dof_handler->levels[this->level()]->active_fe_indices.size ()));
+  return this->dof_handler->levels[this->level()]
     ->active_fe_indices[this->present_index];
 }
 
@@ -960,14 +960,14 @@ DoFCellAccessor<hp::DoFHandler<1> >::set_active_fe_index (const unsigned int i)
 {
   Assert (this->dof_handler != 0,
           BaseClass::ExcInvalidObject());
-  Assert (static_cast<unsigned int>(this->present_level) <
+  Assert (static_cast<unsigned int>(this->level()) <
           this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
   Assert (static_cast<std::vector<unsigned int>::size_type>(this->present_index) <
-         this->dof_handler->levels[this->present_level]->active_fe_indices.size (),
+         this->dof_handler->levels[this->level()]->active_fe_indices.size (),
          ExcIndexRange (this->present_index, 0,
-                        this->dof_handler->levels[this->present_level]->active_fe_indices.size ()));
-  this->dof_handler->levels[this->present_level]
+                        this->dof_handler->levels[this->level()]->active_fe_indices.size ()));
+  this->dof_handler->levels[this->level()]
     ->active_fe_indices[this->present_index] = i;
 }
 
@@ -980,14 +980,14 @@ DoFCellAccessor<hp::DoFHandler<2> >::set_active_fe_index (const unsigned int i)
 {
   Assert (this->dof_handler != 0,
           BaseClass::ExcInvalidObject());
-  Assert (static_cast<unsigned int>(this->present_level) <
+  Assert (static_cast<unsigned int>(this->level()) <
           this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
   Assert (static_cast<std::vector<unsigned int>::size_type>(this->present_index) <
-         this->dof_handler->levels[this->present_level]->active_fe_indices.size (),
+         this->dof_handler->levels[this->level()]->active_fe_indices.size (),
          ExcIndexRange (this->present_index, 0,
-                        this->dof_handler->levels[this->present_level]->active_fe_indices.size ()));
-  this->dof_handler->levels[this->present_level]
+                        this->dof_handler->levels[this->level()]->active_fe_indices.size ()));
+  this->dof_handler->levels[this->level()]
     ->active_fe_indices[this->present_index] = i;
 }
 
@@ -1000,14 +1000,14 @@ DoFCellAccessor<hp::DoFHandler<3> >::set_active_fe_index (const unsigned int i)
 {
   Assert (this->dof_handler != 0,
           BaseClass::ExcInvalidObject());
-  Assert (static_cast<unsigned int>(this->present_level) <
+  Assert (static_cast<unsigned int>(this->level()) <
           this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
   Assert (static_cast<std::vector<unsigned int>::size_type>(this->present_index) <
-         this->dof_handler->levels[this->present_level]->active_fe_indices.size (),
+         this->dof_handler->levels[this->level()]->active_fe_indices.size (),
          ExcIndexRange (this->present_index, 0,
-                        this->dof_handler->levels[this->present_level]->active_fe_indices.size ()));
-  this->dof_handler->levels[this->present_level]
+                        this->dof_handler->levels[this->level()]->active_fe_indices.size ()));
+  this->dof_handler->levels[this->level()]
     ->active_fe_indices[this->present_index] = i;
 }
 
index c55eee4197896468e2275d4ced021b826af56f7f..8684358f454198dac5a7a7364c7838e432f5d230 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -3134,7 +3134,7 @@ class Triangulation : public Subscriptor
 
                                     // make a couple of classes
                                     // friends
-    template <int dim1> friend class TriaAccessor;
+    template <int,int> friend class TriaAccessor;
 
     template <int dim1, int dim2>
     friend class TriaObjectAccessor;
index a898b047e07b32c07e964a2788247d123e2e7d92..b45d70fb7618bad51036d5fb784a1134cf7d856e 100644 (file)
@@ -185,8 +185,158 @@ namespace TriaAccessorExceptions
  * @ingroup Accessors
  * @author Wolfgang Bangerth, 1998
  */
-template <int dim>
+template <int structdim, int dim>
 class TriaAccessor
+{
+  protected:
+                                    /**
+                                     * Declare the data type that
+                                     * this accessor class expects to
+                                     * get passed from the iterator
+                                     * classes. Since the pure
+                                     * triangulation iterators need
+                                     * no additional data, this data
+                                     * type is @p void.
+                                     */
+    typedef void AccessorData;
+
+                                    /**
+                                     *  Constructor. Protected, thus
+                                     *  only callable from friend
+                                     *  classes.
+                                     */
+    TriaAccessor (const Triangulation<dim> *parent =  0,
+                 const int                 level  = -1,
+                 const int                 index  = -1,
+                 const AccessorData       *       =  0);
+
+                                    /**
+                                     *  Copy operator. Since this is
+                                     *  only called from iterators,
+                                     *  do not return anything, since
+                                     *  the iterator will return
+                                     *  itself.
+                                     *
+                                     *  This method is protected,
+                                     *  since it is only to be called
+                                     *  from the iterator class.
+                                     */
+    void copy_from (const TriaAccessor &);
+
+                                    /**
+                                     *  Copy operator. This is normally
+                                     *  used in a context like
+                                     *  <tt>iterator a,b;  *a=*b;</tt>. Since
+                                     *  the meaning is to copy the object
+                                     *  pointed to by @p b to the object
+                                     *  pointed to by @p a and since
+                                     *  accessors are not real but
+                                     *  virtual objects, this operation
+                                     *  is not useful for iterators on
+                                     *  triangulations. We declare this
+                                     *  function here private, thus it may
+                                     *  not be used from outside.
+                                     *  Furthermore it is not implemented
+                                     *  and will give a linker error if
+                                     *  used anyway.
+                                     */
+    void operator = (const TriaAccessor *);
+    
+                                    /**
+                                     *  Same as above.
+                                     */
+    TriaAccessor & operator = (const TriaAccessor &);
+
+  protected:
+    
+                                    /**
+                                     *  Compare for equality.            
+                                     */
+    bool operator == (const TriaAccessor &) const;
+       
+                                    /**
+                                     * Compare for inequality.
+                                     */
+    bool operator != (const TriaAccessor &) const;
+    
+  public:
+                                    /**
+                                     * Data type to be used for passing
+                                     * parameters from iterators to the
+                                     * accessor classes in a unified
+                                     * way, no matter what the type of
+                                     * number of these parameters is.
+                                     */
+    typedef void * LocalData;
+    
+                                    /**@ name Iterator address and state
+                                     */
+                                    /*@{*/
+                                    /**
+                                     *  Return the level the element
+                                     *  pointed to belongs to.
+                                     *  This is only valid for cells.
+                                     */
+    static int level ();
+    
+                                    /**
+                                     *  Return the index of the
+                                     *  element presently pointed to
+                                     *  on the present level.
+                                     */
+    int index () const;
+    
+                                    /**
+                                     *  Return the state of the
+                                     *  iterator.  For the different
+                                     *  states an accessor can be in,
+                                     *  refer to the
+                                     *  TriaRawIterator
+                                     *  documentation.
+                                     */
+    IteratorState::IteratorStates state () const;
+
+                                    /**
+                                     * Return a pointer to the
+                                     * triangulation which the object
+                                     * pointed to by this class
+                                     * belongs to.
+                                     */
+    const Triangulation<dim> & get_triangulation () const;
+    
+                                    /*@}*/
+  protected:
+                                    /**
+                                     *  Used to store the index of
+                                     *  the element presently pointed
+                                     *  to on the level presentl
+                                     *  used.
+                                     */
+    int present_index;
+    
+                                    /**
+                                     *  Pointer to the triangulation
+                                     *  which we act on.
+                                     */
+    const Triangulation<dim> *tria;
+
+  private:
+    
+                                    /**
+                                     * Dimension of the TriaObject
+                                     * this accessor gives access to.
+                                     */
+    static const unsigned int objectdim = dim;
+
+    template <int anydim, typename Accessor> friend class TriaRawIterator;
+    template <int anydim, typename Accessor> friend class TriaIterator;
+    template <int anydim, typename Accessor> friend class TriaActiveIterator;
+};
+
+
+
+template <int dim>
+class TriaAccessor<dim,dim>
 {
   protected:
                                     /**
@@ -343,6 +493,7 @@ class TriaAccessor
 
 
 
+
 /**
  * Common template for line, quad, hex accessors.  According to
  * @p celldim, objects of this class represent lines, quadrilaterals,
@@ -356,14 +507,14 @@ class TriaAccessor
  * @author Wolfgang Bangerth, Guido Kanschat, 1999
  */
 template <int celldim, int dim>
-class TriaObjectAccessor :  public TriaAccessor<dim>
+class TriaObjectAccessor :  public TriaAccessor<celldim,dim>
 {
   public:
                                     /**
                                      * Propagate typedef from
                                      * base class to this class.
                                      */
-    typedef typename TriaAccessor<dim>::AccessorData AccessorData;
+    typedef typename TriaAccessor<celldim,dim>::AccessorData AccessorData;
 
                                     /**
                                      * Constructor.
@@ -397,13 +548,6 @@ class TriaObjectAccessor :  public TriaAccessor<dim>
                                      */
     void set (const internal::Triangulation::Hexahedron&) const;
 
-                                    /**
-                                     *  Return the level the element
-                                     *  pointed to belongs to.
-                                     *  This is only valid for cells.
-                                     */
-    int level () const;
-    
                                     /**
                                      *  Index of vertex. The convention
                                      *  regarding the numbering of vertices
@@ -1001,14 +1145,14 @@ class TriaObjectAccessor :  public TriaAccessor<dim>
  * @ingroup grid
  */
 template<int dim>
-class TriaObjectAccessor<0, dim> : public TriaAccessor<dim>
+class TriaObjectAccessor<0, dim> : public TriaAccessor<0,dim>
 {
   public:
                                     /**
                                      * Propagate typedef from
                                      * base class to this class.
                                      */
-    typedef typename TriaAccessor<dim>::AccessorData AccessorData;
+    typedef typename TriaAccessor<0,dim>::AccessorData AccessorData;
 
                                     /**
                                      * Constructor. Should never be
@@ -1020,7 +1164,7 @@ class TriaObjectAccessor<0, dim> : public TriaAccessor<dim>
                        const int                 index      = -1,
                        const AccessorData       *local_data =  0)
                     :
-                   TriaAccessor<dim> (parent, level, index, local_data)
+                   TriaAccessor<0,dim> (parent, level, index, local_data)
       {
        Assert (false, ExcInternalError());
       };
@@ -1039,14 +1183,14 @@ class TriaObjectAccessor<0, dim> : public TriaAccessor<dim>
  *   @author Wolfgang Bangerth, 1998
  */
 template <int dim>
-class TriaObjectAccessor<1, dim> :  public TriaAccessor<dim>
+class TriaObjectAccessor<1, dim> :  public TriaAccessor<1,dim>
 {
   public:
                                     /**
                                      * Propagate typedef from
                                      * base class to this class.
                                      */
-    typedef typename TriaAccessor<dim>::AccessorData AccessorData;
+    typedef typename TriaAccessor<1,dim>::AccessorData AccessorData;
 
                                     /**
                                      *  Constructor.
@@ -1062,13 +1206,6 @@ class TriaObjectAccessor<1, dim> :  public TriaAccessor<dim>
                                      */
     void set (const internal::Triangulation::Line &l) const;
 
-                                    /**
-                                     *  Return the level the element
-                                     *  pointed to belongs to.
-                                     *  This is only valid for cells.
-                                     */
-    int level () const;
-
                                     /**
                                      *  Return the index of vertex
                                      *  <tt>i=0,1</tt> of a line.
@@ -1604,14 +1741,14 @@ class TriaObjectAccessor<1, dim> :  public TriaAccessor<dim>
  *   @author Wolfgang Bangerth, 1998
  */
 template <int dim>
-class TriaObjectAccessor<2, dim> :  public TriaAccessor<dim>
+class TriaObjectAccessor<2, dim> :  public TriaAccessor<2,dim>
 {
   public:
                                     /**
                                      * Propagate typedef from base
                                      * class to this class.
                                      */
-    typedef typename TriaAccessor<dim>::AccessorData AccessorData;
+    typedef typename TriaAccessor<2,dim>::AccessorData AccessorData;
 
                                     /**
                                      *  Constructor.
@@ -1626,13 +1763,6 @@ class TriaObjectAccessor<2, dim> :  public TriaAccessor<dim>
                                      */
     void set (const internal::Triangulation::Quad &q) const;
 
-                                    /**
-                                     *  Return the level the element
-                                     *  pointed to belongs to.
-                                     *  This is only valid for cells.
-                                     */
-    int level () const;
-    
                                     /**
                                      * Return index of a vertex of a
                                      * quad in the internal data
@@ -2218,14 +2348,14 @@ class TriaObjectAccessor<2, dim> :  public TriaAccessor<dim>
  *   @author Wolfgang Bangerth, 1998
  */
 template <int dim>
-class TriaObjectAccessor<3, dim> :  public TriaAccessor<dim>
+class TriaObjectAccessor<3, dim> :  public TriaAccessor<3,dim>
 {
   public:
                                     /**
                                      * Propagate typedef from base
                                      * class to this class.
                                      */
-    typedef typename TriaAccessor<dim>::AccessorData AccessorData;
+    typedef typename TriaAccessor<3,dim>::AccessorData AccessorData;
 
                                     /**
                                      *  Constructor.
index 6482a58718da3e5f9ed0f95d7835c2e71cc26616..2ce6b5f691681b9f03e895c4c25d01d790f0f94e 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -29,12 +29,106 @@ DEAL_II_NAMESPACE_OPEN
 
 /*------------------------ Functions: TriaAccessor ---------------------------*/
 
+template <int structdim, int dim>
+inline
+TriaAccessor<structdim,dim>::TriaAccessor (const Triangulation<dim> *parent,
+                                          const int                 /*level*/,
+                                          const int                 index,
+                                          const AccessorData       *)
+                :
+                present_index (index),
+                tria (parent)
+{}
+
+
+
+template <int structdim, int dim>
+inline
+void
+TriaAccessor<structdim,dim>::copy_from (const TriaAccessor<structdim,dim> &a)
+{
+  present_index = a.present_index;
+  tria = a.tria;
+}
+
+
+
+template <int structdim, int dim>
+inline
+bool
+TriaAccessor<structdim,dim>::operator == (const TriaAccessor<structdim,dim> &a) const
+{
+  Assert (tria == a.tria, TriaAccessorExceptions::ExcCantCompareIterators());
+  return (present_index == a.present_index);
+}
+
+
+
+template <int structdim, int dim>
+inline
+bool
+TriaAccessor<structdim,dim>::operator != (const TriaAccessor<structdim,dim> &a) const
+{
+  Assert (tria == a.tria, TriaAccessorExceptions::ExcCantCompareIterators());
+  return (present_index != a.present_index);
+}
+
+
+
+template <int structdim, int dim>
+inline
+int
+TriaAccessor<structdim,dim>::level ()
+{
+  return 0;
+}
+
+
+
+template <int structdim, int dim>
+inline
+int
+TriaAccessor<structdim,dim>::index () const
+{
+  return present_index;
+}
+
+
+
+template <int structdim, int dim>
+inline
+IteratorState::IteratorStates
+TriaAccessor<structdim,dim>::state () const
+{
+  if (present_index>=0)
+    return IteratorState::valid;
+  else
+    if (present_index==-1)
+      return IteratorState::past_the_end;
+    else
+      return IteratorState::invalid;
+}
+
+
+
+template <int structdim, int dim>
+inline
+const Triangulation<dim> &
+TriaAccessor<structdim,dim>::get_triangulation () const
+{
+  return *tria;
+}
+
+
+
+/*------------------------ Functions: TriaAccessor<dim,dim> ---------------------------*/
+
 template <int dim>
 inline
-TriaAccessor<dim>::TriaAccessor (const Triangulation<dim> *parent,
-                                 const int                 level,
-                                 const int                 index,
-                                 const AccessorData       *)
+TriaAccessor<dim,dim>::TriaAccessor (const Triangulation<dim> *parent,
+                                    const int                 level,
+                                    const int                 index,
+                                    const AccessorData       *)
                 :
                 present_level (level),
                 present_index (index),
@@ -46,7 +140,7 @@ TriaAccessor<dim>::TriaAccessor (const Triangulation<dim> *parent,
 template <int dim>
 inline
 void
-TriaAccessor<dim>::copy_from (const TriaAccessor<dim> &a)
+TriaAccessor<dim,dim>::copy_from (const TriaAccessor<dim,dim> &a)
 {
   present_level = a.present_level;
   present_index = a.present_index;
@@ -58,7 +152,7 @@ TriaAccessor<dim>::copy_from (const TriaAccessor<dim> &a)
 template <int dim>
 inline
 bool
-TriaAccessor<dim>::operator == (const TriaAccessor<dim> &a) const
+TriaAccessor<dim,dim>::operator == (const TriaAccessor<dim,dim> &a) const
 {
   Assert (tria == a.tria, TriaAccessorExceptions::ExcCantCompareIterators());
   return ((present_index == a.present_index) &&
@@ -70,7 +164,7 @@ TriaAccessor<dim>::operator == (const TriaAccessor<dim> &a) const
 template <int dim>
 inline
 bool
-TriaAccessor<dim>::operator != (const TriaAccessor<dim> &a) const
+TriaAccessor<dim,dim>::operator != (const TriaAccessor<dim,dim> &a) const
 {
   Assert (tria == a.tria, TriaAccessorExceptions::ExcCantCompareIterators());
   return ((present_index != a.present_index) ||
@@ -82,7 +176,7 @@ TriaAccessor<dim>::operator != (const TriaAccessor<dim> &a) const
 template <int dim>
 inline
 int
-TriaAccessor<dim>::level () const
+TriaAccessor<dim,dim>::level () const
 {
   return present_level;
 }
@@ -92,7 +186,7 @@ TriaAccessor<dim>::level () const
 template <int dim>
 inline
 int
-TriaAccessor<dim>::index () const
+TriaAccessor<dim,dim>::index () const
 {
   return present_index;
 }
@@ -102,7 +196,7 @@ TriaAccessor<dim>::index () const
 template <int dim>
 inline
 IteratorState::IteratorStates
-TriaAccessor<dim>::state () const
+TriaAccessor<dim,dim>::state () const
 {
   if ((present_level>=0) && (present_index>=0))
     return IteratorState::valid;
@@ -118,7 +212,7 @@ TriaAccessor<dim>::state () const
 template <int dim>
 inline
 const Triangulation<dim> &
-TriaAccessor<dim>::get_triangulation () const
+TriaAccessor<dim,dim>::get_triangulation () const
 {
   return *tria;
 }
@@ -135,7 +229,7 @@ TriaObjectAccessor (const Triangulation<dim> *parent,
                     const int                 index,
                     const AccessorData       *local_data)
                 :
-                TriaAccessor<dim> (parent, level, index, local_data)
+                TriaAccessor<1,dim> (parent, level, index, local_data)
 {
   if (dim!=1)
     Assert(level <= 0, ExcInternalError());
@@ -164,17 +258,6 @@ TriaObjectAccessor<1,dim>::lines() const
 
 
 
-template <int dim>
-inline
-int
-TriaObjectAccessor<1,dim>::level () const
-{
-  Assert(dim==1, TriaAccessorExceptions::ExcFacesHaveNoLevel());
-  return TriaAccessor<dim>::level();
-}
-
-
-
 template <int dim>
 inline
 bool
@@ -250,14 +333,11 @@ TriaIterator<dim,TriaObjectAccessor<1,dim> >
 TriaObjectAccessor<1,dim>::child (const unsigned int i) const
 {
   Assert (i<2, ExcIndexRange(i,0,2));
-  int next_level;
-  if (dim==1)
-    next_level = this->present_level+1;
-  else
-    next_level = 0;
-  
+
   TriaIterator<dim,TriaObjectAccessor<1,dim> >
-    q (this->tria, next_level, child_index (i));
+    q (this->tria,
+       (dim == 1 ? this->level() + 1 : 0),
+       child_index (i));
 
   Assert ((q.state() == IteratorState::past_the_end) || q->used(),
          TriaAccessorExceptions::ExcUnusedCellAsChild());
@@ -337,11 +417,14 @@ TriaObjectAccessor<1,dim>::operator ++ ()
 {
   ++this->present_index;
                                   // is index still in the range of
-                                  // the vector?
+                                  // the vector? (note that we don't
+                                  // have to set the level, since
+                                  // dim!=1 and the object therefore
+                                  // has no level)
   if (this->present_index
       >=
       static_cast<int>(this->tria->faces->lines.cells.size()))
-    this->present_level = this->present_index = -1;
+    this->present_index = -1;
 }
 
 
@@ -381,9 +464,12 @@ TriaObjectAccessor<1,dim>::operator -- ()
 {
   --this->present_index;
                                   // is index still in the range of
-                                  // the vector?
-  if (this->present_index <0 ) 
-    this->present_level = this->present_index = -1;
+                                  // the vector? (note that we don't
+                                  // have to set the level, since
+                                  // dim!=1 and the object therefore
+                                  // has no level)
+  if (this->present_index < 0) 
+    this->present_index = -1;
   return;
 }
 
@@ -424,7 +510,7 @@ TriaObjectAccessor (const Triangulation<dim> *parent,
                     const int                 index,
                     const AccessorData       *local_data)
                 :
-                TriaAccessor<dim> (parent, level, index, local_data)
+                TriaAccessor<2,dim> (parent, level, index, local_data)
 {
   if (dim!=2)
     Assert(level <= 0, ExcInternalError());
@@ -454,17 +540,6 @@ TriaObjectAccessor<2,dim>::quads() const
 
 
 
-template <int dim>
-inline
-int
-TriaObjectAccessor<2,dim>::level () const
-{
-  Assert(dim==2, TriaAccessorExceptions::ExcFacesHaveNoLevel());
-  return TriaAccessor<dim>::level();
-}
-
-
-
 template <int dim>
 inline
 bool
@@ -566,14 +641,11 @@ TriaIterator<dim,TriaObjectAccessor<2,dim> >
 TriaObjectAccessor<2,dim>::child (const unsigned int i) const
 {
   Assert (i<4, ExcIndexRange(i,0,4));
-  int next_level;
-  if (dim==2)
-    next_level = this->present_level+1;
-  else
-    next_level = 0;
   
   TriaIterator<dim,TriaObjectAccessor<2,dim> >
-    q (this->tria, next_level, child_index (i));
+    q (this->tria,
+       (dim == 2 ? this->level() + 1 : 0),
+       child_index (i));
   
   Assert ((q.state() == IteratorState::past_the_end) || q->used(),
          TriaAccessorExceptions::ExcUnusedCellAsChild());
@@ -675,11 +747,14 @@ TriaObjectAccessor<2,dim>::operator ++ ()
 {
   ++this->present_index;
                                   // is index still in the range of
-                                  // the vector?
+                                  // the vector? (note that we don't
+                                  // have to set the level, since
+                                  // dim!=1 and the object therefore
+                                  // has no level)
   if (this->present_index
       >=
       static_cast<int>(quads().cells.size()))
-    this->present_level = this->present_index = -1;
+    this->present_index = -1;
 }
 
 
@@ -718,9 +793,12 @@ TriaObjectAccessor<2,dim>::operator -- ()
 {
   --this->present_index;
                                   // is index still in the range of
-                                  // the vector?
-  if (this->present_index<0)
-    this->present_level = this->present_index = -1;
+                                  // the vector? (note that we don't
+                                  // have to set the level, since
+                                  // dim!=1 and the object therefore
+                                  // has no level)
+  if (this->present_index < 0)
+    this->present_index = -1;
 }
 
 
@@ -760,7 +838,7 @@ TriaObjectAccessor (const Triangulation<dim> *parent,
                     const int                 index,
                     const AccessorData       *local_data)
                 :
-                TriaAccessor<dim> (parent, level, index, local_data)
+                TriaAccessor<3,dim> (parent, level, index, local_data)
 {
   if (dim!=3)
     Assert(level <= 0, ExcInternalError());
@@ -937,7 +1015,8 @@ TriaObjectAccessor<3,3>::child (const unsigned int i) const
   const int dim=3;
   Assert (i<8, ExcIndexRange(i,0,8));
   
-  TriaIterator<dim,TriaObjectAccessor<3,dim> > q (this->tria, this->present_level+1, child_index (i));
+  TriaIterator<dim,TriaObjectAccessor<3,dim> >
+    q (this->tria, this->present_level+1, child_index (i));
   
   Assert ((q.state() == IteratorState::past_the_end) || q->used(),
          TriaAccessorExceptions::ExcUnusedCellAsChild());
index 8af49ebe4cf26a39d0c5b86c86003186993e544d..8d9dcc13cfedd351d6a9f9a41ab9bb92496dbd37 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 2003, 2004, 2005, 2006, 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -19,7 +19,8 @@
 DEAL_II_NAMESPACE_OPEN
 
 template <int dim> class CellAccessor;
-template <int dim> class TriaAccessor;
+template <int, int> class TriaAccessor;
+template <int dim> class TriaAccessor<dim,dim>;
 template <int, int> class TriaObjectAccessor;
 template <int dim>  class TriaObjectAccessor<0, dim>;
 template <int dim>  class TriaObjectAccessor<1, dim>;
index 2eb7f3e7c053a6122399fd61fefda0ef539d7561..1fc68df26a6c837e9125ac29801578466a567037 100644 (file)
@@ -27,8 +27,8 @@
 DEAL_II_NAMESPACE_OPEN
 
 
-template <int dim>
-const unsigned int TriaAccessor<dim>::objectdim;
+template <int structdim,int dim>
+const unsigned int TriaAccessor<structdim,dim>::objectdim;
 
 
 /*------------------------ Functions: LineAccessor ---------------------------*/
@@ -2316,7 +2316,14 @@ neighbor_child_on_subface (const unsigned int face,
 // For more information, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24331
 
 // explicit instantiations
-template class TriaAccessor<deal_II_dimension>;
+template class TriaAccessor<1,deal_II_dimension>;
+#if deal_II_dimension >= 2
+template class TriaAccessor<2,deal_II_dimension>;
+#endif
+#if deal_II_dimension >= 3
+template class TriaAccessor<3,deal_II_dimension>;
+#endif
+
 template class CellAccessor<deal_II_dimension>;
 template class TriaRawIterator<deal_II_dimension,TriaObjectAccessor<1, deal_II_dimension> >;
 template class TriaRawIterator<deal_II_dimension,CellAccessor<deal_II_dimension> >;
index 1e0ba45598bd1448d3c243f0cfe6af808a66842d..d56870496e9f16b8dd6d21e045b33780ad12aaf0 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -159,16 +159,13 @@ template <int structdim, int dim>
 TriaIterator<dim,MGDoFObjectAccessor<structdim, dim> >
 MGDoFAccessor<structdim, dim>::child (const unsigned int i) const
 {
-  int next_level;
-  if (structdim==dim)
-    next_level=this->present_level+1;
-  else
-    next_level=0;
-  
-  TriaIterator<dim,MGDoFObjectAccessor<structdim, dim> > q (this->tria,
-                                                           next_level,
-                                                           this->child_index (i),
-                                                           this->mg_dof_handler);
+  const TriaIterator<dim,MGDoFObjectAccessor<structdim, dim> >
+    q (this->tria,
+       (structdim == dim ?
+       this->level() + 1 :
+       0),
+       this->child_index (i),
+       this->mg_dof_handler);
   
                                   // make sure that we either created
                                   // a past-the-end iterator or one

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.