From: bangerth Date: Thu, 27 Jul 2006 00:39:12 +0000 (+0000) Subject: Add a few infrastructure functions to query vertex dofs and associated information X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d8c625441dd2ba67e2a70e237f3df274a1d9d4a;p=dealii-svn.git Add a few infrastructure functions to query vertex dofs and associated information git-svn-id: https://svn.dealii.org/trunk@13438 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/dofs/hp_dof_handler.h b/deal.II/deal.II/include/dofs/hp_dof_handler.h index 143a78a6c7..b3a4c00f93 100644 --- a/deal.II/deal.II/include/dofs/hp_dof_handler.h +++ b/deal.II/deal.II/include/dofs/hp_dof_handler.h @@ -1022,18 +1022,52 @@ namespace hp get_vertex_dof_index (const unsigned int vertex_index, const unsigned int fe_index, const unsigned int local_index) const; + + /** + * Return the number of + * different finite elements + * that are active on a given + * vertex. + */ + unsigned int + n_active_vertex_fe_indices (const unsigned int vertex_index) const; + /** - * Return the @p i-th dof-index. This function calls - * the respective function of DoFObjects. + * Return the fe index of the + * n-th finite element active + * on a given vertex. + */ + unsigned int + nth_active_vertex_fe_index (const unsigned int vertex_index, + const unsigned int n) const; + + /** + * Return whether a particular + * finite element index is + * active on the specified + * vertex. + */ + bool + fe_is_active_on_vertex (const unsigned int vertex_index, + const unsigned int fe_index) const; + + /** + * Return the @p i-th + * dof-index. This function + * calls the respective + * function of DoFObjects. */ template unsigned int get_dof_index (const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index) const; + /** - * Set the @p i-th dof-index. This function calls - * the respective function of DoFObjects. + * Set the @p i-th + * dof-index. This function + * calls the respective + * function of DoFObjects. */ template void set_dof_index (const unsigned int obj_level, @@ -1041,16 +1075,21 @@ namespace hp const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index) const; + /** - * number of active fe-indices, calls the respective + * Number of active fe-indices, + * calls the respective * function in DoFObjects */ template unsigned int n_active_fe_indices (const unsigned int obj_level, const unsigned int obj_index) const; + /** - * return, wether fe-index is an active fe, calls the - * respective function in DoFObjects + * Return whether fe-index is + * an active fe, calls the + * respective function in + * DoFObjects */ template bool fe_index_is_active (const unsigned int obj_level, @@ -1418,6 +1457,151 @@ namespace hp pointer += (*finite_elements)[this_fe_index].dofs_per_vertex + 1; } } + + + + template + inline + unsigned int + DoFHandler:: + n_active_vertex_fe_indices (const unsigned int vertex_index) const + { + Assert (finite_elements != 0, + ExcMessage ("No finite element collection is associated with " + "this DoFHandler")); + + // if this vertex is unused, return 0 + if (vertex_dofs_offsets[vertex_index] == deal_II_numbers::invalid_unsigned_int) + return 0; + + // hop along the list of index + // sets and count the number of + // hops + const unsigned int starting_offset = vertex_dofs_offsets[vertex_index]; + const unsigned int *pointer = &vertex_dofs[starting_offset]; + + Assert (*pointer != deal_II_numbers::invalid_unsigned_int, + ExcInternalError()); + + unsigned int counter = 0; + while (true) + { + Assert (pointer <= &vertex_dofs.back(), ExcInternalError()); + + const unsigned int this_fe_index = *pointer; + + if (this_fe_index == deal_II_numbers::invalid_unsigned_int) + return counter; + else + { + pointer += (*finite_elements)[this_fe_index].dofs_per_vertex + 1; + ++counter; + } + } + } + + + + template + inline + unsigned int + DoFHandler:: + nth_active_vertex_fe_index (const unsigned int vertex_index, + const unsigned int n) const + { + Assert (finite_elements != 0, + ExcMessage ("No finite element collection is associated with " + "this DoFHandler")); + Assert (n < n_active_vertex_fe_indices(vertex_index), + ExcIndexRange (n, 0, n_active_vertex_fe_indices(vertex_index))); + // make sure we don't ask on + // unused vertices + Assert (vertex_dofs_offsets[vertex_index] != + deal_II_numbers::invalid_unsigned_int, + ExcInternalError()); + + // hop along the list of index + // sets and count the number of + // hops + const unsigned int starting_offset = vertex_dofs_offsets[vertex_index]; + const unsigned int *pointer = &vertex_dofs[starting_offset]; + + Assert (*pointer != deal_II_numbers::invalid_unsigned_int, + ExcInternalError()); + + unsigned int counter = 0; + while (true) + { + Assert (pointer <= &vertex_dofs.back(), ExcInternalError()); + + const unsigned int this_fe_index = *pointer; + + Assert (this_fe_index < finite_elements->size(), + ExcInternalError()); + + if (counter == n) + return this_fe_index; + + Assert (this_fe_index != deal_II_numbers::invalid_unsigned_int, + ExcInternalError()); + + pointer += (*finite_elements)[this_fe_index].dofs_per_vertex + 1; + ++counter; + } + } + + + + template + inline + bool + DoFHandler:: + fe_is_active_on_vertex (const unsigned int vertex_index, + const unsigned int fe_index) const + { + Assert (fe_index != ::hp::DoFHandler::default_fe_index, + ExcMessage ("You need to specify a FE index when working " + "with hp DoFHandlers")); + Assert (finite_elements != 0, + ExcMessage ("No finite element collection is associated with " + "this DoFHandler")); + Assert (fe_index < finite_elements->size(), + ExcInternalError()); + + // make sure we don't ask on + // unused vertices + Assert (vertex_dofs_offsets[vertex_index] != + deal_II_numbers::invalid_unsigned_int, + ExcInternalError()); + + // hop along the list of index + // sets and see whether we find + // the given index + const unsigned int starting_offset = vertex_dofs_offsets[vertex_index]; + const unsigned int *pointer = &vertex_dofs[starting_offset]; + + Assert (*pointer != deal_II_numbers::invalid_unsigned_int, + ExcInternalError()); + + while (true) + { + Assert (pointer <= &vertex_dofs.back(), ExcInternalError()); + + const unsigned int this_fe_index = *pointer; + + Assert (this_fe_index < finite_elements->size(), + ExcInternalError()); + + if (this_fe_index == deal_II_numbers::invalid_unsigned_int) + return false; + else + if (this_fe_index == fe_index) + return true; + else + pointer += (*finite_elements)[this_fe_index].dofs_per_vertex + 1; + } + } + #endif