]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
The order in which components are to be sorted in
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 17 Oct 2002 20:12:09 +0000 (20:12 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 17 Oct 2002 20:12:09 +0000 (20:12 +0000)
DoFRenumbering::component_wise was not honored. Fix this.

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

deal.II/deal.II/source/dofs/dof_renumbering.cc
deal.II/doc/news/2002/c-3-4.html

index 76d6fab4bd95ee19ef6051b1036f19082c077f27..33b179ac3f00a4ca3752dcccc3feed7a465c9b5d 100644 (file)
@@ -538,6 +538,16 @@ DoFRenumbering::component_wise (DoFHandler<dim>                 &dof_handler,
                                   // within each component and during
                                   // this also remove duplicate
                                   // entries
+                                  //
+                                  // note that we no
+                                  // longer have to care about
+                                  // non-primitive shape functions
+                                  // since the buckets corresponding
+                                  // to the second and following
+                                  // vector components of a
+                                  // non-primitive FE will simply be
+                                  // empty, everything being shoved
+                                  // into the first one
   for (unsigned int component=0; component<fe.n_components(); ++component)
     {
       std::sort (component_to_dof_map[component].begin(),
@@ -547,12 +557,17 @@ DoFRenumbering::component_wise (DoFHandler<dim>                 &dof_handler,
                              component_to_dof_map[component].end()),
                 component_to_dof_map[component].end());
     };
-  
+
+                                   // now concatenate all the
+                                   // components in the order the user
+                                   // desired to see
   unsigned int next_free_index = 0;
   std::vector<unsigned int> new_indices (dof_handler.n_dofs(),
                                         DoFHandler<dim>::invalid_dof_index);
-  for (unsigned int component=0; component<fe.n_components(); ++component)
+  for (unsigned int c=0; c<fe.n_components(); ++c)
     {
+      const unsigned int component = component_order[c];
+      
       const typename std::vector<unsigned int>::const_iterator
        begin_of_component = component_to_dof_map[component].begin(),
        end_of_component   = component_to_dof_map[component].end();
@@ -602,8 +617,7 @@ void DoFRenumbering::component_wise (MGDoFHandler<dim>& dof_handler,
                                   // vector to hold the dof indices on
                                   // the cell we visit at a time
   std::vector<unsigned int> local_dof_indices(dofs_per_cell);
-                                  // prebuilt list to which component
-                                  // a given dof on a cell belongs
+
                                    // prebuilt list to which component
                                   // a given dof on a cell
                                   // belongs. note that we get into
@@ -637,7 +651,7 @@ void DoFRenumbering::component_wise (MGDoFHandler<dim>& dof_handler,
                                          // of freedom with this
                                          // component
         component_list[i] = c;
-      };
+      };  
 
                                   // set up a map where for each
                                   // component the respective degrees
@@ -651,7 +665,8 @@ void DoFRenumbering::component_wise (MGDoFHandler<dim>& dof_handler,
                                   // multiply, so we will have to
                                   // take care of that
   std::vector<std::vector<unsigned int> > component_to_dof_map (fe.n_components());
-  for (typename MGDoFHandler<dim>::cell_iterator cell=dof_handler.begin(level);
+  for (typename MGDoFHandler<dim>::cell_iterator
+         cell=dof_handler.begin(level);
        cell!=dof_handler.end(level); ++cell)
     {
                                       // on each cell: get dof indices
@@ -674,31 +689,48 @@ void DoFRenumbering::component_wise (MGDoFHandler<dim>& dof_handler,
                                   // within each component and during
                                   // this also remove duplicate
                                   // entries
+                                  //
+                                  // note that we no
+                                  // longer have to care about
+                                  // non-primitive shape functions
+                                  // since the buckets corresponding
+                                  // to the second and following
+                                  // vector components of a
+                                  // non-primitive FE will simply be
+                                  // empty, everything being shoved
+                                  // into the first one
   for (unsigned int component=0; component<fe.n_components(); ++component)
     {
       std::sort (component_to_dof_map[component].begin(),
                 component_to_dof_map[component].end());
-      component_to_dof_map[component].erase (std::unique (component_to_dof_map[component].begin(),
-                                                         component_to_dof_map[component].end()),
-                                            component_to_dof_map[component].end());
+      component_to_dof_map[component]
+        .erase (std::unique (component_to_dof_map[component].begin(),
+                             component_to_dof_map[component].end()),
+                component_to_dof_map[component].end());
     };
-  
+
+                                   // now concatenate all the
+                                   // components in the order the user
+                                   // desired to see  
   unsigned int next_free_index = 0;
   std::vector<unsigned int> new_indices (dof_handler.n_dofs(level),
                                         DoFHandler<dim>::invalid_dof_index);
-  for (unsigned int component=0; component<fe.n_components(); ++component)
+  for (unsigned int c=0; c<fe.n_components(); ++c)
     {
+      const unsigned int component = component_order[c];
+      
       const typename std::vector<unsigned int>::const_iterator
        begin_of_component = component_to_dof_map[component].begin(),
        end_of_component   = component_to_dof_map[component].end();
       
-      for (typename std::vector<unsigned int>::const_iterator dof_index = begin_of_component;
+      for (typename std::vector<unsigned int>::const_iterator
+             dof_index = begin_of_component;
           dof_index != end_of_component; ++dof_index)
          new_indices[*dof_index] = next_free_index++;
     };
 
-//  Assert (next_free_index == dof_handler.n_dofs(level),
-//       ExcInternalError());
+  Assert (next_free_index == dof_handler.n_dofs(level),
+          ExcInternalError());
 
   dof_handler.renumber_dofs (level, new_indices);
 };
index 340ac498c9b44307105f3267233545e5261d72c5..e57bbb5ce686b3bbebf0a99cdd8747af61a493ef 100644 (file)
@@ -402,6 +402,17 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>deal.II</h3>
 
 <ol>
+  <li> <p> 
+       Fixed: The <code
+       class="member">DoFRenumbering::component_wise</code> function accepts a
+       parameter indicating the order in which the degrees of freedom
+       corresponding to one vector component are to be sorted. However, it did
+       not honor this order, but always sorted them in the order in which the
+       components appear. This is now fixed.
+       <br>
+       (WB 2002/10/17)
+       </p>
+
   <li> <p> 
        New: The <code
        class="member">FiniteElement::system_to_base_index</code> function now

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.