From: Wolfgang Bangerth Date: Tue, 18 Oct 2016 23:18:07 +0000 (-0600) Subject: Unify some functions. X-Git-Tag: v8.5.0-rc1~536^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13ffc543d7a3a85981210fb9d0255de1ffd7fe5e;p=dealii.git Unify some functions. Currently, the top-level functions GridReordering::reorder_cells() are duplicated for the different (space) dimensions. Unify them all into one. --- diff --git a/include/deal.II/grid/grid_reordering.h b/include/deal.II/grid/grid_reordering.h index a5b49fa98f..d730a22b67 100644 --- a/include/deal.II/grid/grid_reordering.h +++ b/include/deal.II/grid/grid_reordering.h @@ -664,21 +664,6 @@ public: // declaration of explicit specializations -template<> -void -GridReordering<2>::reorder_cells (std::vector > &original_cells, - const bool); - -template<> -void -GridReordering<2,3>::reorder_cells (std::vector > &original_cells, - const bool); - -template<> -void -GridReordering<3>::reorder_cells (std::vector > &original_cells, - const bool); - template<> void GridReordering<2>::invert_all_cells_of_negative_grid(const std::vector > &all_vertices, diff --git a/source/grid/grid_reordering.cc b/source/grid/grid_reordering.cc index 254f7e8a3a..e64ccd956e 100644 --- a/source/grid/grid_reordering.cc +++ b/source/grid/grid_reordering.cc @@ -987,20 +987,17 @@ namespace internal rotate_cell (cell_list, edge_list, c, cells); } - } -} + // overload of the function above for 1d -- there is nothing + // to orient in that case + void reorient (std::vector > &) + {} -template<> -void -GridReordering<1>::reorder_cells (std::vector > &, - const bool) -{ - // there should not be much to do - // in 1d... + } } + template<> void GridReordering<1>::invert_all_cells_of_negative_grid(const std::vector > &, @@ -1009,14 +1006,6 @@ GridReordering<1>::invert_all_cells_of_negative_grid(const std::vector // nothing to be done in 1d } -template<> -void -GridReordering<1,2>::reorder_cells (std::vector > &, - const bool) -{ - // there should not be much to do - // in 1d... -} template<> @@ -1028,15 +1017,6 @@ GridReordering<1,2>::invert_all_cells_of_negative_grid(const std::vector -void -GridReordering<1,3>::reorder_cells (std::vector > &, - const bool) -{ - // there should not be much to do - // in 1d... -} - template<> void @@ -1059,6 +1039,11 @@ namespace * do the reordering of their * arguments in-place. */ + void + reorder_new_to_old_style (std::vector > &) + {} + + void reorder_new_to_old_style (std::vector > &cells) { @@ -1084,6 +1069,11 @@ namespace /** * And now also in the opposite direction. */ + void + reorder_old_to_new_style (std::vector > &) + {} + + void reorder_old_to_new_style (std::vector > &cells) { @@ -1108,52 +1098,6 @@ namespace } -template<> -void -GridReordering<2>::reorder_cells (std::vector > &cells, - const bool use_new_style_ordering) -{ - // if necessary, convert to old (compatibility) to new-style format - if (!use_new_style_ordering) - reorder_old_to_new_style(cells); - - // check if grids are already - // consistent. if so, do - // nothing. if not, then do the - // reordering - if (!internal::GridReordering2d::is_consistent (cells)) - internal::GridReordering2d::reorient(cells); - - - // and convert back if necessary - if (!use_new_style_ordering) - reorder_new_to_old_style(cells); -} - - -template<> -void -GridReordering<2,3>::reorder_cells (std::vector > &cells, - const bool use_new_style_ordering) -{ - // if necessary, convert to old (compatibility) to new-style format - if (!use_new_style_ordering) - reorder_old_to_new_style(cells); - - // check if grids are already - // consistent. if so, do - // nothing. if not, then do the - // reordering - if (!internal::GridReordering2d::is_consistent (cells)) - internal::GridReordering2d::reorient(cells); - - - // and convert back if necessary - if (!use_new_style_ordering) - reorder_new_to_old_style(cells); -} - - template<> void @@ -1221,14 +1165,18 @@ GridReordering<2,3>::invert_all_cells_of_negative_grid(const std::vector +template void -GridReordering<3>::reorder_cells (std::vector > &cells, - const bool use_new_style_ordering) +GridReordering::reorder_cells (std::vector > &cells, + const bool use_new_style_ordering) { Assert (cells.size() != 0, ExcMessage("List of elements to orient must have at least one cell")); + // there is nothing for us to do in 1d + if (dim == 1) + return; + // if necessary, convert to new-style format if (use_new_style_ordering == false) reorder_old_to_new_style(cells); @@ -1242,7 +1190,11 @@ GridReordering<3>::reorder_cells (std::vector > &cells, } catch (const internal::GridReordering2d::ExcMeshNotOrientable &) { - // the mesh is not orientable + // the mesh is not orientable. this is acceptable if we are in 3d, + // as class Triangulation knows how to handle this, but it is + // not in 2d; in that case, re-throw the exception + if (dim < 3) + throw; } // and convert back if necessary @@ -1317,5 +1269,14 @@ GridReordering<3>::invert_all_cells_of_negative_grid( } + +/* ------------------------ explicit instantiations ------------------- */ +template class GridReordering<1,1>; +template class GridReordering<1,2>; +template class GridReordering<1,3>; +template class GridReordering<2,2>; +template class GridReordering<2,3>; +template class GridReordering<3,3>; + DEAL_II_NAMESPACE_CLOSE