]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
remove specializations of TriaLevel for lower dimensions
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 27 May 2007 21:18:14 +0000 (21:18 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 27 May 2007 21:18:14 +0000 (21:18 +0000)
specialization in 3D cannot be avoided, unless TriaObjects is improved

git-svn-id: https://svn.dealii.org/trunk@14717 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria_accessor.templates.h
deal.II/deal.II/include/grid/tria_levels.h
deal.II/deal.II/include/grid/tria_objects.h
deal.II/deal.II/source/grid/tria.cc
deal.II/deal.II/source/grid/tria_accessor.cc
deal.II/deal.II/source/grid/tria_levels.all_dimensions.cc
deal.II/deal.II/source/grid/tria_levels.cc
deal.II/deal.II/source/hp/dof_handler.cc

index 12e354bfa368725911e8829c8c85a8086d150c58..15549f863cb923d6c1de2e10414dbec292df5209 100644 (file)
@@ -252,7 +252,7 @@ inline
 internal::Triangulation::TriaObjects<internal::Triangulation::Line> &
 TriaObjectAccessor<1,1>::lines() const
 {
-  return this->tria->levels[this->present_level]->lines;
+  return this->tria->levels[this->present_level]->cells;
 }
 
 
@@ -448,7 +448,7 @@ TriaObjectAccessor<1,1>::operator ++ ()
                                   // the vector?
   while (this->present_index
         >=
-        static_cast<int>(this->tria->levels[this->present_level]->lines.cells.size()))
+        static_cast<int>(this->tria->levels[this->present_level]->cells.cells.size()))
     {
                                       // no -> go one level up until we find
                                       // one with more than zero cells
@@ -503,7 +503,7 @@ TriaObjectAccessor<1,1>::operator -- ()
          return;
        }
                                         // else
-      this->present_index = this->tria->levels[this->present_level]->lines.cells.size()-1;
+      this->present_index = this->tria->levels[this->present_level]->cells.cells.size()-1;
     }
 }
 
@@ -534,7 +534,7 @@ inline
 internal::Triangulation::TriaObjects<internal::Triangulation::Quad> &
 TriaObjectAccessor<2,2>::quads() const
 {
-  return this->tria->levels[this->present_level]->quads;
+  return this->tria->levels[this->present_level]->cells;
 }
 
 
@@ -862,7 +862,7 @@ TriaObjectAccessor<3,3>::used () const
 {
   Assert (this->state() == IteratorState::valid,
          TriaAccessorExceptions::ExcDereferenceInvalidObject());
-   return this->tria->levels[this->present_level]->hexes.used[this->present_index];
+   return this->tria->levels[this->present_level]->cells.used[this->present_index];
 }
 
 
@@ -873,7 +873,7 @@ bool
 TriaObjectAccessor<3,3>::user_flag_set () const
 {
   Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
-  return this->tria->levels[this->present_level]->hexes.user_flags[this->present_index];
+  return this->tria->levels[this->present_level]->cells.user_flags[this->present_index];
 }
 
 
@@ -884,7 +884,7 @@ void
 TriaObjectAccessor<3,3>::set_user_flag () const
 {
   Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
-  this->tria->levels[this->present_level]->hexes.user_flags[this->present_index] = true;
+  this->tria->levels[this->present_level]->cells.user_flags[this->present_index] = true;
 }
 
 
@@ -894,7 +894,7 @@ inline
 void TriaObjectAccessor<3,3>::clear_user_flag () const
 {
   Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
-  this->tria->levels[this->present_level]->hexes.user_flags[this->present_index] = false;
+  this->tria->levels[this->present_level]->cells.user_flags[this->present_index] = false;
 }
 
 
@@ -989,7 +989,7 @@ TriaObjectAccessor<3,3>::quad_index (const unsigned int i) const
 {
   Assert (i<6, ExcIndexRange(i,0,6));
 
-  return this->tria->levels[this->present_level]->hexes.cells[this->present_index].face(i);
+  return this->tria->levels[this->present_level]->cells.cells[this->present_index].face(i);
 }
 
 
@@ -1001,7 +1001,7 @@ TriaObjectAccessor<3,3>::has_children () const
 {
   Assert (this->state() == IteratorState::valid,
          TriaAccessorExceptions::ExcDereferenceInvalidObject());
-    return (this->tria->levels[this->present_level]->hexes.children[this->present_index] != -1);
+    return (this->tria->levels[this->present_level]->cells.children[this->present_index] != -1);
 }
 
 
@@ -1011,7 +1011,7 @@ int TriaObjectAccessor<3,3>::child_index (const unsigned int i) const
 {
   Assert (i<8, ExcIndexRange(i,0,8));
   Assert (has_children(), TriaAccessorExceptions::ExcCellHasNoChildren());
-    return this->tria->levels[this->present_level]->hexes.children[this->present_index]+i;
+    return this->tria->levels[this->present_level]->cells.children[this->present_index]+i;
 }
 
 
@@ -1080,11 +1080,11 @@ face_orientation (const unsigned int face) const
           ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
   Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
          < this->tria->levels[this->present_level]
-         ->hexes.face_orientations.size(),
+         ->cells.face_orientations.size(),
          ExcInternalError());
   
   return (this->tria->levels[this->present_level]
-         ->hexes.face_orientations[this->present_index *
+         ->cells.face_orientations[this->present_index *
                                    GeometryInfo<3>::faces_per_cell
                                    + face]);
 }
@@ -1101,11 +1101,11 @@ face_flip (const unsigned int face) const
           ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
   Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
          < this->tria->levels[this->present_level]
-         ->hexes.face_flips.size(),
+         ->cells.face_flips.size(),
          ExcInternalError());
   
   return (this->tria->levels[this->present_level]
-         ->hexes.face_flips[this->present_index *
+         ->cells.face_flips[this->present_index *
                             GeometryInfo<3>::faces_per_cell
                             + face]);
 }
@@ -1122,11 +1122,11 @@ face_rotation (const unsigned int face) const
           ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
   Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
          < this->tria->levels[this->present_level]
-         ->hexes.face_rotations.size(),
+         ->cells.face_rotations.size(),
          ExcInternalError());
       
   return (this->tria->levels[this->present_level]
-         ->hexes.face_rotations[this->present_index *
+         ->cells.face_rotations[this->present_index *
                                 GeometryInfo<3>::faces_per_cell
                                 + face]);
 }
@@ -1231,7 +1231,7 @@ TriaObjectAccessor<3,3>::operator ++ ()
                                   // the vector?
     while (this->present_index
           >=
-          static_cast<int>(this->tria->levels[this->present_level]->hexes.cells.size()))
+          static_cast<int>(this->tria->levels[this->present_level]->cells.cells.size()))
       {
                                         // no -> go one level up
        ++this->present_level;
@@ -1268,7 +1268,7 @@ TriaObjectAccessor<3,3>::operator -- ()
            return;
          }
                                         // else
-       this->present_index = this->tria->levels[this->present_level]->hexes.cells.size()-1;
+       this->present_index = this->tria->levels[this->present_level]->cells.cells.size()-1;
       }
 }
 
index 8d6405561d71fbb193376e4d3f97eba8214627dd..68acb12e98a97ed024716e90a704429704da4ec3 100644 (file)
@@ -26,34 +26,16 @@ namespace internal
 {
   namespace Triangulation
   {
-
-/**
- * General template for information belonging to one level of a multilevel
- * hierarchy of a triangulation. However, only the cells are really
- * level-based data if anisotropic rfeinement is allowed. Therefore, only the
- * information concerning cells is considered here, the information concerning
- * cell-faces can be found in the <tt>TriaFaces</tt> classes.
- *
- * This template is only declared to allow
- * specializations for different dimensions.
- *
- * @ingroup grid
- */
-    template <int dim>
-    class TriaLevel
-    {
-    };
-
-
 /**
  * Store all information which belongs to one level of the multilevel
  * hierarchy.
  *
- * In TriaLevel<0> all data is stored which is not dependent on the
+ * 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. Actually, it
- * is only cell-based data, like neighborship info or refinement
- * flags. There is another field, which may fit in here, namely the
+ * (what a cell actually is is declared elsewhere), etc. See also
+ * TriaObjects for non leveloriented data.
+ *
+ * There is another field, which may fit in here, namely the
  * material data (for cells) or the boundary indicators (for faces),
  * but since we need for a line or quad either boundary information or
  * material data, we store them with the lines and quads rather than
@@ -63,10 +45,10 @@ namespace internal
  * material data for cells.
  *
  * @ingroup grid
- * @author Wolfgang Bangerth, 1998
+ * @author Wolfgang Bangerth, Guido Kanschat, 1998, 2007
  */
-    template <>
-    class TriaLevel<0>
+    template <int dim>
+    class TriaLevel
     {
       public:
                                          /**
@@ -186,6 +168,13 @@ namespace internal
                                           * of this object.
                                           */
         unsigned int memory_consumption () const;
+       
+                                        /**
+                                         * The object containing the data on lines and
+                                         * related functions
+                                         */
+       TriaObjects<TriaObject<dim> > cells;
+
 
                                          /**
                                           *  Exception
@@ -203,97 +192,52 @@ namespace internal
                         << "The containers have sizes " << arg1 << " and "
                         << arg2 << ", which is not as expected.");
     };
-
-
-
+    
+//TODO: Replace TriaObjectsHex to avoid this specialization
+    
 /**
- *  Store all information which belongs to one level of the multilevel hierarchy.
- *  
- *  In one dimension, this contains the lines on this level.
- *
- * @ingroup grid
- *  @author Wolfgang Bangerth, 1998
+ * Specialization of TriaLevels for 3D. Since we need TriaObjectsHex
+ * instead of TriaObjects. Refer to the documentation of the template
+ * for details.
  */
-    template <>
-    class TriaLevel<1> : public TriaLevel<0>
-                        
+    template<>
+    class TriaLevel<3>
     {
       public:
-                                        /**
-                                         * The object containing the data on lines and
-                                         * related functions
-                                         */
-       TriaObjects<Line> lines;
-
-      public:
-                                        /**
-                                          * Determine an estimate for the
-                                          * memory consumption (in bytes)
-                                          * of this object.
-                                          */
+        std::vector<bool> refine_flags;
+        std::vector<bool> coarsen_flags;
+        std::vector<std::pair<int,int> > neighbors;
+        std::vector<unsigned int> subdomain_ids;
+        void reserve_space (const unsigned int total_cells,
+                            const unsigned int dimension);
+        void monitor_memory (const unsigned int true_dimension) const;
         unsigned int memory_consumption () const;
-    };
-
+       TriaObjectsHex cells;
 
 
-/**
- *  Store all information which belongs to one level of the multilevel hierarchy.
- *
- *  In 2D this is a vector ocontains the quads on this level.
- *
- * @ingroup grid
- *  @author Wolfgang Bangerth, 1998
- */
-    template <>
-    class TriaLevel<2> : public TriaLevel<0>
-    {
-      public:
-                                        /**
-                                         * The object containing the data on quads and
-                                         * related functions
-                                         */
-       TriaObjects<Quad> quads;
-
-      public:
-                                        /**
-                                          * Determine an estimate for the
-                                          * memory consumption (in bytes)
-                                          * of this object.
+                                         /**
+                                          *  Exception
                                           */
-        unsigned int memory_consumption () const;
-    };
-
-
-
-/**
- *  Store all information which belongs to one level of the multilevel hierarchy.
- *
- *  In 3D this contains the hexahedra on this levels, 
- *
-  * @ingroup grid
- *  @author Wolfgang Bangerth, 1998, 2003
- */
-    template <>
-    class TriaLevel<3> :  public TriaLevel<0>
-    {
-      public:
-                                        /**
-                                         * The object containing the data on hexes and
-                                         * related functions
-                                         */
-       TriaObjectsHex hexes;
-
-      public:
-                                        /**
-                                          * Determine an estimate for the
-                                          * memory consumption (in bytes)
-                                          * of this object.
+        DeclException3 (ExcMemoryWasted,
+                        char*, int, int,
+                        << "The container " << arg1 << " contains "
+                        << arg2 << " elements, but it`s capacity is "
+                        << arg3 << ".");
+                                         /**
+                                          *  Exception
                                           */
-        unsigned int memory_consumption () const;
+        DeclException2 (ExcMemoryInexact,
+                        int, int,
+                        << "The containers have sizes " << arg1 << " and "
+                        << arg2 << ", which is not as expected.");
     };
+    
+    
   }
 }
 
+
+
 DEAL_II_NAMESPACE_CLOSE
 
 #endif
index defdce2a0c3470ae65911745fbb5d0e9f17564dd..cfc33e0b5879adbd1b8042a739a2bc54968ce038 100644 (file)
@@ -283,7 +283,7 @@ namespace internal
  * @ingroup grid
  */
     
-    class TriaObjectsHex: public TriaObjects<Hexahedron>
+    class TriaObjectsHex: public TriaObjects<TriaObject<3> >
     {
       public:
 
index f8bf1d9ce71c1b5f9762bca9ed253d9775cccb67..4d8e5a6377fe1b9978a5a129d3bbd8e950180e2d 100644 (file)
@@ -309,9 +309,8 @@ void Triangulation<1>::create_triangulation (const std::vector<Point<1> >    &v,
 
                                   // reserve enough space
   levels.push_back (new internal::Triangulation::TriaLevel<dim>);
-  levels[0]->internal::Triangulation::TriaLevel<0>
-    ::reserve_space (cells.size(), dim);
-  levels[0]->lines.reserve_space (cells.size());
+  levels[0]->reserve_space (cells.size(), dim);
+  levels[0]->cells.reserve_space (cells.size());
   
                                   // make up cells
   raw_line_iterator next_free_line = begin_raw_line ();
@@ -594,10 +593,9 @@ void Triangulation<2>::create_triangulation (const std::vector<Point<2> >    &v,
                                   // reserve enough space
   levels.push_back (new internal::Triangulation::TriaLevel<dim>);
   faces = new internal::Triangulation::TriaFaces<dim>;
-  levels[0]->internal::Triangulation::TriaLevel<0>
-    ::reserve_space (cells.size(), dim);
+  levels[0]->reserve_space (cells.size(), dim);
   faces->lines.reserve_space (needed_lines.size());
-  levels[0]->quads.reserve_space (cells.size());
+  levels[0]->cells.reserve_space (cells.size());
 
                                   // make up lines
   if (true) 
@@ -1018,8 +1016,7 @@ Triangulation<3>::create_triangulation (const std::vector<Point<3> >    &v,
                                   // reserve enough space
   levels.push_back (new internal::Triangulation::TriaLevel<dim>);
   faces = new internal::Triangulation::TriaFaces<dim>;
-  levels[0]->internal::Triangulation::TriaLevel<0>
-    ::reserve_space (cells.size(), dim);
+  levels[0]->reserve_space (cells.size(), dim);
   faces->lines.reserve_space (needed_lines.size());
 
                                   // make up lines
@@ -1228,7 +1225,7 @@ Triangulation<3>::create_triangulation (const std::vector<Point<3> >    &v,
 
                                   /////////////////////////////////
                                   // finally create the cells
-  levels[0]->hexes.reserve_space (cells.size());  
+  levels[0]->cells.reserve_space (cells.size());  
 
                                   // store for each quad index the
                                   // adjacent cells
@@ -2127,7 +2124,7 @@ template <>
 void Triangulation<1>::clear_user_data ()
 {
   for (unsigned int level=0;level<levels.size();++level)
-    levels[level]->lines.clear_user_data();
+    levels[level]->cells.clear_user_data();
 }
 
 
@@ -2167,7 +2164,7 @@ template <>
 void Triangulation<2>::clear_user_data ()
 {
   for (unsigned int level=0;level<levels.size();++level)
-    levels[level]->quads.clear_user_data();
+    levels[level]->cells.clear_user_data();
   faces->lines.clear_user_data();
 }
 
@@ -2204,7 +2201,7 @@ template <>
 void Triangulation<3>::clear_user_data ()
 {
   for (unsigned int level=0;level<levels.size();++level)
-    levels[level]->hexes.clear_user_data();
+    levels[level]->cells.clear_user_data();
   faces->quads.clear_user_data();
   faces->lines.clear_user_data();
 }
@@ -3769,7 +3766,7 @@ Triangulation<1>::begin_raw_line (const unsigned int level) const
 {
   Assert (level<levels.size(), ExcInvalidLevel(level));
 
-  if (levels[level]->lines.cells.size() == 0)
+  if (levels[level]->cells.cells.size() == 0)
     return end_line ();
 
   return raw_line_iterator (const_cast<Triangulation<1>*>(this),
@@ -3802,7 +3799,7 @@ Triangulation<2>::begin_raw_quad (const unsigned int level) const
 {
   Assert (level<levels.size(), ExcInvalidLevel(level));
 
-  if (levels[level]->quads.cells.size() == 0)
+  if (levels[level]->cells.cells.size() == 0)
     return end_quad();
   
   return raw_quad_iterator (const_cast<Triangulation<2>*>(this),
@@ -3819,7 +3816,7 @@ Triangulation<dim>::begin_raw_hex (const unsigned int level) const
 {
   Assert (level<levels.size(), ExcInvalidLevel(level));
 
-  if (levels[level]->hexes.cells.size() == 0)
+  if (levels[level]->cells.cells.size() == 0)
     return end_hex();
   
   return raw_hex_iterator (const_cast<Triangulation<dim>*>(this),
@@ -3978,12 +3975,12 @@ Triangulation<1>::raw_line_iterator
 Triangulation<1>::last_raw_line (const unsigned int level) const
 {
   Assert (level<levels.size(), ExcInvalidLevel(level));
-  Assert (levels[level]->lines.cells.size() != 0,
+  Assert (levels[level]->cells.cells.size() != 0,
          ExcEmptyLevel (level));
 
   return raw_line_iterator (const_cast<Triangulation<1>*>(this),
                            level,
-                           levels[level]->lines.cells.size()-1);
+                           levels[level]->cells.cells.size()-1);
 }
 
 #endif
@@ -4008,11 +4005,11 @@ Triangulation<2>::last_raw_quad (const unsigned int level) const
 {
   Assert (level<levels.size(),
          ExcInvalidLevel(level));
-  Assert (levels[level]->quads.cells.size() != 0,
+  Assert (levels[level]->cells.cells.size() != 0,
          ExcEmptyLevel (level));
   return raw_quad_iterator (const_cast<Triangulation<2>*>(this),
                            level,
-                           levels[level]->quads.cells.size()-1);
+                           levels[level]->cells.cells.size()-1);
 }
 
 #endif
@@ -4024,12 +4021,12 @@ Triangulation<dim>::last_raw_hex (const unsigned int level) const
 {
   Assert (level<levels.size(),
          ExcInvalidLevel(level));
-  Assert (levels[level]->hexes.cells.size() != 0,
+  Assert (levels[level]->cells.cells.size() != 0,
          ExcEmptyLevel (level));
 
   return raw_hex_iterator (const_cast<Triangulation<dim>*>(this),
                           level,
-                          levels[level]->hexes.cells.size()-1);
+                          levels[level]->cells.cells.size()-1);
 }
 
 
@@ -4505,7 +4502,7 @@ template <>
 unsigned int Triangulation<1>::n_raw_lines (const unsigned int level) const
 {
   Assert(level < n_levels(), ExcIndexRange(level,0,n_levels()));
-  return levels[level]->lines.cells.size();
+  return levels[level]->cells.cells.size();
 }
 
 
@@ -4632,7 +4629,7 @@ template <>
 unsigned int Triangulation<2>::n_raw_quads (const unsigned int level) const
 {
   Assert(level < n_levels(), ExcIndexRange(level,0,n_levels()));
-  return levels[level]->quads.cells.size();
+  return levels[level]->cells.cells.size();
 }
 
 #endif
@@ -4753,7 +4750,7 @@ template <int dim>
 unsigned int Triangulation<dim>::n_raw_hexs (const unsigned int level) const
 {
   Assert(level < n_levels(), ExcIndexRange(level,0,n_levels()));
-  return levels[level]->hexes.cells.size();
+  return levels[level]->cells.cells.size();
 }
 
 
@@ -4983,8 +4980,8 @@ Triangulation<1>::execute_refinement ()
                                       // count number of used cells
                                       // on the next higher level
       const unsigned int used_cells
-       =  std::count_if (levels[level+1]->lines.used.begin(),
-                         levels[level+1]->lines.used.end(),
+       =  std::count_if (levels[level+1]->cells.used.begin(),
+                         levels[level+1]->cells.used.end(),
                          std::bind2nd (std::equal_to<bool>(), true));
 
                                       // reserve space for the
@@ -4993,15 +4990,13 @@ Triangulation<1>::execute_refinement ()
                                       // level as well as for the
                                       // 2*flagged_cells that will be
                                       // created on that level
-      levels[level+1]->
-       internal::Triangulation::TriaLevel<0>
-        ::reserve_space (used_cells+
-                         GeometryInfo<1>::children_per_cell *
-                         flagged_cells, 1);
+      levels[level+1]->reserve_space(
+       used_cells+
+       GeometryInfo<1>::children_per_cell * flagged_cells, 1);
                                       // reserve space for
                                       // 2*flagged_cells new lines on
                                       // the next higher level
-      levels[level+1]->lines.
+      levels[level+1]->cells.
        reserve_space (GeometryInfo<1>::children_per_cell*flagged_cells);
       
       needed_vertices += flagged_cells;
@@ -5173,7 +5168,7 @@ Triangulation<1>::execute_refinement ()
   
 #ifdef DEBUG
   for (unsigned int level=0; level<levels.size(); ++level) 
-    levels[level]->lines.monitor_memory (1);
+    levels[level]->cells.monitor_memory (1);
 
                                   // check whether really all
                                   // refinement flags are reset (also
@@ -5287,8 +5282,8 @@ Triangulation<2>::execute_refinement ()
                                       // count number of used cells
                                       // on the next higher level
       const unsigned int used_cells
-       = std::count_if (levels[level+1]->quads.used.begin(),
-                        levels[level+1]->quads.used.end(),
+       = std::count_if (levels[level+1]->cells.used.begin(),
+                        levels[level+1]->cells.used.end(),
                         std::bind2nd (std::equal_to<bool>(), true));
       
 
@@ -5298,15 +5293,13 @@ Triangulation<2>::execute_refinement ()
                                       // level as well as for the
                                       // 4*flagged_cells that will be
                                       // created on that level
-      levels[level+1]->
-       internal::Triangulation::TriaLevel<0>
-        ::reserve_space (used_cells+4*flagged_cells, 2);
+      levels[level+1]->reserve_space (used_cells+4*flagged_cells, 2);
 
                                       // reserve space for
                                       // 4*flagged_cells
                                       // new quads on the next higher
                                       // level
-      levels[level+1]->quads.
+      levels[level+1]->cells.
        reserve_space (4*flagged_cells);
     }
 
@@ -5859,7 +5852,7 @@ Triangulation<2>::execute_refinement ()
 
 #ifdef DEBUG
   for (unsigned int level=0; level<levels.size(); ++level) 
-    levels[level]->quads.monitor_memory (2);
+    levels[level]->cells.monitor_memory (2);
 
                                   // check whether really all
                                   // refinement flags are reset (also
@@ -5993,8 +5986,8 @@ Triangulation<3>::execute_refinement ()
                                       // count number of used cells on
                                       // the next higher level
       const unsigned int used_cells
-       = std::count_if (levels[level+1]->hexes.used.begin(),
-                        levels[level+1]->hexes.used.end(),
+       = std::count_if (levels[level+1]->cells.used.begin(),
+                        levels[level+1]->cells.used.end(),
                         std::bind2nd (std::equal_to<bool>(), true));
 
 
@@ -6004,15 +5997,12 @@ Triangulation<3>::execute_refinement ()
                                       // level as well as for the
                                       // 8*flagged_cells that will be
                                       // created on that level
-      levels[level+1]->
-       internal::Triangulation::TriaLevel<0>
-        ::reserve_space (used_cells+8*flagged_cells, 3);
+      levels[level+1]->reserve_space (used_cells+8*flagged_cells, 3);
                                       // reserve space for
                                       // 8*flagged_cells
                                       // new hexes on the next higher
                                       // level
-      levels[level+1]->hexes.
-       reserve_space (8*flagged_cells);
+      levels[level+1]->cells.reserve_space (8*flagged_cells);
     }
 
                                   // now count the quads and
@@ -7607,7 +7597,7 @@ Triangulation<3>::execute_refinement ()
 
 #ifdef DEBUG
   for (unsigned int level=0; level<levels.size(); ++level) 
-    levels[level]->hexes.monitor_memory (3);
+    levels[level]->cells.monitor_memory (3);
 
                                   // check whether really all
                                   // refinement flags are reset (also
@@ -9650,7 +9640,7 @@ void Triangulation<1>::update_number_cache_lines ()
     {
                                       // count lines on this level
       number_cache.n_lines_level[level] = 0;
-      if (levels[level]->lines.cells.size() != 0) 
+      if (levels[level]->cells.cells.size() != 0) 
        {
          line_iterator line = begin_line (level),
                        endc = (level == levels.size()-1 ?
@@ -9672,7 +9662,7 @@ void Triangulation<1>::update_number_cache_lines ()
     {
                                       // count lines on this level
       number_cache.n_active_lines_level[level] = 0;
-      if (levels[level]->lines.cells.size() != 0) 
+      if (levels[level]->cells.cells.size() != 0) 
        {
          active_line_iterator line = begin_active_line (level),
                               endc = end_active_line (level);
@@ -9741,7 +9731,7 @@ void Triangulation<2>::update_number_cache_quads ()
     {
                                       // count quads on this level
       number_cache.n_quads_level[level] = 0;
-      if (levels[level]->quads.cells.size() != 0) 
+      if (levels[level]->cells.cells.size() != 0) 
        {
          quad_iterator quad = begin_quad (level),
                        endc = (level == levels.size()-1 ?
@@ -9763,7 +9753,7 @@ void Triangulation<2>::update_number_cache_quads ()
     {
                                       // count quads on this level
       number_cache.n_active_quads_level[level] = 0;
-      if (levels[level]->quads.cells.size() != 0) 
+      if (levels[level]->cells.cells.size() != 0) 
        {
          active_quad_iterator quad = begin_active_quad (level),
                               endc = end_active_quad (level);
@@ -9849,7 +9839,7 @@ void Triangulation<dim>::update_number_cache_hexes ()
     {
                                       // count hexes on this level
       number_cache.n_hexes_level[level] = 0;
-      if (levels[level]->hexes.cells.size() != 0) 
+      if (levels[level]->cells.cells.size() != 0) 
        {
          hex_iterator hex = begin_hex (level),
                      endc = (level == levels.size()-1 ?
@@ -9871,7 +9861,7 @@ void Triangulation<dim>::update_number_cache_hexes ()
     {
                                       // count hexes on this level
       number_cache.n_active_hexes_level[level] = 0;
-      if (levels[level]->hexes.cells.size() != 0) 
+      if (levels[level]->cells.cells.size() != 0) 
        {
          active_hex_iterator hex = begin_active_hex (level),
                             endc = end_active_hex (level);
index 95b071aa09c0337df3621f7adde6628bec5cd22b..243e6a2d957bd6ca4fe6612aeb39b12076e9a41d 100644 (file)
@@ -845,7 +845,7 @@ void
 TriaObjectAccessor<3, 3>::set (const internal::Triangulation::Hexahedron &hex) const
 {
   this->tria->levels[this->present_level]
-    ->hexes.cells[this->present_index] = hex;
+    ->cells.cells[this->present_index] = hex;
 }
 
 #endif
@@ -890,7 +890,7 @@ void TriaObjectAccessor<3, 3>::set_used_flag () const
 {
   Assert (this->state() == IteratorState::valid,
          TriaAccessorExceptions::ExcDereferenceInvalidObject());
-  this->tria->levels[this->present_level]->hexes.used[this->present_index] = true;
+  this->tria->levels[this->present_level]->cells.used[this->present_index] = true;
 }
 
 
@@ -899,7 +899,7 @@ void TriaObjectAccessor<3, 3>::clear_used_flag () const
 {
   Assert (this->state() == IteratorState::valid,
          TriaAccessorExceptions::ExcDereferenceInvalidObject());
-  this->tria->levels[this->present_level]->hexes.used[this->present_index] = false;
+  this->tria->levels[this->present_level]->cells.used[this->present_index] = false;
 }
 
 #endif
@@ -934,7 +934,7 @@ template <>
 void TriaObjectAccessor<3, 3>::set_user_pointer (void *p) const
 {
   Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
-  this->tria->levels[this->present_level]->hexes.user_pointer(this->present_index) = p;
+  this->tria->levels[this->present_level]->cells.user_pointer(this->present_index) = p;
 }
 
 
@@ -942,7 +942,7 @@ template <>
 void TriaObjectAccessor<3, 3>::clear_user_pointer () const
 {
   Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
-  this->tria->levels[this->present_level]->hexes.user_pointer(this->present_index) = 0;
+  this->tria->levels[this->present_level]->cells.user_pointer(this->present_index) = 0;
 }
 
 
@@ -950,7 +950,7 @@ template <>
 void * TriaObjectAccessor<3, 3>::user_pointer () const
 {
   Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
-  return this->tria->levels[this->present_level]->hexes.user_pointer(this->present_index);
+  return this->tria->levels[this->present_level]->cells.user_pointer(this->present_index);
 }
 
 
@@ -958,7 +958,7 @@ template <>
 void TriaObjectAccessor<3, 3>::set_user_index (unsigned int p) const
 {
   Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
-  this->tria->levels[this->present_level]->hexes.user_index(this->present_index) = p;
+  this->tria->levels[this->present_level]->cells.user_index(this->present_index) = p;
 }
 
 
@@ -966,7 +966,7 @@ template <>
 void TriaObjectAccessor<3, 3>::clear_user_index () const
 {
   Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
-  this->tria->levels[this->present_level]->hexes.user_index(this->present_index) = 0;
+  this->tria->levels[this->present_level]->cells.user_index(this->present_index) = 0;
 }
 
 
@@ -974,7 +974,7 @@ template <>
 unsigned int  TriaObjectAccessor<3, 3>::user_index () const
 {
   Assert (used(), TriaAccessorExceptions::ExcCellNotUsed());
-  return this->tria->levels[this->present_level]->hexes.user_index(this->present_index);
+  return this->tria->levels[this->present_level]->cells.user_index(this->present_index);
 }
 
 #endif
@@ -1040,7 +1040,7 @@ void TriaObjectAccessor<3, 3>::set_children (const int index) const
          (!has_children() && (index>=0)),
          TriaAccessorExceptions::ExcCantSetChildren(index));
 
-  this->tria->levels[this->present_level]->hexes.children[this->present_index] = index;
+  this->tria->levels[this->present_level]->cells.children[this->present_index] = index;
 }
 
 #endif
@@ -1824,11 +1824,11 @@ set_face_orientation (const unsigned int face,
           ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
   Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
           < this->tria->levels[this->present_level]
-          ->hexes.face_orientations.size(),
+          ->cells.face_orientations.size(),
           ExcInternalError());
           
   this->tria->levels[this->present_level]
-    ->hexes.face_orientations[this->present_index *
+    ->cells.face_orientations[this->present_index *
                               GeometryInfo<3>::faces_per_cell
                               +
                               face]  = orientation;
@@ -1846,11 +1846,11 @@ set_face_flip (const unsigned int face,
           ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
   Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
           < this->tria->levels[this->present_level]
-          ->hexes.face_flips.size(),
+          ->cells.face_flips.size(),
           ExcInternalError());
           
   this->tria->levels[this->present_level]
-    ->hexes.face_flips[this->present_index *
+    ->cells.face_flips[this->present_index *
                       GeometryInfo<3>::faces_per_cell
                       +
                       face]  = flip;
@@ -1868,11 +1868,11 @@ set_face_rotation (const unsigned int face,
           ExcIndexRange (face, 0, GeometryInfo<3>::faces_per_cell));
   Assert (this->present_index * GeometryInfo<3>::faces_per_cell + face
           < this->tria->levels[this->present_level]
-          ->hexes.face_rotations.size(),
+          ->cells.face_rotations.size(),
           ExcInternalError());
           
   this->tria->levels[this->present_level]
-    ->hexes.face_rotations[this->present_index *
+    ->cells.face_rotations[this->present_index *
                           GeometryInfo<3>::faces_per_cell
                           +
                           face]  = rotation;
@@ -2087,14 +2087,14 @@ template <>
 unsigned char CellAccessor<3>::material_id () const
 {
   Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
-  return this->tria->levels[this->present_level]->hexes.material_id[this->present_index];
+  return this->tria->levels[this->present_level]->cells.material_id[this->present_index];
 }
 
 template <>
 void CellAccessor<3>::set_material_id (const unsigned char mat_id) const
 {
   Assert (this->used(), TriaAccessorExceptions::ExcCellNotUsed());
-  this->tria->levels[this->present_level]->hexes.material_id[this->present_index]
+  this->tria->levels[this->present_level]->cells.material_id[this->present_index]
     = mat_id;                                           
 }
 
index 45e6f2bf804bd7be7a61503ed4781b80a71ca149..6df0e384d7a9b8c77bf5bbf9eb5fd15a74ca8fbd 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2006 by the deal.II authors
+//    Copyright (C) 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
@@ -21,86 +21,7 @@ namespace internal
 {
   namespace Triangulation
   {
-        
-    void
-    TriaLevel<0>::reserve_space (const unsigned int total_cells,
-                                const unsigned int dimension)
-    {
-                                       // we need space for total_cells
-                                       // cells. Maybe we have more already
-                                       // with those cells which are unused,
-                                       // so only allocate new space if needed.
-                                       //
-                                       // note that all arrays should have equal
-                                       // sizes (checked by @p{monitor_memory}
-      if (total_cells > refine_flags.size()) 
-        {
-          refine_flags.reserve (total_cells);
-          refine_flags.insert (refine_flags.end(),
-                               total_cells - refine_flags.size(),
-                               false);
-      
-          coarsen_flags.reserve (total_cells);
-          coarsen_flags.insert (coarsen_flags.end(),
-                                total_cells - coarsen_flags.size(),
-                                false);
-      
-          subdomain_ids.reserve (total_cells);
-          subdomain_ids.insert (subdomain_ids.end(),
-                                total_cells - subdomain_ids.size(),
-                                0);
-      
-          neighbors.reserve (total_cells*(2*dimension));
-          neighbors.insert (neighbors.end(),
-                            total_cells*(2*dimension) - neighbors.size(),
-                            std::make_pair(-1,-1));
-        };
-    }
-
-
-
-    void
-    TriaLevel<0>::monitor_memory (const unsigned int true_dimension) const
-    {
-                                       // check that we have not allocated
-                                       // too much memory. note that bool
-                                       // vectors allocate their memory in
-                                       // chunks of whole integers, so
-                                       // they may over-allocate by up to
-                                       // as many elements as an integer
-                                       // has bits
-      Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 ||
-              refine_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
-              ExcMemoryWasted ("refine_flags",
-                               refine_flags.size(), refine_flags.capacity()));
-      Assert (coarsen_flags.size() <= coarsen_flags.capacity() + sizeof(int)*8 ||
-              coarsen_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
-              ExcMemoryWasted ("coarsen_flags",
-                               coarsen_flags.size(), coarsen_flags.capacity()));
-      Assert (neighbors.size() ==  neighbors.capacity() ||
-              neighbors.size()<DEAL_II_MIN_VECTOR_CAPACITY,
-              ExcMemoryWasted ("neighbors",
-                               neighbors.size(), neighbors.capacity()));
-      Assert (subdomain_ids.size() ==  subdomain_ids.capacity() ||
-              subdomain_ids.size()<DEAL_II_MIN_VECTOR_CAPACITY,
-              ExcMemoryWasted ("subdomain_ids",
-                               subdomain_ids.size(), subdomain_ids.capacity()));
-      Assert (2*true_dimension*refine_flags.size() == neighbors.size(),
-              ExcMemoryInexact (refine_flags.size(), neighbors.size()));
-      Assert (2*true_dimension*coarsen_flags.size() == neighbors.size(),
-              ExcMemoryInexact (coarsen_flags.size(), neighbors.size()));
-    }
-
-
-
-    unsigned int
-    TriaLevel<0>::memory_consumption () const
-    {
-      return (MemoryConsumption::memory_consumption (refine_flags) +
-              MemoryConsumption::memory_consumption (coarsen_flags) +
-              MemoryConsumption::memory_consumption (neighbors));
-    }
-
+    
   }
 }
 
index 81de320c5d5cd011d87003264907b6af28398fe2..9f044db9bb95c129f407fff8140b169ca48881ab 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2006 by the deal.II authors
+//    Copyright (C) 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
@@ -22,42 +22,177 @@ namespace internal
 {
   namespace Triangulation
   {
+    template <int dim>
+    void
+    TriaLevel<dim>::reserve_space (const unsigned int total_cells,
+                                  const unsigned int dimension)
+    {
+                                       // we need space for total_cells
+                                       // cells. Maybe we have more already
+                                       // with those cells which are unused,
+                                       // so only allocate new space if needed.
+                                       //
+                                       // note that all arrays should have equal
+                                       // sizes (checked by @p{monitor_memory}
+      if (total_cells > refine_flags.size()) 
+        {
+          refine_flags.reserve (total_cells);
+          refine_flags.insert (refine_flags.end(),
+                               total_cells - refine_flags.size(),
+                               false);
+      
+          coarsen_flags.reserve (total_cells);
+          coarsen_flags.insert (coarsen_flags.end(),
+                                total_cells - coarsen_flags.size(),
+                                false);
+      
+          subdomain_ids.reserve (total_cells);
+          subdomain_ids.insert (subdomain_ids.end(),
+                                total_cells - subdomain_ids.size(),
+                                0);
+      
+          neighbors.reserve (total_cells*(2*dimension));
+          neighbors.insert (neighbors.end(),
+                            total_cells*(2*dimension) - neighbors.size(),
+                            std::make_pair(-1,-1));
+        };
+    }
 
-#if deal_II_dimension == 1
 
-    unsigned int
-    TriaLevel<1>::memory_consumption () const
+    template <int dim>
+    void
+    TriaLevel<dim>::monitor_memory (const unsigned int true_dimension) const
     {
-      return (TriaLevel<0>::memory_consumption() +
-              MemoryConsumption::memory_consumption (lines));
+                                       // check that we have not allocated
+                                       // too much memory. note that bool
+                                       // vectors allocate their memory in
+                                       // chunks of whole integers, so
+                                       // they may over-allocate by up to
+                                       // as many elements as an integer
+                                       // has bits
+      Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 ||
+              refine_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
+              ExcMemoryWasted ("refine_flags",
+                               refine_flags.size(), refine_flags.capacity()));
+      Assert (coarsen_flags.size() <= coarsen_flags.capacity() + sizeof(int)*8 ||
+              coarsen_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
+              ExcMemoryWasted ("coarsen_flags",
+                               coarsen_flags.size(), coarsen_flags.capacity()));
+      Assert (neighbors.size() ==  neighbors.capacity() ||
+              neighbors.size()<DEAL_II_MIN_VECTOR_CAPACITY,
+              ExcMemoryWasted ("neighbors",
+                               neighbors.size(), neighbors.capacity()));
+      Assert (subdomain_ids.size() ==  subdomain_ids.capacity() ||
+              subdomain_ids.size()<DEAL_II_MIN_VECTOR_CAPACITY,
+              ExcMemoryWasted ("subdomain_ids",
+                               subdomain_ids.size(), subdomain_ids.capacity()));
+      Assert (2*true_dimension*refine_flags.size() == neighbors.size(),
+              ExcMemoryInexact (refine_flags.size(), neighbors.size()));
+      Assert (2*true_dimension*coarsen_flags.size() == neighbors.size(),
+              ExcMemoryInexact (coarsen_flags.size(), neighbors.size()));
     }
 
-#endif
-
-#if deal_II_dimension == 2
 
+    template <int dim>
     unsigned int
-    TriaLevel<2>::memory_consumption () const
+    TriaLevel<dim>::memory_consumption () const
     {
-      return (TriaLevel<0>::memory_consumption() +
-              MemoryConsumption::memory_consumption (quads));
+      return (MemoryConsumption::memory_consumption (refine_flags) +
+              MemoryConsumption::memory_consumption (coarsen_flags) +
+              MemoryConsumption::memory_consumption (neighbors) +
+              MemoryConsumption::memory_consumption (cells));
     }
 
-#endif
-
+// This specialization should be only temporary, until the TriaObjects
+// classes are straightened out.
+    
 #if deal_II_dimension == 3
+    void
+    TriaLevel<3>::reserve_space (const unsigned int total_cells,
+                                const unsigned int dimension)
+    {
+                                       // we need space for total_cells
+                                       // cells. Maybe we have more already
+                                       // with those cells which are unused,
+                                       // so only allocate new space if needed.
+                                       //
+                                       // note that all arrays should have equal
+                                       // sizes (checked by @p{monitor_memory}
+      if (total_cells > refine_flags.size()) 
+        {
+          refine_flags.reserve (total_cells);
+          refine_flags.insert (refine_flags.end(),
+                               total_cells - refine_flags.size(),
+                               false);
+      
+          coarsen_flags.reserve (total_cells);
+          coarsen_flags.insert (coarsen_flags.end(),
+                                total_cells - coarsen_flags.size(),
+                                false);
+      
+          subdomain_ids.reserve (total_cells);
+          subdomain_ids.insert (subdomain_ids.end(),
+                                total_cells - subdomain_ids.size(),
+                                0);
+      
+          neighbors.reserve (total_cells*(2*dimension));
+          neighbors.insert (neighbors.end(),
+                            total_cells*(2*dimension) - neighbors.size(),
+                            std::make_pair(-1,-1));
+        };
+    }
+
+
+    void
+    TriaLevel<3>::monitor_memory (const unsigned int true_dimension) const
+    {
+                                       // check that we have not allocated
+                                       // too much memory. note that bool
+                                       // vectors allocate their memory in
+                                       // chunks of whole integers, so
+                                       // they may over-allocate by up to
+                                       // as many elements as an integer
+                                       // has bits
+      Assert (refine_flags.size() <= refine_flags.capacity() + sizeof(int)*8 ||
+              refine_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
+              ExcMemoryWasted ("refine_flags",
+                               refine_flags.size(), refine_flags.capacity()));
+      Assert (coarsen_flags.size() <= coarsen_flags.capacity() + sizeof(int)*8 ||
+              coarsen_flags.size()<DEAL_II_MIN_BOOL_VECTOR_CAPACITY,
+              ExcMemoryWasted ("coarsen_flags",
+                               coarsen_flags.size(), coarsen_flags.capacity()));
+      Assert (neighbors.size() ==  neighbors.capacity() ||
+              neighbors.size()<DEAL_II_MIN_VECTOR_CAPACITY,
+              ExcMemoryWasted ("neighbors",
+                               neighbors.size(), neighbors.capacity()));
+      Assert (subdomain_ids.size() ==  subdomain_ids.capacity() ||
+              subdomain_ids.size()<DEAL_II_MIN_VECTOR_CAPACITY,
+              ExcMemoryWasted ("subdomain_ids",
+                               subdomain_ids.size(), subdomain_ids.capacity()));
+      Assert (2*true_dimension*refine_flags.size() == neighbors.size(),
+              ExcMemoryInexact (refine_flags.size(), neighbors.size()));
+      Assert (2*true_dimension*coarsen_flags.size() == neighbors.size(),
+              ExcMemoryInexact (coarsen_flags.size(), neighbors.size()));
+    }
+
 
     unsigned int
     TriaLevel<3>::memory_consumption () const
     {
-      return (TriaLevel<0>::memory_consumption() +
-              MemoryConsumption::memory_consumption (hexes));
+      return (MemoryConsumption::memory_consumption (refine_flags) +
+              MemoryConsumption::memory_consumption (coarsen_flags) +
+              MemoryConsumption::memory_consumption (neighbors) +
+              MemoryConsumption::memory_consumption (cells));
     }
 
 #endif
-
+    
   }
 }
 
+
+template class internal::Triangulation::TriaLevel<deal_II_dimension>;
+
+
 DEAL_II_NAMESPACE_CLOSE
 
index 33d6c7572ff058b132f45307f03d64028d966508..d229c18a7658127d86707a7893770933d8800e15 100644 (file)
@@ -4345,8 +4345,8 @@ namespace hp
           new std::vector<bool> (lines_on_level);
 
                                          // Check for each cell, if it has children.
-       transform (tria.levels[i]->lines.children.begin (),
-                  tria.levels[i]->lines.children.end (),
+       transform (tria.levels[i]->cells.children.begin (),
+                  tria.levels[i]->cells.children.end (),
                   has_children_level->begin (),
                   std::bind2nd (std::not_equal_to<int>(), -1));
 
@@ -4374,8 +4374,8 @@ namespace hp
           new std::vector<bool> (quads_on_level);
 
                                          // Check for each cell, if it has children.
-       std::transform (tria.levels[i]->quads.children.begin (),
-                        tria.levels[i]->quads.children.end (),
+       std::transform (tria.levels[i]->cells.children.begin (),
+                        tria.levels[i]->cells.children.end (),
                         has_children_level->begin (),
                         std::bind2nd (std::not_equal_to<int>(), -1));
 
@@ -4403,8 +4403,8 @@ namespace hp
 
                                          // Check for each cell, if it
                                          // has children.
-       transform (tria.levels[i]->hexes.children.begin (),
-                  tria.levels[i]->hexes.children.end (),
+       transform (tria.levels[i]->cells.children.begin (),
+                  tria.levels[i]->cells.children.end (),
                   has_children_level->begin (),
                   std::bind2nd (std::not_equal_to<int>(), -1));
 

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.