From: Wolfgang Bangerth
Date: Fri, 12 May 2000 13:44:50 +0000 (+0000)
Subject: Implement DoFRenumbering::sort_selected_dofs_back
X-Git-Tag: v8.0.0~20559
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31eaf3b36527d73dac015a3e565faa2a3e5cb9d6;p=dealii.git
Implement DoFRenumbering::sort_selected_dofs_back
git-svn-id: https://svn.dealii.org/trunk@2846 0785d39b-7218-0410-832d-ea1e28bc413d
---
diff --git a/deal.II/deal.II/include/numerics/dof_renumbering.h b/deal.II/deal.II/include/numerics/dof_renumbering.h
index 6cfc780663..a92c577239 100644
--- a/deal.II/deal.II/include/numerics/dof_renumbering.h
+++ b/deal.II/deal.II/include/numerics/dof_renumbering.h
@@ -242,9 +242,27 @@ class DoFRenumbering
* identity operation.
*/
template
- static void component_wise (DoFHandler &dof_handler,
- const vector &component_order = vector());
+ static void
+ component_wise (DoFHandler &dof_handler,
+ const vector &component_order = vector());
+ /**
+ * 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
+ static void
+ sort_selected_dofs_back (const vector &selected_dofs,
+ DoFHandler &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 << ".");
};
diff --git a/deal.II/deal.II/source/dofs/dof_renumbering.cc b/deal.II/deal.II/source/dofs/dof_renumbering.cc
index 999ed1d047..a7ad38139c 100644
--- a/deal.II/deal.II/source/dofs/dof_renumbering.cc
+++ b/deal.II/deal.II/source/dofs/dof_renumbering.cc
@@ -401,6 +401,7 @@ void DoFRenumbering::Cuthill_McKee (MGDoFHandler &dof_handler,
};
+
template
void DoFRenumbering::component_wise (DoFHandler &dof_handler,
const vector &component_order_arg)
@@ -496,6 +497,47 @@ void DoFRenumbering::component_wise (DoFHandler &dof_handler,
};
+
+template
+void
+DoFRenumbering::sort_selected_dofs_back (const vector &selected_dofs,
+ DoFHandler &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 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 &dof_handler,
@@ -512,3 +554,8 @@ void DoFRenumbering::Cuthill_McKee (MGDoFHandler &dof_handler
template
void DoFRenumbering::component_wise (DoFHandler &dof_handler,
const vector &component_order_arg);
+
+
+template
+void DoFRenumbering::sort_selected_dofs_back (const vector &selected_dofs,
+ DoFHandler &dof_handler);
diff --git a/deal.II/doc/news/2000/c-3-0.html b/deal.II/doc/news/2000/c-3-0.html
index 4f66df0206..5599b8f308 100644
--- a/deal.II/doc/news/2000/c-3-0.html
+++ b/deal.II/doc/news/2000/c-3-0.html
@@ -188,6 +188,11 @@
New: DoFTools::extract_hanging_node_dofs ()
identifies nodes that will be constrained by hanging node constraints.
+
+
+ New: DoFRenumbering::sort_selected_dofs_back ()
+ sorts selected degrees of freedom to the end of the index range.
+