From: Wolfgang Bangerth Date: Mon, 1 May 2006 16:18:50 +0000 (+0000) Subject: Add a dummy operator[] to make generic programming for non-hp/hp X-Git-Tag: v8.0.0~11836 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48900bf3ab093d85f0803f1a179dedb23c1aa93f;p=dealii.git Add a dummy operator[] to make generic programming for non-hp/hp accessors simpler. git-svn-id: https://svn.dealii.org/trunk@12940 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/fe/fe.h b/deal.II/deal.II/include/fe/fe.h index da31faf488..5a2cc23637 100644 --- a/deal.II/deal.II/include/fe/fe.h +++ b/deal.II/deal.II/include/fe/fe.h @@ -427,6 +427,51 @@ class FiniteElement : public Subscriptor, */ virtual std::string get_name () const = 0; + /** + * This operator returns a + * reference to the present + * object if the argument given + * equals to zero. While this + * does not seem particularly + * useful, it is helpful in + * writing code that works with + * both ::DoFHandler and the hp + * version hp::DoFHandler, since + * one can then write code like + * this: + * @verbatim + * dofs_per_cell + * = dof_handler->get_fe()[cell->active_fe_index()].dofs_per_cell; + * @endverbatim + * + * This code doesn't work in both + * situations without the present + * operator because + * DoFHandler::get_fe() returns a + * finite element, whereas + * hp::DoFHandler::get_fe() + * returns a collection of finite + * elements that doesn't offer a + * dofs_per_cell + * member variable: one first has + * to select which finite element + * to work on, which is done + * using the + * operator[]. Fortunately, + * cell-@>active_fe_index() + * also works for non-hp classes + * and simply returns zero in + * that case. The present + * operator[] accepts this zero + * argument, by returning the + * finite element with index zero + * within its collection (that, + * of course, consists only of + * the present finite element + * anyway). + */ + const FiniteElement & operator[] (const unsigned int fe_index) const; + /** * @name Shape function access * @{ @@ -2171,6 +2216,19 @@ class FiniteElement : public Subscriptor, //----------------------------------------------------------------------// + +template +inline +const FiniteElement & +FiniteElement::operator[] (const unsigned int fe_index) const +{ + Assert (fe_index == 0, + ExcMessage ("A fe_index of zero is the only index allowed here")); + return *this; +} + + + template inline std::pair @@ -2183,6 +2241,8 @@ FiniteElement::system_to_component_index (const unsigned int index) const return system_to_component_table[index]; } + + template inline unsigned int @@ -2265,6 +2325,7 @@ FiniteElement::first_block_of_base (const unsigned int index) const } + template inline std::pair @@ -2277,6 +2338,7 @@ FiniteElement::component_to_base_index (const unsigned int index) const } + template inline std::pair @@ -2294,6 +2356,7 @@ FiniteElement::block_to_base_index (const unsigned int index) const } + template inline std::pair @@ -2311,6 +2374,7 @@ FiniteElement::system_to_block_index (const unsigned int index) const } + template inline bool @@ -2322,6 +2386,7 @@ FiniteElement::restriction_is_additive (const unsigned int index) const } + template inline const std::vector & @@ -2364,6 +2429,7 @@ FiniteElement::is_primitive (const unsigned int i) const } + template inline bool