From 61bf4ebe9455113600252e9b9bb143b8294b3d04 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 4 Sep 2003 19:39:53 +0000 Subject: [PATCH] recursively_set_material_id git-svn-id: https://svn.dealii.org/trunk@7956 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/tria_accessor.h | 11 +++++ deal.II/deal.II/source/grid/tria_accessor.cc | 42 ++++++++++++++++++-- deal.II/doc/news/c-4-0.html | 8 ++++ 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index 028897130a..908f9632d4 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -2336,6 +2336,14 @@ class CellAccessor : public TriaObjectAccessor */ void set_material_id (const unsigned char new_material_id) const; + /** + * Set the material id of this + * cell and all its children (and + * grand-children, and so on) to + * the given value. + */ + void recursively_set_material_id (const unsigned char new_material_id) const; + /** * Return the subdomain id of * this cell. @@ -2423,14 +2431,17 @@ template <> Point<3> TriaObjectAccessor<3, 3>::barycenter () const; template <> bool CellAccessor<1>::at_boundary () const; template <> unsigned char CellAccessor<1>::material_id () const; template <> void CellAccessor<1>::set_material_id (const unsigned char mat_id) const; +template <> void CellAccessor<1>::recursively_set_material_id (const unsigned char mat_id) const; template <> bool CellAccessor<1>::point_inside (const Point<1> &p) const; template <> bool CellAccessor<2>::at_boundary () const; template <> unsigned char CellAccessor<2>::material_id () const; template <> void CellAccessor<2>::set_material_id (const unsigned char mat_id) const; +template <> void CellAccessor<2>::recursively_set_material_id (const unsigned char mat_id) const; template <> bool CellAccessor<2>::point_inside (const Point<2> &p) const; template <> bool CellAccessor<3>::at_boundary () const; template <> unsigned char CellAccessor<3>::material_id () const; template <> void CellAccessor<3>::set_material_id (const unsigned char mat_id) const; +template <> void CellAccessor<3>::recursively_set_material_id (const unsigned char mat_id) const; template <> bool CellAccessor<3>::point_inside (const Point<3> &) const; template <> bool CellAccessor<1>::has_boundary_lines () const; diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index c8762ebdc7..84b110f2ab 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -1657,6 +1657,19 @@ void CellAccessor<1>::set_material_id (const unsigned char mat_id) const } + +template <> +void CellAccessor<1>::recursively_set_material_id (const unsigned char mat_id) const +{ + set_material_id (mat_id); + + if (has_children()) + for (unsigned int c=0; c<2; ++c) + child(c)->recursively_set_material_id (mat_id); +} + + + template <> bool CellAccessor<1>::point_inside (const Point<1> &p) const { @@ -1664,6 +1677,7 @@ bool CellAccessor<1>::point_inside (const Point<1> &p) const } + template <> std::pair CellAccessor<1>::neighbor_of_coarser_neighbor (const unsigned int) const @@ -1709,6 +1723,18 @@ void CellAccessor<2>::set_material_id (const unsigned char mat_id) const +template <> +void CellAccessor<2>::recursively_set_material_id (const unsigned char mat_id) const +{ + set_material_id (mat_id); + + if (has_children()) + for (unsigned int c=0; c<4; ++c) + child(c)->recursively_set_material_id (mat_id); +} + + + template <> bool CellAccessor<2>::point_inside (const Point<2> &p) const { @@ -1782,8 +1808,6 @@ unsigned char CellAccessor<3>::material_id () const return this->tria->levels[this->present_level]->hexes.material_id[this->present_index]; } - - template <> void CellAccessor<3>::set_material_id (const unsigned char mat_id) const { @@ -1794,7 +1818,19 @@ void CellAccessor<3>::set_material_id (const unsigned char mat_id) const template <> -bool CellAccessor<3>::point_inside (const Point<3> &) const +void CellAccessor<3>::recursively_set_material_id (const unsigned char mat_id) const +{ + set_material_id (mat_id); + + if (has_children()) + for (unsigned int c=0; c<8; ++c) + child(c)->recursively_set_material_id (mat_id); +} + + + +template <> +bool CellAccessor<3>::point_inside (const Point<3> &p) const { Assert (false, ExcNotImplemented() ); return false; diff --git a/deal.II/doc/news/c-4-0.html b/deal.II/doc/news/c-4-0.html index 3cdb402966..7037cf8cff 100644 --- a/deal.II/doc/news/c-4-0.html +++ b/deal.II/doc/news/c-4-0.html @@ -150,6 +150,14 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

deal.II

    +
  1. New: The TriaAccessor::recursively_set_material_id function sets + the material id of the present cell and of all its children, + grandchildren, etc to the given value. +
    + (WB 2002/09/04) +

    +
  2. New: The new FETools::get_fe_from_name function can do the reverse of the FiniteElement::