From 31a1747cc089b3bfbcff7ad840275b37553c1be7 Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 18 May 1999 11:11:53 +0000 Subject: [PATCH] Rename a function and implement Triangulation::delete_cell for 1d. git-svn-id: https://svn.dealii.org/trunk@1336 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/tria.h | 5 +- deal.II/deal.II/source/grid/tria.cc | 101 ++++++++++++++++++++++++++-- 2 files changed, 100 insertions(+), 6 deletions(-) diff --git a/deal.II/deal.II/include/grid/tria.h b/deal.II/deal.II/include/grid/tria.h index 6564de3658..ed666954a3 100644 --- a/deal.II/deal.II/include/grid/tria.h +++ b/deal.II/deal.II/include/grid/tria.h @@ -2928,12 +2928,13 @@ class Triangulation : public TriaDimensionInfo, public Subscriptor { istream &in); /** - * Actually delete a cell, which is the + * Actually delete a cell, or rather all + * it children, which is the * main step for the coarsening process. * This is the dimension dependent part * of #execute_coarsening#. */ - void delete_cell (cell_iterator &cell); + void delete_children (cell_iterator &cell); /** * Some dimension dependent stuff for diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 67f7e0c640..5a0acc6364 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -3695,7 +3695,7 @@ void Triangulation::execute_coarsening_and_refinement () { template <> void Triangulation<1>::execute_refinement () { - const unsigned int dim = 2; + const unsigned int dim = 1; // check whether a new level is needed // we have to check for this on the @@ -5815,7 +5815,7 @@ void Triangulation::execute_coarsening () { if (cell->user_flag_set()) // use a separate function, since this // is dimension specific - delete_cell (cell); + delete_children (cell); // in principle no user flags should be // set any more at this point #if DEBUG @@ -6501,11 +6501,104 @@ bool Triangulation::prepare_coarsening_and_refinement () { +#if deal_II_dimension == 1 + +template <> +void Triangulation<1>::delete_children (cell_iterator &cell) { + const unsigned int dim=1; + // first we need to reset the + // neighbor pointers of the neighbors + // of this cell's children to this + // cell. This is different for one + // dimension, since there neighbors + // can have a refinement level + // differing from that of this cell's + // children by more than one level. + + Assert (!cell->child(0)->has_children() && !cell->child(1)->has_children(), + ExcInternalError()); + + // first do it for the cells to the + // left + if (cell->neighbor(0)->has_children()) + { + cell_iterator neighbor = cell->neighbor(0); + Assert (neighbor->level() == cell->level(), ExcInternalError()); + + // right child + neighbor = neighbor->child(1); + while (1) + { + Assert (neighbor->neighbor(1) == cell->child(0), + ExcInternalError()); + neighbor->set_neighbor (1, cell); + + // move on to further children + // on the boundary between this + // cell and its neighbor + if (neighbor->has_children()) + neighbor = neighbor->child(1); + else + break; + }; + }; + + // now do it for the cells to the + // left + if (cell->neighbor(1)->has_children()) + { + cell_iterator neighbor = cell->neighbor(1); + Assert (neighbor->level() == cell->level(), ExcInternalError()); + + // left child + neighbor = neighbor->child(0); + while (1) + { + Assert (neighbor->neighbor(0) == cell->child(1), + ExcInternalError()); + neighbor->set_neighbor (0, cell); + + // move on to further children + // on the boundary between this + // cell and its neighbor + if (neighbor->has_children()) + neighbor = neighbor->child(0); + else + break; + }; + }; + + + // delete the vertex which will not be + // needed anymore. This vertex is the + // second of the second line of the + // first child + vertices_used[cell->child(0)->vertex_index(1)] = false; + + // invalidate children. + // clear user pointers, to avoid that + // they may appear at unwanted places + // later on... + for (unsigned int child=0; child::children_per_cell; ++child) + { + cell->child(child)->clear_user_pointer(); + cell->child(child)->clear_user_flag(); + cell->child(child)->clear_used_flag(); + }; + + + // delete pointer to children + cell->set_children (-1); + cell->clear_user_flag(); +}; + +#endif + #if deal_II_dimension == 2 template <> -void Triangulation<2>::delete_cell (cell_iterator &cell) { +void Triangulation<2>::delete_children (cell_iterator &cell) { const unsigned int dim=2; // first we need to reset the // neighbor pointers of the neighbors @@ -6636,7 +6729,7 @@ void Triangulation<2>::delete_cell (cell_iterator &cell) { template <> -void Triangulation<3>::delete_cell (cell_iterator &cell) { +void Triangulation<3>::delete_children (cell_iterator &cell) { const unsigned int dim=3; // first we need to reset the // neighbor pointers of the neighbors -- 2.39.5