From: bangerth Date: Mon, 5 Mar 2007 20:45:49 +0000 (+0000) Subject: Split the TriaAccessor class into two, one that handles cells and one that handles... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83202aeef19e66bd6ec68c5fe63477f56b01fd2e;p=dealii-svn.git Split the TriaAccessor class into two, one that handles cells and one that handles everything else. The point being that only the former needs levels. git-svn-id: https://svn.dealii.org/trunk@14521 0785d39b-7218-0410-832d-ea1e28bc413d --- 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 d4f3a92c30..a72e369f59 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.templates.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.templates.h @@ -127,12 +127,12 @@ inline TriaIterator > DoFAccessor::child (const unsigned int i) const { - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); int next_level; if (DH::dimension==structdim) - next_level = this->present_level+1; + next_level = this->level()+1; else next_level = 0; @@ -192,7 +192,7 @@ DoFAccessor::dof_index (const unsigned int i, { // access the respective DoF return this->dof_handler - ->template get_dof_index (this->present_level, + ->template get_dof_index (this->level(), this->present_index, fe_index, i); @@ -209,7 +209,7 @@ DoFAccessor::set_dof_index (const unsigned int i, { // access the respective DoF this->dof_handler - ->template set_dof_index (this->present_level, + ->template set_dof_index (this->level(), this->present_index, fe_index, i, @@ -225,7 +225,7 @@ DoFAccessor::n_active_fe_indices () const { // access the respective DoF return this->dof_handler - ->template n_active_fe_indices (this->present_level, + ->template n_active_fe_indices (this->level(), this->present_index); } @@ -238,7 +238,7 @@ DoFAccessor::nth_active_fe_index (const unsigned int n) const { // access the respective DoF return this->dof_handler - ->template nth_active_fe_index (this->present_level, + ->template nth_active_fe_index (this->level(), this->present_index, n); } @@ -252,7 +252,7 @@ DoFAccessor::fe_index_is_active (const unsigned int fe_index) const { // access the respective DoF return this->dof_handler - ->template fe_index_is_active (this->present_level, + ->template fe_index_is_active (this->level(), this->present_index, fe_index); } @@ -365,7 +365,7 @@ void DoFObjectAccessor<1,DH>::get_dof_indices (std::vector &dof_indices, const unsigned int fe_index) const { - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); Assert (this->dof_handler != 0, typename BaseClass::ExcInvalidObject()); @@ -425,7 +425,7 @@ TriaIterator > DoFObjectAccessor<2,DH>::line (const unsigned int i) const { Assert (i<4, ExcIndexRange (i, 0, 4)); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); return TriaIterator > @@ -471,7 +471,7 @@ DoFObjectAccessor<2,DH>::get_dof_indices (std::vector &dof_indices 4*this->dof_handler->get_fe()[fe_index].dofs_per_vertex), ExcInternalError()); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); const unsigned int dofs_per_vertex = this->dof_handler->get_fe()[fe_index].dofs_per_vertex, @@ -567,7 +567,7 @@ DoFObjectAccessor<3,DH>::get_dof_indices (std::vector &dof_indices 6*this->dof_handler->get_fe()[fe_index].dofs_per_quad + this->dof_handler->get_fe()[fe_index].dofs_per_hex), typename BaseClass::ExcVectorDoesNotMatch()); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); // this function really only makes @@ -587,7 +587,7 @@ DoFObjectAccessor<3,DH>::get_dof_indices (std::vector &dof_indices 8*this->dof_handler->get_fe()[fe_index].dofs_per_vertex), ExcInternalError()); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); const unsigned int dofs_per_vertex = this->dof_handler->get_fe()[fe_index].dofs_per_vertex, @@ -680,7 +680,7 @@ TriaIterator > DoFCellAccessor::child (const unsigned int i) const { TriaIterator > q (this->tria, - this->present_level+1, + this->level()+1, this->child_index (i), this->dof_handler); @@ -742,7 +742,7 @@ get_dof_indices (std::vector &dof_indices) const this->get_fe().dofs_per_vertex * GeometryInfo<1>::vertices_per_cell), ExcMessage ("Cell must either be active, or all DoFs must be in vertices")); - unsigned int *cache = &this->dof_handler->levels[this->present_level] + unsigned int *cache = &this->dof_handler->levels[this->level()] ->cell_dof_indices_cache[this->present_index * this->get_fe().dofs_per_cell]; for (unsigned int i=0; iget_fe().dofs_per_cell; ++i, ++cache) dof_indices[i] = *cache; @@ -780,7 +780,7 @@ get_dof_indices (std::vector &dof_indices) const this->get_fe().dofs_per_vertex * GeometryInfo<2>::vertices_per_cell), ExcMessage ("Cell must either be active, or all DoFs must be in vertices")); - unsigned int *cache = &this->dof_handler->levels[this->present_level] + unsigned int *cache = &this->dof_handler->levels[this->level()] ->cell_dof_indices_cache[this->present_index * this->get_fe().dofs_per_cell]; for (unsigned int i=0; iget_fe().dofs_per_cell; ++i, ++cache) dof_indices[i] = *cache; @@ -819,7 +819,7 @@ get_dof_indices (std::vector &dof_indices) const this->get_fe().dofs_per_vertex * GeometryInfo<3>::vertices_per_cell), ExcMessage ("Cell must either be active, or all DoFs must be in vertices")); - unsigned int *cache = &this->dof_handler->levels[this->present_level] + unsigned int *cache = &this->dof_handler->levels[this->level()] ->cell_dof_indices_cache[this->present_index * this->get_fe().dofs_per_cell]; for (unsigned int i=0; iget_fe().dofs_per_cell; ++i, ++cache) dof_indices[i] = *cache; @@ -907,13 +907,13 @@ inline unsigned int DoFCellAccessor >::active_fe_index () const { - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); Assert (static_cast::size_type>(this->present_index) < - this->dof_handler->levels[this->present_level]->active_fe_indices.size (), + this->dof_handler->levels[this->level()]->active_fe_indices.size (), ExcIndexRange (this->present_index, 0, - this->dof_handler->levels[this->present_level]->active_fe_indices.size ())); - return this->dof_handler->levels[this->present_level] + this->dof_handler->levels[this->level()]->active_fe_indices.size ())); + return this->dof_handler->levels[this->level()] ->active_fe_indices[this->present_index]; } @@ -924,13 +924,13 @@ inline unsigned int DoFCellAccessor >::active_fe_index () const { - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); Assert (static_cast::size_type>(this->present_index) < - this->dof_handler->levels[this->present_level]->active_fe_indices.size (), + this->dof_handler->levels[this->level()]->active_fe_indices.size (), ExcIndexRange (this->present_index, 0, - this->dof_handler->levels[this->present_level]->active_fe_indices.size ())); - return this->dof_handler->levels[this->present_level] + this->dof_handler->levels[this->level()]->active_fe_indices.size ())); + return this->dof_handler->levels[this->level()] ->active_fe_indices[this->present_index]; } @@ -941,13 +941,13 @@ inline unsigned int DoFCellAccessor >::active_fe_index () const { - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); Assert (static_cast::size_type>(this->present_index) < - this->dof_handler->levels[this->present_level]->active_fe_indices.size (), + this->dof_handler->levels[this->level()]->active_fe_indices.size (), ExcIndexRange (this->present_index, 0, - this->dof_handler->levels[this->present_level]->active_fe_indices.size ())); - return this->dof_handler->levels[this->present_level] + this->dof_handler->levels[this->level()]->active_fe_indices.size ())); + return this->dof_handler->levels[this->level()] ->active_fe_indices[this->present_index]; } @@ -960,14 +960,14 @@ DoFCellAccessor >::set_active_fe_index (const unsigned int i) { Assert (this->dof_handler != 0, BaseClass::ExcInvalidObject()); - Assert (static_cast(this->present_level) < + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); Assert (static_cast::size_type>(this->present_index) < - this->dof_handler->levels[this->present_level]->active_fe_indices.size (), + this->dof_handler->levels[this->level()]->active_fe_indices.size (), ExcIndexRange (this->present_index, 0, - this->dof_handler->levels[this->present_level]->active_fe_indices.size ())); - this->dof_handler->levels[this->present_level] + this->dof_handler->levels[this->level()]->active_fe_indices.size ())); + this->dof_handler->levels[this->level()] ->active_fe_indices[this->present_index] = i; } @@ -980,14 +980,14 @@ DoFCellAccessor >::set_active_fe_index (const unsigned int i) { Assert (this->dof_handler != 0, BaseClass::ExcInvalidObject()); - Assert (static_cast(this->present_level) < + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); Assert (static_cast::size_type>(this->present_index) < - this->dof_handler->levels[this->present_level]->active_fe_indices.size (), + this->dof_handler->levels[this->level()]->active_fe_indices.size (), ExcIndexRange (this->present_index, 0, - this->dof_handler->levels[this->present_level]->active_fe_indices.size ())); - this->dof_handler->levels[this->present_level] + this->dof_handler->levels[this->level()]->active_fe_indices.size ())); + this->dof_handler->levels[this->level()] ->active_fe_indices[this->present_index] = i; } @@ -1000,14 +1000,14 @@ DoFCellAccessor >::set_active_fe_index (const unsigned int i) { Assert (this->dof_handler != 0, BaseClass::ExcInvalidObject()); - Assert (static_cast(this->present_level) < + Assert (static_cast(this->level()) < this->dof_handler->levels.size(), ExcMessage ("DoFHandler not initialized")); Assert (static_cast::size_type>(this->present_index) < - this->dof_handler->levels[this->present_level]->active_fe_indices.size (), + this->dof_handler->levels[this->level()]->active_fe_indices.size (), ExcIndexRange (this->present_index, 0, - this->dof_handler->levels[this->present_level]->active_fe_indices.size ())); - this->dof_handler->levels[this->present_level] + this->dof_handler->levels[this->level()]->active_fe_indices.size ())); + this->dof_handler->levels[this->level()] ->active_fe_indices[this->present_index] = i; } diff --git a/deal.II/deal.II/include/grid/tria.h b/deal.II/deal.II/include/grid/tria.h index c55eee4197..8684358f45 100644 --- a/deal.II/deal.II/include/grid/tria.h +++ b/deal.II/deal.II/include/grid/tria.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -3134,7 +3134,7 @@ class Triangulation : public Subscriptor // make a couple of classes // friends - template friend class TriaAccessor; + template friend class TriaAccessor; template friend class TriaObjectAccessor; diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index a898b047e0..b45d70fb76 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -185,8 +185,158 @@ namespace TriaAccessorExceptions * @ingroup Accessors * @author Wolfgang Bangerth, 1998 */ -template +template class TriaAccessor +{ + protected: + /** + * Declare the data type that + * this accessor class expects to + * get passed from the iterator + * classes. Since the pure + * triangulation iterators need + * no additional data, this data + * type is @p void. + */ + typedef void AccessorData; + + /** + * Constructor. Protected, thus + * only callable from friend + * classes. + */ + TriaAccessor (const Triangulation *parent = 0, + const int level = -1, + const int index = -1, + const AccessorData * = 0); + + /** + * Copy operator. Since this is + * only called from iterators, + * do not return anything, since + * the iterator will return + * itself. + * + * This method is protected, + * since it is only to be called + * from the iterator class. + */ + void copy_from (const TriaAccessor &); + + /** + * Copy operator. This is normally + * used in a context like + * iterator a,b; *a=*b;. Since + * the meaning is to copy the object + * pointed to by @p b to the object + * pointed to by @p a and since + * accessors are not real but + * virtual objects, this operation + * is not useful for iterators on + * triangulations. We declare this + * function here private, thus it may + * not be used from outside. + * Furthermore it is not implemented + * and will give a linker error if + * used anyway. + */ + void operator = (const TriaAccessor *); + + /** + * Same as above. + */ + TriaAccessor & operator = (const TriaAccessor &); + + protected: + + /** + * Compare for equality. + */ + bool operator == (const TriaAccessor &) const; + + /** + * Compare for inequality. + */ + bool operator != (const TriaAccessor &) const; + + public: + /** + * Data type to be used for passing + * parameters from iterators to the + * accessor classes in a unified + * way, no matter what the type of + * number of these parameters is. + */ + typedef void * LocalData; + + /**@ name Iterator address and state + */ + /*@{*/ + /** + * Return the level the element + * pointed to belongs to. + * This is only valid for cells. + */ + static int level (); + + /** + * Return the index of the + * element presently pointed to + * on the present level. + */ + int index () const; + + /** + * Return the state of the + * iterator. For the different + * states an accessor can be in, + * refer to the + * TriaRawIterator + * documentation. + */ + IteratorState::IteratorStates state () const; + + /** + * Return a pointer to the + * triangulation which the object + * pointed to by this class + * belongs to. + */ + const Triangulation & get_triangulation () const; + + /*@}*/ + protected: + /** + * Used to store the index of + * the element presently pointed + * to on the level presentl + * used. + */ + int present_index; + + /** + * Pointer to the triangulation + * which we act on. + */ + const Triangulation *tria; + + private: + + /** + * Dimension of the TriaObject + * this accessor gives access to. + */ + static const unsigned int objectdim = dim; + + template friend class TriaRawIterator; + template friend class TriaIterator; + template friend class TriaActiveIterator; +}; + + + +template +class TriaAccessor { protected: /** @@ -343,6 +493,7 @@ class TriaAccessor + /** * Common template for line, quad, hex accessors. According to * @p celldim, objects of this class represent lines, quadrilaterals, @@ -356,14 +507,14 @@ class TriaAccessor * @author Wolfgang Bangerth, Guido Kanschat, 1999 */ template -class TriaObjectAccessor : public TriaAccessor +class TriaObjectAccessor : public TriaAccessor { public: /** * Propagate typedef from * base class to this class. */ - typedef typename TriaAccessor::AccessorData AccessorData; + typedef typename TriaAccessor::AccessorData AccessorData; /** * Constructor. @@ -397,13 +548,6 @@ class TriaObjectAccessor : public TriaAccessor */ void set (const internal::Triangulation::Hexahedron&) const; - /** - * Return the level the element - * pointed to belongs to. - * This is only valid for cells. - */ - int level () const; - /** * Index of vertex. The convention * regarding the numbering of vertices @@ -1001,14 +1145,14 @@ class TriaObjectAccessor : public TriaAccessor * @ingroup grid */ template -class TriaObjectAccessor<0, dim> : public TriaAccessor +class TriaObjectAccessor<0, dim> : public TriaAccessor<0,dim> { public: /** * Propagate typedef from * base class to this class. */ - typedef typename TriaAccessor::AccessorData AccessorData; + typedef typename TriaAccessor<0,dim>::AccessorData AccessorData; /** * Constructor. Should never be @@ -1020,7 +1164,7 @@ class TriaObjectAccessor<0, dim> : public TriaAccessor const int index = -1, const AccessorData *local_data = 0) : - TriaAccessor (parent, level, index, local_data) + TriaAccessor<0,dim> (parent, level, index, local_data) { Assert (false, ExcInternalError()); }; @@ -1039,14 +1183,14 @@ class TriaObjectAccessor<0, dim> : public TriaAccessor * @author Wolfgang Bangerth, 1998 */ template -class TriaObjectAccessor<1, dim> : public TriaAccessor +class TriaObjectAccessor<1, dim> : public TriaAccessor<1,dim> { public: /** * Propagate typedef from * base class to this class. */ - typedef typename TriaAccessor::AccessorData AccessorData; + typedef typename TriaAccessor<1,dim>::AccessorData AccessorData; /** * Constructor. @@ -1062,13 +1206,6 @@ class TriaObjectAccessor<1, dim> : public TriaAccessor */ void set (const internal::Triangulation::Line &l) const; - /** - * Return the level the element - * pointed to belongs to. - * This is only valid for cells. - */ - int level () const; - /** * Return the index of vertex * i=0,1 of a line. @@ -1604,14 +1741,14 @@ class TriaObjectAccessor<1, dim> : public TriaAccessor * @author Wolfgang Bangerth, 1998 */ template -class TriaObjectAccessor<2, dim> : public TriaAccessor +class TriaObjectAccessor<2, dim> : public TriaAccessor<2,dim> { public: /** * Propagate typedef from base * class to this class. */ - typedef typename TriaAccessor::AccessorData AccessorData; + typedef typename TriaAccessor<2,dim>::AccessorData AccessorData; /** * Constructor. @@ -1626,13 +1763,6 @@ class TriaObjectAccessor<2, dim> : public TriaAccessor */ void set (const internal::Triangulation::Quad &q) const; - /** - * Return the level the element - * pointed to belongs to. - * This is only valid for cells. - */ - int level () const; - /** * Return index of a vertex of a * quad in the internal data @@ -2218,14 +2348,14 @@ class TriaObjectAccessor<2, dim> : public TriaAccessor * @author Wolfgang Bangerth, 1998 */ template -class TriaObjectAccessor<3, dim> : public TriaAccessor +class TriaObjectAccessor<3, dim> : public TriaAccessor<3,dim> { public: /** * Propagate typedef from base * class to this class. */ - typedef typename TriaAccessor::AccessorData AccessorData; + typedef typename TriaAccessor<3,dim>::AccessorData AccessorData; /** * Constructor. diff --git a/deal.II/deal.II/include/grid/tria_accessor.templates.h b/deal.II/deal.II/include/grid/tria_accessor.templates.h index 6482a58718..2ce6b5f691 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.templates.h +++ b/deal.II/deal.II/include/grid/tria_accessor.templates.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -29,12 +29,106 @@ DEAL_II_NAMESPACE_OPEN /*------------------------ Functions: TriaAccessor ---------------------------*/ +template +inline +TriaAccessor::TriaAccessor (const Triangulation *parent, + const int /*level*/, + const int index, + const AccessorData *) + : + present_index (index), + tria (parent) +{} + + + +template +inline +void +TriaAccessor::copy_from (const TriaAccessor &a) +{ + present_index = a.present_index; + tria = a.tria; +} + + + +template +inline +bool +TriaAccessor::operator == (const TriaAccessor &a) const +{ + Assert (tria == a.tria, TriaAccessorExceptions::ExcCantCompareIterators()); + return (present_index == a.present_index); +} + + + +template +inline +bool +TriaAccessor::operator != (const TriaAccessor &a) const +{ + Assert (tria == a.tria, TriaAccessorExceptions::ExcCantCompareIterators()); + return (present_index != a.present_index); +} + + + +template +inline +int +TriaAccessor::level () +{ + return 0; +} + + + +template +inline +int +TriaAccessor::index () const +{ + return present_index; +} + + + +template +inline +IteratorState::IteratorStates +TriaAccessor::state () const +{ + if (present_index>=0) + return IteratorState::valid; + else + if (present_index==-1) + return IteratorState::past_the_end; + else + return IteratorState::invalid; +} + + + +template +inline +const Triangulation & +TriaAccessor::get_triangulation () const +{ + return *tria; +} + + + +/*------------------------ Functions: TriaAccessor ---------------------------*/ + template inline -TriaAccessor::TriaAccessor (const Triangulation *parent, - const int level, - const int index, - const AccessorData *) +TriaAccessor::TriaAccessor (const Triangulation *parent, + const int level, + const int index, + const AccessorData *) : present_level (level), present_index (index), @@ -46,7 +140,7 @@ TriaAccessor::TriaAccessor (const Triangulation *parent, template inline void -TriaAccessor::copy_from (const TriaAccessor &a) +TriaAccessor::copy_from (const TriaAccessor &a) { present_level = a.present_level; present_index = a.present_index; @@ -58,7 +152,7 @@ TriaAccessor::copy_from (const TriaAccessor &a) template inline bool -TriaAccessor::operator == (const TriaAccessor &a) const +TriaAccessor::operator == (const TriaAccessor &a) const { Assert (tria == a.tria, TriaAccessorExceptions::ExcCantCompareIterators()); return ((present_index == a.present_index) && @@ -70,7 +164,7 @@ TriaAccessor::operator == (const TriaAccessor &a) const template inline bool -TriaAccessor::operator != (const TriaAccessor &a) const +TriaAccessor::operator != (const TriaAccessor &a) const { Assert (tria == a.tria, TriaAccessorExceptions::ExcCantCompareIterators()); return ((present_index != a.present_index) || @@ -82,7 +176,7 @@ TriaAccessor::operator != (const TriaAccessor &a) const template inline int -TriaAccessor::level () const +TriaAccessor::level () const { return present_level; } @@ -92,7 +186,7 @@ TriaAccessor::level () const template inline int -TriaAccessor::index () const +TriaAccessor::index () const { return present_index; } @@ -102,7 +196,7 @@ TriaAccessor::index () const template inline IteratorState::IteratorStates -TriaAccessor::state () const +TriaAccessor::state () const { if ((present_level>=0) && (present_index>=0)) return IteratorState::valid; @@ -118,7 +212,7 @@ TriaAccessor::state () const template inline const Triangulation & -TriaAccessor::get_triangulation () const +TriaAccessor::get_triangulation () const { return *tria; } @@ -135,7 +229,7 @@ TriaObjectAccessor (const Triangulation *parent, const int index, const AccessorData *local_data) : - TriaAccessor (parent, level, index, local_data) + TriaAccessor<1,dim> (parent, level, index, local_data) { if (dim!=1) Assert(level <= 0, ExcInternalError()); @@ -164,17 +258,6 @@ TriaObjectAccessor<1,dim>::lines() const -template -inline -int -TriaObjectAccessor<1,dim>::level () const -{ - Assert(dim==1, TriaAccessorExceptions::ExcFacesHaveNoLevel()); - return TriaAccessor::level(); -} - - - template inline bool @@ -250,14 +333,11 @@ TriaIterator > TriaObjectAccessor<1,dim>::child (const unsigned int i) const { Assert (i<2, ExcIndexRange(i,0,2)); - int next_level; - if (dim==1) - next_level = this->present_level+1; - else - next_level = 0; - + TriaIterator > - q (this->tria, next_level, child_index (i)); + q (this->tria, + (dim == 1 ? this->level() + 1 : 0), + child_index (i)); Assert ((q.state() == IteratorState::past_the_end) || q->used(), TriaAccessorExceptions::ExcUnusedCellAsChild()); @@ -337,11 +417,14 @@ TriaObjectAccessor<1,dim>::operator ++ () { ++this->present_index; // is index still in the range of - // the vector? + // the vector? (note that we don't + // have to set the level, since + // dim!=1 and the object therefore + // has no level) if (this->present_index >= static_cast(this->tria->faces->lines.cells.size())) - this->present_level = this->present_index = -1; + this->present_index = -1; } @@ -381,9 +464,12 @@ TriaObjectAccessor<1,dim>::operator -- () { --this->present_index; // is index still in the range of - // the vector? - if (this->present_index <0 ) - this->present_level = this->present_index = -1; + // the vector? (note that we don't + // have to set the level, since + // dim!=1 and the object therefore + // has no level) + if (this->present_index < 0) + this->present_index = -1; return; } @@ -424,7 +510,7 @@ TriaObjectAccessor (const Triangulation *parent, const int index, const AccessorData *local_data) : - TriaAccessor (parent, level, index, local_data) + TriaAccessor<2,dim> (parent, level, index, local_data) { if (dim!=2) Assert(level <= 0, ExcInternalError()); @@ -454,17 +540,6 @@ TriaObjectAccessor<2,dim>::quads() const -template -inline -int -TriaObjectAccessor<2,dim>::level () const -{ - Assert(dim==2, TriaAccessorExceptions::ExcFacesHaveNoLevel()); - return TriaAccessor::level(); -} - - - template inline bool @@ -566,14 +641,11 @@ TriaIterator > TriaObjectAccessor<2,dim>::child (const unsigned int i) const { Assert (i<4, ExcIndexRange(i,0,4)); - int next_level; - if (dim==2) - next_level = this->present_level+1; - else - next_level = 0; TriaIterator > - q (this->tria, next_level, child_index (i)); + q (this->tria, + (dim == 2 ? this->level() + 1 : 0), + child_index (i)); Assert ((q.state() == IteratorState::past_the_end) || q->used(), TriaAccessorExceptions::ExcUnusedCellAsChild()); @@ -675,11 +747,14 @@ TriaObjectAccessor<2,dim>::operator ++ () { ++this->present_index; // is index still in the range of - // the vector? + // the vector? (note that we don't + // have to set the level, since + // dim!=1 and the object therefore + // has no level) if (this->present_index >= static_cast(quads().cells.size())) - this->present_level = this->present_index = -1; + this->present_index = -1; } @@ -718,9 +793,12 @@ TriaObjectAccessor<2,dim>::operator -- () { --this->present_index; // is index still in the range of - // the vector? - if (this->present_index<0) - this->present_level = this->present_index = -1; + // the vector? (note that we don't + // have to set the level, since + // dim!=1 and the object therefore + // has no level) + if (this->present_index < 0) + this->present_index = -1; } @@ -760,7 +838,7 @@ TriaObjectAccessor (const Triangulation *parent, const int index, const AccessorData *local_data) : - TriaAccessor (parent, level, index, local_data) + TriaAccessor<3,dim> (parent, level, index, local_data) { if (dim!=3) Assert(level <= 0, ExcInternalError()); @@ -937,7 +1015,8 @@ TriaObjectAccessor<3,3>::child (const unsigned int i) const const int dim=3; Assert (i<8, ExcIndexRange(i,0,8)); - TriaIterator > q (this->tria, this->present_level+1, child_index (i)); + TriaIterator > + q (this->tria, this->present_level+1, child_index (i)); Assert ((q.state() == IteratorState::past_the_end) || q->used(), TriaAccessorExceptions::ExcUnusedCellAsChild()); diff --git a/deal.II/deal.II/include/grid/tria_iterator_selector.h b/deal.II/deal.II/include/grid/tria_iterator_selector.h index 8af49ebe4c..8d9dcc13cf 100644 --- a/deal.II/deal.II/include/grid/tria_iterator_selector.h +++ b/deal.II/deal.II/include/grid/tria_iterator_selector.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2003, 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -19,7 +19,8 @@ DEAL_II_NAMESPACE_OPEN template class CellAccessor; -template class TriaAccessor; +template class TriaAccessor; +template class TriaAccessor; template class TriaObjectAccessor; template class TriaObjectAccessor<0, dim>; template class TriaObjectAccessor<1, dim>; diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 2eb7f3e7c0..1fc68df26a 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -27,8 +27,8 @@ DEAL_II_NAMESPACE_OPEN -template -const unsigned int TriaAccessor::objectdim; +template +const unsigned int TriaAccessor::objectdim; /*------------------------ Functions: LineAccessor ---------------------------*/ @@ -2316,7 +2316,14 @@ neighbor_child_on_subface (const unsigned int face, // For more information, see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24331 // explicit instantiations -template class TriaAccessor; +template class TriaAccessor<1,deal_II_dimension>; +#if deal_II_dimension >= 2 +template class TriaAccessor<2,deal_II_dimension>; +#endif +#if deal_II_dimension >= 3 +template class TriaAccessor<3,deal_II_dimension>; +#endif + template class CellAccessor; template class TriaRawIterator >; template class TriaRawIterator >; diff --git a/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc b/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc index 1e0ba45598..d56870496e 100644 --- a/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc +++ b/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -159,16 +159,13 @@ template TriaIterator > MGDoFAccessor::child (const unsigned int i) const { - int next_level; - if (structdim==dim) - next_level=this->present_level+1; - else - next_level=0; - - TriaIterator > q (this->tria, - next_level, - this->child_index (i), - this->mg_dof_handler); + const TriaIterator > + q (this->tria, + (structdim == dim ? + this->level() + 1 : + 0), + this->child_index (i), + this->mg_dof_handler); // make sure that we either created // a past-the-end iterator or one