From: leicht Date: Wed, 13 Dec 2006 13:33:14 +0000 (+0000) Subject: do something in invert_all_cells_of_negative_grid() also in 2d X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90c4c4fb7891085ddfa2a2908c3838027aeb6643;p=dealii-svn.git do something in invert_all_cells_of_negative_grid() also in 2d git-svn-id: https://svn.dealii.org/trunk@14234 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/grid/grid_reordering.cc b/deal.II/deal.II/source/grid/grid_reordering.cc index 88a39a654c..c0620f368c 100644 --- a/deal.II/deal.II/source/grid/grid_reordering.cc +++ b/deal.II/deal.II/source/grid/grid_reordering.cc @@ -588,13 +588,46 @@ GridReordering<2>::reorder_cells (std::vector > &original_cells) template<> void -GridReordering<2>::invert_all_cells_of_negative_grid(const std::vector > &, - std::vector > &) +GridReordering<2>::invert_all_cells_of_negative_grid(const std::vector > &all_vertices, + std::vector > &cells) { - // nothing to be done in 2d + unsigned int vertices_lex[GeometryInfo<2>::vertices_per_cell]; + unsigned int n_negative_cells=0; + for (unsigned int cell_no=0; cell_no::vertices_per_cell; ++i) + vertices_lex[GeometryInfo<2>::ucd_to_deal[i]]=cells[cell_no].vertices[i]; + if (GridTools::cell_measure<2>(all_vertices, vertices_lex) < 0) + { + ++n_negative_cells; + std::swap(cells[cell_no].vertices[1], cells[cell_no].vertices[3]); + + // check whether the + // resulting cell is now ok. + // if not, then the grid is + // seriously broken and + // should be sticked into the + // bin + for (unsigned int i=0; i::vertices_per_cell; ++i) + vertices_lex[GeometryInfo<2>::ucd_to_deal[i]]=cells[cell_no].vertices[i]; + AssertThrow(GridTools::cell_measure<2>(all_vertices, vertices_lex) > 0, + ExcInternalError()); + } + } + + // We assume that all cells of a grid have + // either positive or negative volumes but + // not both mixed. Although above reordering + // might work also on single cells, grids + // with both kind of cells are very likely to + // be broken. Check for this here. + AssertThrow(n_negative_cells==0 || n_negative_cells==cells.size(), ExcInternalError()); } -#endif +#endif // deal_II_dimension == 2 @@ -1465,6 +1498,7 @@ GridReordering<3>::invert_all_cells_of_negative_grid( if (GridTools::cell_measure<3>(all_vertices, vertices_lex) < 0) { ++n_negative_cells; + // reorder vertices: swap front and back face for (unsigned int i=0; i<4; ++i) std::swap(cells[cell_no].vertices[i], cells[cell_no].vertices[i+4]); @@ -1481,7 +1515,7 @@ GridReordering<3>::invert_all_cells_of_negative_grid( } } - // We assuming that all cells of a + // We assume that all cells of a // grid have either positive or // negative volumes but not both // mixed. Although above reordering diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index e564a39fd6..19cc56e4c1 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -928,6 +928,14 @@ inconvenience this causes.
    +
  1. Extended: So far, the + GridReordering::invert_all_cells_of_negative_grid function + did nothing in 2d. Now, it inverts cells from clockwise to + counterclockwise sense (in the old numbering scheme). +
    + (Tobias Leicht 2006/12/13) +

    +
  2. New: There is now a function GridTools::delete_duplicated_vertices that deletes duplicate vertices which can occur if structured grids are read into deal, leading