From 788c9cbdb4a97cec236aeea29198e8c32b87cd97 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 14 Dec 2001 16:40:08 +0000 Subject: [PATCH] Allow renumbering of unconnected domains (patch by Michael Stadler). git-svn-id: https://svn.dealii.org/trunk@5338 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/source/grid/grid_reordering.cc | 166 ++++++++++-------- deal.II/doc/news/2001/c-3-2.html | 8 + 2 files changed, 103 insertions(+), 71 deletions(-) diff --git a/deal.II/deal.II/source/grid/grid_reordering.cc b/deal.II/deal.II/source/grid/grid_reordering.cc index eaed1be8a4..733ad37b3d 100644 --- a/deal.II/deal.II/source/grid/grid_reordering.cc +++ b/deal.II/deal.II/source/grid/grid_reordering.cc @@ -1091,15 +1091,7 @@ GridReordering::presort_cells (typename std::vector &cells, // least neighbors unsigned int min_neighbors = cells[0].count_neighbors(); unsigned int cell_with_min_neighbors = 0; - for (unsigned int i=1; i cells[i].count_neighbors()) - { - min_neighbors = cells[i].count_neighbors(); - cell_with_min_neighbors = i; - if (min_neighbors == 1) - // better is not possible - break; - }; + // have an array into which we // insert the new cells numbers of @@ -1107,69 +1099,102 @@ GridReordering::presort_cells (typename std::vector &cells, const unsigned int invalid_cell_number = static_cast(-1); std::vector new_cell_numbers (cells.size(), invalid_cell_number); - // and have an array of the next - // cells to be numbered (old numbers) - std::vector next_round_cells (1, cell_with_min_neighbors); - unsigned int next_free_new_number = 0; - // while there are still cells to - // be renumbered: - while (next_round_cells.size() != 0) - { - for (unsigned int i=0; i cells[i].count_neighbors()) && + (new_cell_numbers[i]==invalid_cell_number)) + { + min_neighbors = cells[i].count_neighbors(); + cell_with_min_neighbors = i; + if (min_neighbors == 1) + // better is not possible + break; + }; + // have an array of the next + // cells to be numbered (old numbers) + std::vector next_round_cells (1, cell_with_min_neighbors); + + // while there are still cells to + // be renumbered: + while (next_round_cells.size() != 0) + { + for (unsigned int i=0; i new_next_round_cells; + for (unsigned int i=0; i::faces_per_cell; ++n) + if (cells[next_round_cells[i]].neighbors[n] != Cell::invalid_neighbor) + if (new_cell_numbers[cells[next_round_cells[i]].neighbors[n]] + == invalid_cell_number) + new_next_round_cells.push_back (cells[next_round_cells[i]].neighbors[n]); + + + // eliminate duplicates from + // the new_next_round_cells + // array. note that a cell + // which is entered into this + // array might have been + // entered more than once since + // it might be a neighbor of + // more than one cell of the + // present round + // + // in order to eliminate + // duplicates, we first sort + // tha array and then copy over + // only unique elements to the + // next_round_cells array, + // which is needed for the next + // loop iteration anyway + std::sort (new_next_round_cells.begin(), new_next_round_cells.end()); + next_round_cells.clear (); + unique_copy (new_next_round_cells.begin(), new_next_round_cells.end(), + back_inserter(next_round_cells)); + }; + }; // end of loop over subdomains + - // for the next round, find all - // neighbors of the cells of - // this round which have not - // yet been renumbered - std::vector new_next_round_cells; - for (unsigned int i=0; i::faces_per_cell; ++n) - if (cells[next_round_cells[i]].neighbors[n] != Cell::invalid_neighbor) - if (new_cell_numbers[cells[next_round_cells[i]].neighbors[n]] - == invalid_cell_number) - new_next_round_cells.push_back (cells[next_round_cells[i]].neighbors[n]); - - - - // if no more cells have been - // found, then we must have - // renumbered all cells already - if (new_next_round_cells.size() == 0) - Assert (next_free_new_number == cells.size(), ExcInternalError()); - - // eliminate duplicates from - // the new_next_round_cells - // array. note that a cell - // which is entered into this - // array might have been - // entered more than once since - // it might be a neighbor of - // more than one cell of the - // present round - // - // in order to eliminate - // duplicates, we first sort - // tha array and then copy over - // only unique elements to the - // next_round_cells array, - // which is needed for the next - // loop iteration anyway - std::sort (new_next_round_cells.begin(), new_next_round_cells.end()); - next_round_cells.clear (); - unique_copy (new_next_round_cells.begin(), new_next_round_cells.end(), - back_inserter(next_round_cells)); - }; - Assert (std::find (new_cell_numbers.begin(), new_cell_numbers.end(), - invalid_cell_number) + + Assert (std::find (new_cell_numbers.begin(), new_cell_numbers.end(), invalid_cell_number) == new_cell_numbers.end(), ExcInternalError()); @@ -1191,8 +1216,7 @@ GridReordering::presort_cells (typename std::vector &cells, Assert (cells[c].cell_no == c, ExcInternalError()); for (unsigned int n=0; n::faces_per_cell; ++n) - if (cells[c].neighbors[n] != invalid_cell_number) - cells[c].neighbors[n] = new_cell_numbers[cells[c].neighbors[n]]; + cells[c].neighbors[n] = new_cell_numbers[cells[c].neighbors[n]]; }; for (typename std::map::iterator i=faces.begin(); i!=faces.end(); ++i) diff --git a/deal.II/doc/news/2001/c-3-2.html b/deal.II/doc/news/2001/c-3-2.html index 48411257c2..5670dcf24a 100644 --- a/deal.II/doc/news/2001/c-3-2.html +++ b/deal.II/doc/news/2001/c-3-2.html @@ -250,6 +250,14 @@ documentation, etc.

deal.II

    +
  1. + Improved: It is now possible to read in unconnected domains + through the GridIn class, since + renumbering the cells now also works for these domains. +
    + (Michael Stadler 2001/12/14) +

    +
  2. Improved: Both functions VectorTools::