/**
* Common template for line, quad, hex.
+ *
+ * Internal: inheritance is necessary for the general template due to
+ * a compiler error.
+ * @author Guido Kanschat, 1999
*/
template<int celldim, int dim, typename BaseClass>
-class DoFObjectAccessor;
-
+class DoFObjectAccessor : public DoFAccessor<dim>,
+ public BaseClass
+{};
+/**
+ * Closure class.
+ */
+template<int dim, typename BaseClass>
+class DoFObjectAccessor<0, dim, BaseClass> : public DoFAccessor<dim>,
+ public BaseClass
+{
+ public:
+ typedef void* AccessorData;
+ DoFObjectAccessor (Triangulation<dim> *,
+ const int,
+ const int,
+ const AccessorData *)
+ {}
+};
/**
-
-
-
-
-/**
- * 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 <int dim>
-class DoFSubstructAccessor : public DoFAccessor<dim>,
- public TriaAccessor<dim> {
- 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<dim>#. 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<dim>
- // 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<dim>
- // 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<dim>
- // 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
* @author Wolfgang Bangerth, 1998
*/
template <int dim>
-class DoFCellAccessor : public DoFSubstructAccessor<dim> {
+class DoFCellAccessor : public DoFObjectAccessor<dim, dim, CellAccessor<dim> > {
public:
+ /**
+ * Type of faces.
+ */
+ typedef
+ TriaIterator<dim, DoFObjectAccessor<dim-1, dim,TriaObjectAccessor<dim-1, dim> > >
+ face_iterator;
+
/**
* Declare the data type that this accessor
* class expects to get passed from the
* iterator classes.
*/
- typedef typename DoFSubstructAccessor<dim>::AccessorData AccessorData;
+ typedef typename DoFObjectAccessor<dim, dim, CellAccessor<dim> >::AccessorData AccessorData;
/**
* Constructor
const int level,
const int index,
const AccessorData *local_data) :
- DoFSubstructAccessor<dim> (tria,level,index,local_data) {};
+ DoFObjectAccessor<dim, dim, CellAccessor<dim> > (tria,level,index,local_data) {};
/**
* Return the #i#th neighbor as a DoF cell
* This function is not implemented in 1D,
* and maps to DoFObjectAccessor<2, dim>::line in 2D.
*/
- typename DoFSubstructAccessor<dim>::face_iterator
+ face_iterator
face (const unsigned int i) const;
/**
template <int celldim, int dim, typename BaseClass>
-class MGDoFObjectAccessor;
+class MGDoFObjectAccessor : public MGDoFAccessor<dim>,
+ public DoFObjectAccessor<celldim, dim, BaseClass>
+{};
+
+
+/**
+ * Closure class.
+ */
+template<int dim, typename BaseClass>
+class MGDoFObjectAccessor<0, dim, BaseClass>
+{
+ public:
+ typedef void* AccessorData;
+ MGDoFObjectAccessor (Triangulation<dim> *,
+ const int,
+ const int,
+ const AccessorData *)
+ {}
+};
+
/**
-
-
-/**
- * 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 <int dim>
-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<dim>#. 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<dim>
- // 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<dim>
- // 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<dim>
- // 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
* @author Wolfgang Bangerth, 1998
*/
template <int dim>
-class MGDoFCellAccessor : public MGDoFSubstructAccessor<dim> {
+class MGDoFCellAccessor : public MGDoFObjectAccessor<dim, dim, CellAccessor<dim> > {
public:
+ /**
+ * Type of faces.
+ */
+ typedef
+ TriaIterator<dim, MGDoFObjectAccessor<dim-1, dim,TriaObjectAccessor<dim-1, dim> > >
+ face_iterator;
/**
* Declare the data type that this accessor
* class expects to get passed from the
* iterator classes.
*/
- typedef typename MGDoFSubstructAccessor<dim>::AccessorData AccessorData;
+ typedef typename
+ MGDoFObjectAccessor<dim, dim, CellAccessor<dim> >::AccessorData
+ AccessorData;
/**
* Constructor
const int level,
const int index,
const AccessorData *local_data) :
- MGDoFSubstructAccessor<dim> (tria,level,index,local_data) {};
+ MGDoFObjectAccessor<dim, dim, CellAccessor<dim> > (tria,level,index,local_data) {};
/**
* Return the #i#th neighbor as a MGDoF cell
* This function is not implemented in 1D,
* and maps to MGDoFObjectAccessor<2, dim>::line in 2D.
*/
- typename MGDoFSubstructAccessor<dim>::face_iterator
+ face_iterator
face (const unsigned int i) const;
/**
* Pointer to the #i#th
* child.
*/
- TriaIterator<dim,TriaObjectAccessor<3, dim> > child (const unsigned int i) const;
+ TriaIterator<dim,TriaObjectAccessor<celldim, dim> >
+ child (const unsigned int i) const;
/**
* Index of the #i#th child.
template <int anydim, typename AnyAccessor> friend class TriaRawIterator;
};
-
+/**
+ * Closure class.
+ */
template<int dim>
class TriaObjectAccessor<0, dim> : public TriaAccessor<dim>
{};
-/*------------------------ Functions: TriaObjectAccessor ---------------------------*/
+/*------------------------ Functions: HexAccessor ---------------------------*/
+/*------------------------ Functions: TriaObjectAccessor ---------------------------*/
+
+
+
+template <int celldim, int dim>
+inline
+bool
+TriaObjectAccessor<celldim, dim>::used () const
+{
+ Assert (state() == valid, ExcDereferenceInvalidObject());
+ return tria->levels[present_level]->hexes.used[present_index];
+};
+
+
+
+template<int celldim, int dim>
+inline
+bool
+TriaObjectAccessor<celldim, dim>::user_flag_set () const
+{
+ Assert (used(), ExcCellNotUsed());
+ return tria->levels[present_level]->hexes.user_flags[present_index];
+};
+
+
+
+template<int celldim, int dim>
+inline
+void
+TriaObjectAccessor<celldim, dim>::set_user_flag () const
+{
+ Assert (used(), ExcCellNotUsed());
+ tria->levels[present_level]->hexes.user_flags[present_index] = true;
+};
+
+
+
+template<int celldim, int dim>
+inline
+void TriaObjectAccessor<celldim, dim>::clear_user_flag () const
+{
+ Assert (used(), ExcCellNotUsed());
+ tria->levels[present_level]->hexes.user_flags[present_index] = false;
+};
+
+
+
+
+template<int celldim, int dim>
+inline
+TriaIterator<dim,TriaObjectAccessor<1, dim> >
+TriaObjectAccessor<celldim, dim>::line (const unsigned int i) const
+{
+ Assert (used(), ExcCellNotUsed());
+ Assert (i < GeometryInfo<celldim>::lines_per_cell,
+ ExcIndexRange(i,0,GeometryInfo<celldim>::lines_per_cell));
+
+ switch(celldim)
+ {
+ case 2:
+ return
+ TriaIterator<dim,TriaObjectAccessor<1, dim> >
+ (
+ 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<dim,TriaObjectAccessor<1, dim> >(tria, -1, -1, 0);
+};
+
+
+
+template<int celldim, int dim>
+inline
+TriaIterator<dim,TriaObjectAccessor<2, dim> >
+TriaObjectAccessor<celldim, dim>::quad (const unsigned int i) const
+{
+ Assert (used(), ExcCellNotUsed());
+ Assert (i < GeometryInfo<celldim>::quads_per_cell,
+ ExcIndexRange(i,0,GeometryInfo<celldim>::quads_per_cell));
+ return
+ TriaIterator<dim,TriaObjectAccessor<2, dim> >
+ (
+ tria,
+ present_level,
+ quad_index (i)
+ );
+};
+
+
+
+template<int celldim, int dim>
+inline
+unsigned int
+TriaObjectAccessor<celldim, dim>::line_index (unsigned int i) const
+{
+ Assert (i < GeometryInfo<celldim>::lines_per_cell,
+ ExcIndexRange(i,0,GeometryInfo<celldim>::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<int celldim, int dim>
+inline
+unsigned int
+TriaObjectAccessor<celldim, dim>::quad_index (unsigned int i) const
+{
+ Assert (i < GeometryInfo<celldim>::quads_per_cell,
+ ExcIndexRange(i,0,GeometryInfo<celldim>::quads_per_cell));
+
+ return tria->levels[present_level]->hexes.hexes[present_index].quad(i);
+};
+
+
+
+template<int celldim, int dim>
+inline
+TriaIterator<dim,TriaObjectAccessor<celldim, dim> >
+TriaObjectAccessor<celldim, dim>::child (const unsigned int i) const
+{
+ Assert (i < GeometryInfo<celldim>::children_per_cell,
+ ExcIndexRange(i,0,GeometryInfo<celldim>::children_per_cell));
+
+ TriaIterator<dim,TriaObjectAccessor<celldim, dim> > q (tria, present_level+1, child_index (i));
+
+#ifdef DEBUG
+ if (q.state() != past_the_end)
+ Assert (q->used(), ExcUnusedCellAsChild());
+#endif
+ return q;
+};
+
+
+
+template<int celldim, int dim>
+inline
+int TriaObjectAccessor<celldim, dim>::child_index (unsigned int i) const
+{
+ Assert (i < GeometryInfo<celldim>::children_per_cell,
+ ExcIndexRange(i,0,GeometryInfo<celldim>::children_per_cell));
+ return tria->levels[present_level]->hexes.children[present_index]+i;
+};
+
+
+
+template<int celldim, int dim>
+bool TriaObjectAccessor<celldim, dim>::has_children () const
+{
+ Assert (state() == valid, ExcDereferenceInvalidObject());
+ return (tria->levels[present_level]->hexes.children[present_index] != -1);
+};
+
+
+
+template<int celldim, int dim>
+inline
+unsigned int
+TriaObjectAccessor<celldim, dim>::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<int celldim, int dim>
+inline
+void
+TriaObjectAccessor<celldim, dim>::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<int celldim, int dim>
+inline
+void
+TriaObjectAccessor<celldim, dim>::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<dim> -----------------------*/
template <int celldim, int dim, typename BaseClass>
-class MGDoFObjectAccessor;
+class MGDoFObjectAccessor : public MGDoFAccessor<dim>,
+ public DoFObjectAccessor<celldim, dim, BaseClass>
+{};
+
+
+/**
+ * Closure class.
+ */
+template<int dim, typename BaseClass>
+class MGDoFObjectAccessor<0, dim, BaseClass>
+{
+ public:
+ typedef void* AccessorData;
+ MGDoFObjectAccessor (Triangulation<dim> *,
+ const int,
+ const int,
+ const AccessorData *)
+ {}
+};
+
/**
-
-
-/**
- * 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 <int dim>
-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<dim>#. 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<dim>
- // 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<dim>
- // 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<dim>
- // 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
* @author Wolfgang Bangerth, 1998
*/
template <int dim>
-class MGDoFCellAccessor : public MGDoFSubstructAccessor<dim> {
+class MGDoFCellAccessor : public MGDoFObjectAccessor<dim, dim, CellAccessor<dim> > {
public:
+ /**
+ * Type of faces.
+ */
+ typedef
+ TriaIterator<dim, MGDoFObjectAccessor<dim-1, dim,TriaObjectAccessor<dim-1, dim> > >
+ face_iterator;
/**
* Declare the data type that this accessor
* class expects to get passed from the
* iterator classes.
*/
- typedef typename MGDoFSubstructAccessor<dim>::AccessorData AccessorData;
+ typedef typename
+ MGDoFObjectAccessor<dim, dim, CellAccessor<dim> >::AccessorData
+ AccessorData;
/**
* Constructor
const int level,
const int index,
const AccessorData *local_data) :
- MGDoFSubstructAccessor<dim> (tria,level,index,local_data) {};
+ MGDoFObjectAccessor<dim, dim, CellAccessor<dim> > (tria,level,index,local_data) {};
/**
* Return the #i#th neighbor as a MGDoF cell
* This function is not implemented in 1D,
* and maps to MGDoFObjectAccessor<2, dim>::line in 2D.
*/
- typename MGDoFSubstructAccessor<dim>::face_iterator
+ face_iterator
face (const unsigned int i) const;
/**
template <int dim, typename BaseClass>
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<dim>::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<dim>::ExcInvalidObject());
Assert (i<dof_handler->selected_fe->dofs_per_line,
ExcIndexRange (i, 0, dof_handler->selected_fe->dofs_per_line));
#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();
};
void
DoFCellAccessor<dim>::get_dof_values (const Vector<number> &values,
Vector<number> &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,
void
DoFCellAccessor<dim>::set_dof_values (const Vector<number> &local_values,
Vector<number> &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,
#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);
};
template <typename number>
void
DoFCellAccessor<dim>::get_dof_values (const Vector<number> &values,
- Vector<number> &local_values) const {
- Assert (dim==2, ::ExcInternalError());
+ Vector<number> &local_values) const
+{
+ Assert (dim==2, ExcInternalError());
- Assert (dof_handler != 0, ExcInvalidObject());
- Assert (&dof_handler->get_fe() != 0, ExcInvalidObject());
+ Assert (dof_handler != 0, DoFAccessor<dim>::ExcInvalidObject());
+ Assert (&dof_handler->get_fe() != 0, DoFAccessor<dim>::ExcInvalidObject());
Assert (local_values.size() == dof_handler->get_fe().total_dofs,
- ExcVectorDoesNotMatch());
+ DoFAccessor<dim>::ExcVectorDoesNotMatch());
Assert (values.size() == dof_handler->n_dofs(),
- ExcVectorDoesNotMatch());
+ DoFAccessor<dim>::ExcVectorDoesNotMatch());
Assert (active(), ExcNotActive());
const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex,
void
DoFCellAccessor<dim>::set_dof_values (const Vector<number> &local_values,
Vector<number> &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<dim>::ExcInvalidObject());
+ Assert (&dof_handler->get_fe() != 0, DoFAccessor<dim>::ExcInvalidObject());
Assert (local_values.size() == dof_handler->get_fe().total_dofs,
- ExcVectorDoesNotMatch());
+ DoFAccessor<dim>::ExcVectorDoesNotMatch());
Assert (values.size() == dof_handler->n_dofs(),
- ExcVectorDoesNotMatch());
+ DoFAccessor<dim>::ExcVectorDoesNotMatch());
Assert (active(), ExcNotActive());
const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex,
#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);
};
void
DoFCellAccessor<dim>::get_dof_values (const Vector<number> &values,
Vector<number> &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,
void
DoFCellAccessor<dim>::set_dof_values (const Vector<number> &local_values,
Vector<number> &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,
Vector<number> &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<dim>::ExcInvalidObject());
+ Assert (&dof_handler->get_fe() != 0, DoFAccessor<dim>::ExcInvalidObject());
Assert (interpolated_values.size() == total_dofs,
- ExcVectorDoesNotMatch());
+ DoFAccessor<dim>::ExcVectorDoesNotMatch());
Assert (values.size() == dof_handler->n_dofs(),
- ExcVectorDoesNotMatch());
+ DoFAccessor<dim>::ExcVectorDoesNotMatch());
if (!has_children())
// if this cell has no children: simply
Vector<number> &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<dim>::ExcInvalidObject());
+ Assert (&dof_handler->get_fe() != 0, DoFAccessor<dim>::ExcInvalidObject());
Assert (local_values.size() == total_dofs,
- ExcVectorDoesNotMatch());
+ DoFAccessor<dim>::ExcVectorDoesNotMatch());
Assert (values.size() == dof_handler->n_dofs(),
- ExcVectorDoesNotMatch());
+ DoFAccessor<dim>::ExcVectorDoesNotMatch());
if (!has_children())
// if this cell has no children: simply
-/* ------------------------ MGDoFObjectAccessor --------------------------- */
+/* ------------------------ MGDoFHexAccessor --------------------------- */
template <int dim, typename BaseClass>
MGDoFObjectAccessor<3, dim,BaseClass>::MGDoFObjectAccessor (Triangulation<dim> *tria,
#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();
};
#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);
};
-/* ------------------------ MGDoFObjectAccessor --------------------------- */
+/* ------------------------ MGDoFHexAccessor --------------------------- */
template <int dim, typename BaseClass>
MGDoFObjectAccessor<3, dim,BaseClass>::MGDoFObjectAccessor (Triangulation<dim> *tria,
#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();
};
#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);
};