From 6f63a0be1cfe9f7d290af33d7d7bae1205943426 Mon Sep 17 00:00:00 2001 From: guido Date: Wed, 21 Jul 1999 18:03:43 +0000 Subject: [PATCH] ..DoFSubstructAccessor removed git-svn-id: https://svn.dealii.org/trunk@1617 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/dofs/dof_accessor.h | 190 ++---------- .../deal.II/include/dofs/mg_dof_accessor.h | 187 ++---------- deal.II/deal.II/include/grid/tria_accessor.h | 7 +- .../include/grid/tria_accessor.templates.h | 285 +++++++++++++++++- .../include/multigrid/mg_dof_accessor.h | 187 ++---------- deal.II/deal.II/source/dofs/dof_accessor.cc | 100 +++--- .../deal.II/source/dofs/mg_dof_accessor.cc | 14 +- .../source/multigrid/mg_dof_accessor.cc | 14 +- 8 files changed, 454 insertions(+), 530 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_accessor.h b/deal.II/deal.II/include/dofs/dof_accessor.h index ae10947c0a..ed1e0ab732 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.h @@ -111,12 +111,32 @@ class DoFAccessor { /** * Common template for line, quad, hex. + * + * Internal: inheritance is necessary for the general template due to + * a compiler error. + * @author Guido Kanschat, 1999 */ template -class DoFObjectAccessor; - +class DoFObjectAccessor : public DoFAccessor, + public BaseClass +{}; +/** + * Closure class. + */ +template +class DoFObjectAccessor<0, dim, BaseClass> : public DoFAccessor, + public BaseClass +{ + public: + typedef void* AccessorData; + DoFObjectAccessor (Triangulation *, + const int, + const int, + const AccessorData *) + {} +}; /** @@ -539,157 +559,6 @@ class DoFObjectAccessor<3, dim, BaseClass> : public DoFAccessor, - - - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * Rationale for the declaration of members for this class: gcc 2.8 has a bug - * when deriving from explicitely specialized classes which materializes in - * the calculation of wrong addresses of member variables. By declaring the - * general template of #DoFSubstructAccessor# to have the same object layout as - * the specialized versions (using the same base classes), we fool the compiler, - * which still looks in the wrong place for the addresses but finds the - * right information. This way, at least ot works. - * - * Insert a guard, however, in the constructor to avoid that anyone (including - * the compiler) happens to use this class. - */ -template -class DoFSubstructAccessor : public DoFAccessor, - public TriaAccessor { - public: - DoFSubstructAccessor () { - Assert (false, ExcInternalError()); - }; - - DeclException0 (ExcInternalError); -}; - - - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * \subsection{Rationale} - * - * This class is only a wrapper class used to do kind of a typedef - * with template parameters. This class and #DoFSubstructAccessor<2># - * wrap the following names: - * \begin{verbatim} - * DoFSubstructAccessor<1> := DoFObjectAccessor<1, 1,CellAccessor<1> >; - * DoFSubstructAccessor<2> := DoFObjectAccessor<2, 2,CellAccessor<2> >; - * \end{verbatim} - * We do this rather complex (and needless, provided C++ the needed constructs!) - * class hierarchy manipulation, since this way we can declare and implement - * the \Ref{DoFCellAccessor} dimension independent as an inheritance from - * #DoFSubstructAccessor#. If we had not declared these - * types, we would have to write two class declarations, one for - * #DoFCellAccessor<1>#, derived from #DoFObjectAccessor<1, 1,CellAccessor<1> ># - * and one for #DoFCellAccessor<2>#, derived from - * #DoFObjectAccessor<2, 2,CellAccessor<2> >#. - */ -template <> -class DoFSubstructAccessor<1> : public DoFObjectAccessor<1, 1,CellAccessor<1> > { - public: - /** - * Declare the data type that this accessor - * class expects to get passed from the - * iterator classes. - */ - typedef DoFObjectAccessor<1, 1,CellAccessor<1> >::AccessorData AccessorData; - - /** - * Constructor - */ - DoFSubstructAccessor (Triangulation<1> *tria, - const int level, - const int index, - const AccessorData *local_data) : - DoFObjectAccessor<1, 1,CellAccessor<1> > (tria,level,index,local_data) {}; - // do this here, since this way the - // CellAccessor has the possibility to know - // what a face_iterator is. Otherwise - // it would have to ask the DoFHandler - // which would need another big include - // file and maybe cyclic interdependence - typedef void * face_iterator; -}; - - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * @see DoFSubstructAccessor<1> - */ -template <> -class DoFSubstructAccessor<2> : public DoFObjectAccessor<2, 2,CellAccessor<2> > { - public: - /** - * Declare the data type that this accessor - * class expects to get passed from the - * iterator classes. - */ - typedef DoFObjectAccessor<2, 2,CellAccessor<2> >::AccessorData AccessorData; - - /** - * Constructor - */ - DoFSubstructAccessor (Triangulation<2> *tria, - const int level, - const int index, - const AccessorData *local_data) : - DoFObjectAccessor<2, 2,CellAccessor<2> > (tria,level,index,local_data) {}; - // do this here, since this way the - // CellAccessor has the possibility to know - // what a face_iterator is. Otherwise - // it would have to ask the DoFHandler - // which would need another big include - // file and maybe cyclic interdependence - typedef TriaIterator<2,DoFObjectAccessor<1, 2,TriaObjectAccessor<1, 2> > > face_iterator; -}; - - - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * @see DoFSubstructAccessor<1> - */ -template <> -class DoFSubstructAccessor<3> : public DoFObjectAccessor<3, 3,CellAccessor<3> > { - public: - /** - * Declare the data type that this accessor - * class expects to get passed from the - * iterator classes. - */ - typedef DoFObjectAccessor<2, 3,CellAccessor<3> >::AccessorData AccessorData; - - /** - * Constructor - */ - DoFSubstructAccessor (Triangulation<3> *tria, - const int level, - const int index, - const AccessorData *local_data) : - DoFObjectAccessor<3, 3,CellAccessor<3> > (tria,level,index,local_data) {}; - // do this here, since this way the - // CellAccessor has the possibility to know - // what a face_iterator is. Otherwise - // it would have to ask the DoFHandler - // which would need another big include - // file and maybe cyclic interdependence - typedef TriaIterator<3,DoFObjectAccessor<2, 3,TriaObjectAccessor<2, 3> > > face_iterator; -}; - - - /** * Grant access to the degrees of freedom on a cell. In fact, since all * access to the degrees of freedom has been enabled by the classes @@ -704,14 +573,21 @@ class DoFSubstructAccessor<3> : public DoFObjectAccessor<3, 3,CellAccessor<3> > * @author Wolfgang Bangerth, 1998 */ template -class DoFCellAccessor : public DoFSubstructAccessor { +class DoFCellAccessor : public DoFObjectAccessor > { public: + /** + * Type of faces. + */ + typedef + TriaIterator > > + face_iterator; + /** * Declare the data type that this accessor * class expects to get passed from the * iterator classes. */ - typedef typename DoFSubstructAccessor::AccessorData AccessorData; + typedef typename DoFObjectAccessor >::AccessorData AccessorData; /** * Constructor @@ -720,7 +596,7 @@ class DoFCellAccessor : public DoFSubstructAccessor { const int level, const int index, const AccessorData *local_data) : - DoFSubstructAccessor (tria,level,index,local_data) {}; + DoFObjectAccessor > (tria,level,index,local_data) {}; /** * Return the #i#th neighbor as a DoF cell @@ -747,7 +623,7 @@ class DoFCellAccessor : public DoFSubstructAccessor { * This function is not implemented in 1D, * and maps to DoFObjectAccessor<2, dim>::line in 2D. */ - typename DoFSubstructAccessor::face_iterator + face_iterator face (const unsigned int i) const; /** diff --git a/deal.II/deal.II/include/dofs/mg_dof_accessor.h b/deal.II/deal.II/include/dofs/mg_dof_accessor.h index 030ea02c76..8c4233effe 100644 --- a/deal.II/deal.II/include/dofs/mg_dof_accessor.h +++ b/deal.II/deal.II/include/dofs/mg_dof_accessor.h @@ -85,7 +85,26 @@ class MGDoFAccessor { template -class MGDoFObjectAccessor; +class MGDoFObjectAccessor : public MGDoFAccessor, + public DoFObjectAccessor +{}; + + +/** + * Closure class. + */ +template +class MGDoFObjectAccessor<0, dim, BaseClass> +{ + public: + typedef void* AccessorData; + MGDoFObjectAccessor (Triangulation *, + const int, + const int, + const AccessorData *) + {} +}; + /** @@ -442,156 +461,6 @@ class MGDoFObjectAccessor<3, dim, BaseClass> : public MGDoFAccessor, - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * Rationale for the declaration of members for this class: gcc 2.8 has a bug - * when deriving from explicitely specialized classes which materializes in - * the calculation of wrong addresses of member variables. By declaring the - * general template of #DoFSubstructAccessor# to have the same object layout as - * the specialized versions (using the same base classes), we fool the compiler, - * which still looks in the wrong place for the addresses but finds the - * right information. This way, at least ot works. - * - * Insert a guard, however, in the constructor to avoid that anyone (including - * the compiler) happens to use this class. - */ -template -class MGDoFSubstructAccessor : public MGDoFObjectAccessor<1, 1,CellAccessor<1> > { - public: - MGDoFSubstructAccessor () { - Assert (false, ExcInternalError()); - }; - - DeclException0 (ExcInternalError); -}; - - - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * \subsection{Rationale} - * - * This class is only a wrapper class used to do kind of a typedef - * with template parameters. This class and #DoFSubstructAccessor<2># - * wrap the following names: - * \begin{verbatim} - * MGDoFSubstructAccessor<1> := MGDoFObjectAccessor<1, 1,CellAccessor<1> >; - * MGDoFSubstructAccessor<2> := MGDoFObjectAccessor<2, 2,CellAccessor<2> >; - * \end{verbatim} - * We do this rather complex (and needless, provided C++ the needed constructs!) - * class hierarchy manipulation, since this way we can declare and implement - * the \Ref{DoFCellAccessor} dimension independent as an inheritance from - * #DoFSubstructAccessor#. If we had not declared these - * types, we would have to write two class declarations, one for - * #DoFCellAccessor<1>#, derived from #DoFObjectAccessor<1, 1,CellAccessor<1> ># - * and one for #DoFCellAccessor<2>#, derived from - * #DoFObjectAccessor<2, 2,CellAccessor<2> >#. - */ -template <> -class MGDoFSubstructAccessor<1> : public MGDoFObjectAccessor<1, 1,CellAccessor<1> > { - public: - /** - * Declare the data type that this accessor - * class expects to get passed from the - * iterator classes. - */ - typedef MGDoFObjectAccessor<1, 1,CellAccessor<1> >::AccessorData AccessorData; - - /** - * Constructor - */ - MGDoFSubstructAccessor (Triangulation<1> *tria, - const int level, - const int index, - const AccessorData *local_data) : - MGDoFObjectAccessor<1, 1,CellAccessor<1> > (tria,level,index,local_data) {}; - // do this here, since this way the - // CellAccessor has the possibility to know - // what a face_iterator is. Otherwise - // it would have to ask the MGDoFHandler - // which would need another big include - // file and maybe cyclic interdependence - typedef void * face_iterator; -}; - - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * @see MGDoFSubstructAccessor<1> - */ -template <> -class MGDoFSubstructAccessor<2> : public MGDoFObjectAccessor<2, 2,CellAccessor<2> > { - public: - /** - * Declare the data type that this accessor - * class expects to get passed from the - * iterator classes. - */ - typedef MGDoFObjectAccessor<2, 2,CellAccessor<2> >::AccessorData AccessorData; - - /** - * Constructor - */ - MGDoFSubstructAccessor (Triangulation<2> *tria, - const int level, - const int index, - const AccessorData *local_data) : - MGDoFObjectAccessor<2, 2,CellAccessor<2> > (tria,level,index,local_data) {}; - // do this here, since this way the - // CellAccessor has the possibility to know - // what a face_iterator is. Otherwise - // it would have to ask the DoFHandler - // which would need another big include - // file and maybe cyclic interdependence - typedef TriaIterator<2,MGDoFObjectAccessor<1, 2,TriaObjectAccessor<1, 2> > > face_iterator; -}; - - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * @see MGDoFSubstructAccessor<1> - */ -template <> -class MGDoFSubstructAccessor<3> : public MGDoFObjectAccessor<3, 3,CellAccessor<3> > { - public: - /** - * Declare the data type that this accessor - * class expects to get passed from the - * iterator classes. - */ - typedef MGDoFObjectAccessor<3, 3,CellAccessor<3> >::AccessorData AccessorData; - - /** - * Constructor - */ - MGDoFSubstructAccessor (Triangulation<3> *tria, - const int level, - const int index, - const AccessorData *local_data) : - MGDoFObjectAccessor<3, 3,CellAccessor<3> > (tria,level,index,local_data) {}; - // do this here, since this way the - // CellAccessor has the possibility to know - // what a face_iterator is. Otherwise - // it would have to ask the DoFHandler - // which would need another big include - // file and maybe cyclic interdependence - typedef TriaIterator<3,MGDoFObjectAccessor<2, 3,TriaObjectAccessor<2, 3> > > face_iterator; -}; - - - - - - /** * Grant access to the degrees of freedom on a cell. In fact, since all * access to the degrees of freedom has been enabled by the classes @@ -606,14 +475,22 @@ class MGDoFSubstructAccessor<3> : public MGDoFObjectAccessor<3, 3,CellAccessor<3 * @author Wolfgang Bangerth, 1998 */ template -class MGDoFCellAccessor : public MGDoFSubstructAccessor { +class MGDoFCellAccessor : public MGDoFObjectAccessor > { public: + /** + * Type of faces. + */ + typedef + TriaIterator > > + face_iterator; /** * Declare the data type that this accessor * class expects to get passed from the * iterator classes. */ - typedef typename MGDoFSubstructAccessor::AccessorData AccessorData; + typedef typename + MGDoFObjectAccessor >::AccessorData + AccessorData; /** * Constructor @@ -622,7 +499,7 @@ class MGDoFCellAccessor : public MGDoFSubstructAccessor { const int level, const int index, const AccessorData *local_data) : - MGDoFSubstructAccessor (tria,level,index,local_data) {}; + MGDoFObjectAccessor > (tria,level,index,local_data) {}; /** * Return the #i#th neighbor as a MGDoF cell @@ -649,7 +526,7 @@ class MGDoFCellAccessor : public MGDoFSubstructAccessor { * This function is not implemented in 1D, * and maps to MGDoFObjectAccessor<2, dim>::line in 2D. */ - typename MGDoFSubstructAccessor::face_iterator + face_iterator face (const unsigned int i) const; /** diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index e7d15db8e7..299936ce73 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -398,7 +398,8 @@ class TriaObjectAccessor : public TriaAccessor * Pointer to the #i#th * child. */ - TriaIterator > child (const unsigned int i) const; + TriaIterator > + child (const unsigned int i) const; /** * Index of the #i#th child. @@ -600,7 +601,9 @@ class TriaObjectAccessor : public TriaAccessor template friend class TriaRawIterator; }; - +/** + * Closure class. + */ template class TriaObjectAccessor<0, dim> : public TriaAccessor {}; 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 f75682dd43..f13c09455a 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.templates.h +++ b/deal.II/deal.II/include/grid/tria_accessor.templates.h @@ -427,7 +427,7 @@ TriaObjectAccessor<2, dim>::operator -- () { -/*------------------------ Functions: TriaObjectAccessor ---------------------------*/ +/*------------------------ Functions: HexAccessor ---------------------------*/ @@ -667,6 +667,289 @@ TriaObjectAccessor<3, dim>::operator -- () { +/*------------------------ Functions: TriaObjectAccessor ---------------------------*/ + + + +template +inline +bool +TriaObjectAccessor::used () const +{ + Assert (state() == valid, ExcDereferenceInvalidObject()); + return tria->levels[present_level]->hexes.used[present_index]; +}; + + + +template +inline +bool +TriaObjectAccessor::user_flag_set () const +{ + Assert (used(), ExcCellNotUsed()); + return tria->levels[present_level]->hexes.user_flags[present_index]; +}; + + + +template +inline +void +TriaObjectAccessor::set_user_flag () const +{ + Assert (used(), ExcCellNotUsed()); + tria->levels[present_level]->hexes.user_flags[present_index] = true; +}; + + + +template +inline +void TriaObjectAccessor::clear_user_flag () const +{ + Assert (used(), ExcCellNotUsed()); + tria->levels[present_level]->hexes.user_flags[present_index] = false; +}; + + + + +template +inline +TriaIterator > +TriaObjectAccessor::line (const unsigned int i) const +{ + Assert (used(), ExcCellNotUsed()); + Assert (i < GeometryInfo::lines_per_cell, + ExcIndexRange(i,0,GeometryInfo::lines_per_cell)); + + switch(celldim) + { + case 2: + return + TriaIterator > + ( + tria, + present_level, + line_index (i) + ); + case 3: + if (i<4) + return quad(0)->line(i); + else + if (i<8) + return quad(1)->line(i-4); + else + switch (i) + { + case 8: + return quad(2)->line(3); + case 9: + return quad(2)->line(1); + case 10: + return quad(4)->line(1); + case 11: + return quad(4)->line(3); + } + break; + default: + Assert(false, ExcNotImplemented()); + } + + return TriaIterator >(tria, -1, -1, 0); +}; + + + +template +inline +TriaIterator > +TriaObjectAccessor::quad (const unsigned int i) const +{ + Assert (used(), ExcCellNotUsed()); + Assert (i < GeometryInfo::quads_per_cell, + ExcIndexRange(i,0,GeometryInfo::quads_per_cell)); + return + TriaIterator > + ( + tria, + present_level, + quad_index (i) + ); +}; + + + +template +inline +unsigned int +TriaObjectAccessor::line_index (unsigned int i) const +{ + Assert (i < GeometryInfo::lines_per_cell, + ExcIndexRange(i,0,GeometryInfo::lines_per_cell)); + + switch(celldim) + { + case 2: + return tria->levels[present_level] + ->quads.quads[present_index].line(i); + case 3: + if (i<4) + return quad(0)->line_index(i); + else + if (i<8) + return quad(1)->line_index(i-4); + else + switch (i) + { + case 8: + return quad(2)->line_index(3); + case 9: + return quad(2)->line_index(1); + case 10: + return quad(4)->line_index(1); + case 11: + return quad(4)->line_index(3); + }; + break; + default: + Assert(false, ExcNotImplemented()); + } + return 0; +}; + + + +template +inline +unsigned int +TriaObjectAccessor::quad_index (unsigned int i) const +{ + Assert (i < GeometryInfo::quads_per_cell, + ExcIndexRange(i,0,GeometryInfo::quads_per_cell)); + + return tria->levels[present_level]->hexes.hexes[present_index].quad(i); +}; + + + +template +inline +TriaIterator > +TriaObjectAccessor::child (const unsigned int i) const +{ + Assert (i < GeometryInfo::children_per_cell, + ExcIndexRange(i,0,GeometryInfo::children_per_cell)); + + TriaIterator > q (tria, present_level+1, child_index (i)); + +#ifdef DEBUG + if (q.state() != past_the_end) + Assert (q->used(), ExcUnusedCellAsChild()); +#endif + return q; +}; + + + +template +inline +int TriaObjectAccessor::child_index (unsigned int i) const +{ + Assert (i < GeometryInfo::children_per_cell, + ExcIndexRange(i,0,GeometryInfo::children_per_cell)); + return tria->levels[present_level]->hexes.children[present_index]+i; +}; + + + +template +bool TriaObjectAccessor::has_children () const +{ + Assert (state() == valid, ExcDereferenceInvalidObject()); + return (tria->levels[present_level]->hexes.children[present_index] != -1); +}; + + + +template +inline +unsigned int +TriaObjectAccessor::max_refinement_depth () const +{ + if (!has_children()) + return 0; + + const unsigned int depths[8] = { child(0)->max_refinement_depth() + 1, + child(1)->max_refinement_depth() + 1, + child(2)->max_refinement_depth() + 1, + child(3)->max_refinement_depth() + 1, + child(4)->max_refinement_depth() + 1, + child(5)->max_refinement_depth() + 1, + child(6)->max_refinement_depth() + 1, + child(7)->max_refinement_depth() + 1 }; + return max (max (max (depths[0], depths[1]), + max (depths[2], depths[3])), + max (max (depths[4], depths[5]), + max (depths[6], depths[7]))); +}; + + + +template +inline +void +TriaObjectAccessor::operator ++ () { + ++present_index; + // is index still in the range of + // the vector? + while (present_index + >= + (int)tria->levels[present_level]->hexes.hexes.size()) + { + // no -> go one level up + ++present_level; + present_index = 0; + // highest level reached? + if (present_level >= (int)tria->levels.size()) + { + // return with past the end pointer + present_level = present_index = -1; + return; + }; + }; +}; + + + +template +inline +void +TriaObjectAccessor::operator -- () +{ + --present_index; + // is index still in the range of + // the vector? + while (present_index < 0) + { + // no -> go one level down + --present_level; + // lowest level reached? + if (present_level == -1) + { + // return with past the end pointer + present_level = present_index = -1; + return; + }; + // else + present_index = tria->levels[present_level]->hexes.hexes.size()-1; + }; +}; + + + + /*------------------------ Functions: CellAccessor -----------------------*/ diff --git a/deal.II/deal.II/include/multigrid/mg_dof_accessor.h b/deal.II/deal.II/include/multigrid/mg_dof_accessor.h index 030ea02c76..8c4233effe 100644 --- a/deal.II/deal.II/include/multigrid/mg_dof_accessor.h +++ b/deal.II/deal.II/include/multigrid/mg_dof_accessor.h @@ -85,7 +85,26 @@ class MGDoFAccessor { template -class MGDoFObjectAccessor; +class MGDoFObjectAccessor : public MGDoFAccessor, + public DoFObjectAccessor +{}; + + +/** + * Closure class. + */ +template +class MGDoFObjectAccessor<0, dim, BaseClass> +{ + public: + typedef void* AccessorData; + MGDoFObjectAccessor (Triangulation *, + const int, + const int, + const AccessorData *) + {} +}; + /** @@ -442,156 +461,6 @@ class MGDoFObjectAccessor<3, dim, BaseClass> : public MGDoFAccessor, - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * Rationale for the declaration of members for this class: gcc 2.8 has a bug - * when deriving from explicitely specialized classes which materializes in - * the calculation of wrong addresses of member variables. By declaring the - * general template of #DoFSubstructAccessor# to have the same object layout as - * the specialized versions (using the same base classes), we fool the compiler, - * which still looks in the wrong place for the addresses but finds the - * right information. This way, at least ot works. - * - * Insert a guard, however, in the constructor to avoid that anyone (including - * the compiler) happens to use this class. - */ -template -class MGDoFSubstructAccessor : public MGDoFObjectAccessor<1, 1,CellAccessor<1> > { - public: - MGDoFSubstructAccessor () { - Assert (false, ExcInternalError()); - }; - - DeclException0 (ExcInternalError); -}; - - - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * \subsection{Rationale} - * - * This class is only a wrapper class used to do kind of a typedef - * with template parameters. This class and #DoFSubstructAccessor<2># - * wrap the following names: - * \begin{verbatim} - * MGDoFSubstructAccessor<1> := MGDoFObjectAccessor<1, 1,CellAccessor<1> >; - * MGDoFSubstructAccessor<2> := MGDoFObjectAccessor<2, 2,CellAccessor<2> >; - * \end{verbatim} - * We do this rather complex (and needless, provided C++ the needed constructs!) - * class hierarchy manipulation, since this way we can declare and implement - * the \Ref{DoFCellAccessor} dimension independent as an inheritance from - * #DoFSubstructAccessor#. If we had not declared these - * types, we would have to write two class declarations, one for - * #DoFCellAccessor<1>#, derived from #DoFObjectAccessor<1, 1,CellAccessor<1> ># - * and one for #DoFCellAccessor<2>#, derived from - * #DoFObjectAccessor<2, 2,CellAccessor<2> >#. - */ -template <> -class MGDoFSubstructAccessor<1> : public MGDoFObjectAccessor<1, 1,CellAccessor<1> > { - public: - /** - * Declare the data type that this accessor - * class expects to get passed from the - * iterator classes. - */ - typedef MGDoFObjectAccessor<1, 1,CellAccessor<1> >::AccessorData AccessorData; - - /** - * Constructor - */ - MGDoFSubstructAccessor (Triangulation<1> *tria, - const int level, - const int index, - const AccessorData *local_data) : - MGDoFObjectAccessor<1, 1,CellAccessor<1> > (tria,level,index,local_data) {}; - // do this here, since this way the - // CellAccessor has the possibility to know - // what a face_iterator is. Otherwise - // it would have to ask the MGDoFHandler - // which would need another big include - // file and maybe cyclic interdependence - typedef void * face_iterator; -}; - - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * @see MGDoFSubstructAccessor<1> - */ -template <> -class MGDoFSubstructAccessor<2> : public MGDoFObjectAccessor<2, 2,CellAccessor<2> > { - public: - /** - * Declare the data type that this accessor - * class expects to get passed from the - * iterator classes. - */ - typedef MGDoFObjectAccessor<2, 2,CellAccessor<2> >::AccessorData AccessorData; - - /** - * Constructor - */ - MGDoFSubstructAccessor (Triangulation<2> *tria, - const int level, - const int index, - const AccessorData *local_data) : - MGDoFObjectAccessor<2, 2,CellAccessor<2> > (tria,level,index,local_data) {}; - // do this here, since this way the - // CellAccessor has the possibility to know - // what a face_iterator is. Otherwise - // it would have to ask the DoFHandler - // which would need another big include - // file and maybe cyclic interdependence - typedef TriaIterator<2,MGDoFObjectAccessor<1, 2,TriaObjectAccessor<1, 2> > > face_iterator; -}; - - - -/** - * Intermediate, "typedef"-class, not for public use. - * - * @see MGDoFSubstructAccessor<1> - */ -template <> -class MGDoFSubstructAccessor<3> : public MGDoFObjectAccessor<3, 3,CellAccessor<3> > { - public: - /** - * Declare the data type that this accessor - * class expects to get passed from the - * iterator classes. - */ - typedef MGDoFObjectAccessor<3, 3,CellAccessor<3> >::AccessorData AccessorData; - - /** - * Constructor - */ - MGDoFSubstructAccessor (Triangulation<3> *tria, - const int level, - const int index, - const AccessorData *local_data) : - MGDoFObjectAccessor<3, 3,CellAccessor<3> > (tria,level,index,local_data) {}; - // do this here, since this way the - // CellAccessor has the possibility to know - // what a face_iterator is. Otherwise - // it would have to ask the DoFHandler - // which would need another big include - // file and maybe cyclic interdependence - typedef TriaIterator<3,MGDoFObjectAccessor<2, 3,TriaObjectAccessor<2, 3> > > face_iterator; -}; - - - - - - /** * Grant access to the degrees of freedom on a cell. In fact, since all * access to the degrees of freedom has been enabled by the classes @@ -606,14 +475,22 @@ class MGDoFSubstructAccessor<3> : public MGDoFObjectAccessor<3, 3,CellAccessor<3 * @author Wolfgang Bangerth, 1998 */ template -class MGDoFCellAccessor : public MGDoFSubstructAccessor { +class MGDoFCellAccessor : public MGDoFObjectAccessor > { public: + /** + * Type of faces. + */ + typedef + TriaIterator > > + face_iterator; /** * Declare the data type that this accessor * class expects to get passed from the * iterator classes. */ - typedef typename MGDoFSubstructAccessor::AccessorData AccessorData; + typedef typename + MGDoFObjectAccessor >::AccessorData + AccessorData; /** * Constructor @@ -622,7 +499,7 @@ class MGDoFCellAccessor : public MGDoFSubstructAccessor { const int level, const int index, const AccessorData *local_data) : - MGDoFSubstructAccessor (tria,level,index,local_data) {}; + MGDoFObjectAccessor > (tria,level,index,local_data) {}; /** * Return the #i#th neighbor as a MGDoF cell @@ -649,7 +526,7 @@ class MGDoFCellAccessor : public MGDoFSubstructAccessor { * This function is not implemented in 1D, * and maps to MGDoFObjectAccessor<2, dim>::line in 2D. */ - typename MGDoFSubstructAccessor::face_iterator + face_iterator face (const unsigned int i) const; /** diff --git a/deal.II/deal.II/source/dofs/dof_accessor.cc b/deal.II/deal.II/source/dofs/dof_accessor.cc index 17be9b9261..b02207d5cf 100644 --- a/deal.II/deal.II/source/dofs/dof_accessor.cc +++ b/deal.II/deal.II/source/dofs/dof_accessor.cc @@ -28,10 +28,10 @@ template void DoFObjectAccessor<1, dim,BaseClass>::set_dof_index (const unsigned int i, const int index) const { - Assert (dof_handler != 0, ExcInvalidObject()); + Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected // and enough room was reserved - Assert (dof_handler->selected_fe != 0, ExcInvalidObject()); + Assert (dof_handler->selected_fe != 0, DoFAccessor::ExcInvalidObject()); Assert (iselected_fe->dofs_per_line, ExcIndexRange (i, 0, dof_handler->selected_fe->dofs_per_line)); @@ -316,10 +316,11 @@ distribute_local_to_global (const FullMatrix &local_source, #if deal_II_dimension == 1 template <> -DoFSubstructAccessor<1>::face_iterator -DoFCellAccessor<1>::face (const unsigned int) const { +DoFCellAccessor<1>::face_iterator +DoFCellAccessor<1>::face (const unsigned int) const +{ Assert (false, ExcNotUsefulForThisDimension()); - return 0; + return face_iterator(); }; @@ -344,14 +345,14 @@ template void DoFCellAccessor::get_dof_values (const Vector &values, Vector &local_values) const { - Assert (dim==1, ::ExcInternalError()); + Assert (dim==1, ExcInternalError()); - Assert (dof_handler != 0, ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); + Assert (dof_handler != 0, DoFAccessor<1>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<1>::ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, - ExcVectorDoesNotMatch()); + DoFAccessor<1>::ExcVectorDoesNotMatch()); Assert (values.size() == dof_handler->n_dofs(), - ExcVectorDoesNotMatch()); + DoFAccessor<1>::ExcVectorDoesNotMatch()); Assert (active(), ExcNotActive()); const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, @@ -389,14 +390,14 @@ template void DoFCellAccessor::set_dof_values (const Vector &local_values, Vector &values) const { - Assert (dim==1, ::ExcInternalError()); + Assert (dim==1, ExcInternalError()); - Assert (dof_handler != 0, ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); + Assert (dof_handler != 0, DoFAccessor<1>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<1>::ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, - ExcVectorDoesNotMatch()); + DoFAccessor<1>::ExcVectorDoesNotMatch()); Assert (values.size() == dof_handler->n_dofs(), - ExcVectorDoesNotMatch()); + DoFAccessor<1>::ExcVectorDoesNotMatch()); Assert (active(), ExcNotActive()); const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, @@ -421,8 +422,9 @@ DoFCellAccessor::set_dof_values (const Vector &local_values, #if deal_II_dimension == 2 template <> -DoFSubstructAccessor<2>::face_iterator -DoFCellAccessor<2>::face (const unsigned int i) const { +DoFCellAccessor<2>::face_iterator +DoFCellAccessor<2>::face (const unsigned int i) const +{ return line(i); }; @@ -447,15 +449,16 @@ template template void DoFCellAccessor::get_dof_values (const Vector &values, - Vector &local_values) const { - Assert (dim==2, ::ExcInternalError()); + Vector &local_values) const +{ + Assert (dim==2, ExcInternalError()); - Assert (dof_handler != 0, ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); + Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, - ExcVectorDoesNotMatch()); + DoFAccessor::ExcVectorDoesNotMatch()); Assert (values.size() == dof_handler->n_dofs(), - ExcVectorDoesNotMatch()); + DoFAccessor::ExcVectorDoesNotMatch()); Assert (active(), ExcNotActive()); const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, @@ -497,14 +500,14 @@ template void DoFCellAccessor::set_dof_values (const Vector &local_values, Vector &values) const { - Assert (dim==2, ::ExcInternalError()); + Assert (dim==2, ExcInternalError()); - Assert (dof_handler != 0, ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); + Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, - ExcVectorDoesNotMatch()); + DoFAccessor::ExcVectorDoesNotMatch()); Assert (values.size() == dof_handler->n_dofs(), - ExcVectorDoesNotMatch()); + DoFAccessor::ExcVectorDoesNotMatch()); Assert (active(), ExcNotActive()); const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, @@ -532,8 +535,9 @@ DoFCellAccessor::set_dof_values (const Vector &local_values, #if deal_II_dimension == 3 template <> -DoFSubstructAccessor<3>::face_iterator -DoFCellAccessor<3>::face (const unsigned int i) const { +DoFCellAccessor<3>::face_iterator +DoFCellAccessor<3>::face (const unsigned int i) const +{ return quad(i); }; @@ -559,14 +563,14 @@ template void DoFCellAccessor::get_dof_values (const Vector &values, Vector &local_values) const { - Assert (dim==3, ::ExcInternalError()); + Assert (dim==3, ExcInternalError()); - Assert (dof_handler != 0, ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); + Assert (dof_handler != 0, DoFAccessor<3>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<3>::ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, - ExcVectorDoesNotMatch()); + DoFAccessor<3>::ExcVectorDoesNotMatch()); Assert (values.size() == dof_handler->n_dofs(), - ExcVectorDoesNotMatch()); + DoFAccessor<3>::ExcVectorDoesNotMatch()); Assert (active(), ExcNotActive()); const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, @@ -612,14 +616,14 @@ template void DoFCellAccessor::set_dof_values (const Vector &local_values, Vector &values) const { - Assert (dim==3, ::ExcInternalError()); + Assert (dim==3, ExcInternalError()); - Assert (dof_handler != 0, ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); + Assert (dof_handler != 0, DoFAccessor<3>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<3>::ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, - ExcVectorDoesNotMatch()); + DoFAccessor<3>::ExcVectorDoesNotMatch()); Assert (values.size() == dof_handler->n_dofs(), - ExcVectorDoesNotMatch()); + DoFAccessor<3>::ExcVectorDoesNotMatch()); Assert (active(), ExcNotActive()); const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, @@ -657,12 +661,12 @@ DoFCellAccessor::get_interpolated_dof_values (const Vector &values, Vector &interpolated_values) const { const unsigned int total_dofs = dof_handler->get_fe().total_dofs; - Assert (dof_handler != 0, ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); + Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); Assert (interpolated_values.size() == total_dofs, - ExcVectorDoesNotMatch()); + DoFAccessor::ExcVectorDoesNotMatch()); Assert (values.size() == dof_handler->n_dofs(), - ExcVectorDoesNotMatch()); + DoFAccessor::ExcVectorDoesNotMatch()); if (!has_children()) // if this cell has no children: simply @@ -711,12 +715,12 @@ DoFCellAccessor::set_dof_values_by_interpolation (const Vector &loc Vector &values) const { const unsigned int total_dofs = dof_handler->get_fe().total_dofs; - Assert (dof_handler != 0, ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); + Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); Assert (local_values.size() == total_dofs, - ExcVectorDoesNotMatch()); + DoFAccessor::ExcVectorDoesNotMatch()); Assert (values.size() == dof_handler->n_dofs(), - ExcVectorDoesNotMatch()); + DoFAccessor::ExcVectorDoesNotMatch()); if (!has_children()) // if this cell has no children: simply diff --git a/deal.II/deal.II/source/dofs/mg_dof_accessor.cc b/deal.II/deal.II/source/dofs/mg_dof_accessor.cc index 69b6055849..147b6926b2 100644 --- a/deal.II/deal.II/source/dofs/mg_dof_accessor.cc +++ b/deal.II/deal.II/source/dofs/mg_dof_accessor.cc @@ -301,7 +301,7 @@ MGDoFObjectAccessor<2, dim,BaseClass>::copy_from (const MGDoFObjectAccessor<2, d -/* ------------------------ MGDoFObjectAccessor --------------------------- */ +/* ------------------------ MGDoFHexAccessor --------------------------- */ template MGDoFObjectAccessor<3, dim,BaseClass>::MGDoFObjectAccessor (Triangulation *tria, @@ -512,10 +512,11 @@ MGDoFCellAccessor::child (const unsigned int i) const { #if deal_II_dimension == 1 template <> -MGDoFSubstructAccessor<1>::face_iterator -MGDoFCellAccessor<1>::face (const unsigned int) const { +MGDoFCellAccessor<1>::face_iterator +MGDoFCellAccessor<1>::face (const unsigned int) const +{ Assert (false, ExcNotUsefulForThisDimension()); - return 0; + return face_iterator(); }; @@ -549,8 +550,9 @@ MGDoFCellAccessor<1>::get_mg_dof_values (const Vector &values, #if deal_II_dimension == 2 template <> -MGDoFSubstructAccessor<2>::face_iterator -MGDoFCellAccessor<2>::face (const unsigned int i) const { +MGDoFCellAccessor<2>::face_iterator +MGDoFCellAccessor<2>::face (const unsigned int i) const +{ return line(i); }; 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 69b6055849..147b6926b2 100644 --- a/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc +++ b/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc @@ -301,7 +301,7 @@ MGDoFObjectAccessor<2, dim,BaseClass>::copy_from (const MGDoFObjectAccessor<2, d -/* ------------------------ MGDoFObjectAccessor --------------------------- */ +/* ------------------------ MGDoFHexAccessor --------------------------- */ template MGDoFObjectAccessor<3, dim,BaseClass>::MGDoFObjectAccessor (Triangulation *tria, @@ -512,10 +512,11 @@ MGDoFCellAccessor::child (const unsigned int i) const { #if deal_II_dimension == 1 template <> -MGDoFSubstructAccessor<1>::face_iterator -MGDoFCellAccessor<1>::face (const unsigned int) const { +MGDoFCellAccessor<1>::face_iterator +MGDoFCellAccessor<1>::face (const unsigned int) const +{ Assert (false, ExcNotUsefulForThisDimension()); - return 0; + return face_iterator(); }; @@ -549,8 +550,9 @@ MGDoFCellAccessor<1>::get_mg_dof_values (const Vector &values, #if deal_II_dimension == 2 template <> -MGDoFSubstructAccessor<2>::face_iterator -MGDoFCellAccessor<2>::face (const unsigned int i) const { +MGDoFCellAccessor<2>::face_iterator +MGDoFCellAccessor<2>::face (const unsigned int i) const +{ return line(i); }; -- 2.39.5