]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
DoFRenumbering::sort_selected_dofs_back(..) on each level for mg
authorjanssen <janssen@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 14 Aug 2012 13:04:05 +0000 (13:04 +0000)
committerjanssen <janssen@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 14 Aug 2012 13:04:05 +0000 (13:04 +0000)
implemented

git-svn-id: https://svn.dealii.org/trunk@25982 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/dofs/dof_renumbering.h
deal.II/source/dofs/dof_renumbering.cc
deal.II/source/dofs/dof_renumbering.inst.in

index f760b6d86cde97bbb6d4c204d3a589ef3cf20af2..472c76ea4c5e79aa41b66fd4989db39443c32c17 100644 (file)
@@ -1155,6 +1155,26 @@ namespace DoFRenumbering
   sort_selected_dofs_back (DH&                      dof_handler,
                            const std::vector<bool>& 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 <class DH>
+  void
+  sort_selected_dofs_back (DH&                      dof_handler,
+                           const std::vector<bool>& 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<bool>&   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 <class DH>
+  void
+  compute_sort_selected_dofs_back (std::vector<unsigned int>& new_dof_indices,
+                                   const DH&                  dof_handler,
+                                   const std::vector<bool>&   selected_dofs,
+                                   const unsigned int         level);
+
                                    /**
                                     * Renumber the degrees of
                                     * freedom in a random way.
index b65bdb052c0af85316ca0d4c1077a2c8592e62b4..2791e024ce15d557ff4041f0ff063c2bd33b7d2e 100644 (file)
@@ -1037,6 +1037,21 @@ namespace DoFRenumbering
 
 
 
+  template <class DH>
+  void
+  sort_selected_dofs_back (DH&                      dof_handler,
+                           const std::vector<bool>& selected_dofs,
+                           const unsigned int       level)
+  {
+    std::vector<unsigned int> 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 <class DH>
   void
   compute_sort_selected_dofs_back (std::vector<unsigned int>& new_indices,
@@ -1075,6 +1090,45 @@ namespace DoFRenumbering
 
 
 
+  template <class DH>
+  void
+  compute_sort_selected_dofs_back (std::vector<unsigned int>& new_indices,
+                                   const DH&                  dof_handler,
+                                   const std::vector<bool>&   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<n_dofs; ++i)
+      if (selected_dofs[i] == false)
+        {
+          new_indices[i] = next_unselected;
+          ++next_unselected;
+        }
+      else
+        {
+          new_indices[i] = next_selected;
+          ++next_selected;
+        };
+    Assert (next_unselected == n_selected_dofs, ExcInternalError());
+    Assert (next_selected == n_dofs, ExcInternalError());
+  }
+
+
+
   template <class DH>
   void
   cell_wise_dg (DH& dof,
index dd5c1facbe1ff1ec17a95ba392fa771266070817..769af6b944c1748ada8b79b8ebbfc1f44257b78c 100644 (file)
@@ -345,6 +345,12 @@ namespace DoFRenumbering
       (DoFHandler<deal_II_dimension> &,
        const std::vector<bool> &);
 
+    template
+      void sort_selected_dofs_back<MGDoFHandler<deal_II_dimension> >
+      (MGDoFHandler<deal_II_dimension> &,
+       const std::vector<bool> &,
+       const unsigned int);
+
     template
       void
       compute_sort_selected_dofs_back<DoFHandler<deal_II_dimension> >
@@ -352,6 +358,14 @@ namespace DoFRenumbering
        const DoFHandler<deal_II_dimension> &,
        const std::vector<bool> &);
 
+    template
+      void
+      compute_sort_selected_dofs_back<MGDoFHandler<deal_II_dimension> >
+      (std::vector<unsigned int>&,
+       const MGDoFHandler<deal_II_dimension> &,
+       const std::vector<bool> &,
+       const unsigned int);
+
     template
       void random<hp::DoFHandler<deal_II_dimension> >
       (hp::DoFHandler<deal_II_dimension> &);

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.