From 4f443740e5ad6a09d75a86421a17504b229b15ae Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Fri, 8 Aug 2003 20:05:47 +0000 Subject: [PATCH] counter?clockwise renumbering must be tested git-svn-id: https://svn.dealii.org/trunk@7908 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/include/dofs/dof_renumbering.h | 60 ++++++++- .../deal.II/source/dofs/dof_renumbering.cc | 122 ++++++++++++++++-- 2 files changed, 165 insertions(+), 17 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_renumbering.h b/deal.II/deal.II/include/dofs/dof_renumbering.h index dbff2d8893..ff86e725f4 100644 --- a/deal.II/deal.II/include/dofs/dof_renumbering.h +++ b/deal.II/deal.II/include/dofs/dof_renumbering.h @@ -434,6 +434,19 @@ class DoFRenumbering template static void downstream_dg (DoFHandler &dof_handler, + const Point &direction); + + /** + * Cell-wise downstream numbering + * with respect to a constant + * flow direction on one + * level. See the other function + * with the same name. + */ + template + static void + downstream_dg (MGDoFHandler &dof_handler, + const unsigned int level, const Point &direction); /** @@ -452,18 +465,51 @@ class DoFRenumbering const DoFHandler &dof_handler, const Point &direction); +//TODO:[GK] Documentation! /** - * Cell-wise downstream numbering - * with respect to a constant - * flow direction on one - * level. See the other function - * with the same name. + * Cell-wise clockwise numbering. + * + * This function produces a + * clockwise ordering of the + * mesh cells and calls + * @ref{cell_wise_dg}. + * Therefore, it only works with + * Discontinuous Galerkin Finite + * Elements, i.e. all degrees of + * freedom have to be associated + * with the interior of the cell. */ template static void - downstream_dg (MGDoFHandler &dof_handler, + clockwise_dg (DoFHandler &dof_handler, + const Point ¢er); + + /** + * Cell-wise clockwise numbering + * on one level. See the other + * function with the same name. + */ + template + static void + clockwise_dg (MGDoFHandler &dof_handler, const unsigned int level, - const Point &direction); + const Point ¢er); + + /** + * Computes the renumbering + * vector needed by the + * @p{clockwise_dg} + * functions. Does not perform the + * renumbering on the + * @p{DoFHandler} dofs but + * returns the renumbering + * vector. + */ + template + static void + compute_clockwise_dg (std::vector&, + const DoFHandler &dof_handler, + const Point ¢er); /** * Sort those degrees of freedom diff --git a/deal.II/deal.II/source/dofs/dof_renumbering.cc b/deal.II/deal.II/source/dofs/dof_renumbering.cc index c13771225a..719d679d1c 100644 --- a/deal.II/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/deal.II/source/dofs/dof_renumbering.cc @@ -973,7 +973,6 @@ DoFRenumbering::compute_downstream_dg ( } -#ifdef ENABLE_MULTIGRID template void DoFRenumbering::downstream_dg (MGDoFHandler& dof, const unsigned int level, @@ -991,7 +990,93 @@ void DoFRenumbering::downstream_dg (MGDoFHandler& dof, cell_wise_dg(dof, level, ordered_cells); } -#endif + + + +/** + * Provide comparator for DoFCellAccessors + */ + +template +struct ClockCells +{ + /** + * Center of rotation. + */ + const Point& center; + /** + * Constructor. + */ + ClockCells (const Point& center) : + center(center) + {} + /** + * Return true if c1 < c2. + */ + bool operator () (const typename DoFHandler::cell_iterator& c1, + const typename DoFHandler::cell_iterator&c2) const + { + + const Point v1 = c1->center() - center; + const Point v2 = c2->center() - center; + const double s1 = atan2(v1(0), v1(1)); + const double s2 = atan2(v2(0), v2(1)); + return (s1>s2); + } +}; + + +template +void +DoFRenumbering::clockwise_dg (DoFHandler& dof, + const Point& center) +{ + std::vector renumbering(dof.n_dofs()); + compute_clockwise_dg(renumbering, dof, center); + + dof.renumber_dofs(renumbering); +} + + + +template +void +DoFRenumbering::compute_clockwise_dg ( + std::vector& new_indices, + const DoFHandler& dof, + const Point& center) +{ + std::vector::cell_iterator> + ordered_cells(dof.get_tria().n_active_cells()); + ClockCells comparator(center); + + typename DoFHandler::active_cell_iterator begin = dof.begin_active(); + typename DoFHandler::active_cell_iterator end = dof.end(); + + copy (begin, end, ordered_cells.begin()); + sort (ordered_cells.begin(), ordered_cells.end(), comparator); + + compute_cell_wise_dg(new_indices, dof, ordered_cells); +} + + +template +void DoFRenumbering::clockwise_dg (MGDoFHandler& dof, + const unsigned int level, + const Point& center) +{ + std::vector::cell_iterator> + ordered_cells(dof.get_tria().n_cells(level)); + ClockCells comparator(center); + + typename MGDoFHandler::cell_iterator begin = dof.begin(level); + typename MGDoFHandler::cell_iterator end = dof.end(level); + + std::copy (begin, end, ordered_cells.begin()); + std::sort (ordered_cells.begin(), ordered_cells.end(), comparator); + + cell_wise_dg(dof, level, ordered_cells); +} @@ -1088,6 +1173,31 @@ DoFRenumbering::compute_downstream_dg const DoFHandler&, const Point&); +template +void DoFRenumbering::downstream_dg +(MGDoFHandler&, + const unsigned int, + const Point&); + +template +void +DoFRenumbering::clockwise_dg +(DoFHandler&, + const Point&); + +template +void +DoFRenumbering::compute_clockwise_dg +(std::vector&, + const DoFHandler&, + const Point&); + +template +void DoFRenumbering::clockwise_dg +(MGDoFHandler&, + const unsigned int, + const Point&); + template void DoFRenumbering::sort_selected_dofs_back (DoFHandler &, @@ -1110,7 +1220,6 @@ DoFRenumbering::compute_random (std::vector&, const DoFHandler &); -#ifdef ENABLE_MULTIGRID template void DoFRenumbering::Cuthill_McKee (MGDoFHandler&, @@ -1124,10 +1233,3 @@ void DoFRenumbering::cell_wise_dg const unsigned int, const std::vector::cell_iterator>&); -template -void DoFRenumbering::downstream_dg -(MGDoFHandler&, - const unsigned int, - const Point&); - -#endif -- 2.39.5