From dad7acf55180776177576eef4a5ec4f9a764f62d Mon Sep 17 00:00:00 2001 From: bangerth Date: Tue, 10 Sep 2013 19:49:25 +0000 Subject: [PATCH] Introduce a way to query the address of the DoF cache in a generic way. This will allow unifying in the next step. git-svn-id: https://svn.dealii.org/trunk@30668 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/dofs/dof_accessor.templates.h | 10 ++++--- deal.II/include/deal.II/dofs/dof_levels.h | 29 ++++++++++++++++++ deal.II/include/deal.II/hp/dof_level.h | 30 +++++++++++++++++++ 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/deal.II/include/deal.II/dofs/dof_accessor.templates.h b/deal.II/include/deal.II/dofs/dof_accessor.templates.h index 5fee314d9e..af53612a03 100644 --- a/deal.II/include/deal.II/dofs/dof_accessor.templates.h +++ b/deal.II/include/deal.II/dofs/dof_accessor.templates.h @@ -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; ilevels[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 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 + 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*dofs_per_cell+dofs_per_cell + <= + cell_dof_indices_cache.size(), + ExcInternalError()); + + return &cell_dof_indices_cache[obj_index*dofs_per_cell]; + } + + + template inline std::size_t diff --git a/deal.II/include/deal.II/hp/dof_level.h b/deal.II/include/deal.II/hp/dof_level.h index 37f56ed13c..80c4e24b3f 100644 --- a/deal.II/include/deal.II/hp/dof_level.h +++ b/deal.II/include/deal.II/hp/dof_level.h @@ -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 -- 2.39.5