]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce a way to query the address of the DoF cache in a generic way. This will...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 10 Sep 2013 19:49:25 +0000 (19:49 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 10 Sep 2013 19:49:25 +0000 (19:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@30668 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/dofs/dof_accessor.templates.h
deal.II/include/deal.II/dofs/dof_levels.h
deal.II/include/deal.II/hp/dof_level.h

index 5fee314d9e6d206850048a96a974c54dda82bf29..af53612a033bb88b0204063db90751f21c7d4300 100644 (file)
@@ -2773,8 +2773,9 @@ namespace internal
         Assert (!accessor.has_children(),
                 ExcMessage ("Cell must be active."));
 
-        types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()]
-                                         ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell];
+        const types::global_dof_index *cache
+        = accessor.dof_handler->levels[accessor.level()]
+          ->get_cell_cache_start (accessor.present_index, accessor.get_fe().dofs_per_cell);
         for (unsigned int i=0; i<accessor.get_fe().dofs_per_cell; ++i, ++cache)
           dof_indices[i] = *cache;
       }
@@ -2797,8 +2798,9 @@ namespace internal
         Assert (!accessor.has_children(),
                 ExcMessage ("Cell must be active."));
 
-        types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()]
-                                         ->cell_dof_indices_cache[accessor.dof_handler->levels[accessor.level()]->cell_cache_offsets[accessor.present_index]];
+        const types::global_dof_index *cache
+        = accessor.dof_handler->levels[accessor.level()]
+          ->get_cell_cache_start (accessor.present_index, accessor.get_fe().dofs_per_cell);
         for (unsigned int i=0; i<accessor.get_fe().dofs_per_cell; ++i, ++cache)
           dof_indices[i] = *cache;
       }
index a153fa1c7bf002f3a47c31f8fe942d23909b3359..c657388fe9d7bb892d44ca1e136bab68cd195ae0 100644 (file)
@@ -90,6 +90,18 @@ namespace internal
        */
       DoFObjects<dim> dof_object;
 
+      /**
+       * Return a pointer to the beginning of the DoF indices cache
+       * for a given cell.
+       *
+       * @param obj_index The number of the cell we are looking at.
+       * @param dofs_per_cell The number of DoFs per cell for this cell.
+       * @return A pointer to the first DoF index for the current cell. The
+       *   next dofs_per_cell indices are for the current cell.
+       */
+      const types::global_dof_index *
+      get_cell_cache_start (const unsigned int obj_index,
+                               const unsigned int dofs_per_cell) const;
 
       /**
        * Determine an estimate for the
@@ -108,6 +120,23 @@ namespace internal
     };
 
 
+
+    template <int dim>
+    inline
+    const types::global_dof_index *
+    DoFLevel<dim>::get_cell_cache_start (const unsigned int obj_index,
+                                             const unsigned int dofs_per_cell) const
+    {
+      Assert (obj_index*dofs_per_cell+dofs_per_cell
+              <=
+              cell_dof_indices_cache.size(),
+              ExcInternalError());
+
+      return &cell_dof_indices_cache[obj_index*dofs_per_cell];
+    }
+
+
+
     template <int dim>
     inline
     std::size_t
index 37f56ed13c2080b5db3efac37034f0c1c04d69d8..80c4e24b3fc74a7a24a8a16b251112ca55e34447 100644 (file)
@@ -252,6 +252,20 @@ namespace internal
       set_active_fe_index (const unsigned int obj_index,
                           const unsigned int fe_index);
 
+      /**
+       * Return a pointer to the beginning of the DoF indices cache
+       * for a given cell.
+       *
+       * @param obj_index The number of the cell we are looking at.
+       * @param dofs_per_cell The number of DoFs per cell for this cell. This
+       *   is not used for the hp case but necessary to keep the interface
+       *   the same as for the non-hp case.
+       * @return A pointer to the first DoF index for the current cell. The
+       *   next dofs_per_cell indices are for the current cell.
+       */
+      const types::global_dof_index *
+      get_cell_cache_start (const unsigned int obj_index,
+                               const unsigned int dofs_per_cell) const;
 
       /**
        * Determine an estimate for the
@@ -393,6 +407,22 @@ namespace internal
       active_fe_indices[obj_index] = fe_index;
     }
 
+
+
+    inline
+    const types::global_dof_index *
+    DoFLevel::get_cell_cache_start (const unsigned int obj_index,
+                                        const unsigned int dofs_per_cell) const
+    {
+      Assert (obj_index < cell_cache_offsets.size(),
+              ExcInternalError());
+      Assert (cell_cache_offsets[obj_index]+dofs_per_cell
+              <=
+              cell_dof_indices_cache.size(),
+              ExcInternalError());
+
+      return &cell_dof_indices_cache[cell_cache_offsets[obj_index]];
+    }
   } // namespace hp
 
 } // namespace internal

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.