From 1488b9544b0b1c1d02d8463f7ce8c1ff61deb7a4 Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 23 Oct 2000 08:38:30 +0000 Subject: [PATCH] DoFRenumbering::random git-svn-id: https://svn.dealii.org/trunk@3454 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/numerics/dof_renumbering.h | 29 +++++++++++++++---- .../deal.II/source/dofs/dof_renumbering.cc | 17 +++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/deal.II/deal.II/include/numerics/dof_renumbering.h b/deal.II/deal.II/include/numerics/dof_renumbering.h index 808c9027b3..a3b9907e48 100644 --- a/deal.II/deal.II/include/numerics/dof_renumbering.h +++ b/deal.II/deal.II/include/numerics/dof_renumbering.h @@ -148,11 +148,13 @@ * are numbered cell-wise without taking into account that they may belong to * different components. * - * This kind of numbering may be obtained by calling the @p{component_wise} function - * of this class. Since it does not touch the order of indices within each, it - * may be worthwhile to first renumber using the Cuthill-McKee or a similar - * algorithm and afterwards renumbering component-wise. This will bring out the - * matrix structure and additionally have a good numbering within each block. + * This kind of numbering may be obtained by calling the + * @p{component_wise} function of this class. Since it does not touch + * the order of indices within each, it may be worthwhile to first + * renumber using the Cuthill-McKee or a similar algorithm and + * afterwards renumbering component-wise. This will bring out the + * matrix structure and additionally have a good numbering within each + * block. * * * @sect2{Cell-wise numbering for Discontinuous Galerkin FEM} @@ -171,6 +173,15 @@ * preserved, so it may be useful to apply @component_wise} first. * * + * @sect2{Random renumbering} + * + * The @p{random} function renumbers degrees of freedom randomly. This + * function is probably seldom of use, but to check the dependence of + * solvers (iterative or direct ones) on the numbering of the degrees + * of freedom. It uses the @p{random_shuffle} function from the C++ + * standard library to do its work. + * + * * @sect2{Multigrid DoF numbering} * * Most algorithms also work on multigrid degree of freedom numberings. Refer @@ -364,6 +375,14 @@ class DoFRenumbering sort_selected_dofs_back (DoFHandler &dof_handler, const vector &selected_dofs); + /** + * Renumber the degrees of + * freedom in a random way. + */ + template + static void + random (DoFHandler &dof_handler); + /** * Exception */ diff --git a/deal.II/deal.II/source/dofs/dof_renumbering.cc b/deal.II/deal.II/source/dofs/dof_renumbering.cc index 1628385fe1..d056afc75f 100644 --- a/deal.II/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/deal.II/source/dofs/dof_renumbering.cc @@ -716,6 +716,20 @@ DoFRenumbering::downstream_dg (MGDoFHandler& dof, +extern "C" long int lrand48 (void); + + +template +void +DoFRenumbering::random (DoFHandler &dof_handler) +{ + vector new_indices (dof_handler.n_dofs()); + random_shuffle (new_indices.begin(), new_indices.end()); + dof_handler.renumber_dofs(new_indices); +}; + + + // explicit instantiations template void DoFRenumbering::Cuthill_McKee (DoFHandler&, @@ -755,3 +769,6 @@ void DoFRenumbering::downstream_dg (MGDoFHandler&, template void DoFRenumbering::sort_selected_dofs_back (DoFHandler &, const vector &); + +template +void DoFRenumbering::random (DoFHandler &); -- 2.39.5