From 178aafe10587e2aa3685a27673e2a7164eb2a4b9 Mon Sep 17 00:00:00 2001 From: bangerth Date: Sat, 29 Jul 2006 04:48:45 +0000 Subject: [PATCH] Merge a number of functions that were previously in existence 6 times but could be written as one relatively straightforward. git-svn-id: https://svn.dealii.org/trunk@13495 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/dofs/dof_objects.h | 24 + deal.II/deal.II/include/dofs/hp_dof_objects.h | 389 ++++- deal.II/deal.II/source/dofs/dof_objects.cc | 26 +- deal.II/deal.II/source/dofs/hp_dof_objects.cc | 1519 ----------------- 4 files changed, 414 insertions(+), 1544 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_objects.h b/deal.II/deal.II/include/dofs/dof_objects.h index 487417b302..7e1297fb4e 100644 --- a/deal.II/deal.II/include/dofs/dof_objects.h +++ b/deal.II/deal.II/include/dofs/dof_objects.h @@ -205,6 +205,30 @@ namespace internal } + + template + template + inline + unsigned int + DoFObjects:: + get_dof_index (const ::DoFHandler &dof_handler, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index) const + { + Assert (fe_index == ::DoFHandler::default_fe_index, + ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); + Assert (local_index(), + ExcIndexRange (local_index, 0, dof_handler.get_fe().template n_dofs_per_object())); + Assert (obj_index * dof_handler.get_fe().template n_dofs_per_object()+local_index + < + dofs.size(), + ExcInternalError()); + + return dofs[obj_index * dof_handler.get_fe() + .template n_dofs_per_object() + local_index]; + } + } } #endif diff --git a/deal.II/deal.II/include/dofs/hp_dof_objects.h b/deal.II/deal.II/include/dofs/hp_dof_objects.h index 33b19b3b40..b4be1e955b 100644 --- a/deal.II/deal.II/include/dofs/hp_dof_objects.h +++ b/deal.II/deal.II/include/dofs/hp_dof_objects.h @@ -91,7 +91,7 @@ namespace internal * @author Tobias Leicht, 2006 */ - template + template class DoFObjects { @@ -247,6 +247,393 @@ namespace internal */ template friend class ::hp::DoFHandler; }; + + +// --------------------- inline and template functions ------------------ + + template + template + inline + unsigned int + DoFObjects:: + get_dof_index (const ::hp::DoFHandler &dof_handler, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int obj_level) const + { + 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 (fe_index < dof_handler.get_fe().size(), + ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); + Assert (local_index < + dof_handler.get_fe()[fe_index].template n_dofs_per_object(), + ExcIndexRange(local_index, 0, + dof_handler.get_fe()[fe_index] + .template n_dofs_per_object())); + Assert (obj_index < dof_offsets.size(), + ExcIndexRange (obj_index, 0, dof_offsets.size())); + + // make sure we are on an + // object for which DoFs have + // been allocated at all + Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, + ExcMessage ("You are trying to access degree of freedom " + "information for an object on which no such " + "information is available")); + + if (dim == spacedim) + { + // if we are on a cell, then + // the only set of indices we + // store is the one for the + // cell, which is unique. then + // fe_index must be + // active_fe_index + Assert (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index], + ExcMessage ("FE index does not match that of the present cell")); + return dofs[dof_offsets[obj_index]+local_index]; + } + else + { + // we are in higher space + // dimensions, so there may + // be multiple finite + // elements associated with + // this object. 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_offsets[obj_index]; + const unsigned int *pointer = &dofs[starting_offset]; + while (true) + { + Assert (*pointer != deal_II_numbers::invalid_unsigned_int, + ExcInternalError()); + if (*pointer == fe_index) + return *(pointer + 1 + local_index); + else + pointer += dof_handler.get_fe()[*pointer] + .template n_dofs_per_object() + 1; + } + } + } + + + + template + template + inline + void + DoFObjects:: + set_dof_index (const ::hp::DoFHandler &dof_handler, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index, + const unsigned int obj_level) + { + 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 (fe_index < dof_handler.get_fe().size(), + ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); + Assert (local_index < + dof_handler.get_fe()[fe_index].template n_dofs_per_object(), + ExcIndexRange(local_index, 0, + dof_handler.get_fe()[fe_index] + .template n_dofs_per_object())); + Assert (obj_index < dof_offsets.size(), + ExcIndexRange (obj_index, 0, dof_offsets.size())); + + // make sure we are on an + // object for which DoFs have + // been allocated at all + Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, + ExcMessage ("You are trying to access degree of freedom " + "information for an object on which no such " + "information is available")); + + if (dim == spacedim) + { + // if we are on a cell, then + // the only set of indices we + // store is the one for the + // cell, which is unique. then + // fe_index must be + // active_fe_index + Assert (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index], + ExcMessage ("FE index does not match that of the present cell")); + dofs[dof_offsets[obj_index]+local_index] = global_index; + } + else + { + // we are in higher space + // dimensions, so there may + // be multiple finite + // elements associated with + // this object. 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_offsets[obj_index]; + unsigned int *pointer = &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] + .template n_dofs_per_object() + 1; + } + } + } + + + + template + template + inline + unsigned int + DoFObjects:: + n_active_fe_indices (const ::hp::DoFHandler &dof_handler, + const unsigned int obj_index) const + { + Assert (dim <= spacedim, ExcInternalError()); + 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 (obj_index < dof_offsets.size(), + ExcIndexRange (obj_index, 0, dof_offsets.size())); + + // make sure we are on an + // object for which DoFs have + // been allocated at all + if (dof_offsets[obj_index] == deal_II_numbers::invalid_unsigned_int) + return 0; + + // if we are on a cell, then the + // only set of indices we store + // is the one for the cell, + // which is unique + if (dim == spacedim) + return 1; + else + { + // otherwise, there may be + // multiple finite elements + // associated with this + // object. 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_offsets[obj_index]; + const unsigned int *pointer = &dofs[starting_offset]; + unsigned int counter = 0; + while (true) + { + if (*pointer == deal_II_numbers::invalid_unsigned_int) + // end of list reached + return counter; + else + { + ++counter; + pointer += dof_handler.get_fe()[*pointer] + .template n_dofs_per_object() + 1; + } + } + } + } + + + + template + template + inline + unsigned int + DoFObjects:: + nth_active_fe_index (const ::hp::DoFHandler &dof_handler, + const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int n) const + { + Assert (dim <= spacedim, ExcInternalError()); + 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 (obj_index < dof_offsets.size(), + ExcIndexRange (obj_index, 0, dof_offsets.size())); + + // make sure we are on an + // object for which DoFs have + // been allocated at all + Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, + ExcMessage ("You are trying to access degree of freedom " + "information for an object on which no such " + "information is available")); + + if (dim == spacedim) + { + // this is a cell, so there + // is only a single + // fe_index + Assert (n == 0, ExcIndexRange (n, 0, 1)); + + return dof_handler.levels[obj_level]->active_fe_indices[obj_index]; + } + else + { + Assert (n < n_active_fe_indices(dof_handler, obj_index), + ExcIndexRange (n, 0, + n_active_fe_indices(dof_handler, obj_index))); + + // we are in higher space + // dimensions, so there may + // be multiple finite + // elements associated with + // this object. 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_offsets[obj_index]; + const unsigned int *pointer = &dofs[starting_offset]; + unsigned int counter = 0; + while (true) + { + Assert (*pointer != deal_II_numbers::invalid_unsigned_int, + ExcInternalError()); + + const unsigned int fe_index = *pointer; + + Assert (fe_index < dof_handler.get_fe().size(), + ExcInternalError()); + + if (counter == n) + return fe_index; + + ++counter; + pointer += dof_handler.get_fe()[fe_index] + .template n_dofs_per_object() + 1; + } + } + } + + + + template + template + inline + bool + DoFObjects:: + fe_index_is_active (const ::hp::DoFHandler &dof_handler, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int obj_level) const + { + 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 (obj_index < dof_offsets.size(), + ExcIndexRange (obj_index, 0, dof_offsets.size())); + Assert (fe_index != ::hp::DoFHandler<1>::default_fe_index, + ExcMessage ("You need to specify a FE index when working " + "with hp DoFHandlers")); + Assert (fe_index < dof_handler.get_fe().size(), + ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); + + // make sure we are on an + // object for which DoFs have + // been allocated at all + Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, + ExcMessage ("You are trying to access degree of freedom " + "information for an object on which no such " + "information is available")); + + if (dim == spacedim) + { + // if we are on a cell, + // then the only set of + // indices we store is the + // one for the cell, which + // is unique + Assert (obj_index < dof_handler.levels[obj_level]->active_fe_indices.size(), + ExcInternalError()); + return (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index]); + } + else + { + // we are in higher space + // dimensions, so there may + // be multiple finite + // elements associated with + // this object. 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_offsets[obj_index]; + const unsigned int *pointer = &dofs[starting_offset]; + while (true) + { + if (*pointer == deal_II_numbers::invalid_unsigned_int) + // end of list reached + return false; + else + if (*pointer == fe_index) + return true; + else + pointer += dof_handler.get_fe()[*pointer] + .template n_dofs_per_object() + 1; + } + } + } + } } diff --git a/deal.II/deal.II/source/dofs/dof_objects.cc b/deal.II/deal.II/source/dofs/dof_objects.cc index 792515ef34..d513077c73 100644 --- a/deal.II/deal.II/source/dofs/dof_objects.cc +++ b/deal.II/deal.II/source/dofs/dof_objects.cc @@ -31,29 +31,6 @@ namespace internal - template - template - unsigned int - DoFObjects:: - get_dof_index (const ::DoFHandler &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index) const - { - Assert (fe_index == ::DoFHandler::default_fe_index, - ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); - Assert (local_index(), - ExcIndexRange (local_index, 0, dof_handler.get_fe().template n_dofs_per_object())); - Assert (obj_index * dof_handler.get_fe().template n_dofs_per_object()+local_index - < - dofs.size(), - ExcInternalError()); - - return dofs[obj_index * dof_handler.get_fe().template n_dofs_per_object() + local_index]; - } - - - template template void @@ -73,7 +50,8 @@ namespace internal dofs.size(), ExcInternalError()); - dofs[obj_index * dof_handler.get_fe().template n_dofs_per_object() + local_index] = global_index; + dofs[obj_index * dof_handler.get_fe() + .template n_dofs_per_object() + local_index] = global_index; } // explicit instantiations diff --git a/deal.II/deal.II/source/dofs/hp_dof_objects.cc b/deal.II/deal.II/source/dofs/hp_dof_objects.cc index a9afdf9964..f4fe776aaf 100644 --- a/deal.II/deal.II/source/dofs/hp_dof_objects.cc +++ b/deal.II/deal.II/source/dofs/hp_dof_objects.cc @@ -32,1525 +32,6 @@ namespace internal MemoryConsumption::memory_consumption (dof_offsets)); } -#if deal_II_dimension == 1 - template <> - template <> - unsigned int - DoFObjects<1>:: - get_dof_index<1> (const ::hp::DoFHandler<1> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int obj_level) const - { - Assert (fe_index != ::hp::DoFHandler<1>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_line, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_line)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // if we are in 1d, then the - // only set of indices we store - // is the one for the cell, - // which is unique. then - // fe_index must be - // active_fe_index - - Assert (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index], - ExcMessage ("FE index does not match that of the present cell")); - return dofs[dof_offsets[obj_index]+local_index]; - } - - - template <> - template <> - void - DoFObjects<1>:: - set_dof_index<1> (const ::hp::DoFHandler<1> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index, - const unsigned int obj_level) - { - Assert (fe_index != ::hp::DoFHandler<1>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_line, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_line)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // if we are in 1d, then the - // only set of indices we store - // is the one for the cell, - // which is unique. then - // fe_index must be - // active_fe_index - Assert (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index], - ExcMessage ("FE index does not match that of the present cell")); - dofs[dof_offsets[obj_index]+local_index] = global_index; - } - - - - - - template <> - template <> - unsigned int - DoFObjects<1>:: - n_active_fe_indices<1> (const ::hp::DoFHandler<1> &dof_handler, - const unsigned int obj_index) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - if (dof_offsets[obj_index] == deal_II_numbers::invalid_unsigned_int) - return 0; - - // if we are in 1d, then the - // only set of indices we store - // is the one for the cell, - // which is unique - return 1; - } - - - - template <> - template <> - unsigned int - DoFObjects<1>:: - nth_active_fe_index<1> (const ::hp::DoFHandler<1> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int n) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // this is a cell, so there is - // only a single fe_index - Assert (n == 0, ExcIndexRange (n, 0, 1)); - - return dof_handler.levels[obj_level]->active_fe_indices[obj_index]; - } - - - - template <> - template <> - bool - DoFObjects<1>:: - fe_index_is_active<1> (const ::hp::DoFHandler<1> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int obj_level) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - Assert (fe_index != ::hp::DoFHandler<1>::default_fe_index, - ExcMessage ("You need to specify a FE index when working " - "with hp DoFHandlers")); - Assert (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // if we are in 1d, then the - // only set of indices we store - // is the one for the cell, - // which is unique - Assert (obj_index < dof_handler.levels[obj_level]->active_fe_indices.size(), - ExcInternalError()); - return (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index]); - } -#endif -#if deal_II_dimension == 2 - - template <> - template <> - unsigned int - DoFObjects<1>:: - get_dof_index<2> (const ::hp::DoFHandler<2> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int ) const - { - Assert (fe_index != ::hp::DoFHandler<2>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_line, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_line)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - while (true) - { - Assert (*pointer != deal_II_numbers::invalid_unsigned_int, - ExcInternalError()); - if (*pointer == fe_index) - return *(pointer + 1 + local_index); - else - pointer += dof_handler.get_fe()[*pointer].dofs_per_line + 1; - } - } - - - template <> - template <> - void - DoFObjects<1>:: - set_dof_index<2> (const ::hp::DoFHandler<2> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index, - const unsigned int ) - { - Assert (fe_index != ::hp::DoFHandler<2>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_line, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_line)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - unsigned int *pointer = &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_line + 1; - } - } - - - - - - template <> - template <> - unsigned int - DoFObjects<1>:: - n_active_fe_indices<2> (const ::hp::DoFHandler<2> &dof_handler, - const unsigned int obj_index) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - if (dof_offsets[obj_index] == deal_II_numbers::invalid_unsigned_int) - return 0; - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - unsigned int counter = 0; - while (true) - { - if (*pointer == deal_II_numbers::invalid_unsigned_int) - // end of list reached - return counter; - else - { - ++counter; - pointer += dof_handler.get_fe()[*pointer].dofs_per_line + 1; - } - } - } - - - - template <> - template <> - unsigned int - DoFObjects<1>:: - nth_active_fe_index<2> (const ::hp::DoFHandler<2> &dof_handler, - const unsigned int , - const unsigned int obj_index, - const unsigned int n) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - Assert (n < n_active_fe_indices(dof_handler, obj_index), - ExcIndexRange (n, 0, - n_active_fe_indices(dof_handler, obj_index))); - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - unsigned int counter = 0; - while (true) - { - Assert (*pointer != deal_II_numbers::invalid_unsigned_int, - ExcInternalError()); - - const unsigned int fe_index = *pointer; - - Assert (fe_index < dof_handler.get_fe().size(), - ExcInternalError()); - - if (counter == n) - return fe_index; - - ++counter; - pointer += dof_handler.get_fe()[fe_index].dofs_per_line + 1; - } - } - - - - template <> - template <> - bool - DoFObjects<1>:: - fe_index_is_active<2> (const ::hp::DoFHandler<2> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int ) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - Assert (fe_index != ::hp::DoFHandler<2>::default_fe_index, - ExcMessage ("You need to specify a FE index when working " - "with hp DoFHandlers")); - Assert (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - while (true) - { - if (*pointer == deal_II_numbers::invalid_unsigned_int) - // end of list reached - return false; - else - if (*pointer == fe_index) - return true; - else - pointer += dof_handler.get_fe()[*pointer].dofs_per_line + 1; - } - } -#endif -#if deal_II_dimension == 3 - - template <> - template <> - unsigned int - DoFObjects<1>:: - get_dof_index<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int ) const - { - Assert (fe_index != ::hp::DoFHandler<3>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_line, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_line)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - while (true) - { - Assert (*pointer != deal_II_numbers::invalid_unsigned_int, - ExcInternalError()); - if (*pointer == fe_index) - return *(pointer + 1 + local_index); - else - pointer += dof_handler.get_fe()[*pointer].dofs_per_line + 1; - } - } - - - - template <> - template <> - void - DoFObjects<1>:: - set_dof_index<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index, - const unsigned int ) - { - Assert (fe_index != ::hp::DoFHandler<3>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_line, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_line)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - unsigned int *pointer = &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_line + 1; - } - } - - - - template <> - template <> - unsigned int - DoFObjects<1>:: - n_active_fe_indices<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - if (dof_offsets[obj_index] == deal_II_numbers::invalid_unsigned_int) - return 0; - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - unsigned int counter = 0; - while (true) - { - if (*pointer == deal_II_numbers::invalid_unsigned_int) - // end of list reached - return counter; - else - { - ++counter; - pointer += dof_handler.get_fe()[*pointer].dofs_per_line + 1; - } - } - } - - - - template <> - template <> - unsigned int - DoFObjects<1>:: - nth_active_fe_index<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int , - const unsigned int obj_index, - const unsigned int n) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - Assert (n < n_active_fe_indices(dof_handler, obj_index), - ExcIndexRange (n, 0, - n_active_fe_indices(dof_handler, obj_index))); - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - unsigned int counter = 0; - while (true) - { - Assert (*pointer != deal_II_numbers::invalid_unsigned_int, - ExcInternalError()); - - const unsigned int fe_index = *pointer; - - Assert (fe_index < dof_handler.get_fe().size(), - ExcInternalError()); - - if (counter == n) - return fe_index; - - ++counter; - pointer += dof_handler.get_fe()[fe_index].dofs_per_line + 1; - } - } - - - - template <> - template <> - bool - DoFObjects<1>:: - fe_index_is_active<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int ) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - Assert (fe_index != ::hp::DoFHandler<3>::default_fe_index, - ExcMessage ("You need to specify a FE index when working " - "with hp DoFHandlers")); - Assert (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - while (true) - { - if (*pointer == deal_II_numbers::invalid_unsigned_int) - // end of list reached - return false; - else - if (*pointer == fe_index) - return true; - else - pointer += dof_handler.get_fe()[*pointer].dofs_per_line + 1; - } - } - -#endif -#if deal_II_dimension == 2 - - template <> - template <> - unsigned int - DoFObjects<2>:: - get_dof_index<2> (const ::hp::DoFHandler<2> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int obj_level) const - { - Assert (fe_index != ::hp::DoFHandler<2>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_quad, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_quad)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // if we are in 2d, then the - // only set of indices we store - // is the one for the cell, - // which is unique. then - // fe_index must be - // active_fe_index - Assert (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index], - ExcMessage ("FE index does not match that of the present cell")); - return dofs[dof_offsets[obj_index]+local_index]; - } - - - - template <> - template <> - void - DoFObjects<2>:: - set_dof_index<2> (const ::hp::DoFHandler<2> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index, - const unsigned int obj_level) - { - Assert (fe_index != ::hp::DoFHandler<2>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_quad, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_quad)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // if we are in 2d, then the - // only set of indices we store - // is the one for the cell, - // which is unique. then - // fe_index must be - // active_fe_index - Assert (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index], - ExcMessage ("FE index does not match that of the present cell")); - dofs[dof_offsets[obj_index]+local_index] = global_index; - } - - - - template <> - template <> - unsigned int - DoFObjects<2>:: - n_active_fe_indices<2> (const ::hp::DoFHandler<2> &dof_handler, - const unsigned int obj_index) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - if (dof_offsets[obj_index] == deal_II_numbers::invalid_unsigned_int) - return 0; - - // if we are in 2d, then the - // only set of indices we store - // is the one for the cell, - // which is unique - return 1; - } - - - - template <> - template <> - unsigned int - DoFObjects<2>:: - nth_active_fe_index<2> (const ::hp::DoFHandler<2> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int n) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // this is a cell, so there is - // only a single fe_index - Assert (n == 0, ExcIndexRange (n, 0, 1)); - - return dof_handler.levels[obj_level]->active_fe_indices[obj_index]; - } - - - - template <> - template <> - bool - DoFObjects<2>:: - fe_index_is_active<2> (const ::hp::DoFHandler<2> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int obj_level) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - Assert (fe_index != ::hp::DoFHandler<2>::default_fe_index, - ExcMessage ("You need to specify a FE index when working " - "with hp DoFHandlers")); - Assert (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // if we are in 2d, then the - // only set of indices we store - // is the one for the cell, - // which is unique - Assert (obj_index < dof_handler.levels[obj_level]->active_fe_indices.size(), - ExcInternalError()); - return (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index]); - } -#endif - -#if deal_II_dimension == 3 - template <> - template <> - unsigned int - DoFObjects<2>:: - get_dof_index<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int ) const - { - Assert (fe_index != ::hp::DoFHandler<3>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_quad, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_quad)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - while (true) - { - Assert (*pointer != deal_II_numbers::invalid_unsigned_int, - ExcInternalError()); - if (*pointer == fe_index) - return *(pointer + 1 + local_index); - else - pointer += dof_handler.get_fe()[*pointer].dofs_per_quad + 1; - } - } - - - - template <> - template <> - void - DoFObjects<2>:: - set_dof_index<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index, - const unsigned int ) - { - Assert (fe_index != ::hp::DoFHandler<3>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_quad, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_quad)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - unsigned int *pointer = &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_quad + 1; - } - } - - - - template <> - template <> - unsigned int - DoFObjects<2>:: - n_active_fe_indices<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - if (dof_offsets[obj_index] == deal_II_numbers::invalid_unsigned_int) - return 0; - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - unsigned int counter = 0; - while (true) - { - if (*pointer == deal_II_numbers::invalid_unsigned_int) - // end of list reached - return counter; - else - { - ++counter; - pointer += dof_handler.get_fe()[*pointer].dofs_per_quad + 1; - } - } - } - - - - template <> - template <> - unsigned int - DoFObjects<2>:: - nth_active_fe_index<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int , - const unsigned int obj_index, - const unsigned int n) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - Assert (n < n_active_fe_indices(dof_handler, obj_index), - ExcIndexRange (n, 0, - n_active_fe_indices(dof_handler, obj_index))); - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - unsigned int counter = 0; - while (true) - { - Assert (*pointer != deal_II_numbers::invalid_unsigned_int, - ExcInternalError()); - - const unsigned int fe_index = *pointer; - - Assert (fe_index < dof_handler.get_fe().size(), - ExcInternalError()); - - if (counter == n) - return fe_index; - - ++counter; - pointer += dof_handler.get_fe()[fe_index].dofs_per_quad + 1; - } - } - - - - template <> - template <> - bool - DoFObjects<2>:: - fe_index_is_active<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int ) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - Assert (fe_index != ::hp::DoFHandler<3>::default_fe_index, - ExcMessage ("You need to specify a FE index when working " - "with hp DoFHandlers")); - Assert (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // we are in higher space - // dimensions, so there may - // be multiple finite - // elements associated with - // this object. 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_offsets[obj_index]; - const unsigned int *pointer = &dofs[starting_offset]; - while (true) - { - if (*pointer == deal_II_numbers::invalid_unsigned_int) - // end of list reached - return false; - else - if (*pointer == fe_index) - return true; - else - pointer += dof_handler.get_fe()[*pointer].dofs_per_quad + 1; - } - } - - - - template <> - template <> - unsigned int - DoFObjects<3>:: - get_dof_index<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int obj_level) const - { - Assert (fe_index != ::hp::DoFHandler<3>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_hex, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_hex)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // if we are in 3d, then the - // only set of indices we store - // is the one for the cell, - // which is unique. then - // fe_index must be - // active_fe_index - Assert (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index], - ExcMessage ("FE index does not match that of the present cell")); - return dofs[dof_offsets[obj_index]+local_index]; - } - - - - template <> - template <> - void - DoFObjects<3>:: - set_dof_index<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index, - const unsigned int obj_level) - { - Assert (fe_index != ::hp::DoFHandler<3>::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 (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - Assert (local_index < dof_handler.get_fe()[fe_index].dofs_per_hex, - ExcIndexRange(local_index, 0, - dof_handler.get_fe()[fe_index].dofs_per_hex)); - Assert (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // if we are in 3d, then the - // only set of indices we store - // is the one for the cell, - // which is unique. then - // fe_index must be - // active_fe_index - Assert (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index], - ExcMessage ("FE index does not match that of the present cell")); - dofs[dof_offsets[obj_index]+local_index] = global_index; - } - - - - template <> - template <> - unsigned int - DoFObjects<3>:: - n_active_fe_indices<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - if (dof_offsets[obj_index] == deal_II_numbers::invalid_unsigned_int) - return 0; - - // if we are in 3d, then the - // only set of indices we store - // is the one for the cell, - // which is unique - return 1; - } - - - - template <> - template <> - unsigned int - DoFObjects<3>:: - nth_active_fe_index<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int n) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // this is a cell, so there is - // only a single fe_index - Assert (n == 0, ExcIndexRange (n, 0, 1)); - - return dof_handler.levels[obj_level]->active_fe_indices[obj_index]; - } - - - - template <> - template <> - bool - DoFObjects<3>:: - fe_index_is_active<3> (const ::hp::DoFHandler<3> &dof_handler, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int obj_level) const - { - 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 (obj_index < dof_offsets.size(), - ExcIndexRange (obj_index, 0, dof_offsets.size())); - Assert (fe_index != ::hp::DoFHandler<3>::default_fe_index, - ExcMessage ("You need to specify a FE index when working " - "with hp DoFHandlers")); - Assert (fe_index < dof_handler.get_fe().size(), - ExcIndexRange (fe_index, 0, dof_handler.get_fe().size())); - - // make sure we are on an - // object for which DoFs have - // been allocated at all - Assert (dof_offsets[obj_index] != deal_II_numbers::invalid_unsigned_int, - ExcMessage ("You are trying to access degree of freedom " - "information for an object on which no such " - "information is available")); - - // if we are in 3d, then the - // only set of indices we store - // is the one for the cell, - // which is unique - Assert (obj_index < dof_handler.levels[obj_level]->active_fe_indices.size(), - ExcInternalError()); - return (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index]); - } -#endif // explicit instantiations template -- 2.39.5