From add424f896b100f774c8d866afdc38d1e11e3f55 Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 8 Aug 2005 17:26:51 +0000 Subject: [PATCH] In dof accessors, make sure that they point to the same DoFHandler object. Everything else wouldn't make much sense. git-svn-id: https://svn.dealii.org/trunk@11246 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/dofs/dof_accessor.h | 96 +++++++++++++++- .../include/dofs/dof_accessor.templates.h | 103 ++++++++++++++++++ 2 files changed, 198 insertions(+), 1 deletion(-) diff --git a/deal.II/deal.II/include/dofs/dof_accessor.h b/deal.II/deal.II/include/dofs/dof_accessor.h index ec6998e4b6..62927533ca 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.h @@ -31,6 +31,7 @@ template class DoFObjectAccessor<1, dim>; template class DoFObjectAccessor<2, dim>; template class DoFObjectAccessor<3, dim>; +template class TriaRawIterator; @@ -146,13 +147,30 @@ class DoFAccessor * @ingroup Exceptions */ DeclException0 (ExcNotActive); + /** + * Exception + * + * @ingroup Exceptions + */ + DeclException0 (ExcCantCompareIterators); + + protected: + /** + * Compare for equality. + */ + bool operator == (const DoFAccessor &) const; + + /** + * Compare for inequality. + */ + bool operator != (const DoFAccessor &) const; protected: /** * Store the address of the DoFHandler object * to be accessed. */ - DoFHandler *dof_handler; + DoFHandler *dof_handler; }; @@ -460,6 +478,25 @@ class DoFObjectAccessor : public DoFAccessor, * for the iterator classes. */ void copy_from (const DoFObjectAccessor &a); + + protected: + /** + * Compare for equality. + */ + bool operator == (const DoFObjectAccessor &) const; + + /** + * Compare for inequality. + */ + bool operator != (const DoFObjectAccessor &) const; + + + /** + * Iterator classes need to be friends + * because they need to access operator== + * and operator!=. + */ + template friend class TriaRawIterator; }; @@ -703,6 +740,25 @@ class DoFObjectAccessor<1, dim> : public DoFAccessor, * for the iterator classes. */ void copy_from (const DoFObjectAccessor<1,dim> &a); + + protected: + /** + * Compare for equality. + */ + bool operator == (const DoFObjectAccessor<1,dim> &) const; + + /** + * Compare for inequality. + */ + bool operator != (const DoFObjectAccessor<1,dim> &) const; + + + /** + * Iterator classes need to be friends + * because they need to access operator== + * and operator!=. + */ + template friend class TriaRawIterator; }; @@ -905,6 +961,25 @@ class DoFObjectAccessor<2, dim> : public DoFAccessor, * for the iterator classes. */ void copy_from (const DoFObjectAccessor<2, dim> &a); + + protected: + /** + * Compare for equality. + */ + bool operator == (const DoFObjectAccessor<2,dim> &) const; + + /** + * Compare for inequality. + */ + bool operator != (const DoFObjectAccessor<2,dim> &) const; + + + /** + * Iterator classes need to be friends + * because they need to access operator== + * and operator!=. + */ + template friend class TriaRawIterator; }; @@ -1115,6 +1190,25 @@ class DoFObjectAccessor<3, dim> : public DoFAccessor, * for the iterator classes. */ void copy_from (const DoFObjectAccessor<3, dim> &a); + + protected: + /** + * Compare for equality. + */ + bool operator == (const DoFObjectAccessor<3,dim> &) const; + + /** + * Compare for inequality. + */ + bool operator != (const DoFObjectAccessor<3,dim> &) const; + + + /** + * Iterator classes need to be friends + * because they need to access operator== + * and operator!=. + */ + template friend class TriaRawIterator; }; 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 37ea1edcc8..982a7bcb25 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.templates.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.templates.h @@ -86,6 +86,39 @@ DoFAccessor::operator = (const DoFAccessor &da) +template +inline +bool +DoFAccessor::operator == (const DoFAccessor &a) const +{ + Assert (dof_handler == a.dof_handler, ExcCantCompareIterators()); + + // there is no real data to compare, except + // to make sure that the dof_handler + // objects in use are the same + return true; +} + + + +template +inline +bool +DoFAccessor::operator != (const DoFAccessor &a) const +{ + Assert (dof_handler == a.dof_handler, ExcCantCompareIterators()); + + // there is no real data to compare, except + // to make sure that the dof_handler + // objects in use are the same. this is + // checked above, and apart from this there + // is no reason for us to believe that the + // two accessors are different + return false; +} + + + /*------------------------- Functions: DoFObjectAccessor<1,dim> -----------------------*/ @@ -336,6 +369,29 @@ DoFObjectAccessor<1,dim>::copy_from (const DoFObjectAccessor<1,dim> &a) } + +template +inline +bool +DoFObjectAccessor<1,dim>::operator == (const DoFObjectAccessor<1,dim> &a) const +{ + return (TriaObjectAccessor<1,dim>::operator == (a) + && + DoFAccessor::operator == (a)); +} + + +template +inline +bool +DoFObjectAccessor<1,dim>::operator != (const DoFObjectAccessor<1,dim> &a) const +{ + return (TriaObjectAccessor<1,dim>::operator != (a) + || + DoFAccessor::operator != (a)); +} + + /*------------------------- Functions: DoFObjectAccessor<2,dim> -----------------------*/ template @@ -580,6 +636,30 @@ DoFObjectAccessor<2,dim>::copy_from (const DoFObjectAccessor<2,dim> &a) } + +template +inline +bool +DoFObjectAccessor<2,dim>::operator == (const DoFObjectAccessor<2,dim> &a) const +{ + return (TriaObjectAccessor<2,dim>::operator == (a) + && + DoFAccessor::operator == (a)); +} + + +template +inline +bool +DoFObjectAccessor<2,dim>::operator != (const DoFObjectAccessor<2,dim> &a) const +{ + return (TriaObjectAccessor<2,dim>::operator != (a) + || + DoFAccessor::operator != (a)); +} + + + /*------------------------- Functions: DoFObjectAccessor<3,dim> -----------------------*/ @@ -848,6 +928,29 @@ void DoFObjectAccessor<3,dim>::copy_from (const DoFObjectAccessor<3,dim> &a) } + +template +inline +bool +DoFObjectAccessor<3,dim>::operator == (const DoFObjectAccessor<3,dim> &a) const +{ + return (TriaObjectAccessor<3,dim>::operator == (a) + && + DoFAccessor::operator == (a)); +} + + +template +inline +bool +DoFObjectAccessor<3,dim>::operator != (const DoFObjectAccessor<3,dim> &a) const +{ + return (TriaObjectAccessor<3,dim>::operator != (a) + || + DoFAccessor::operator != (a)); +} + + /*------------------------- Functions: DoFCellAccessor -----------------------*/ -- 2.39.5