From 97d03670d497386eeecd9414f36632c1af4d223d Mon Sep 17 00:00:00 2001 From: hartmann Date: Wed, 6 Jul 2005 16:42:03 +0000 Subject: [PATCH] Remove specializations of the GridReordering template class. Implementation of new invert_all_cells_of_negative_grid function. git-svn-id: https://svn.dealii.org/trunk@11080 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/include/grid/grid_reordering.h | 92 ++++++++----------- .../deal.II/source/grid/grid_reordering.cc | 66 ++++++++++++- 2 files changed, 99 insertions(+), 59 deletions(-) diff --git a/deal.II/deal.II/include/grid/grid_reordering.h b/deal.II/deal.II/include/grid/grid_reordering.h index d58434e6c5..6ae4fea002 100644 --- a/deal.II/deal.II/include/grid/grid_reordering.h +++ b/deal.II/deal.II/include/grid/grid_reordering.h @@ -585,77 +585,57 @@ * the triangulation from this data using the * Triangulation::create_triangulation() function. * - * @author Wolfgang Bangerth, 2000, Michael Anderson 2003 + * @author Wolfgang Bangerth, 2000, Michael Anderson 2003, Ralf Hartmann 2005 */ template class GridReordering -{ -}; - - - -/** - * This is the specialization of the general template for 1d. In 1d, - * there is actually nothing to be done. - * - * @author Wolfgang Bangerth, 2000 - */ -template <> -class GridReordering<1> -{ - public: - /** - * Do nothing, since in 1d no - * reordering is necessary. - */ - static void reorder_cells (const std::vector > &); -}; - - - -/** - * This specialization of the general template implements the - * 2d-algorithm described in the documentation of the general - * template. - * - * @author Michael Anderson, 2003 - */ -template <> -class GridReordering<2> { public: + /** * This is the main function, * doing what is announced in * the general documentation of - * this class. + * this class for dim=2 and 3 + * and doing nothing for dim=1. */ - static void reorder_cells (std::vector > &original_cells); -}; + static void reorder_cells (std::vector > &original_cells); - - -/** - * This specialization of the general template implements the - * 3d-algorithm described in the documentation of the general - * template. - * - * @author Michael Anderson, 2003 - */ -template <> -class GridReordering<3> -{ - public: /** - * This is the main function, - * doing what is announced in - * the general documentation of - * this class. + * Grids generated by grid + * generators may have an + * orientation of cells which is + * the inverse of the orientation + * required by deal.II. + * + * In 3d this function checks + * whether all cells have + * negative or positiv + * measure/volume. In the former + * case, all cells are inverted. + * It does nothing in 1 and 2d. + * + * The invertion of cells might + * also work when only a subset + * of all cells have negative + * volume. However, grids + * consisting of a mixture of + * negative and positiv oriented + * cells are very likely to be + * broken. Therefore, an + * exception is thrown, in case + * cells are not uniformly + * oriented. + * + * Note, that this function + * should be called before + * reorder_cells(). */ - static void reorder_cells (std::vector > &original_cells); + static void invert_all_cells_of_negative_grid( + const std::vector > &all_vertices, + std::vector > &original_cells); }; - #endif diff --git a/deal.II/deal.II/source/grid/grid_reordering.cc b/deal.II/deal.II/source/grid/grid_reordering.cc index 74c51493c3..4d9bf6c38e 100644 --- a/deal.II/deal.II/source/grid/grid_reordering.cc +++ b/deal.II/deal.II/source/grid/grid_reordering.cc @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -22,12 +23,23 @@ #if deal_II_dimension == 1 -void GridReordering<1>::reorder_cells (const std::vector > &) +template<> +void +GridReordering<1>::reorder_cells (std::vector > &) { // there should not be much to do // in 1d... } + +template<> +void +GridReordering<1>::invert_all_cells_of_negative_grid(const std::vector > &, + std::vector > &) +{ + // nothing to be done in 1d +} + #endif @@ -557,7 +569,9 @@ namespace internal } // namespace internal -void GridReordering<2>::reorder_cells (std::vector > &original_cells) +template<> +void +GridReordering<2>::reorder_cells (std::vector > &original_cells) { // check if grids are already // consistent. if so, do @@ -569,6 +583,15 @@ void GridReordering<2>::reorder_cells (std::vector > &original_cells internal::GridReordering2d::GridReordering().reorient(original_cells); } + +template<> +void +GridReordering<2>::invert_all_cells_of_negative_grid(const std::vector > &, + std::vector > &) +{ + // nothing to be done in 2d +} + #endif @@ -1409,7 +1432,7 @@ namespace internal } - +template<> void GridReordering<3>::reorder_cells (std::vector > &incubes) { @@ -1422,6 +1445,43 @@ GridReordering<3>::reorder_cells (std::vector > &incubes) } +template<> +void +GridReordering<3>::invert_all_cells_of_negative_grid( + const std::vector > &all_vertices, + std::vector > &cells) +{ + unsigned int n_negative_cells=0; + for (unsigned int cell_no=0; cell_no 0, + ExcInternalError()); + } + + // We assuming 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 // deal_II_dimension == 3 -- 2.39.5