From cd7004b16da2f4ab496ea4a520989dc051b4e86a Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 1 May 2006 22:30:11 +0000 Subject: [PATCH] For the moment, a last wave of restructuring and consolidation of code. git-svn-id: https://svn.dealii.org/trunk@12946 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/dofs/dof_accessor.templates.h | 453 ++++-------------- deal.II/deal.II/include/dofs/dof_levels.h | 47 ++ deal.II/deal.II/include/dofs/hp_dof_levels.h | 1 + deal.II/deal.II/source/dofs/dof_accessor.cc | 78 --- deal.II/deal.II/source/dofs/dof_levels.cc | 200 ++++++++ 5 files changed, 344 insertions(+), 435 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 a3de91ff91..8946d4ca8a 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.templates.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.templates.h @@ -190,6 +190,38 @@ DoFObjectAccessor (const Triangulation *tria, +template +inline +unsigned int +DoFObjectAccessor<1,DH>::dof_index (const unsigned int i, + const unsigned int fe_index) const +{ + return this->dof_handler->levels[this->present_level] + ->get_line_dof_index (*this->dof_handler, + this->present_index, + fe_index, + i); +} + + + +template +inline +void +DoFObjectAccessor<1,DH>::set_dof_index (const unsigned int i, + const unsigned int index, + const unsigned int fe_index) const +{ + this->dof_handler->levels[this->present_level] + ->set_line_dof_index (*this->dof_handler, + this->present_index, + fe_index, + i, + index); +} + + + template inline void @@ -266,6 +298,38 @@ DoFObjectAccessor<2,DH>::line (const unsigned int i) const +template +inline +unsigned int +DoFObjectAccessor<2,DH>::dof_index (const unsigned int i, + const unsigned int fe_index) const +{ + return this->dof_handler->levels[this->present_level] + ->get_quad_dof_index (*this->dof_handler, + this->present_index, + fe_index, + i); +} + + + +template +inline +void +DoFObjectAccessor<2,DH>::set_dof_index (const unsigned int i, + const unsigned int index, + const unsigned int fe_index) const +{ + this->dof_handler->levels[this->present_level] + ->set_quad_dof_index (*this->dof_handler, + this->present_index, + fe_index, + i, + index); +} + + + template inline void @@ -362,6 +426,38 @@ DoFObjectAccessor<3,DH>::quad (const unsigned int i) const +template +inline +unsigned int +DoFObjectAccessor<3,DH>::dof_index (const unsigned int i, + const unsigned int fe_index) const +{ + return this->dof_handler->levels[this->present_level] + ->get_hex_dof_index (*this->dof_handler, + this->present_index, + fe_index, + i); +} + + + +template +inline +void +DoFObjectAccessor<3,DH>::set_dof_index (const unsigned int i, + const unsigned int index, + const unsigned int fe_index) const +{ + this->dof_handler->levels[this->present_level] + ->set_hex_dof_index (*this->dof_handler, + this->present_index, + fe_index, + i, + index); +} + + + template inline void @@ -416,363 +512,6 @@ DoFObjectAccessor<3,DH>::get_dof_indices (std::vector &dof_indices -/*--------------- Functions: DoFObjectAccessor<1,DoFHandler> -----------*/ - - -template <> -inline -unsigned int -DoFObjectAccessor<1,DoFHandler<1> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - Assert (fe_index == DoFHandler<1>::default_fe_index, - ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); - - Assert (this->dof_handler != 0, BaseClass::ExcInvalidObject()); - // make sure a FE has been selected - // and enough room was reserved - Assert (&this->dof_handler->get_fe() != 0, BaseClass::ExcInvalidObject()); - Assert (idof_handler->get_fe().dofs_per_line, - ExcIndexRange (i, 0, this->dof_handler->get_fe().dofs_per_line)); - - return this->dof_handler->levels[this->present_level] - ->line_dofs[this->present_index*this->dof_handler->get_fe().dofs_per_line+i]; -} - - - -template <> -inline -unsigned int -DoFObjectAccessor<1,DoFHandler<2> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - Assert (fe_index == DoFHandler<2>::default_fe_index, - ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); - - Assert (this->dof_handler != 0, BaseClass::ExcInvalidObject()); - // make sure a FE has been selected - // and enough room was reserved - Assert (&this->dof_handler->get_fe() != 0, BaseClass::ExcInvalidObject()); - Assert (idof_handler->get_fe().dofs_per_line, - ExcIndexRange (i, 0, this->dof_handler->get_fe().dofs_per_line)); - - return this->dof_handler->levels[this->present_level] - ->line_dofs[this->present_index*this->dof_handler->get_fe().dofs_per_line+i]; -} - - - -template <> -inline -unsigned int -DoFObjectAccessor<1,DoFHandler<3> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - Assert (fe_index == DoFHandler<3>::default_fe_index, - ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); - - Assert (this->dof_handler != 0, BaseClass::ExcInvalidObject()); - // make sure a FE has been selected - // and enough room was reserved - Assert (&this->dof_handler->get_fe() != 0, BaseClass::ExcInvalidObject()); - Assert (idof_handler->get_fe().dofs_per_line, - ExcIndexRange (i, 0, this->dof_handler->get_fe().dofs_per_line)); - - return this->dof_handler->levels[this->present_level] - ->line_dofs[this->present_index*this->dof_handler->get_fe().dofs_per_line+i]; -} - - - -/*--------------- Functions: DoFObjectAccessor<2,DoFHandler> -----------*/ - -template <> -inline -unsigned int -DoFObjectAccessor<2,DoFHandler<2> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - Assert (fe_index == DoFHandler<2>::default_fe_index, - ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); - Assert (this->dof_handler != 0, - BaseClass::ExcInvalidObject()); - // make sure a FE has been selected - // and enough room was reserved - Assert (&this->dof_handler->get_fe() != 0, - BaseClass::ExcInvalidObject()); - Assert (idof_handler->get_fe().dofs_per_quad, - ExcIndexRange (i, 0, this->dof_handler->get_fe().dofs_per_quad)); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); - - return this->dof_handler->levels[this->present_level] - ->quad_dofs[this->present_index*this->dof_handler->get_fe().dofs_per_quad+i]; -} - - - -template <> -inline -unsigned int -DoFObjectAccessor<2,DoFHandler<3> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - Assert (fe_index == DoFHandler<3>::default_fe_index, - ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); - Assert (this->dof_handler != 0, - BaseClass::ExcInvalidObject()); - // make sure a FE has been selected - // and enough room was reserved - Assert (&this->dof_handler->get_fe() != 0, - BaseClass::ExcInvalidObject()); - Assert (idof_handler->get_fe().dofs_per_quad, - ExcIndexRange (i, 0, this->dof_handler->get_fe().dofs_per_quad)); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); - - return this->dof_handler->levels[this->present_level] - ->quad_dofs[this->present_index*this->dof_handler->get_fe().dofs_per_quad+i]; -} - - - -/*--------------- Functions: DoFObjectAccessor<3,DoFHandler> -----------*/ - - - - -template <> -inline -unsigned int -DoFObjectAccessor<3,DoFHandler<3> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - Assert (fe_index == DoFHandler<3>::default_fe_index, - ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); - Assert (this->dof_handler != 0, - BaseClass::ExcInvalidObject()); - // make sure a FE has been selected - // and enough room was reserved - Assert (&this->dof_handler->get_fe() != 0, - BaseClass::ExcInvalidObject()); - Assert (idof_handler->get_fe().dofs_per_hex, - ExcIndexRange (i, 0, this->dof_handler->get_fe().dofs_per_hex)); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); - - return this->dof_handler->levels[this->present_level] - ->hex_dofs[this->present_index*this->dof_handler->get_fe().dofs_per_hex+i]; -} - - - -/* -------------- hp vertex dofs stuff ------------------------------------ */ - - -/*--------------- Functions: DoFObjectAccessor<1,hp::DoFHandler> -----------*/ - -template <> -inline -unsigned int -DoFObjectAccessor<1,hp::DoFHandler<1> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - return this->dof_handler->levels[this->present_level] - ->get_line_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i); -} - - - -template <> -inline -unsigned int -DoFObjectAccessor<1,hp::DoFHandler<2> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - return this->dof_handler->levels[this->present_level] - ->get_line_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i); -} - - - -template <> -inline -unsigned int -DoFObjectAccessor<1,hp::DoFHandler<3> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - return this->dof_handler->levels[this->present_level] - ->get_line_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i); -} - - - -template <> -inline -void -DoFObjectAccessor<1,hp::DoFHandler<1> >::set_dof_index (const unsigned int i, - const unsigned int index, - const unsigned int fe_index) const -{ - this->dof_handler->levels[this->present_level] - ->set_line_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i, - index); -} - - - -template <> -inline -void -DoFObjectAccessor<1, hp::DoFHandler<2> >::set_dof_index (const unsigned int i, - const unsigned int index, - const unsigned int fe_index) const -{ - this->dof_handler->levels[this->present_level] - ->set_line_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i, - index); -} - - - -template <> -inline -void -DoFObjectAccessor<1, hp::DoFHandler<3> >::set_dof_index (const unsigned int i, - const unsigned int index, - const unsigned int fe_index) const -{ - this->dof_handler->levels[this->present_level] - ->set_line_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i, - index); -} - - - - -/*------------- Functions: DoFObjectAccessor<2,hp::DoFHandler> -------------*/ - -template <> -inline -unsigned int DoFObjectAccessor<2,hp::DoFHandler<2> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - return this->dof_handler->levels[this->present_level] - ->get_quad_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i); -} - - - -template <> -inline -unsigned int DoFObjectAccessor<2,hp::DoFHandler<3> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - return this->dof_handler->levels[this->present_level] - ->get_quad_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i); -} - - - -template <> -inline -void -DoFObjectAccessor<2, hp::DoFHandler<2> >::set_dof_index (const unsigned int i, - const unsigned int index, - const unsigned int fe_index) const -{ - this->dof_handler->levels[this->present_level] - ->set_quad_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i, - index); -} - - - -template <> -inline -void -DoFObjectAccessor<2, hp::DoFHandler<3> >::set_dof_index (const unsigned int i, - const unsigned int index, - const unsigned int fe_index) const -{ - this->dof_handler->levels[this->present_level] - ->set_quad_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i, - index); -} - - - - -/*------------- Functions: DoFObjectAccessor<3,hp::DoFHandler> -------------*/ - -template <> -inline -unsigned int -DoFObjectAccessor<3,hp::DoFHandler<3> >::dof_index (const unsigned int i, - const unsigned int fe_index) const -{ - return this->dof_handler->levels[this->present_level] - ->get_hex_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i); -} - - - -template <> -inline -void -DoFObjectAccessor<3, hp::DoFHandler<3> >::set_dof_index (const unsigned int i, - const unsigned int index, - const unsigned int fe_index) const -{ - this->dof_handler->levels[this->present_level] - ->set_hex_dof_index (*this->dof_handler, - this->present_index, - fe_index, - i, - index); -} - - /*------------------------- Functions: DoFCellAccessor -----------------------*/ diff --git a/deal.II/deal.II/include/dofs/dof_levels.h b/deal.II/deal.II/include/dofs/dof_levels.h index a361c9a0fd..2e1a3f1ca4 100644 --- a/deal.II/deal.II/include/dofs/dof_levels.h +++ b/deal.II/deal.II/include/dofs/dof_levels.h @@ -17,6 +17,8 @@ #include #include +template class DoFHandler; + namespace internal { @@ -141,6 +143,21 @@ namespace internal */ std::vector line_dofs; + template + void + set_line_dof_index (const ::DoFHandler &dof_handler, + const unsigned int line_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index); + + template + unsigned int + get_line_dof_index (const ::DoFHandler &dof_handler, + const unsigned int line_index, + const unsigned int fe_index, + const unsigned int local_index) const; + /** * Determine an estimate for the * memory consumption (in bytes) @@ -170,6 +187,21 @@ namespace internal */ std::vector quad_dofs; + template + void + set_quad_dof_index (const ::DoFHandler &dof_handler, + const unsigned int quad_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index); + + template + unsigned int + get_quad_dof_index (const ::DoFHandler &dof_handler, + const unsigned int quad_index, + const unsigned int fe_index, + const unsigned int local_index) const; + /** * Determine an estimate for the * memory consumption (in bytes) @@ -199,6 +231,21 @@ namespace internal */ std::vector hex_dofs; + template + void + set_hex_dof_index (const ::DoFHandler &dof_handler, + const unsigned int hex_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index); + + template + unsigned int + get_hex_dof_index (const ::DoFHandler &dof_handler, + const unsigned int hex_index, + const unsigned int fe_index, + const unsigned int local_index) const; + /** * Determine an estimate for the * memory consumption (in bytes) 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 42fc106fad..e7cd776871 100644 --- a/deal.II/deal.II/include/dofs/hp_dof_levels.h +++ b/deal.II/deal.II/include/dofs/hp_dof_levels.h @@ -295,6 +295,7 @@ namespace internal + } // namespace hp } // namespace internal diff --git a/deal.II/deal.II/source/dofs/dof_accessor.cc b/deal.II/deal.II/source/dofs/dof_accessor.cc index e18099bb2c..7bee86dcbb 100644 --- a/deal.II/deal.II/source/dofs/dof_accessor.cc +++ b/deal.II/deal.II/source/dofs/dof_accessor.cc @@ -31,84 +31,6 @@ #include -/*------------------------- Functions: DoFObjectAccessor<1,dim> -----------------------*/ - - -template -void DoFObjectAccessor<1, DH>::set_dof_index (const unsigned int i, - const unsigned int index, - const unsigned int fe_index) const -{ - Assert (fe_index == DoFHandler<1>::default_fe_index, - ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); - Assert (this->dof_handler != 0, - typename BaseClass::ExcInvalidObject()); - // make sure a FE has been selected - // and enough room was reserved - Assert (&this->dof_handler->get_fe() != 0, - typename BaseClass::ExcInvalidObject()); - Assert (idof_handler->get_fe().dofs_per_line, - ExcIndexRange (i, 0, this->dof_handler->get_fe().dofs_per_line)); - - this->dof_handler->levels[this->present_level] - ->line_dofs[this->present_index*this->dof_handler->get_fe().dofs_per_line+i] - = index; -} - - - - -/*------------------------- Functions: DoFObjectAccessor<2,dim> -----------------------*/ - - -template -void DoFObjectAccessor<2, DH>::set_dof_index (const unsigned int i, - const unsigned int index, - const unsigned int fe_index) const -{ - Assert (fe_index == DoFHandler<1>::default_fe_index, - ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); - Assert (this->dof_handler != 0, - typename BaseClass::ExcInvalidObject()); - // make sure a FE has been selected - // and enough room was reserved - Assert (&this->dof_handler->get_fe() != 0, - typename BaseClass::ExcInvalidObject()); - Assert (idof_handler->get_fe().dofs_per_quad, - ExcIndexRange (i, 0, this->dof_handler->get_fe().dofs_per_quad)); - - this->dof_handler->levels[this->present_level] - ->quad_dofs[this->present_index*this->dof_handler->get_fe().dofs_per_quad+i] = index; -} - - - - - -/*------------------------- Functions: DoFObjectAccessor<3,dim> -----------------------*/ - - -template -void DoFObjectAccessor<3, DH>::set_dof_index (const unsigned int i, - const unsigned int index, - const unsigned int fe_index) const -{ - Assert (fe_index == DoFHandler<1>::default_fe_index, - ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); - Assert (this->dof_handler != 0, - typename BaseClass::ExcInvalidObject()); - // make sure a FE has been selected - // and enough room was reserved - Assert (&this->dof_handler->get_fe() != 0, - typename BaseClass::ExcInvalidObject()); - Assert (idof_handler->get_fe().dofs_per_hex, - ExcIndexRange (i, 0, this->dof_handler->get_fe().dofs_per_hex)); - - this->dof_handler->levels[this->present_level] - ->hex_dofs[this->present_index*this->dof_handler->get_fe().dofs_per_hex+i] = index; -} - - /*------------------------- Functions: DoFCellAccessor -----------------------*/ diff --git a/deal.II/deal.II/source/dofs/dof_levels.cc b/deal.II/deal.II/source/dofs/dof_levels.cc index 2f97a2661b..3d2cef2538 100644 --- a/deal.II/deal.II/source/dofs/dof_levels.cc +++ b/deal.II/deal.II/source/dofs/dof_levels.cc @@ -12,8 +12,11 @@ //--------------------------------------------------------------------------- +#include #include #include +#include +#include namespace internal @@ -52,6 +55,203 @@ namespace internal return (DoFLevel<2>::memory_consumption () + MemoryConsumption::memory_consumption (hex_dofs)); } + + + + template + unsigned int + DoFLevel<1>:: + get_line_dof_index (const ::DoFHandler &dof_handler, + const unsigned int line_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 + void + DoFLevel<1>:: + set_line_dof_index (const ::DoFHandler &dof_handler, + const unsigned int line_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index) + { + Assert (fe_index == ::DoFHandler::default_fe_index, + ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); + Assert (local_index + unsigned int + DoFLevel<2>:: + get_quad_dof_index (const ::DoFHandler &dof_handler, + const unsigned int quad_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 + void + DoFLevel<2>:: + set_quad_dof_index (const ::DoFHandler &dof_handler, + const unsigned int quad_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index) + { + Assert (fe_index == ::DoFHandler::default_fe_index, + ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); + Assert (local_index + unsigned int + DoFLevel<3>:: + get_hex_dof_index (const ::DoFHandler &dof_handler, + const unsigned int hex_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 + void + DoFLevel<3>:: + set_hex_dof_index (const ::DoFHandler &dof_handler, + const unsigned int hex_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index) + { + Assert (fe_index == ::DoFHandler::default_fe_index, + ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects")); + Assert (local_index:: + get_line_dof_index (const ::DoFHandler &dof_handler, + const unsigned int line_index, + const unsigned int fe_index, + const unsigned int local_index) const; + + template + void + DoFLevel<1>:: + set_line_dof_index (const ::DoFHandler &dof_handler, + const unsigned int line_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index); + +#if deal_II_dimension >= 2 + + template + unsigned int + DoFLevel<2>:: + get_quad_dof_index (const ::DoFHandler &dof_handler, + const unsigned int quad_index, + const unsigned int fe_index, + const unsigned int local_index) const; + + template + void + DoFLevel<2>:: + set_quad_dof_index (const ::DoFHandler &dof_handler, + const unsigned int quad_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index); + +#endif + +#if deal_II_dimension >= 3 + + template + unsigned int + DoFLevel<3>:: + get_hex_dof_index (const ::DoFHandler &dof_handler, + const unsigned int hex_index, + const unsigned int fe_index, + const unsigned int local_index) const; + + template + void + DoFLevel<3>:: + set_hex_dof_index (const ::DoFHandler &dof_handler, + const unsigned int hex_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index); + +#endif } -- 2.39.5