From f20638592f89af89f6973f07552bbb2870a4e129 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 3 Jul 2003 10:02:56 +0000 Subject: [PATCH] component_wise renumbering changed and header moved where it belongs git-svn-id: https://svn.dealii.org/trunk@7830 0785d39b-7218-0410-832d-ea1e28bc413d --- .../{numerics => dofs}/dof_renumbering.h | 6 +- .../deal.II/source/dofs/dof_renumbering.cc | 120 +++++++++++------- 2 files changed, 80 insertions(+), 46 deletions(-) rename deal.II/deal.II/include/{numerics => dofs}/dof_renumbering.h (99%) diff --git a/deal.II/deal.II/include/numerics/dof_renumbering.h b/deal.II/deal.II/include/dofs/dof_renumbering.h similarity index 99% rename from deal.II/deal.II/include/numerics/dof_renumbering.h rename to deal.II/deal.II/include/dofs/dof_renumbering.h index f7ae3a3ef6..96fac9c929 100644 --- a/deal.II/deal.II/include/numerics/dof_renumbering.h +++ b/deal.II/deal.II/include/dofs/dof_renumbering.h @@ -22,6 +22,7 @@ #include +// moved here from directory numerics. See there for previous logs. /** * Implementation of a number of renumbering algorithms for the degrees of @@ -325,10 +326,11 @@ class DoFRenumbering * returns the renumbering * vector. */ - template + template static void compute_component_wise (std::vector& new_index, - const DoFHandler& dof_handler, + ITERATOR& start, + const ENDITERATOR& end, const std::vector &component_order = std::vector()); /** diff --git a/deal.II/deal.II/source/dofs/dof_renumbering.cc b/deal.II/deal.II/source/dofs/dof_renumbering.cc index 2d46ee83bd..e392281427 100644 --- a/deal.II/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/deal.II/source/dofs/dof_renumbering.cc @@ -51,6 +51,22 @@ extern "C" long int lrand48 (void); +// The following two class is defined to be used in the compute_* +// functions. Using them allows to use the same function to compute +// level numbering for multigrid as well as numbering for the global +// system matrix. +template +class WrapMGDoFIterator : public T +{ + public: + void get_dof_indices (std::vector& v) const + { + T::get_mg_dof_indices(v); + } +}; + + + template void DoFRenumbering::Cuthill_McKee ( @@ -428,6 +444,7 @@ void DoFRenumbering::Cuthill_McKee ( #ifdef DEBUG // test for all indices numbered +//TODO: Test fails. Do not check before unification. if (std::find (new_indices.begin(), new_indices.end(), DoFHandler::invalid_dof_index) != @@ -458,26 +475,38 @@ DoFRenumbering::component_wise ( std::vector renumbering (dof_handler.n_dofs(), DoFHandler::invalid_dof_index); - compute_component_wise(renumbering, dof_handler, component_order_arg); + typename DoFHandler::active_cell_iterator + start = dof_handler.begin_active(); + const typename DoFHandler::cell_iterator + end = dof_handler.end(); + + compute_component_wise::active_cell_iterator, + typename DoFHandler::cell_iterator>(renumbering, + start, end, + component_order_arg); if (renumbering.size()!=0) dof_handler.renumber_dofs (renumbering); } - -template + +template void DoFRenumbering::compute_component_wise ( std::vector& new_indices, - const DoFHandler& dof_handler, + ITERATOR& start, + const ENDITERATOR& end, const std::vector &component_order_arg) { - const unsigned int dofs_per_cell = dof_handler.get_fe().dofs_per_cell; - const FiniteElement &fe = dof_handler.get_fe(); +// Modify for hp + const FiniteElement& fe = start->get_fe(); + const unsigned int dofs_per_cell = fe.dofs_per_cell; - Assert (new_indices.size() == dof_handler.n_dofs(), - ExcDimensionMismatch(new_indices.size(), dof_handler.n_dofs())); +// Assert (new_indices.size() == start->dof_handler().n_dofs(), +// ExcDimensionMismatch(new_indices.size(), +// start->dof_handler.n_dofs())); // do nothing if the FE has only // one component @@ -486,29 +515,32 @@ DoFRenumbering::compute_component_wise ( new_indices.resize(0); return; } - + + // Copy last argument into a + // writable vector. std::vector component_order (component_order_arg); + // If the last argument was an + // empty vector, set up things to + // store components in the order + // found in the system. if (component_order.size() == 0) for (unsigned int i=0; i local_dof_indices(dofs_per_cell); // prebuilt list to which component // a given dof on a cell - // belongs. note that we get into + // should go. note that we get into // trouble here if the shape // function is not primitive, since // then there is no single vector @@ -519,7 +551,8 @@ DoFRenumbering::compute_component_wise ( std::vector component_list (dofs_per_cell); for (unsigned int i=0; i > component_to_dof_map (fe.n_components()); - for (typename DoFHandler::active_cell_iterator - cell=dof_handler.begin_active(); - cell!=dof_handler.end(); ++cell) + for (;start!=end;++start) { // on each cell: get dof indices // and insert them into the global // list using their component - cell->get_dof_indices (local_dof_indices); + start->get_dof_indices (local_dof_indices); for (unsigned int i=0; i::const_iterator begin_of_component = component_to_dof_map[component].begin(), @@ -616,8 +648,8 @@ DoFRenumbering::compute_component_wise ( new_indices[*dof_index] = next_free_index++; }; - Assert (next_free_index == dof_handler.n_dofs(), - ExcInternalError()); +// Assert (next_free_index == dof_handler.n_dofs(), +// ExcInternalError()); } @@ -1098,12 +1130,12 @@ void DoFRenumbering::component_wise (DoFHandler&, const std::vector&); -template -void -DoFRenumbering::compute_component_wise -(std::vector&, - const DoFHandler&, - const std::vector&); +// template +// void +// DoFRenumbering::compute_component_wise +// (std::vector&, +// const DoFHandler&, +// const std::vector&); template void DoFRenumbering::component_wise -- 2.39.5