From: Ralf Hartmann Date: Wed, 28 Sep 2005 11:18:30 +0000 (+0000) Subject: Move delete_unused_vertices function from GridIn (private) to GridTools (public). X-Git-Tag: v8.0.0~13068 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77c95f6c3bb6b1fea4cefb788868a5d8129aafc2;p=dealii.git Move delete_unused_vertices function from GridIn (private) to GridTools (public). git-svn-id: https://svn.dealii.org/trunk@11535 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/grid_in.h b/deal.II/deal.II/include/grid/grid_in.h index 036c127dbe..ca5da2b4cc 100644 --- a/deal.II/deal.II/include/grid/grid_in.h +++ b/deal.II/deal.II/include/grid/grid_in.h @@ -358,37 +358,6 @@ class GridIn static void skip_comment_lines (std::istream &in, const char comment_start); - /** - * Remove vertices that are not - * referenced by any of the - * cells. This function is called - * by all read_* functions to - * eliminate vertices that are - * listed in the input files but - * are not used by the cells in - * the input file. While these - * vertices should not be in the - * input from the beginning, they - * sometimes are, most often when - * some cells have been removed - * by hand without wanting to - * update the vertex lists, as - * they might be lengthy. - * - * This function is called by all - * read_* functions as the - * triangulation class requires - * them to be called with used - * vertices only. This is so, - * since the vertices are copied - * verbatim by that class, so we - * have to eliminate unused - * vertices beforehand. - */ - static void delete_unused_vertices (std::vector > &vertices, - std::vector > &cells, - SubCellData &subcelldata); - /** * This function can write the * raw cell data objects created diff --git a/deal.II/deal.II/include/grid/grid_tools.h b/deal.II/deal.II/include/grid/grid_tools.h index 2155e25ac0..e4af48ae8a 100644 --- a/deal.II/deal.II/include/grid/grid_tools.h +++ b/deal.II/deal.II/include/grid/grid_tools.h @@ -29,7 +29,7 @@ * individual functions for more information. * * @ingroup grid - * @author Wolfgang Bangerth, 2001, 2003, 2004 + * @author Wolfgang Bangerth, 2001, 2003, 2004, Ralf Hartmann, 2005 */ class GridTools { @@ -68,6 +68,41 @@ class GridTools double cell_measure(const std::vector > &all_vertices, const int vertex_indices[GeometryInfo::vertices_per_cell]); + /** + * Remove vertices that are not + * referenced by any of the + * cells. This function is called + * by all GridIn::read_* + * functions to eliminate + * vertices that are listed in + * the input files but are not + * used by the cells in the input + * file. While these vertices + * should not be in the input + * from the beginning, they + * sometimes are, most often when + * some cells have been removed + * by hand without wanting to + * update the vertex lists, as + * they might be lengthy. + * + * This function is called by all + * GridIn::read_* + * functions as the triangulation + * class requires them to be + * called with used vertices + * only. This is so, since the + * vertices are copied verbatim + * by that class, so we have to + * eliminate unused vertices + * beforehand. + */ + template + static + void delete_unused_vertices (std::vector > &vertices, + std::vector > &cells, + SubCellData &subcelldata); + /** * Transform the vertices of the * given triangulation by diff --git a/deal.II/deal.II/source/grid/grid_in.cc b/deal.II/deal.II/source/grid/grid_in.cc index 7fe4bfd0cf..1c0a776c9b 100644 --- a/deal.II/deal.II/source/grid/grid_in.cc +++ b/deal.II/deal.II/source/grid/grid_in.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -196,7 +197,7 @@ void GridIn::read_ucd (std::istream &in) AssertThrow (in, ExcIO()); // do some clean-up on vertices... - delete_unused_vertices (vertices, cells, subcelldata); + GridTools::delete_unused_vertices (vertices, cells, subcelldata); // ... and cells GridReordering::invert_all_cells_of_negative_grid (vertices, cells); GridReordering::reorder_cells (cells); @@ -361,7 +362,7 @@ void GridIn::read_dbmesh (std::istream &in) AssertThrow (in, ExcIO()); // do some clean-up on vertices... - delete_unused_vertices (vertices, cells, subcelldata); + GridTools::delete_unused_vertices (vertices, cells, subcelldata); // ...and cells GridReordering::invert_all_cells_of_negative_grid (vertices, cells); GridReordering::reorder_cells (cells); @@ -443,7 +444,7 @@ void GridIn<2>::read_xda (std::istream &in) AssertThrow (in, ExcIO()); // do some clean-up on vertices... - delete_unused_vertices (vertices, cells, subcelldata); + GridTools::delete_unused_vertices (vertices, cells, subcelldata); // ... and cells GridReordering<2>::invert_all_cells_of_negative_grid (vertices, cells); GridReordering<2>::reorder_cells (cells); @@ -526,7 +527,7 @@ void GridIn<3>::read_xda (std::istream &in) AssertThrow (in, ExcIO()); // do some clean-up on vertices... - delete_unused_vertices (vertices, cells, subcelldata); + GridTools::delete_unused_vertices (vertices, cells, subcelldata); // ... and cells GridReordering<3>::invert_all_cells_of_negative_grid (vertices, cells); GridReordering<3>::reorder_cells (cells); @@ -730,7 +731,7 @@ void GridIn::read_msh (std::istream &in) AssertThrow (in, ExcIO()); // do some clean-up on vertices... - delete_unused_vertices (vertices, cells, subcelldata); + GridTools::delete_unused_vertices (vertices, cells, subcelldata); // ... and cells GridReordering::invert_all_cells_of_negative_grid (vertices, cells); GridReordering::reorder_cells (cells); @@ -999,7 +1000,7 @@ void GridIn<2>::read_netcdf (const std::string &filename) } SubCellData subcelldata; - delete_unused_vertices(vertices, cells, subcelldata); + GridTools::delete_unused_vertices(vertices, cells, subcelldata); GridReordering::reorder_cells (cells); tria->create_triangulation (vertices, cells, subcelldata); #endif @@ -1121,7 +1122,7 @@ void GridIn<3>::read_netcdf (const std::string &filename) cells[cell].vertices[i]=vertex_indices[cell*vertices_per_hex+i]; SubCellData subcelldata; - delete_unused_vertices(vertices, cells, subcelldata); + GridTools::delete_unused_vertices(vertices, cells, subcelldata); GridReordering::reorder_cells (cells); tria->create_triangulation (vertices, cells, subcelldata); #endif @@ -1178,62 +1179,6 @@ void GridIn::skip_comment_lines (std::istream &in, -template -void -GridIn::delete_unused_vertices (std::vector > &vertices, - std::vector > &cells, - SubCellData &subcelldata) -{ - // first check which vertices are - // actually used - std::vector vertex_used (vertices.size(), false); - for (unsigned int c=0; c::vertices_per_cell; ++v) - vertex_used[cells[c].vertices[v]] = true; - - // then renumber the vertices that - // are actually used in the same - // order as they were beforehand - const unsigned int invalid_vertex = deal_II_numbers::invalid_unsigned_int; - std::vector new_vertex_numbers (vertices.size(), invalid_vertex); - unsigned int next_free_number = 0; - for (unsigned int i=0; i::vertices_per_cell; ++v) - cells[c].vertices[v] = new_vertex_numbers[cells[c].vertices[v]]; - - // same for boundary data - for (unsigned int c=0; c::vertices_per_cell; ++v) - subcelldata.boundary_lines[c].vertices[v] - = new_vertex_numbers[subcelldata.boundary_lines[c].vertices[v]]; - for (unsigned int c=0; c::vertices_per_cell; ++v) - subcelldata.boundary_quads[c].vertices[v] - = new_vertex_numbers[subcelldata.boundary_quads[c].vertices[v]]; - - // finally copy over the vertices - // which we really need to a new - // array and replace the old one by - // the new one - std::vector > tmp; - tmp.reserve (std::count(vertex_used.begin(), vertex_used.end(), true)); - for (unsigned int v=0; v void GridIn::debug_output_grid (const std::vector > &/*cells*/, const std::vector > &/*vertices*/, diff --git a/deal.II/deal.II/source/grid/grid_tools.cc b/deal.II/deal.II/source/grid/grid_tools.cc index f3813c1689..d9350c3d75 100644 --- a/deal.II/deal.II/source/grid/grid_tools.cc +++ b/deal.II/deal.II/source/grid/grid_tools.cc @@ -205,6 +205,61 @@ GridTools::cell_measure(const std::vector > &all_vertices, #endif +template +void +GridTools::delete_unused_vertices (std::vector > &vertices, + std::vector > &cells, + SubCellData &subcelldata) +{ + // first check which vertices are + // actually used + std::vector vertex_used (vertices.size(), false); + for (unsigned int c=0; c::vertices_per_cell; ++v) + vertex_used[cells[c].vertices[v]] = true; + + // then renumber the vertices that + // are actually used in the same + // order as they were beforehand + const unsigned int invalid_vertex = deal_II_numbers::invalid_unsigned_int; + std::vector new_vertex_numbers (vertices.size(), invalid_vertex); + unsigned int next_free_number = 0; + for (unsigned int i=0; i::vertices_per_cell; ++v) + cells[c].vertices[v] = new_vertex_numbers[cells[c].vertices[v]]; + + // same for boundary data + for (unsigned int c=0; c::vertices_per_cell; ++v) + subcelldata.boundary_lines[c].vertices[v] + = new_vertex_numbers[subcelldata.boundary_lines[c].vertices[v]]; + for (unsigned int c=0; c::vertices_per_cell; ++v) + subcelldata.boundary_quads[c].vertices[v] + = new_vertex_numbers[subcelldata.boundary_quads[c].vertices[v]]; + + // finally copy over the vertices + // which we really need to a new + // array and replace the old one by + // the new one + std::vector > tmp; + tmp.reserve (std::count(vertex_used.begin(), vertex_used.end(), true)); + for (unsigned int v=0; v (const Triangulation &); #endif +template +void GridTools::delete_unused_vertices (std::vector > &, + std::vector > &, + SubCellData &); + template void GridTools::shift (const Point &, Triangulation &); diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index 99b9641cf7..eb549340f0 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -116,6 +116,16 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

deal.II

    +
  1. + New: There is now a new GridTools::delete_unused_vertices + function. Previously a private function in GridIn it has now been moved to and made + public in GridTools. +
    + (RH 2005/09/28) +

    +
  2. New: The GridIn<dim>::read_netcdf(string