From 422ab13b0fe1474243ad989326b3b0a09a5e51b3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 2 Jul 2021 17:25:56 -0600 Subject: [PATCH] No longer require active_fe_index when calling cell->vertex_dof_index(). --- include/deal.II/dofs/dof_accessor.h | 18 +++++++++++------- include/deal.II/dofs/dof_accessor.templates.h | 18 ++++++++++++++---- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/include/deal.II/dofs/dof_accessor.h b/include/deal.II/dofs/dof_accessor.h index a011cda7da..39d95fc465 100644 --- a/include/deal.II/dofs/dof_accessor.h +++ b/include/deal.II/dofs/dof_accessor.h @@ -477,14 +477,18 @@ public: * ::DoFHandler class, this value must be equal to its default value since * that class only supports the same finite element on all cells anyway. * - * However, when hp-capabilities are enabled, different finite element - * objects may be used on different cells. On faces between two cells, as - * well as vertices, there may therefore be two sets of degrees of freedom, - * one for each of the finite elements used on the adjacent cells. In order - * to specify which set of degrees of freedom to work on, the last argument - * is used to disambiguate. Finally, if this function is called for a cell + * However, when hp-capabilities are enabled, different finite + * element objects may be used on different cells. On faces between + * two cells, as well as vertices, there may therefore be two sets + * of degrees of freedom, one for each of the finite elements used + * on the adjacent cells. In order to specify which set of degrees + * of freedom to work on, the last argument is used to + * disambiguate. Finally, if this function is called for a cell * object, there can only be a single set of degrees of freedom, and - * fe_index has to match the result of active_fe_index(). + * `fe_index` has to match the result of + * `cell->active_fe_index()`. Alternatively, if `fe_index` is left + * to its default value when this function is called on a cell, then + * this is interpreted as equal to `cell->active_fe_index()`. */ types::global_dof_index vertex_dof_index(const unsigned int vertex, diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index 1f3c77bc6c..d665de9ff0 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -1627,10 +1627,20 @@ DoFAccessor::vertex_dof_index( const unsigned int fe_index_) const { const unsigned int fe_index = - (this->dof_handler->hp_capability_enabled == false && - fe_index_ == DoFHandler::invalid_fe_index) ? - DoFHandler::default_fe_index : - fe_index_; + (((this->dof_handler->hp_capability_enabled == false) && + (fe_index_ == DoFHandler::invalid_fe_index)) ? + // No hp enabled, and the argument is at its default value -> we + // can translate to the default active fe index + DoFHandler::default_fe_index : + // Otherwise: If anything other than the default is provided by + // the caller, then we should take just that. As an exception, if + // we are on a cell (rather than a face/edge/vertex), then we know + // that there is only one active fe index on this cell and we can + // use that: + ((dim == structdim) && + (fe_index_ == DoFHandler::invalid_fe_index) ? + this->nth_active_fe_index(0) : + fe_index_)); return dealii::internal::DoFAccessorImplementation::Implementation:: get_dof_index(*this->dof_handler, -- 2.39.5