From: bangerth Date: Sat, 18 Dec 2010 05:00:38 +0000 (+0000) Subject: Also introduce MGDoFAccessor<0,1,spacedim>. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a496c94679fc74b5f7d7c8ae443b8b55e40cffa2;p=dealii-svn.git Also introduce MGDoFAccessor<0,1,spacedim>. git-svn-id: https://svn.dealii.org/trunk@23000 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/dofs/dof_accessor.h b/deal.II/include/deal.II/dofs/dof_accessor.h index b74f47048e..d33b447bac 100644 --- a/deal.II/include/deal.II/dofs/dof_accessor.h +++ b/deal.II/include/deal.II/dofs/dof_accessor.h @@ -859,7 +859,7 @@ class DoFAccessor<0,DH<1,spacedim> > : public TriaAccessor<0,1,spacedim> * do anything useful here and so * may not actually be called. */ - DoFAccessor (const Triangulation<1,spacedim> * = 0, + DoFAccessor (const Triangulation<1,spacedim> *, const int = 0, const int = 0, const DH<1,spacedim> * = 0); diff --git a/deal.II/include/deal.II/multigrid/mg_dof_accessor.h b/deal.II/include/deal.II/multigrid/mg_dof_accessor.h index 42a14d8942..438add06a8 100644 --- a/deal.II/include/deal.II/multigrid/mg_dof_accessor.h +++ b/deal.II/include/deal.II/multigrid/mg_dof_accessor.h @@ -338,6 +338,14 @@ class MGDoFAccessor : public internal::MGDoFAccessor::Inheritance & + get_mg_dof_handler () const; + /** * Return an iterator pointing to * the the parent. @@ -413,6 +421,161 @@ class MGDoFAccessor : public internal::MGDoFAccessor::Inheritance +class MGDoFAccessor<0,1,spacedim> : public internal::MGDoFAccessor::Inheritance<0,1,spacedim>::BaseClass +{ + public: + /** + * Declare a typedef to the base + * class to make accessing some + * of the exception classes + * simpler. + */ + typedef + typename internal::MGDoFAccessor::Inheritance<0,1,spacedim>::BaseClass + BaseClass; + + /** + * A typedef necessary for the + * iterator classes. + */ + typedef MGDoFHandler<1,spacedim> AccessorData; + + /** + * The dof handler type used by + * this accessor. + */ + typedef MGDoFHandler<1, spacedim> Container; + + /** + * @name Constructors + */ + /** + * @{ + */ + + /** + * Default constructor. Provides + * an accessor that can't be + * used. + */ + MGDoFAccessor (); + + /** + * Constructor to be used if the + * object here refers to a vertex + * of a one-dimensional + * triangulation, i.e. a face of + * the triangulation. + * + * Since there is no mapping from + * vertices to cells, an accessor + * object for a point has no way + * to figure out whether it is at + * the boundary of the domain or + * not. Consequently, the second + * argument must be passed by the + * object that generates this + * accessor -- e.g. a 1d cell + * that can figure out whether + * its left or right vertex are + * at the boundary. + * + * The third argument is the + * global index of the vertex we + * point to. + * + * The fourth argument is a + * pointer to the MGDoFHandler + * object. + * + * This iterator can only be + * called for one-dimensional + * triangulations. + */ + MGDoFAccessor (const Triangulation<1,spacedim> * tria, + const typename TriaAccessor<0,1,spacedim>::VertexKind vertex_kind, + const unsigned int vertex_index, + const MGDoFHandler<1,spacedim> * dof_handler); + + /** + * Constructor. This constructor + * exists in order to maintain + * interface compatibility with + * the other accessor + * classes. However, it doesn't + * do anything useful here and so + * may not actually be called. + */ + MGDoFAccessor (const Triangulation<1,spacedim> * = 0, + const int = 0, + const int = 0, + const MGDoFHandler<1,spacedim> * = 0); + + /** + * Conversion constructor. This + * constructor exists to make certain + * constructs simpler to write in + * dimension independent code. For + * example, it allows assigning a face + * iterator to a line iterator, an + * operation that is useful in 2d but + * doesn't make any sense in 3d. The + * constructor here exists for the + * purpose of making the code conform to + * C++ but it will unconditionally abort; + * in other words, assigning a face + * iterator to a line iterator is better + * put into an if-statement that checks + * that the dimension is two, and assign + * to a quad iterator in 3d (an operator + * that, without this constructor would + * be illegal if we happen to compile for + * 2d). + */ + template + MGDoFAccessor (const InvalidAccessor &); + + /** + * Another conversion operator + * between objects that don't + * make sense, just like the + * previous one. + */ + template + MGDoFAccessor (const MGDoFAccessor &); + + + /** + * Another conversion operator + * between objects that don't + * make sense, just like the + * previous one. + */ + template + MGDoFAccessor (const MGDoFCellAccessor &); + + protected: + /** + * Store the address of the @p MGDoFHandler object + * to be accessed. + */ + MGDoFHandler<1,spacedim> *mg_dof_handler; +}; + + + /* -------------------------------------------------------------------------- */ diff --git a/deal.II/include/deal.II/multigrid/mg_dof_iterator_selector.h b/deal.II/include/deal.II/multigrid/mg_dof_iterator_selector.h index bcbdc8fbfc..716a864cbb 100644 --- a/deal.II/include/deal.II/multigrid/mg_dof_iterator_selector.h +++ b/deal.II/include/deal.II/multigrid/mg_dof_iterator_selector.h @@ -45,8 +45,8 @@ namespace internal { public: typedef dealii::MGDoFCellAccessor<1,spacedim> CellAccessor; - typedef InvalidAccessor<0,1,spacedim> FaceAccessor; - + typedef dealii::MGDoFAccessor<0,1,spacedim> FaceAccessor; + typedef TriaRawIterator raw_line_iterator; typedef TriaIterator line_iterator; typedef TriaActiveIterator active_line_iterator; @@ -80,11 +80,11 @@ namespace internal public: typedef dealii::MGDoFCellAccessor<2,spacedim> CellAccessor; typedef dealii::MGDoFAccessor<1,2,spacedim> FaceAccessor; - + typedef TriaRawIterator raw_line_iterator; typedef TriaIterator line_iterator; typedef TriaActiveIterator active_line_iterator; - + typedef TriaRawIterator raw_quad_iterator; typedef TriaIterator quad_iterator; typedef TriaActiveIterator active_quad_iterator; @@ -99,7 +99,7 @@ namespace internal typedef raw_line_iterator raw_face_iterator; typedef line_iterator face_iterator; - typedef active_line_iterator active_face_iterator; + typedef active_line_iterator active_face_iterator; }; @@ -133,7 +133,7 @@ namespace internal typedef raw_quad_iterator raw_face_iterator; typedef quad_iterator face_iterator; - typedef active_quad_iterator active_face_iterator; + typedef active_quad_iterator active_face_iterator; }; } } diff --git a/deal.II/source/multigrid/mg_dof_accessor.cc b/deal.II/source/multigrid/mg_dof_accessor.cc index b5efa2acfc..61007de2d5 100644 --- a/deal.II/source/multigrid/mg_dof_accessor.cc +++ b/deal.II/source/multigrid/mg_dof_accessor.cc @@ -65,6 +65,15 @@ MGDoFAccessor::set_mg_dof_handler (MGDoFHandler +const MGDoFHandler & +MGDoFAccessor::get_mg_dof_handler () const +{ + return *mg_dof_handler; +} + + + template unsigned int MGDoFAccessor::mg_vertex_dof_index (const int level, @@ -454,9 +463,78 @@ get_mg_dof_values (const int level, +/*------------------------- Functions: MGDoFAccessor<0,1,spacedim> -----------------------*/ + +template +inline +MGDoFAccessor<0,1,spacedim>::MGDoFAccessor () + : + BaseClass () +{ + Assert (false, typename BaseClass::ExcInvalidObject()); +} + + + +template +inline +MGDoFAccessor<0,1,spacedim>:: +MGDoFAccessor (const Triangulation<1,spacedim> *tria, + const typename TriaAccessor<0,1,spacedim>::VertexKind vertex_kind, + const unsigned int vertex_index, + const MGDoFHandler<1,spacedim> * dof_handler) + : + BaseClass (tria, + vertex_kind, + vertex_index), + mg_dof_handler(const_cast*>(dof_handler)) +{} + + + +template +inline +MGDoFAccessor<0,1,spacedim>:: +MGDoFAccessor (const Triangulation<1,spacedim> *, + const int , + const int , + const MGDoFHandler<1,spacedim> *) + : + mg_dof_handler(0) +{ + Assert (false, + ExcMessage ("This constructor can not be called for face iterators in 1d.")); +} + + + +template +template +MGDoFAccessor<0,1,spacedim>::MGDoFAccessor (const InvalidAccessor &) +{ + Assert (false, typename BaseClass::ExcInvalidObject()); +} +template +template +inline +MGDoFAccessor<0,1,spacedim>::MGDoFAccessor (const MGDoFAccessor &) +{ + Assert (false, typename BaseClass::ExcInvalidObject()); +} + + + +template +template +inline +MGDoFAccessor<0,1,spacedim>::MGDoFAccessor (const MGDoFCellAccessor &) +{ + Assert (false, typename BaseClass::ExcInvalidObject()); +} + /*------------------------- Functions: MGDoFCellAccessor -----------------------*/ @@ -538,25 +616,65 @@ MGDoFCellAccessor::parent () const } +namespace internal +{ + namespace MGDoFCellAccessor + { + template + inline + typename internal::MGDoFHandler::Iterators<1,spacedim>::face_iterator + get_face (const dealii::MGDoFCellAccessor<1,spacedim> &cell, + const unsigned int i, + const internal::int2type<1>) + { + dealii::MGDoFAccessor<0,1,spacedim> + a (&cell.get_triangulation(), + ((i == 0) && cell.at_boundary(0) + ? + dealii::TriaAccessor<0, 1, spacedim>::left_vertex + : + ((i == 1) && cell.at_boundary(1) + ? + dealii::TriaAccessor<0, 1, spacedim>::right_vertex + : + dealii::TriaAccessor<0, 1, spacedim>::interior_vertex)), + cell.vertex_index(i), + &cell.get_mg_dof_handler()); + return typename internal::MGDoFHandler::Iterators<1,spacedim>::face_iterator(a); + } + + + template + inline + typename internal::MGDoFHandler::Iterators<2,spacedim>::face_iterator + get_face (const dealii::MGDoFCellAccessor<2,spacedim> &cell, + const unsigned int i, + const internal::int2type<2>) + { + return cell.line(i); + } + + + template + inline + typename internal::MGDoFHandler::Iterators<3,spacedim>::face_iterator + get_face (const dealii::MGDoFCellAccessor<3,spacedim> &cell, + const unsigned int i, + const internal::int2type<3>) + { + return cell.quad(i); + } + } +} + + template typename internal::MGDoFHandler::Iterators::face_iterator MGDoFCellAccessor::face (const unsigned int i) const { - switch (dim) - { - case 1: - Assert (false, ExcImpossibleInDim(1)); - return - typename internal::MGDoFHandler::Iterators::face_iterator(); - case 2: - return this->line(i); - case 3: - return this->quad(i); - default: - Assert (false, ExcNotImplemented()); - return - typename internal::MGDoFHandler::Iterators::face_iterator(); - } + Assert (i::faces_per_cell, ExcIndexRange (i, 0, GeometryInfo::faces_per_cell)); + + return internal::MGDoFCellAccessor::get_face (*this, i, internal::int2type()); } diff --git a/deal.II/source/multigrid/mg_dof_accessor.inst.in b/deal.II/source/multigrid/mg_dof_accessor.inst.in index 4888f59abb..4fdcec74de 100644 --- a/deal.II/source/multigrid/mg_dof_accessor.inst.in +++ b/deal.II/source/multigrid/mg_dof_accessor.inst.in @@ -82,6 +82,9 @@ for (deal_II_dimension : DIMENSIONS) #if deal_II_dimension == 1 + template class MGDoFAccessor<0, 1, 1>; + template class MGDoFAccessor<0, 1, 2>; + template class MGDoFAccessor<1, 1, 1>; template class MGDoFAccessor<1, 1, 2>;