]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implement DoFRenumbering::sort_selected_dofs_back
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 12 May 2000 13:44:50 +0000 (13:44 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 12 May 2000 13:44:50 +0000 (13:44 +0000)
git-svn-id: https://svn.dealii.org/trunk@2846 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/numerics/dof_renumbering.h
deal.II/deal.II/source/dofs/dof_renumbering.cc
deal.II/doc/news/2000/c-3-0.html

index 6cfc7806635cda8e4aaf24130459889be5ec03ee..a92c5772393fb93f9efc390309d17de5653fba60 100644 (file)
@@ -242,9 +242,27 @@ class DoFRenumbering
                                      * identity operation.
                                      */
     template <int dim>
-    static void component_wise (DoFHandler<dim>            &dof_handler,
-                               const vector<unsigned int> &component_order = vector<unsigned int>());
+    static void
+    component_wise (DoFHandler<dim>            &dof_handler,
+                   const vector<unsigned int> &component_order = vector<unsigned int>());
 
+                                    /**
+                                     * Sort those degrees of freedom
+                                     * which are tagged with #true#
+                                     * in the #selected_dofs# array
+                                     * 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 <int dim>
+    static void
+    sort_selected_dofs_back (const vector<bool> &selected_dofs,
+                            DoFHandler<dim>    &dof_handler);
 
                                     /**
                                      * Exception
@@ -254,6 +272,13 @@ class DoFRenumbering
                                      * Exception
                                      */
     DeclException0 (ExcInvalidComponentOrder);
+                                    /**
+                                     * Exception
+                                     */
+    DeclException2 (ExcInvalidArraySize,
+                   int, int,
+                   << "The array has size " << arg1 << " but should have "
+                   << arg2 << ".");
 };
 
 
index 999ed1d047916dc9fd95ffad0c1373f5a72a1849..a7ad38139c20d61d604a102211aa68ad613d1947 100644 (file)
@@ -401,6 +401,7 @@ void DoFRenumbering::Cuthill_McKee (MGDoFHandler<dim>          &dof_handler,
 };
 
 
+
 template <int dim>
 void DoFRenumbering::component_wise (DoFHandler<dim>            &dof_handler,
                                     const vector<unsigned int> &component_order_arg)
@@ -496,6 +497,47 @@ void DoFRenumbering::component_wise (DoFHandler<dim>            &dof_handler,
 };
 
 
+
+template <int dim>
+void
+DoFRenumbering::sort_selected_dofs_back (const vector<bool> &selected_dofs,
+                                        DoFHandler<dim>    &dof_handler)
+{
+  const unsigned int n_dofs = dof_handler.n_dofs();
+  Assert (selected_dofs.size() == n_dofs,
+         ExcInvalidArraySize (selected_dofs.size(), n_dofs));
+
+                                  // re-sort the dofs according to
+                                  // their selection state
+  vector<unsigned int> new_dof_indices (n_dofs);
+  const unsigned int   n_selected_dofs = 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<n_dofs; ++i)
+    if (selected_dofs[i] == false)
+      {
+       new_dof_indices[i] = next_unselected;
+       ++next_unselected;
+      }
+    else
+      {
+       new_dof_indices[i] = next_selected;
+       ++next_selected;
+      };
+  Assert (next_unselected == n_selected_dofs, ExcInternalError());
+  Assert (next_selected == n_dofs, ExcInternalError());
+
+                                  // now perform the renumbering
+  dof_handler.renumber_dofs (new_dof_indices);
+};
+
+
+
+
+
 // explicit instantiations
 template
 void DoFRenumbering::Cuthill_McKee (DoFHandler<deal_II_dimension> &dof_handler,
@@ -512,3 +554,8 @@ void DoFRenumbering::Cuthill_McKee (MGDoFHandler<deal_II_dimension> &dof_handler
 template
 void DoFRenumbering::component_wise (DoFHandler<deal_II_dimension> &dof_handler,
                                     const vector<unsigned int>    &component_order_arg);
+
+
+template
+void DoFRenumbering::sort_selected_dofs_back (const vector<bool> &selected_dofs,
+                                             DoFHandler<deal_II_dimension> &dof_handler);
index 4f66df0206f3fb0cd619df4bd5c3127df1f88b58..5599b8f308c5f058bbe7a52a53c93400498bfd69 100644 (file)
        New: <code class="member">DoFTools::extract_hanging_node_dofs ()</code>
        identifies nodes that will be constrained by hanging node constraints.
        </p>
+
+  <li> <p> 
+       New: <code class="member">DoFRenumbering::sort_selected_dofs_back ()</code>
+       sorts selected degrees of freedom to the end of the index range.
+       </p>
 </ol>
 
 <hr>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.