From: janssen Date: Tue, 14 Aug 2012 13:04:05 +0000 (+0000) Subject: DoFRenumbering::sort_selected_dofs_back(..) on each level for mg X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bec205f7db800a70069dc9499ff5e1825a6ebce;p=dealii-svn.git DoFRenumbering::sort_selected_dofs_back(..) on each level for mg implemented git-svn-id: https://svn.dealii.org/trunk@25982 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/dofs/dof_renumbering.h b/deal.II/include/deal.II/dofs/dof_renumbering.h index f760b6d86c..472c76ea4c 100644 --- a/deal.II/include/deal.II/dofs/dof_renumbering.h +++ b/deal.II/include/deal.II/dofs/dof_renumbering.h @@ -1155,6 +1155,26 @@ namespace DoFRenumbering sort_selected_dofs_back (DH& dof_handler, const std::vector& selected_dofs); + /** + * Sort those degrees of freedom + * which are tagged with @p true + * in the @p selected_dofs array + * on the level @level + * to the back of the DoF + * numbers. The sorting is + * stable, i.e. the relative + * order within the tagged + * degrees of freedom is + * preserved, as is the relative + * order within the untagged + * ones. + */ + template + void + sort_selected_dofs_back (DH& dof_handler, + const std::vector& selected_dofs, + const unsigned int level); + /** * Computes the renumbering * vector needed by the @@ -1170,6 +1190,23 @@ namespace DoFRenumbering const DH& dof_handler, const std::vector& selected_dofs); + /** + * Computes the renumbering + * vector on each level + * needed by the + * sort_selected_dofs_back() + * function. Does not perform the + * renumbering on the MGDoFHandler + * dofs but returns the + * renumbering vector. + */ + template + void + compute_sort_selected_dofs_back (std::vector& new_dof_indices, + const DH& dof_handler, + const std::vector& selected_dofs, + const unsigned int level); + /** * Renumber the degrees of * freedom in a random way. diff --git a/deal.II/source/dofs/dof_renumbering.cc b/deal.II/source/dofs/dof_renumbering.cc index b65bdb052c..2791e024ce 100644 --- a/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/source/dofs/dof_renumbering.cc @@ -1037,6 +1037,21 @@ namespace DoFRenumbering + template + void + sort_selected_dofs_back (DH& dof_handler, + const std::vector& selected_dofs, + const unsigned int level) + { + std::vector renumbering(dof_handler.n_dofs(level), + DH::invalid_dof_index); + compute_sort_selected_dofs_back(renumbering, dof_handler, selected_dofs, level); + + dof_handler.renumber_dofs(level, renumbering); + } + + + template void compute_sort_selected_dofs_back (std::vector& new_indices, @@ -1075,6 +1090,45 @@ namespace DoFRenumbering + template + void + compute_sort_selected_dofs_back (std::vector& new_indices, + const DH& dof_handler, + const std::vector& selected_dofs, + const unsigned int level) + { + const unsigned int n_dofs = dof_handler.n_dofs(level); + Assert (selected_dofs.size() == n_dofs, + ExcDimensionMismatch (selected_dofs.size(), n_dofs)); + + // re-sort the dofs according to + // their selection state + Assert (new_indices.size() == n_dofs, + ExcDimensionMismatch(new_indices.size(), n_dofs)); + + const unsigned int n_selected_dofs = std::count (selected_dofs.begin(), + selected_dofs.end(), + false); + + unsigned int next_unselected = 0; + unsigned int next_selected = n_selected_dofs; + for (unsigned int i=0; i void cell_wise_dg (DH& dof, diff --git a/deal.II/source/dofs/dof_renumbering.inst.in b/deal.II/source/dofs/dof_renumbering.inst.in index dd5c1facbe..769af6b944 100644 --- a/deal.II/source/dofs/dof_renumbering.inst.in +++ b/deal.II/source/dofs/dof_renumbering.inst.in @@ -345,6 +345,12 @@ namespace DoFRenumbering (DoFHandler &, const std::vector &); + template + void sort_selected_dofs_back > + (MGDoFHandler &, + const std::vector &, + const unsigned int); + template void compute_sort_selected_dofs_back > @@ -352,6 +358,14 @@ namespace DoFRenumbering const DoFHandler &, const std::vector &); + template + void + compute_sort_selected_dofs_back > + (std::vector&, + const MGDoFHandler &, + const std::vector &, + const unsigned int); + template void random > (hp::DoFHandler &);