From 6a8dd3d1d202b5f1bdbd892d729becbec1fcacdc Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 28 Apr 2006 19:08:54 +0000 Subject: [PATCH] Fix a stupid problem that prevented compilation and that was introduced in my last checkin. Make code a lot simpler actually. git-svn-id: https://svn.dealii.org/trunk@12936 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/dofs/dof_accessor.templates.h | 111 ++---------------- deal.II/deal.II/include/dofs/hp_dof_handler.h | 13 ++ deal.II/deal.II/include/dofs/hp_dof_levels.h | 18 +-- deal.II/deal.II/source/dofs/hp_dof_levels.cc | 106 ++++++++++++----- 4 files changed, 112 insertions(+), 136 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_accessor.templates.h b/deal.II/deal.II/include/dofs/dof_accessor.templates.h index df56233c56..6bcd68b5fc 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.templates.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.templates.h @@ -965,24 +965,10 @@ DoFObjectAccessor<1,hp::DoFHandler<1> >::vertex_dof_index (const unsigned int ve const unsigned int i, const unsigned int fe_index) const { - Assert (fe_index != hp::DoFHandler<1>::default_fe_index, - ExcMessage ("You need to specify a FE index when working with hp DoFHandlers")); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("hp::DoFHandler not initialized")); - - Assert (this->dof_handler != 0, DoFAccessor >::ExcInvalidObject()); - Assert (&this->dof_handler->get_fe() != 0, DoFAccessor >::ExcInvalidObject()); - Assert (vertex<2, ExcIndexRange (i,0,2)); - Assert (idof_handler->get_fe()[fe_index].dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->get_fe()[fe_index].dofs_per_vertex)); - - const unsigned int starting_offset - = this->dof_handler->vertex_dofs_offsets[this->vertex_index(vertex)]; - return internal::hp::DoFLevel<0>:: - get_hp_vertex_dof_index (this->dof_handler->get_fe(), + get_hp_vertex_dof_index (*this->dof_handler, + this->vertex_index(vertex), fe_index, - &this->dof_handler->vertex_dofs[starting_offset], i); } @@ -995,24 +981,10 @@ DoFObjectAccessor<1,hp::DoFHandler<2> >::vertex_dof_index (const unsigned int ve const unsigned int i, const unsigned int fe_index) const { - Assert (fe_index != hp::DoFHandler<2>::default_fe_index, - ExcMessage ("You need to specify a FE index when working with hp DoFHandlers")); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("hp::DoFHandler not initialized")); - - Assert (this->dof_handler != 0, DoFAccessor >::ExcInvalidObject()); - Assert (&this->dof_handler->get_fe() != 0, DoFAccessor >::ExcInvalidObject()); - Assert (vertex<2, ExcIndexRange (i,0,2)); - Assert (idof_handler->get_fe()[fe_index].dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->get_fe()[fe_index].dofs_per_vertex)); - - const unsigned int starting_offset - = this->dof_handler->vertex_dofs_offsets[this->vertex_index(vertex)]; - return internal::hp::DoFLevel<0>:: - get_hp_vertex_dof_index (this->dof_handler->get_fe(), + get_hp_vertex_dof_index (*this->dof_handler, + this->vertex_index(vertex), fe_index, - &this->dof_handler->vertex_dofs[starting_offset], i); } @@ -1024,24 +996,10 @@ DoFObjectAccessor<1,hp::DoFHandler<3> >::vertex_dof_index (const unsigned int ve const unsigned int i, const unsigned int fe_index) const { - Assert (fe_index != hp::DoFHandler<3>::default_fe_index, - ExcMessage ("You need to specify a FE index when working with hp DoFHandlers")); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("hp::DoFHandler not initialized")); - - Assert (this->dof_handler != 0, DoFAccessor >::ExcInvalidObject()); - Assert (&this->dof_handler->get_fe() != 0, DoFAccessor >::ExcInvalidObject()); - Assert (vertex<2, ExcIndexRange (i,0,2)); - Assert (idof_handler->get_fe()[fe_index].dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->get_fe()[fe_index].dofs_per_vertex)); - - const unsigned int starting_offset - = this->dof_handler->vertex_dofs_offsets[this->vertex_index(vertex)]; - return internal::hp::DoFLevel<0>:: - get_hp_vertex_dof_index (this->dof_handler->get_fe(), + get_hp_vertex_dof_index (*this->dof_handler, + this->vertex_index(vertex), fe_index, - &this->dof_handler->vertex_dofs[starting_offset], i); } @@ -1053,25 +1011,10 @@ DoFObjectAccessor<2,hp::DoFHandler<2> >::vertex_dof_index (const unsigned int ve const unsigned int i, const unsigned int fe_index) const { - Assert (fe_index != hp::DoFHandler<2>::default_fe_index, - ExcMessage ("You need to specify a FE index when working with hp DoFHandlers")); - Assert (this->dof_handler != 0, - DoFAccessor >::ExcInvalidObject()); - Assert (&this->dof_handler->get_fe() != 0, - DoFAccessor >::ExcInvalidObject()); - Assert (vertex<4, ExcIndexRange (i,0,4)); - Assert (idof_handler->get_fe()[fe_index].dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->get_fe()[fe_index].dofs_per_vertex)); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("hp::DoFHandler not initialized")); - - const unsigned int starting_offset - = this->dof_handler->vertex_dofs_offsets[this->vertex_index(vertex)]; - return internal::hp::DoFLevel<0>:: - get_hp_vertex_dof_index (this->dof_handler->get_fe(), + get_hp_vertex_dof_index (*this->dof_handler, + this->vertex_index(vertex), fe_index, - &this->dof_handler->vertex_dofs[starting_offset], i); } @@ -1084,25 +1027,10 @@ DoFObjectAccessor<2,hp::DoFHandler<3> >::vertex_dof_index (const unsigned int ve const unsigned int i, const unsigned int fe_index) const { - Assert (fe_index != hp::DoFHandler<3>::default_fe_index, - ExcMessage ("You need to specify a FE index when working with hp DoFHandlers")); - Assert (this->dof_handler != 0, - DoFAccessor >::ExcInvalidObject()); - Assert (&this->dof_handler->get_fe() != 0, - DoFAccessor >::ExcInvalidObject()); - Assert (vertex<4, ExcIndexRange (i,0,4)); - Assert (idof_handler->get_fe()[fe_index].dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->get_fe()[fe_index].dofs_per_vertex)); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("hp::DoFHandler not initialized")); - - const unsigned int starting_offset - = this->dof_handler->vertex_dofs_offsets[this->vertex_index(vertex)]; - return internal::hp::DoFLevel<0>:: - get_hp_vertex_dof_index (this->dof_handler->get_fe(), + get_hp_vertex_dof_index (*this->dof_handler, + this->vertex_index(vertex), fe_index, - &this->dof_handler->vertex_dofs[starting_offset], i); } @@ -1115,25 +1043,10 @@ DoFObjectAccessor<3,hp::DoFHandler<3> >::vertex_dof_index (const unsigned int ve const unsigned int i, const unsigned int fe_index) const { - Assert (fe_index != hp::DoFHandler<3>::default_fe_index, - ExcMessage ("You need to specify a FE index when working with hp DoFHandlers")); - Assert (this->dof_handler != 0, - DoFAccessor >::ExcInvalidObject()); - Assert (&this->dof_handler->get_fe() != 0, - DoFAccessor >::ExcInvalidObject()); - Assert (vertex<4, ExcIndexRange (i,0,4)); - Assert (idof_handler->get_fe()[fe_index].dofs_per_vertex, - ExcIndexRange (i, 0, this->dof_handler->get_fe()[fe_index].dofs_per_vertex)); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("hp::DoFHandler not initialized")); - - const unsigned int starting_offset - = this->dof_handler->vertex_dofs_offsets[this->vertex_index(vertex)]; - return internal::hp::DoFLevel<0>:: - get_hp_vertex_dof_index (this->dof_handler->get_fe(), + get_hp_vertex_dof_index (*this->dof_handler, + this->vertex_index(vertex), fe_index, - &this->dof_handler->vertex_dofs[starting_offset], i); } 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 c9facc4c51..19c42f9e83 100644 --- a/deal.II/deal.II/include/dofs/hp_dof_handler.h +++ b/deal.II/deal.II/include/dofs/hp_dof_handler.h @@ -32,6 +32,10 @@ namespace internal namespace hp { template class DoFLevel; + template <> class DoFLevel<0>; + template <> class DoFLevel<1>; + template <> class DoFLevel<2>; + template <> class DoFLevel<3>; } } @@ -1071,6 +1075,15 @@ namespace hp * Make accessor objects friends. */ template friend class ::DoFCellAccessor; + + /** + * Likewise for DoFLevel<0> + * objects since they need to + * access the vertex dofs in + * the functions that set and + * retrieve vertex dof indices. + */ + template friend class internal::hp::DoFLevel; }; diff --git a/deal.II/deal.II/include/dofs/hp_dof_levels.h b/deal.II/deal.II/include/dofs/hp_dof_levels.h index fdc3da243b..db47306c48 100644 --- a/deal.II/deal.II/include/dofs/hp_dof_levels.h +++ b/deal.II/deal.II/include/dofs/hp_dof_levels.h @@ -88,20 +88,20 @@ namespace internal template static - unsigned int - get_hp_vertex_dof_index (const ::hp::FECollection &fe, + void + set_hp_vertex_dof_index (::hp::DoFHandler &dof_handler, + const unsigned int vertex_index, const unsigned int fe_index, - const unsigned int *start_of_list, - const unsigned int local_index); + const unsigned int local_index, + const unsigned int global_index); template static - void - set_hp_vertex_dof_index (const ::hp::FECollection &fe, + unsigned int + get_hp_vertex_dof_index (const ::hp::DoFHandler &dof_handler, + const unsigned int vertex_index, const unsigned int fe_index, - const unsigned int *start_of_list, - const unsigned int local_index, - const unsigned int global_index); + const unsigned int local_index); }; diff --git a/deal.II/deal.II/source/dofs/hp_dof_levels.cc b/deal.II/deal.II/source/dofs/hp_dof_levels.cc index e6b32b4ef6..c47a5dd720 100644 --- a/deal.II/deal.II/source/dofs/hp_dof_levels.cc +++ b/deal.II/deal.II/source/dofs/hp_dof_levels.cc @@ -14,6 +14,8 @@ #include #include +#include +#include namespace internal @@ -47,33 +49,29 @@ namespace internal MemoryConsumption::memory_consumption (dof_hex_index_offset)); } - template - void - DoFLevel<0>:: - set_hp_vertex_dof_index (const ::hp::FECollection &fe, - const unsigned int fe_index, - const unsigned int *start_of_list, - const unsigned int local_index, - const unsigned int global_index) - { - Assert (fe_index != hp::DoFHandler::default_fe_index, - ExcMessage ("You need to specify a FE index when working with hp DoFHandlers")); - abort (); - } + template unsigned int DoFLevel<0>:: - get_hp_vertex_dof_index (const ::hp::FECollection &fe, + get_hp_vertex_dof_index (const ::hp::DoFHandler &dof_handler, + const unsigned int vertex_index, const unsigned int fe_index, - const unsigned int *start_of_list, const unsigned int local_index) { - Assert (fe_index != hp::DoFHandler::default_fe_index, - ExcMessage ("You need to specify a FE index when working with hp DoFHandlers")); - Assert (local_index < fe[fe_index].dofs_per_vertex, - ExcIndexRange(local_index, 0, fe[fe_index].dofs_per_vertex)); + Assert (fe_index != ::hp::DoFHandler::default_fe_index, + ExcMessage ("You need to specify a FE index when working " + "with hp DoFHandlers")); + Assert (&dof_handler != 0, + ExcMessage ("No DoFHandler is specified for this iterator")); + Assert (&dof_handler.get_fe() != 0, + ExcMessage ("No finite element collection is associated with " + "this DoFHandler")); + Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_vertex, + ExcIndexRange(local_index, 0, + dof_handler.get_fe()[fe_index].dofs_per_vertex)); + // hop along the list of index // sets until we find the one // with the correct fe_index, and @@ -81,7 +79,10 @@ namespace internal // part. trigger an exception if // we can't find a set for this // particular fe_index - const unsigned int *pointer = start_of_list; + const unsigned int starting_offset + = dof_handler.vertex_dofs_offsets[vertex_index]; + const unsigned int *pointer + = &dof_handler.vertex_dofs[starting_offset]; while (true) { Assert (*pointer != deal_II_numbers::invalid_unsigned_int, @@ -89,27 +90,76 @@ namespace internal if (*pointer == fe_index) return *(pointer + 1 + local_index); else - pointer += fe[*pointer].dofs_per_vertex; + pointer += dof_handler.get_fe()[*pointer].dofs_per_vertex; } } -// explicit instantiations - template + + template void DoFLevel<0>:: - set_hp_vertex_dof_index (const ::hp::FECollection &fe, + set_hp_vertex_dof_index (::hp::DoFHandler &dof_handler, + const unsigned int vertex_index, const unsigned int fe_index, - const unsigned int *start_of_list, const unsigned int local_index, - const unsigned int global_index); + const unsigned int global_index) + { + Assert (fe_index != ::hp::DoFHandler::default_fe_index, + ExcMessage ("You need to specify a FE index when working " + "with hp DoFHandlers")); + Assert (&dof_handler != 0, + ExcMessage ("No DoFHandler is specified for this iterator")); + Assert (&dof_handler.get_fe() != 0, + ExcMessage ("No finite element collection is associated with " + "this DoFHandler")); + Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_vertex, + ExcIndexRange(local_index, 0, + dof_handler.get_fe()[fe_index].dofs_per_vertex)); + + // hop along the list of index + // sets until we find the one + // with the correct fe_index, and + // then poke into that + // part. trigger an exception if + // we can't find a set for this + // particular fe_index + const unsigned int starting_offset + = dof_handler.vertex_dofs_offsets[vertex_index]; + unsigned int *pointer + = &dof_handler.vertex_dofs[starting_offset]; + while (true) + { + Assert (*pointer != deal_II_numbers::invalid_unsigned_int, + ExcInternalError()); + if (*pointer == fe_index) + { + *(pointer + 1 + local_index) = global_index; + return; + } + else + pointer += dof_handler.get_fe()[*pointer].dofs_per_vertex; + } + } + + +// explicit instantiations template unsigned int DoFLevel<0>:: - get_hp_vertex_dof_index (const ::hp::FECollection &fe, + get_hp_vertex_dof_index (const ::hp::DoFHandler &dof_handler, + const unsigned int vertex_index, const unsigned int fe_index, - const unsigned int *start_of_list, const unsigned int local_index); + + template + void + DoFLevel<0>:: + set_hp_vertex_dof_index (::hp::DoFHandler &dof_handler, + const unsigned int vertex_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index); } } -- 2.39.5