From dcccf9afae0cee3adecdff3728252ba7123d971c Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 12 Jul 2004 13:54:23 +0000 Subject: [PATCH] Small clean-ups. git-svn-id: https://svn.dealii.org/trunk@9501 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/source/dofs/dof_renumbering.cc | 101 ++++++++++-------- 1 file changed, 57 insertions(+), 44 deletions(-) diff --git a/deal.II/deal.II/source/dofs/dof_renumbering.cc b/deal.II/deal.II/source/dofs/dof_renumbering.cc index 50e4892435..3960d5988c 100644 --- a/deal.II/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/deal.II/source/dofs/dof_renumbering.cc @@ -60,10 +60,12 @@ class WrapDoFIterator : private T { public: WrapDoFIterator (const T& t) : T(t) {} + void get_dof_indices (std::vector& v) const { (*this)->get_dof_indices(v); } + template bool operator != (const T2& i) const { @@ -75,15 +77,19 @@ class WrapDoFIterator : private T T::operator==; }; + + template class WrapMGDoFIterator : private T { public: WrapMGDoFIterator (const T& t) : T(t) {} + void get_dof_indices (std::vector& v) const { (*this)->get_mg_dof_indices(v); } + bool operator != (const WrapMGDoFIterator& i) const { return (! (T::operator==(i))); @@ -96,13 +102,47 @@ class WrapMGDoFIterator : private T +/** + * Provide comparator for DoFCellAccessors: it returns @p true if the center + * of the second cell is downstream of the center of the first one with + * respect to the direction given to the constructor. + */ +template +struct CompareDownstream +{ + /** + * Constructor. + */ + CompareDownstream (const Point &dir) + : + dir(dir) + {} + /** + * Return true if c1 < c2. + */ + bool operator () (const typename DoFHandler::cell_iterator &c1, + const typename DoFHandler::cell_iterator &c2) const + { + const Point diff = c2->center() - c1->center(); + return (diff*dir > 0); + } + + private: + /** + * Flow direction. + */ + const Point dir; +}; + + + template void -DoFRenumbering::Cuthill_McKee ( - DoFHandler& dof_handler, - const bool reversed_numbering, - const bool use_constraints, - const std::vector& starting_indices) +DoFRenumbering:: +Cuthill_McKee (DoFHandler &dof_handler, + const bool reversed_numbering, + const bool use_constraints, + const std::vector &starting_indices) { std::vector renumbering(dof_handler.n_dofs(), DoFHandler::invalid_dof_index); @@ -119,12 +159,12 @@ DoFRenumbering::Cuthill_McKee ( template void -DoFRenumbering::compute_Cuthill_McKee ( - std::vector& new_indices, - const DoFHandler& dof_handler, - const bool reversed_numbering, - const bool use_constraints, - const std::vector& starting_indices) +DoFRenumbering:: +compute_Cuthill_McKee (std::vector& new_indices, + const DoFHandler& dof_handler, + const bool reversed_numbering, + const bool use_constraints, + const std::vector& starting_indices) { // make the connection graph. in // more than 2d use an intermediate @@ -167,8 +207,9 @@ DoFRenumbering::compute_Cuthill_McKee ( constraints.clear (); const unsigned int n_dofs = sparsity.n_rows(); - // store the new dof numbers; invalid_dof_index means - // that no new number was chosen yet + // store the new dof numbers; + // invalid_dof_index means that no new + // number was chosen yet Assert(new_indices.size() == n_dofs, ExcDimensionMismatch(new_indices.size(), n_dofs)); @@ -934,34 +975,6 @@ void DoFRenumbering::cell_wise_dg ( dof.renumber_dofs(level, reverse); } -/** - * Provide comparator for DoFCellAccessors - */ - -template -struct CompCells -{ - /** - * Flow direction. - */ - const Point& dir; - /** - * Constructor. - */ - CompCells (const Point& dir) : - dir(dir) - {} - /** - * Return true if c1 < c2. - */ - bool operator () (const typename DoFHandler::cell_iterator& c1, - const typename DoFHandler::cell_iterator&c2) const - { - Point diff = c2->center() - c1->center(); - double s = diff*dir; - return (s>0); - } -}; template @@ -986,7 +999,7 @@ DoFRenumbering::compute_downstream_dg ( { std::vector::cell_iterator> ordered_cells(dof.get_tria().n_active_cells()); - CompCells comparator(direction); + const CompareDownstream comparator(direction); typename DoFHandler::active_cell_iterator begin = dof.begin_active(); typename DoFHandler::active_cell_iterator end = dof.end(); @@ -1005,7 +1018,7 @@ void DoFRenumbering::downstream_dg (MGDoFHandler& dof, { std::vector::cell_iterator> ordered_cells(dof.get_tria().n_cells(level)); - CompCells comparator(direction); + const CompareDownstream comparator(direction); typename MGDoFHandler::cell_iterator begin = dof.begin(level); typename MGDoFHandler::cell_iterator end = dof.end(level); @@ -1013,7 +1026,7 @@ void DoFRenumbering::downstream_dg (MGDoFHandler& dof, std::copy (begin, end, ordered_cells.begin()); std::sort (ordered_cells.begin(), ordered_cells.end(), comparator); - cell_wise_dg(dof, level, ordered_cells); + cell_wise_dg (dof, level, ordered_cells); } -- 2.39.5