From: wolf Date: Fri, 11 Apr 2003 21:24:12 +0000 (+0000) Subject: recursively_{set,clear}_user_pointer X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=508e6eaadc0a111fa969ab4fcfd1d5933c956807;p=dealii-svn.git recursively_{set,clear}_user_pointer git-svn-id: https://svn.dealii.org/trunk@7392 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index 7c6dfe6f50..ec11df6aa1 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -445,7 +445,7 @@ class TriaObjectAccessor : public TriaAccessor * to a @p{NULL} pointer. */ void clear_user_pointer () const; - + /** * Access the value of the user * pointer. It is in the @@ -460,6 +460,45 @@ class TriaObjectAccessor : public TriaAccessor */ void * user_pointer () const; + /** + * Set the user pointer of this + * object and all its children to + * the given value. This is + * useful for example if all + * cells of a certain subdomain, + * or all faces of a certain part + * of the boundary should have + * user pointers pointing to + * objects describing this part + * of the domain or boundary. + * + * Note that the user pointer is + * not inherited under mesh + * refinement, so after mesh + * refinement there might be + * cells or faces that don't have + * user pointers pointing to the + * describing object. In this + * case, simply loop over all the + * elements of the coarsest level + * that has this information, and + * use this function to + * recursively set the user + * pointer of all finer levels of + * the triangulation. + */ + void recursively_set_user_pointer (void *p) const; + + /** + * Clear the user pointer of this + * object and all of its + * descendants. The same holds as + * said for the + * @ref{recursively_set_user_pointer} + * function. + */ + void recursively_clear_user_pointer () const; + /** * Pointer to the @p{i}th * child. @@ -834,6 +873,45 @@ class TriaObjectAccessor<1, dim> : public TriaAccessor */ void set_user_pointer (void *p) const; + /** + * Set the user pointer of this + * object and all its children to + * the given value. This is + * useful for example if all + * cells of a certain subdomain, + * or all faces of a certain part + * of the boundary should have + * user pointers pointing to + * objects describing this part + * of the domain or boundary. + * + * Note that the user pointer is + * not inherited under mesh + * refinement, so after mesh + * refinement there might be + * cells or faces that don't have + * user pointers pointing to the + * describing object. In this + * case, simply loop over all the + * elements of the coarsest level + * that has this information, and + * use this function to + * recursively set the user + * pointer of all finer levels of + * the triangulation. + */ + void recursively_set_user_pointer (void *p) const; + + /** + * Clear the user pointer of this + * object and all of its + * descendants. The same holds as + * said for the + * @ref{recursively_set_user_pointer} + * function. + */ + void recursively_clear_user_pointer () const; + /** * Reset the user pointer of this * line to a @p{NULL} pointer. @@ -1253,6 +1331,45 @@ class TriaObjectAccessor<2, dim> : public TriaAccessor */ void * user_pointer () const; + /** + * Set the user pointer of this + * object and all its children to + * the given value. This is + * useful for example if all + * cells of a certain subdomain, + * or all faces of a certain part + * of the boundary should have + * user pointers pointing to + * objects describing this part + * of the domain or boundary. + * + * Note that the user pointer is + * not inherited under mesh + * refinement, so after mesh + * refinement there might be + * cells or faces that don't have + * user pointers pointing to the + * describing object. In this + * case, simply loop over all the + * elements of the coarsest level + * that has this information, and + * use this function to + * recursively set the user + * pointer of all finer levels of + * the triangulation. + */ + void recursively_set_user_pointer (void *p) const; + + /** + * Clear the user pointer of this + * object and all of its + * descendants. The same holds as + * said for the + * @ref{recursively_set_user_pointer} + * function. + */ + void recursively_clear_user_pointer () const; + /** * Return a pointer to the @p{i}th * child. @@ -1695,6 +1812,45 @@ class TriaObjectAccessor<3, dim> : public TriaAccessor */ void * user_pointer () const; + /** + * Set the user pointer of this + * object and all its children to + * the given value. This is + * useful for example if all + * cells of a certain subdomain, + * or all faces of a certain part + * of the boundary should have + * user pointers pointing to + * objects describing this part + * of the domain or boundary. + * + * Note that the user pointer is + * not inherited under mesh + * refinement, so after mesh + * refinement there might be + * cells or faces that don't have + * user pointers pointing to the + * describing object. In this + * case, simply loop over all the + * elements of the coarsest level + * that has this information, and + * use this function to + * recursively set the user + * pointer of all finer levels of + * the triangulation. + */ + void recursively_set_user_pointer (void *p) const; + + /** + * Clear the user pointer of this + * object and all of its + * descendants. The same holds as + * said for the + * @ref{recursively_set_user_pointer} + * function. + */ + void recursively_clear_user_pointer () const; + /** * Return a pointer to the * @p{i}th child. diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 455ac5b55f..f960002868 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -122,6 +122,32 @@ void * TriaObjectAccessor<1, dim>::user_pointer () const +template +void +TriaObjectAccessor<1, dim>::recursively_set_user_pointer (void *p) const +{ + set_user_pointer (p); + + if (has_children()) + for (unsigned int c=0; c<2; ++c) + child(c)->recursively_set_user_pointer (p); +} + + + +template +void +TriaObjectAccessor<1, dim>::recursively_clear_user_pointer () const +{ + clear_user_pointer (); + + if (has_children()) + for (unsigned int c=0; c<2; ++c) + child(c)->recursively_clear_user_pointer (); +} + + + template void TriaObjectAccessor<1, dim>::set_children (const int index) const { @@ -324,6 +350,32 @@ void * TriaObjectAccessor<2, dim>::user_pointer () const +template +void +TriaObjectAccessor<2, dim>::recursively_set_user_pointer (void *p) const +{ + set_user_pointer (p); + + if (has_children()) + for (unsigned int c=0; c<4; ++c) + child(c)->recursively_set_user_pointer (p); +} + + + +template +void +TriaObjectAccessor<2, dim>::recursively_clear_user_pointer () const +{ + clear_user_pointer (); + + if (has_children()) + for (unsigned int c=0; c<4; ++c) + child(c)->recursively_clear_user_pointer (); +} + + + template void TriaObjectAccessor<2, dim>::set_children (const int index) const { @@ -719,6 +771,32 @@ void * TriaObjectAccessor<3, dim>::user_pointer () const +template +void +TriaObjectAccessor<3, dim>::recursively_set_user_pointer (void *p) const +{ + set_user_pointer (p); + + if (has_children()) + for (unsigned int c=0; c<8; ++c) + child(c)->recursively_set_user_pointer (p); +} + + + +template +void +TriaObjectAccessor<3, dim>::recursively_clear_user_pointer () const +{ + clear_user_pointer (); + + if (has_children()) + for (unsigned int c=0; c<8; ++c) + child(c)->recursively_clear_user_pointer (); +} + + + template void TriaObjectAccessor<3, dim>::set_children (const int index) const { diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index 3c53bdc8b0..e93362d6c8 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -747,10 +747,21 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

deal.II

    +
  1. + New: There are now functions recursively_set/clear_user_pointer that + do much the same as recursively_set/clear_user_flag on a + line/quad/hex and all of its descendants, but on user pointers + rather than flags. +
    + (WB 2003/04/11) +

    +
  2. New: The functions in the DerivativeApproximation class can now also - work on BlockVectors/ + work on BlockVector.
    (WB 2003/04/11)