]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Merge from mainline.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 Oct 2012 18:36:08 +0000 (18:36 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 8 Oct 2012 18:36:08 +0000 (18:36 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_bigger_global_dof_indices_3@27015 0785d39b-7218-0410-832d-ea1e28bc413d

25 files changed:
1  2 
deal.II/examples/step-18/step-18.cc
deal.II/examples/step-42/step-42.cc
deal.II/include/deal.II/base/index_set.h
deal.II/include/deal.II/dofs/dof_handler.h
deal.II/include/deal.II/dofs/dof_levels.h
deal.II/include/deal.II/dofs/dof_renumbering.h
deal.II/include/deal.II/dofs/dof_tools.h
deal.II/include/deal.II/fe/fe_values.h
deal.II/include/deal.II/hp/dof_handler.h
deal.II/include/deal.II/lac/block_sparsity_pattern.h
deal.II/include/deal.II/lac/block_vector_base.h
deal.II/include/deal.II/lac/constraint_matrix.templates.h
deal.II/include/deal.II/multigrid/mg_constrained_dofs.h
deal.II/include/deal.II/multigrid/mg_tools.h
deal.II/include/deal.II/numerics/vector_tools.h
deal.II/include/deal.II/numerics/vector_tools.templates.h
deal.II/source/dofs/dof_handler.cc
deal.II/source/dofs/dof_renumbering.cc
deal.II/source/dofs/dof_renumbering.inst.in
deal.II/source/dofs/dof_tools.cc
deal.II/source/dofs/dof_tools.inst.in
deal.II/source/fe/fe_values.cc
deal.II/source/multigrid/mg_tools.cc
deal.II/source/multigrid/mg_tools.inst.in
deal.II/source/numerics/point_value_history.cc

Simple merge
Simple merge
index 46710d65b3a284e5c31a039d1e0700b497224bb1,2baa1127086c465ed7ae02eeca865353f1607e9c..b1de672aede3806a21c2c8bc431023fa66bf0530
@@@ -64,7 -64,7 +64,7 @@@ class IndexSe
                                        * overall size of the index
                                        * range.
                                        */
-     IndexSet (const types::global_dof_index size);
 -    explicit IndexSet (const unsigned int size);
++    explicit IndexSet (const types::global_dof_index size);
  
                                       /**
                                        * Remove all indices from this
index 294c13ea88a13359d5fb04adc9d3e8bbb2f23863,341d1da45e2a19ddc2c1496d3a1b14e92b240e46..16328740bbd44d9708b4d14d103358fd4f94c602
@@@ -667,8 -688,13 +688,13 @@@ namespace DoFRenumberin
    Cuthill_McKee (MGDoFHandler<dim>          &dof_handler,
                   const unsigned int          level,
                   const bool                  reversed_numbering = false,
 -                 const std::vector<unsigned int> &starting_indices   = std::vector<unsigned int> ());
 +                 const std::vector<types::global_dof_index> &starting_indices   = std::vector<types::global_dof_index> ());
  
+   /**
+    * @name Component-wise numberings
+    * @{
+    */
                                     /**
                                      * Sort the degrees of freedom by
                                      * vector component. The
                                      */
    template <class DH>
    void
 -  compute_random (std::vector<unsigned int> &new_dof_indices,
 +  compute_random (std::vector<types::global_dof_index> &new_dof_indices,
                    const DH& dof_handler);
  
+   /**
+    * @}
+    */
+   /**
+    * @name Numberings based on cell attributes
+    * @{
+    */
                                     /**
                                      * Renumber the degrees of
                                      * freedom such that they are
                                      */
    template <class DH>
    void
 -  compute_subdomain_wise (std::vector<unsigned int> &new_dof_indices,
 +  compute_subdomain_wise (std::vector<types::global_dof_index> &new_dof_indices,
                            const DH                  &dof_handler);
  
+   /**
+    * @}
+    */
                                     /**
                                      * Exception
                                      *
index b6f7b2a5311cb65ced485353adcf87fed79367b5,3565e81af0c22a85a472f184afd3a2bb116c9a56..b3db9a13d6dcc8275b177876023a35287c30c423
@@@ -737,8 -738,8 +738,8 @@@ namespace DoFTool
    template <class DH, class SparsityPattern>
    void
    make_boundary_sparsity_pattern (const DH                        &dof,
-                                                 const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
-                                                 SparsityPattern                 &sparsity_pattern);
 -                                  const std::vector<unsigned int> &dof_to_boundary_mapping,
 -                                  SparsityPattern                 &sparsity_pattern);
++                                const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
++                                SparsityPattern                 &sparsity_pattern);
  
                                     /**
                                      * Write the sparsity structure of the
    template <class DH, class SparsityPattern>
    void
    make_boundary_sparsity_pattern (const DH &dof,
-                                                 const typename FunctionMap<DH::space_dimension>::type &boundary_indicators,
-                                                 const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
-                                                 SparsityPattern    &sparsity);
 -                                  const typename FunctionMap<DH::space_dimension>::type &boundary_indicators,
 -                                  const std::vector<unsigned int> &dof_to_boundary_mapping,
 -                                  SparsityPattern    &sparsity);
++                                const typename FunctionMap<DH::space_dimension>::type &boundary_indicators,
++                                const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
++                                SparsityPattern    &sparsity);
  
                                     /**
                                      * Generate sparsity pattern for
    template <int dim, int spacedim>
    void
    extract_dofs (const hp::DoFHandler<dim,spacedim>   &dof_handler,
-                       const std::vector<bool> &select,
-                       std::vector<bool>       &selected_dofs,
-                       const bool               blocks = false);
+                 const ComponentMask     &component_mask,
+                 std::vector<bool>       &selected_dofs);
  
-                                    /**
-                                     * Do the same thing as
-                                     * extract_dofs() for one level
-                                     * of a multi-grid DoF numbering.
-                                     */
+   /**
+    * This function is the equivalent to the DoFTools::extract_dofs() functions above
+    * except that the selection of which degrees of freedom to extract is not done
+    * based on components (see @ref GlossComponent) but instead based on whether they
+    * are part of a particular block (see @ref GlossBlock). Consequently, the second
+    * argument is not a ComponentMask but a BlockMask object.
+    *
+    * @param dof_handler The DoFHandler object from which to extract degrees of freedom
+    * @param block_mask The block mask that describes which blocks to consider (see
+    *       @ref GlossBlockMask)
+    * @param selected_dofs A vector of length DoFHandler::n_dofs() in which those
+    *       entries are true that correspond to the selected blocks.
+    */
+   template <int dim, int spacedim>
+   void
+   extract_dofs (const DoFHandler<dim,spacedim>   &dof_handler,
+                 const BlockMask &block_mask,
+                 std::vector<bool>       &selected_dofs);
+   /**
+    * The same function as above,
+    * but for a hp::DoFHandler.
+    */
+   template <int dim, int spacedim>
+   void
+   extract_dofs (const hp::DoFHandler<dim,spacedim>   &dof_handler,
+                 const BlockMask        &block_mask,
+                 std::vector<bool>       &selected_dofs);
+   /**
+    * Do the same thing as the corresponding
+    * extract_dofs() functino for one level
+    * of a multi-grid DoF numbering.
+    */
 -  template <int dim, int spacedim>
++  template <class DH>
+   void
+   extract_level_dofs (const unsigned int       level,
 -                      const MGDoFHandler<dim,spacedim> &dof,
++                      const DH &dof,
+                       const ComponentMask     &component_mask,
+                       std::vector<bool>       &selected_dofs);
+   /**
+    * Do the same thing as the corresponding
+    * extract_dofs() functino for one level
+    * of a multi-grid DoF numbering.
+    */
 -  template <int dim, int spacedim>
 +  template <class DH>
    void
    extract_level_dofs (const unsigned int       level,
-                             const DH &dof,
-                             const std::vector<bool> &select,
-                             std::vector<bool>       &selected_dofs,
-                             const bool               blocks = false);
 -                      const MGDoFHandler<dim,spacedim> &dof,
++                      const DH &dof,
+                       const BlockMask     &component_mask,
+                       std::vector<bool>       &selected_dofs);
  
    /**
     * Extract all degrees of freedom
    template <class DH>
    IndexSet
    dof_indices_with_subdomain_association (const DH           &dof_handler,
-                                                             const types::subdomain_id subdomain);
+                                           const types::subdomain_id subdomain);
 -
                                     // @}
                                     /**
                                      * @name Dof indices for patches
    template <class DH>
    void
    count_dofs_per_component (const DH &     dof_handler,
-                                       std::vector<types::global_dof_index>& dofs_per_component,
-                                       const bool vector_valued_once = false,
-                                       std::vector<types::global_dof_index>  target_component
-                                       = std::vector<types::global_dof_index>());
 -                            std::vector<unsigned int>& dofs_per_component,
 -                            const bool vector_valued_once = false,
 -                            std::vector<unsigned int>  target_component
 -                            = std::vector<unsigned int>());
++                          std::vector<types::global_dof_index>& dofs_per_component,
++                          const bool vector_valued_once = false,
++                          std::vector<types::global_dof_index>  target_component
++                          = std::vector<types::global_dof_index>());
  
                                     /**
                                      * Count the degrees of freedom
    template <int dim, int spacedim>
    void
    count_dofs_per_component (const DoFHandler<dim,spacedim>&     dof_handler,
-                                       std::vector<types::global_dof_index>& dofs_per_component,
-                                       std::vector<types::global_dof_index>  target_component);
 -                            std::vector<unsigned int>& dofs_per_component,
 -                            std::vector<unsigned int>  target_component);
++                          std::vector<types::global_dof_index>& dofs_per_component,
++                          std::vector<types::global_dof_index>  target_component);
  
                                     /**
                                      * This function can be used when
    template <class DH>
    void
    map_dof_to_boundary_indices (const DH                   &dof_handler,
-                                          std::vector<types::global_dof_index>  &mapping);
 -                               std::vector<unsigned int>  &mapping);
++                             std::vector<types::global_dof_index>  &mapping);
  
                                     /**
                                      * Same as the previous function,
    template <class DH>
    void
    map_dof_to_boundary_indices (const DH                      &dof_handler,
-                                          const std::set<types::boundary_id> &boundary_indicators,
-                                          std::vector<types::global_dof_index>     &mapping);
 -                               const std::set<types::boundary_id> &boundary_indicators,
 -                               std::vector<unsigned int>     &mapping);
++                             const std::set<types::boundary_id> &boundary_indicators,
++                             std::vector<types::global_dof_index>     &mapping);
  
                                     /**
                                      * Return a list of support
    template <int dim, int spacedim>
    void
    map_dofs_to_support_points (const Mapping<dim,spacedim>       &mapping,
-                                         const DoFHandler<dim,spacedim>    &dof_handler,
-                                         std::vector<Point<spacedim> >     &support_points);
+                               const DoFHandler<dim,spacedim>    &dof_handler,
+                               std::vector<Point<spacedim> >     &support_points);
  
              /**
 -             * Same as the previous function but for the hp case.
 +             * Same as above for the hp case.
               */
 +
    template <int dim, int spacedim>
    void
    map_dofs_to_support_points (const dealii::hp::MappingCollection<dim,spacedim>   &mapping,
    template <class DH, class Comp>
    void
    map_support_points_to_dofs (const Mapping<DH::dimension, DH::space_dimension> &mapping,
-                                         const DH                                          &dof_handler,
-                                         std::map<Point<DH::space_dimension>, types::global_dof_index, Comp> &point_to_index_map);
 -                              const DH                                          &dof_handler,
 -                              std::map<Point<DH::space_dimension>, unsigned int, Comp> &point_to_index_map);
++                            const DH                                          &dof_handler,
++                            std::map<Point<DH::space_dimension>, types::global_dof_index, Comp> &point_to_index_map);
  
                                     /**
                                      * Map a coupling table from the
index 4288c6d92ccc52e6cb0e91a91a6e6bd2c898a5ff,e011893a8ecbb9690636d5ce09c0e6988ae0e0fe..5b90025982735842422e8c9789992644c7f3dcaf
@@@ -59,14 -58,9 +59,14 @@@ class MGConstrainedDoFs : public Subscr
                                        */
      template <int dim, int spacedim>
      void initialize(const MGDoFHandler<dim,spacedim>& dof,
-                           const typename FunctionMap<dim>::type& function_map,
-                           const std::vector<bool>& component_mask = std::vector<bool>());
+                     const typename FunctionMap<dim>::type& function_map,
+                     const ComponentMask &component_mask = ComponentMask());
  
 +    template <int dim, int spacedim>
 +    void initialize(const DoFHandler<dim,spacedim>& dof,
 +                          const typename FunctionMap<dim>::type& function_map,
 +                          const std::vector<bool>& component_mask = std::vector<bool>());
 +
                                       /**
                                        * Reset the data structures.
                                        */
index b9b2b94cd8e9b79512d83cadab37e30638f97372,3dcf1b751eb5e5cb39c27edcfd4ae2b3f1be2a06..c724e722804bb5adcc05eb9f378dfd489b1ae58f
@@@ -173,11 -173,11 +173,11 @@@ namespace MGTool
                                      * for each block (access is
                                      * <tt>result[level][block]</tt>).
                                      */
 -  template <int dim, int spacedim>
 +  template <class DH>
    void
 -  count_dofs_per_block (const MGDoFHandler<dim,spacedim> &mg_dof,
 -                        std::vector<std::vector<unsigned int> > &result,
 -                        std::vector<unsigned int> target_block = std::vector<unsigned int>());
 +  count_dofs_per_block (const DH&     dof_handler,
-                       std::vector<std::vector<unsigned int> >& dofs_per_block,
-                       std::vector<unsigned int>  target_block = std::vector<unsigned int>());
++                        std::vector<std::vector<unsigned int> >& dofs_per_block,
++                        std::vector<unsigned int>  target_block = std::vector<unsigned int>());
  
                                     /**
                                      * Count the dofs component-wise
index b770a8085339d5dca95c054b49ffcc459d31d234,5e3cd8225739a583651b4b5730c68f8e2d86f393..6f489e05116eb89ae4d8afc8b69d3a11a09e9f20
@@@ -747,8 -747,8 +747,8 @@@ namespace VectorTool
    interpolate_boundary_values (const Mapping<DH::dimension,DH::space_dimension>            &mapping,
                                 const DH                 &dof,
                                 const typename FunctionMap<DH::space_dimension>::type &function_map,
 -                               std::map<unsigned int,double> &boundary_values,
 +                               std::map<types::global_dof_index,double> &boundary_values,
-                                const std::vector<bool>       &component_mask = std::vector<bool>());
+                                const ComponentMask       &component_mask = ComponentMask());
  
                                     /**
                                      * @deprecated This function exists mainly
                                 const DH                 &dof,
                                 const types::boundary_id            boundary_component,
                                 const Function<DH::space_dimension>           &boundary_function,
 -                               std::map<unsigned int,double> &boundary_values,
 +                               std::map<types::global_dof_index,double> &boundary_values,
-                                const std::vector<bool>       &component_mask = std::vector<bool>());
+                                const ComponentMask       &component_mask = ComponentMask());
  
                                     /**
                                      * Calls the other
    interpolate_boundary_values (const DH        &dof,
                                 const types::boundary_id            boundary_component,
                                 const Function<DH::space_dimension>           &boundary_function,
 -                               std::map<unsigned int,double> &boundary_values,
 +                               std::map<types::global_dof_index,double> &boundary_values,
-                                const std::vector<bool>       &component_mask = std::vector<bool>());
+                                const ComponentMask       &component_mask = ComponentMask());
  
  
                                     /**
    void
    interpolate_boundary_values (const DH                &dof,
                                 const typename FunctionMap<DH::space_dimension>::type &function_map,
 -                               std::map<unsigned int,double>         &boundary_values,
 +                               std::map<types::global_dof_index,double>         &boundary_values,
-                                const std::vector<bool>               &component_mask = std::vector<bool>());
+                                const ComponentMask               &component_mask = ComponentMask());
  
  
                                     /**
index ed9ffbac2553172066bb68cd6e34295b48d6aa59,aa7adf8d71a3addae44ab653e0d856abd4d9680d..c7c30bc3647e97fdc3b619d586a136453f22da2e
@@@ -1477,8 -1477,8 +1477,8 @@@ namespace VectorTool
      void interpolate_boundary_values (const Mapping<DH::dimension, DH::space_dimension> &,
                                        const DH                 &dof,
                                        const typename FunctionMap<DH::space_dimension>::type &function_map,
 -                                      std::map<unsigned int,double> &boundary_values,
 +                                      std::map<types::global_dof_index,double> &boundary_values,
-                                       const std::vector<bool>       &component_mask_,
+                                       const ComponentMask       &component_mask,
                                        const dealii::internal::int2type<1>)
      {
        const unsigned int dim = DH::dimension;
      interpolate_boundary_values (const Mapping<DH::dimension, DH::space_dimension> &mapping,
                                   const DH                 &dof,
                                   const typename FunctionMap<DH::space_dimension>::type &function_map,
 -                                 std::map<unsigned int,double> &boundary_values,
 +                                 std::map<types::global_dof_index,double> &boundary_values,
-                                  const std::vector<bool>       &component_mask_,
+                                  const ComponentMask       &component_mask,
                                   const dealii::internal::int2type<DH::dimension>)
      {
        const unsigned int dim = DH::dimension;
          Assert (n_components == i->second->n_components,
                  ExcDimensionMismatch(n_components, i->second->n_components));
  
-                                        // set the component mask to either
-                                        // the original value or a vector
-                                        // of trues
-       const std::vector<bool> component_mask ((component_mask_.size() == 0) ?
-                                               std::vector<bool> (n_components, true) :
-                                               component_mask_);
-       Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0,
-               ExcNoComponentSelected());
                                         // field to store the indices
 -      std::vector<unsigned int> face_dofs;
 +      std::vector<types::global_dof_index> face_dofs;
        face_dofs.reserve (DoFTools::max_dofs_per_face(dof));
  
        std::vector<Point<spacedim> >  dof_locations;
    interpolate_boundary_values (const Mapping<DH::dimension, DH::space_dimension>            &mapping,
                                 const DH                 &dof,
                                 const typename FunctionMap<DH::space_dimension>::type &function_map,
 -                               std::map<unsigned int,double> &boundary_values,
 +                               std::map<types::global_dof_index,double> &boundary_values,
-                                const std::vector<bool>       &component_mask_)
+                                const ComponentMask       &component_mask_)
    {
      internal::
        interpolate_boundary_values (mapping, dof, function_map, boundary_values,
                                 const DH                 &dof,
                                 const types::boundary_id            boundary_component,
                                 const Function<DH::space_dimension>           &boundary_function,
 -                               std::map<unsigned int,double> &boundary_values,
 +                               std::map<types::global_dof_index,double> &boundary_values,
-                                const std::vector<bool>       &component_mask)
+                                const ComponentMask       &component_mask)
    {
      typename FunctionMap<DH::space_dimension>::type function_map;
      function_map[boundary_component] = &boundary_function;
    interpolate_boundary_values (const DH                 &dof,
                                 const types::boundary_id            boundary_component,
                                 const Function<DH::space_dimension>           &boundary_function,
 -                               std::map<unsigned int,double> &boundary_values,
 +                               std::map<types::global_dof_index,double> &boundary_values,
-                                const std::vector<bool>       &component_mask)
+                                const ComponentMask       &component_mask)
    {
      Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping"));
      interpolate_boundary_values(StaticMappingQ1<DH::dimension,DH::space_dimension>::mapping,
    void
    interpolate_boundary_values (const DH                 &dof,
                                 const typename FunctionMap<DH::space_dimension>::type &function_map,
 -                               std::map<unsigned int,double> &boundary_values,
 +                               std::map<types::global_dof_index,double> &boundary_values,
-                                const std::vector<bool>       &component_mask)
+                                const ComponentMask       &component_mask)
    {
      Assert (DEAL_II_COMPAT_MAPPING, ExcCompatibility("mapping"));
      interpolate_boundary_values(StaticMappingQ1<DH::dimension,DH::space_dimension>::mapping,
     const DH                                              &dof,
     const typename FunctionMap<DH::space_dimension>::type &function_map,
     ConstraintMatrix                                      &constraints,
-    const std::vector<bool>                               &component_mask_)
+    const ComponentMask                               &component_mask_)
    {
 -    std::map<unsigned int,double> boundary_values;
 +    std::map<types::global_dof_index,double> boundary_values;
      interpolate_boundary_values (mapping, dof, function_map,
                                   boundary_values, component_mask_);
 -    std::map<unsigned int,double>::const_iterator boundary_value =
 +    std::map<types::global_dof_index,double>::const_iterator boundary_value =
        boundary_values.begin();
      for ( ; boundary_value !=boundary_values.end(); ++boundary_value)
        {
                                        update_JxW_values |
                                        update_quadrature_points |
                                        update_values);
+     std::vector<bool> dofs_processed;
      std::vector<double> dof_values;
 -    std::vector<unsigned int> face_dof_indices;
 +    std::vector<types::global_dof_index> face_dof_indices;
      typename hp::DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active ();
  
      switch (dim)
index b808d04f5ec75e561160789b06dd3bfed2b3c598,1d4cacf434f2ae0a01e82c19423dc67e474e19be..0a68adaa5cca92b7532404823b687b584be7020e
@@@ -1137,15 -714,15 +1044,15 @@@ DoFHandler<dim,spacedim>::last_active_f
    switch (dim)
      {
        case 1:
 -            Assert (false, ExcImpossibleInDim(1));
 -            return raw_face_iterator();
 +              Assert (false, ExcImpossibleInDim(1));
 +              return raw_face_iterator();
        case 2:
 -            return last_active_line ();
 +             return last_active_line ();
        case 3:
 -            return last_active_quad ();
 +             return last_active_quad ();
        default:
-               Assert (false, ExcNotImplemented());
-               return raw_face_iterator ();
+             Assert (false, ExcNotImplemented());
+             return face_iterator ();
      }
  }
  
@@@ -1155,30 -741,34 +1071,32 @@@ DoFHandler<dim,spacedim>::begin_raw_lin
  
  
  template <int dim, int spacedim>
- typename DoFHandler<dim, spacedim>::raw_line_iterator
- DoFHandler<dim, spacedim>::begin_raw_line (const unsigned int level) const
+ typename DoFHandler<dim,spacedim>::line_iterator
+ DoFHandler<dim,spacedim>::begin_line (const unsigned int level) const
  {
-   Assert(tria != 0, ExcNotInitialized());
-   switch (dim)
-     {
-       case 1:
-               Assert (level<tria->n_levels(), ExcInvalidLevel(level));
+   typename Triangulation<dim,spacedim>::line_iterator ti = tria->begin_line(level);
+   typename DoFHandler<dim, spacedim>::line_iterator ri(*ti, this);
+   return ri;
+ }
  
-               if (tria->n_raw_lines(level) == 0)
-                 return end_line ();
 -
 -
+ template <int dim, int spacedim>
+ typename DoFHandler<dim, spacedim>::active_line_iterator
+ DoFHandler<dim, spacedim>::begin_active_line (const unsigned int level) const
+ {
+   typename Triangulation<dim,spacedim>::active_line_iterator ti = tria->begin_active_line(level);
+   typename DoFHandler<dim, spacedim>::active_line_iterator ri(*ti, this);
+   return ri;
+ }
  
-               return raw_line_iterator (tria,
-                                                     level,
-                                                     0,
-                                                     this);
  
-       default:
-               Assert (level == 0, ExcFacesHaveNoLevel());
-               return raw_line_iterator (tria,
-                                                     0,
-                                                     0,
-                                                     this);
-     }
+ template <int dim, int spacedim>
+ typename DoFHandler<dim, spacedim>::raw_line_iterator
+ DoFHandler<dim, spacedim>::end_raw_line (const unsigned int level) const
+ {
+   typename Triangulation<dim,spacedim>::raw_line_iterator ti = tria->end_raw_line(level);
+   typename DoFHandler<dim, spacedim>::raw_line_iterator ri(ti.access_any(), this);
+   return ri;
  }
  
  
index fdf9356d4e487d990bb0db7476f77fbe3538c7a4,a955d6d26b21a6cebe01ff2c1fd250bbc4471b6a..ab9851811a3c240b3a57e8e3d2e51aef2447597a
@@@ -80,13 -80,13 +80,13 @@@ namespace DoFTool
        ||
        (subdomain_id == dof.get_tria().locally_owned_subdomain()),
        ExcMessage ("For parallel::distributed::Triangulation objects and "
-                         "associated DoF handler objects, asking for any subdomain other "
-                         "than the locally owned one does not make sense."));
+                   "associated DoF handler objects, asking for any subdomain other "
+                   "than the locally owned one does not make sense."));
  
 -    std::vector<unsigned int> dofs_on_this_cell;
 +    std::vector<types::global_dof_index> dofs_on_this_cell;
      dofs_on_this_cell.reserve (max_dofs_per_cell(dof));
      typename DH::active_cell_iterator cell = dof.begin_active(),
-                                                     endc = dof.end();
+                                       endc = dof.end();
  
                                       // In case we work with a distributed
                                       // sparsity pattern of Trilinos type, we
  
      if (need_dof_mask == true)
        for (unsigned int f=0; f<fe_collection.size(); ++f)
-           {
-             const unsigned int dofs_per_cell = fe_collection[f].dofs_per_cell;
-             dof_mask[f].reinit (dofs_per_cell, dofs_per_cell);
-             for (unsigned int i=0; i<dofs_per_cell; ++i)
-               for (unsigned int j=0; j<dofs_per_cell; ++j)
-                 if (fe_collection[f].is_primitive(i) &&
-                         fe_collection[f].is_primitive(j))
-                       dof_mask[f](i,j)
-                         = (couplings(fe_collection[f].system_to_component_index(i).first,
-                                          fe_collection[f].system_to_component_index(j).first) != none);
-                 else
-                       {
-                         const unsigned int first_nonzero_comp_i
-                           = (std::find (fe_collection[f].get_nonzero_components(i).begin(),
-                                                 fe_collection[f].get_nonzero_components(i).end(),
-                                                 true)
-                              -
-                              fe_collection[f].get_nonzero_components(i).begin());
-                         const unsigned int first_nonzero_comp_j
-                           = (std::find (fe_collection[f].get_nonzero_components(j).begin(),
-                                                 fe_collection[f].get_nonzero_components(j).end(),
-                                                 true)
-                              -
-                              fe_collection[f].get_nonzero_components(j).begin());
-                         Assert (first_nonzero_comp_i < fe_collection[f].n_components(),
-                                     ExcInternalError());
-                         Assert (first_nonzero_comp_j < fe_collection[f].n_components(),
-                                     ExcInternalError());
-                         dof_mask[f](i,j)
-                           = (couplings(first_nonzero_comp_i,first_nonzero_comp_j) != none);
-                       }
-           }
+         {
+           const unsigned int dofs_per_cell = fe_collection[f].dofs_per_cell;
+           dof_mask[f].reinit (dofs_per_cell, dofs_per_cell);
+           for (unsigned int i=0; i<dofs_per_cell; ++i)
+             for (unsigned int j=0; j<dofs_per_cell; ++j)
+               if (fe_collection[f].is_primitive(i) &&
+                   fe_collection[f].is_primitive(j))
+                 dof_mask[f](i,j)
+                   = (couplings(fe_collection[f].system_to_component_index(i).first,
+                                fe_collection[f].system_to_component_index(j).first) != none);
+               else
+                 {
+                   const unsigned int first_nonzero_comp_i
+                   = fe_collection[f].get_nonzero_components(i).first_selected_component();
+                   const unsigned int first_nonzero_comp_j
+                   = fe_collection[f].get_nonzero_components(j).first_selected_component();
+                   Assert (first_nonzero_comp_i < fe_collection[f].n_components(),
+                           ExcInternalError());
+                   Assert (first_nonzero_comp_j < fe_collection[f].n_components(),
+                           ExcInternalError());
+                   dof_mask[f](i,j)
+                     = (couplings(first_nonzero_comp_i,first_nonzero_comp_j) != none);
+                 }
+         }
  
  
 -    std::vector<unsigned int> dofs_on_this_cell(fe_collection.max_dofs_per_cell());
 +    std::vector<types::global_dof_index> dofs_on_this_cell(fe_collection.max_dofs_per_cell());
      typename DH::active_cell_iterator cell = dof.begin_active(),
-                                                     endc = dof.end();
+                                       endc = dof.end();
  
                                       // In case we work with a distributed
                                       // sparsity pattern of Trilinos type, we
  
  
      const std::list<std::pair<typename DH::cell_iterator,
--      typename DH::cell_iterator> >
++                              typename DH::cell_iterator> >
        cell_list
        = GridTools::get_finest_common_cells (dof_row, dof_col);
  
  
      for (; cell_iter!=cell_list.end(); ++cell_iter)
        {
-           const typename DH::cell_iterator cell_row = cell_iter->first;
-           const typename DH::cell_iterator cell_col = cell_iter->second;
-           if (!cell_row->has_children() && !cell_col->has_children())
+         const typename DH::cell_iterator cell_row = cell_iter->first;
+         const typename DH::cell_iterator cell_col = cell_iter->second;
 -        if (!cell_row->has_children() && !cell_col->has_children())
 -          {
 -            const unsigned int dofs_per_cell_row =
 -              cell_row->get_fe().dofs_per_cell;
 -            const unsigned int dofs_per_cell_col =
 -              cell_col->get_fe().dofs_per_cell;
 -            std::vector<unsigned int>
 -              local_dof_indices_row(dofs_per_cell_row);
 -            std::vector<unsigned int>
 -              local_dof_indices_col(dofs_per_cell_col);
 -            cell_row->get_dof_indices (local_dof_indices_row);
 -            cell_col->get_dof_indices (local_dof_indices_col);
 -            for (unsigned int i=0; i<dofs_per_cell_row; ++i)
 -              sparsity.add_entries (local_dof_indices_row[i],
 -                                    local_dof_indices_col.begin(),
 -                                    local_dof_indices_col.end());
 -          }
 -        else if (cell_row->has_children())
 -          {
 -            const std::vector<typename DH::active_cell_iterator >
 -              child_cells = GridTools::get_active_child_cells<DH> (cell_row);
 -            for (unsigned int i=0; i<child_cells.size(); i++)
 -              {
 -                const typename DH::active_cell_iterator
 -                  cell_row_child = child_cells[i];
 -                const unsigned int dofs_per_cell_row =
 -                  cell_row_child->get_fe().dofs_per_cell;
 -                const unsigned int dofs_per_cell_col =
 -                  cell_col->get_fe().dofs_per_cell;
 -                std::vector<unsigned int>
 -                  local_dof_indices_row(dofs_per_cell_row);
 -                std::vector<unsigned int>
 -                  local_dof_indices_col(dofs_per_cell_col);
 -                cell_row_child->get_dof_indices (local_dof_indices_row);
 -                cell_col->get_dof_indices (local_dof_indices_col);
 -                for (unsigned int i=0; i<dofs_per_cell_row; ++i)
 -                  sparsity.add_entries (local_dof_indices_row[i],
 -                                        local_dof_indices_col.begin(),
 -                                        local_dof_indices_col.end());
 -              }
 -          }
 -        else
 -          {
 -            std::vector<typename DH::active_cell_iterator>
 -              child_cells = GridTools::get_active_child_cells<DH> (cell_col);
 -            for (unsigned int i=0; i<child_cells.size(); i++)
 -              {
 -                const typename DH::active_cell_iterator
 -                  cell_col_child = child_cells[i];
 -                const unsigned int dofs_per_cell_row =
 -                  cell_row->get_fe().dofs_per_cell;
 -                const unsigned int dofs_per_cell_col =
 -                  cell_col_child->get_fe().dofs_per_cell;
 -                std::vector<unsigned int>
 -                  local_dof_indices_row(dofs_per_cell_row);
 -                std::vector<unsigned int>
 -                  local_dof_indices_col(dofs_per_cell_col);
 -                cell_row->get_dof_indices (local_dof_indices_row);
 -                cell_col_child->get_dof_indices (local_dof_indices_col);
 -                for (unsigned int i=0; i<dofs_per_cell_row; ++i)
 -                  sparsity.add_entries (local_dof_indices_row[i],
 -                                        local_dof_indices_col.begin(),
 -                                        local_dof_indices_col.end());
 -              }
 -          }
++      if (!cell_row->has_children() && !cell_col->has_children())
++        {
++          const unsigned int dofs_per_cell_row =
++            cell_row->get_fe().dofs_per_cell;
++          const unsigned int dofs_per_cell_col =
++            cell_col->get_fe().dofs_per_cell;
++          std::vector<types::global_dof_index>
++            local_dof_indices_row(dofs_per_cell_row);
++          std::vector<types::global_dof_index>
++            local_dof_indices_col(dofs_per_cell_col);
++          cell_row->get_dof_indices (local_dof_indices_row);
++          cell_col->get_dof_indices (local_dof_indices_col);
++          for (unsigned int i=0; i<dofs_per_cell_row; ++i)
++            sparsity.add_entries (local_dof_indices_row[i],
++                                  local_dof_indices_col.begin(),
++                                  local_dof_indices_col.end());
++        }
++      else if (cell_row->has_children())
++        {
++          const std::vector<typename DH::active_cell_iterator >
++            child_cells = GridTools::get_active_child_cells<DH> (cell_row);
++          for (unsigned int i=0; i<child_cells.size(); i++)
 +            {
-               const unsigned int dofs_per_cell_row =
-                 cell_row->get_fe().dofs_per_cell;
-               const unsigned int dofs_per_cell_col =
-                 cell_col->get_fe().dofs_per_cell;
-               std::vector<types::global_dof_index>
-                 local_dof_indices_row(dofs_per_cell_row);
-               std::vector<types::global_dof_index>
-                 local_dof_indices_col(dofs_per_cell_col);
-               cell_row->get_dof_indices (local_dof_indices_row);
-               cell_col->get_dof_indices (local_dof_indices_col);
-               for (unsigned int i=0; i<dofs_per_cell_row; ++i)
-                 sparsity.add_entries (local_dof_indices_row[i],
-                                                   local_dof_indices_col.begin(),
-                                                   local_dof_indices_col.end());
++              const typename DH::active_cell_iterator
++                cell_row_child = child_cells[i];
++              const unsigned int dofs_per_cell_row =
++                cell_row_child->get_fe().dofs_per_cell;
++              const unsigned int dofs_per_cell_col =
++                cell_col->get_fe().dofs_per_cell;
++              std::vector<types::global_dof_index>
++                local_dof_indices_row(dofs_per_cell_row);
++              std::vector<types::global_dof_index>
++                local_dof_indices_col(dofs_per_cell_col);
++              cell_row_child->get_dof_indices (local_dof_indices_row);
++              cell_col->get_dof_indices (local_dof_indices_col);
++              for (unsigned int i=0; i<dofs_per_cell_row; ++i)
++                sparsity.add_entries (local_dof_indices_row[i],
++                                      local_dof_indices_col.begin(),
++                                      local_dof_indices_col.end());
 +            }
-           else if (cell_row->has_children())
++        }
++      else
++        {
++          std::vector<typename DH::active_cell_iterator>
++            child_cells = GridTools::get_active_child_cells<DH> (cell_col);
++          for (unsigned int i=0; i<child_cells.size(); i++)
 +            {
-               const std::vector<typename DH::active_cell_iterator >
-                 child_cells = GridTools::get_active_child_cells<DH> (cell_row);
-               for (unsigned int i=0; i<child_cells.size(); i++)
-                 {
-                       const typename DH::active_cell_iterator
-                         cell_row_child = child_cells[i];
-                       const unsigned int dofs_per_cell_row =
-                         cell_row_child->get_fe().dofs_per_cell;
-                       const unsigned int dofs_per_cell_col =
-                         cell_col->get_fe().dofs_per_cell;
-                       std::vector<types::global_dof_index>
-                         local_dof_indices_row(dofs_per_cell_row);
-                       std::vector<types::global_dof_index>
-                         local_dof_indices_col(dofs_per_cell_col);
-                       cell_row_child->get_dof_indices (local_dof_indices_row);
-                       cell_col->get_dof_indices (local_dof_indices_col);
-                       for (unsigned int i=0; i<dofs_per_cell_row; ++i)
-                         sparsity.add_entries (local_dof_indices_row[i],
-                                                           local_dof_indices_col.begin(),
-                                                           local_dof_indices_col.end());
-                 }
-             }
-           else
-             {
-               std::vector<typename DH::active_cell_iterator>
-                 child_cells = GridTools::get_active_child_cells<DH> (cell_col);
-               for (unsigned int i=0; i<child_cells.size(); i++)
-                 {
-                       const typename DH::active_cell_iterator
-                         cell_col_child = child_cells[i];
-                       const unsigned int dofs_per_cell_row =
-                         cell_row->get_fe().dofs_per_cell;
-                       const unsigned int dofs_per_cell_col =
-                         cell_col_child->get_fe().dofs_per_cell;
-                       std::vector<types::global_dof_index>
-                         local_dof_indices_row(dofs_per_cell_row);
-                       std::vector<types::global_dof_index>
-                         local_dof_indices_col(dofs_per_cell_col);
-                       cell_row->get_dof_indices (local_dof_indices_row);
-                       cell_col_child->get_dof_indices (local_dof_indices_col);
-                       for (unsigned int i=0; i<dofs_per_cell_row; ++i)
-                         sparsity.add_entries (local_dof_indices_row[i],
-                                                           local_dof_indices_col.begin(),
-                                                           local_dof_indices_col.end());
-                 }
++              const typename DH::active_cell_iterator
++                cell_col_child = child_cells[i];
++              const unsigned int dofs_per_cell_row =
++                cell_row->get_fe().dofs_per_cell;
++              const unsigned int dofs_per_cell_col =
++                cell_col_child->get_fe().dofs_per_cell;
++              std::vector<types::global_dof_index>
++                local_dof_indices_row(dofs_per_cell_row);
++              std::vector<types::global_dof_index>
++                local_dof_indices_col(dofs_per_cell_col);
++              cell_row->get_dof_indices (local_dof_indices_row);
++              cell_col_child->get_dof_indices (local_dof_indices_col);
++              for (unsigned int i=0; i<dofs_per_cell_row; ++i)
++                sparsity.add_entries (local_dof_indices_row[i],
++                                      local_dof_indices_col.begin(),
++                                      local_dof_indices_col.end());
 +            }
++        }
        }
    }
  
  #ifdef DEBUG
      if (sparsity.n_rows() != 0)
        {
-           unsigned int max_element = 0;
-           for (std::vector<types::global_dof_index>::const_iterator i=dof_to_boundary_mapping.begin();
-                i!=dof_to_boundary_mapping.end(); ++i)
-             if ((*i != DH::invalid_dof_index) &&
-                 (*i > max_element))
-               max_element = *i;
-           AssertDimension (max_element, sparsity.n_rows()-1);
 -        unsigned int max_element = 0;
 -        for (std::vector<unsigned int>::const_iterator i=dof_to_boundary_mapping.begin();
 -             i!=dof_to_boundary_mapping.end(); ++i)
 -          if ((*i != DH::invalid_dof_index) &&
 -              (*i > max_element))
 -            max_element = *i;
 -        AssertDimension (max_element, sparsity.n_rows()-1);
++      types::global_dof_index max_element = 0;
++      for (std::vector<types::global_dof_index>::const_iterator i=dof_to_boundary_mapping.begin();
++           i!=dof_to_boundary_mapping.end(); ++i)
++        if ((*i != DH::invalid_dof_index) &&
++            (*i > max_element))
++          max_element = *i;
++      AssertDimension (max_element, sparsity.n_rows()-1);
        };
  #endif
  
                                               // find active cell at that
                                               // boundary: first go to
                                               // left/right, then to children
-               typename DH::cell_iterator cell = dof.begin(0);
-               while (!cell->at_boundary(direction))
-                 cell = cell->neighbor(direction);
-               while (!cell->active())
-                 cell = cell->child(direction);
+             typename DH::cell_iterator cell = dof.begin(0);
+             while (!cell->at_boundary(direction))
+               cell = cell->neighbor(direction);
+             while (!cell->active())
+               cell = cell->child(direction);
  
-               const unsigned int dofs_per_vertex = cell->get_fe().dofs_per_vertex;
-               std::vector<types::global_dof_index> boundary_dof_boundary_indices (dofs_per_vertex);
 -            const unsigned int dofs_per_vertex = cell->get_fe().dofs_per_vertex;
 -            std::vector<unsigned int> boundary_dof_boundary_indices (dofs_per_vertex);
++          const unsigned int dofs_per_vertex = cell->get_fe().dofs_per_vertex;
++          std::vector<types::global_dof_index> boundary_dof_boundary_indices (dofs_per_vertex);
  
                                               // next get boundary mapped dof
                                               // indices of boundary dofs
  #ifdef DEBUG
      if (sparsity.n_rows() != 0)
        {
-           unsigned int max_element = 0;
-           for (std::vector<types::global_dof_index>::const_iterator i=dof_to_boundary_mapping.begin();
-                i!=dof_to_boundary_mapping.end(); ++i)
-             if ((*i != DH::invalid_dof_index) &&
-                 (*i > max_element))
-               max_element = *i;
-           AssertDimension (max_element, sparsity.n_rows()-1);
 -        unsigned int max_element = 0;
 -        for (std::vector<unsigned int>::const_iterator i=dof_to_boundary_mapping.begin();
 -             i!=dof_to_boundary_mapping.end(); ++i)
 -          if ((*i != DH::invalid_dof_index) &&
 -              (*i > max_element))
 -            max_element = *i;
 -        AssertDimension (max_element, sparsity.n_rows()-1);
++      types::global_dof_index max_element = 0;
++      for (std::vector<types::global_dof_index>::const_iterator i=dof_to_boundary_mapping.begin();
++           i!=dof_to_boundary_mapping.end(); ++i)
++        if ((*i != DH::invalid_dof_index) &&
++            (*i > max_element))
++          max_element = *i;
++      AssertDimension (max_element, sparsity.n_rows()-1);
        };
  #endif
  
 -    std::vector<unsigned int> dofs_on_this_face;
 +    std::vector<types::global_dof_index> dofs_on_this_face;
      dofs_on_this_face.reserve (max_dofs_per_face(dof));
      typename DH::active_cell_iterator cell = dof.begin_active(),
-                                                     endc = dof.end();
+                                       endc = dof.end();
      for (; cell!=endc; ++cell)
        for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
-           if (boundary_indicators.find(cell->face(f)->boundary_indicator()) !=
-               boundary_indicators.end())
-             {
-               const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
-               dofs_on_this_face.resize (dofs_per_face);
-               cell->face(f)->get_dof_indices (dofs_on_this_face,
-                                                               cell->active_fe_index());
+         if (boundary_indicators.find(cell->face(f)->boundary_indicator()) !=
+             boundary_indicators.end())
+           {
+             const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
+             dofs_on_this_face.resize (dofs_per_face);
+             cell->face(f)->get_dof_indices (dofs_on_this_face,
+                                             cell->active_fe_index());
  
                                               // make sparsity pattern for this cell
-               for (unsigned int i=0; i<dofs_per_face; ++i)
-                 for (unsigned int j=0; j<dofs_per_face; ++j)
-                       sparsity.add (dof_to_boundary_mapping[dofs_on_this_face[i]],
-                                         dof_to_boundary_mapping[dofs_on_this_face[j]]);
-             }
+             for (unsigned int i=0; i<dofs_per_face; ++i)
+               for (unsigned int j=0; j<dofs_per_face; ++j)
+                 sparsity.add (dof_to_boundary_mapping[dofs_on_this_face[i]],
+                               dof_to_boundary_mapping[dofs_on_this_face[j]]);
+           }
    }
  
  
        ||
        (subdomain_id == dof.get_tria().locally_owned_subdomain()),
        ExcMessage ("For parallel::distributed::Triangulation objects and "
-                         "associated DoF handler objects, asking for any subdomain other "
-                         "than the locally owned one does not make sense."));
+                   "associated DoF handler objects, asking for any subdomain other "
+                   "than the locally owned one does not make sense."));
  
 -    std::vector<unsigned int> dofs_on_this_cell;
 -    std::vector<unsigned int> dofs_on_other_cell;
 +    std::vector<types::global_dof_index> dofs_on_this_cell;
 +    std::vector<types::global_dof_index> dofs_on_other_cell;
      dofs_on_this_cell.reserve (max_dofs_per_cell(dof));
      dofs_on_other_cell.reserve (max_dofs_per_cell(dof));
      typename DH::active_cell_iterator cell = dof.begin_active(),
        template <class DH, class SparsityPattern>
        void
        make_flux_sparsity_pattern (const DH                &dof,
-                                                 SparsityPattern         &sparsity,
-                                                 const Table<2,Coupling> &int_mask,
-                                                 const Table<2,Coupling> &flux_mask)
+                                   SparsityPattern         &sparsity,
+                                   const Table<2,Coupling> &int_mask,
+                                   const Table<2,Coupling> &flux_mask)
        {
-           const FiniteElement<DH::dimension,DH::space_dimension> &fe = dof.get_fe();
+         const FiniteElement<DH::dimension,DH::space_dimension> &fe = dof.get_fe();
  
-           std::vector<types::global_dof_index> dofs_on_this_cell(fe.dofs_per_cell);
-           std::vector<types::global_dof_index> dofs_on_other_cell(fe.dofs_per_cell);
 -        std::vector<unsigned int> dofs_on_this_cell(fe.dofs_per_cell);
 -        std::vector<unsigned int> dofs_on_other_cell(fe.dofs_per_cell);
++      std::vector<types::global_dof_index> dofs_on_this_cell(fe.dofs_per_cell);
++      std::vector<types::global_dof_index> dofs_on_other_cell(fe.dofs_per_cell);
  
-           const Table<2,Coupling>
-             int_dof_mask  = dof_couplings_from_component_couplings(fe, int_mask),
-             flux_dof_mask = dof_couplings_from_component_couplings(fe, flux_mask);
+         const Table<2,Coupling>
+           int_dof_mask  = dof_couplings_from_component_couplings(fe, int_mask),
+           flux_dof_mask = dof_couplings_from_component_couplings(fe, flux_mask);
  
-           Table<2,bool> support_on_face(fe.dofs_per_cell,
-                                                     GeometryInfo<DH::dimension>::faces_per_cell);
-           for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
-             for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell;++f)
-               support_on_face(i,f) = fe.has_support_on_face(i,f);
+         Table<2,bool> support_on_face(fe.dofs_per_cell,
+                                       GeometryInfo<DH::dimension>::faces_per_cell);
+         for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+           for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell;++f)
+             support_on_face(i,f) = fe.has_support_on_face(i,f);
  
-           typename DH::active_cell_iterator cell = dof.begin_active(),
-                                                             endc = dof.end();
-           for (; cell!=endc; ++cell)
+         typename DH::active_cell_iterator cell = dof.begin_active(),
+                                           endc = dof.end();
+         for (; cell!=endc; ++cell)
            if (cell->is_locally_owned())
-               {
-                 cell->get_dof_indices (dofs_on_this_cell);
+             {
+               cell->get_dof_indices (dofs_on_this_cell);
                                                 // make sparsity pattern for this cell
-                 for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
-                       for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
-                         if (int_dof_mask(i,j) != none)
-                           sparsity.add (dofs_on_this_cell[i],
-                                                 dofs_on_this_cell[j]);
+               for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+                 for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
+                   if (int_dof_mask(i,j) != none)
+                     sparsity.add (dofs_on_this_cell[i],
+                                   dofs_on_this_cell[j]);
  
                                                 // Loop over all interior neighbors
-                 for (unsigned int face = 0;
-                          face < GeometryInfo<DH::dimension>::faces_per_cell;
-                          ++face)
-                       {
-                         const typename DH::face_iterator
-                           cell_face = cell->face(face);
-                         if (cell_face->user_flag_set ())
-                           continue;
-                         if (cell->at_boundary (face) )
-                           {
-                             for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
-                                   {
-                                     const bool i_non_zero_i = support_on_face (i, face);
-                                     for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
-                                       {
-                                         const bool j_non_zero_i = support_on_face (j, face);
-                                         if ((flux_dof_mask(i,j) == always)
-                                                 ||
-                                                 (flux_dof_mask(i,j) == nonzero
-                                                  &&
-                                                  i_non_zero_i
-                                                  &&
-                                                  j_non_zero_i))
-                                               sparsity.add (dofs_on_this_cell[i],
-                                                                 dofs_on_this_cell[j]);
-                                       }
-                                   }
-                           }
-                         else
-                           {
-                             typename DH::cell_iterator
-                                   neighbor = cell->neighbor(face);
+               for (unsigned int face = 0;
+                    face < GeometryInfo<DH::dimension>::faces_per_cell;
+                    ++face)
+                 {
+                   const typename DH::face_iterator
+                     cell_face = cell->face(face);
+                   if (cell_face->user_flag_set ())
+                     continue;
+                   if (cell->at_boundary (face) )
+                     {
+                       for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+                         {
+                           const bool i_non_zero_i = support_on_face (i, face);
+                           for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
+                             {
+                               const bool j_non_zero_i = support_on_face (j, face);
+                               if ((flux_dof_mask(i,j) == always)
+                                   ||
+                                   (flux_dof_mask(i,j) == nonzero
+                                    &&
+                                    i_non_zero_i
+                                    &&
+                                    j_non_zero_i))
+                                 sparsity.add (dofs_on_this_cell[i],
+                                               dofs_on_this_cell[j]);
+                             }
+                         }
+                     }
+                   else
+                     {
+                       typename DH::cell_iterator
+                         neighbor = cell->neighbor(face);
                                                         // Refinement edges are taken care of
                                                         // by coarser cells
-                             if (cell->neighbor_is_coarser(face))
-                                   continue;
-                             typename DH::face_iterator cell_face = cell->face(face);
-                             const unsigned int
-                                   neighbor_face = cell->neighbor_of_neighbor(face);
-                             if (cell_face->has_children())
-                                   {
-                                     for (unsigned int sub_nr = 0;
-                                          sub_nr != cell_face->n_children();
-                                          ++sub_nr)
-                                       {
-                                         const typename DH::cell_iterator
-                                               sub_neighbor
-                                               = cell->neighbor_child_on_subface (face, sub_nr);
-                                         sub_neighbor->get_dof_indices (dofs_on_other_cell);
-                                         for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
-                                               {
-                                                 const bool i_non_zero_i = support_on_face (i, face);
-                                                 const bool i_non_zero_e = support_on_face (i, neighbor_face);
-                                                 for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
-                                                   {
-                                                     const bool j_non_zero_i = support_on_face (j, face);
-                                                     const bool j_non_zero_e = support_on_face (j, neighbor_face);
-                                                     if (flux_dof_mask(i,j) == always)
-                                                           {
-                                                             sparsity.add (dofs_on_this_cell[i],
-                                                                                   dofs_on_other_cell[j]);
-                                                             sparsity.add (dofs_on_other_cell[i],
-                                                                                   dofs_on_this_cell[j]);
-                                                             sparsity.add (dofs_on_this_cell[i],
-                                                                                   dofs_on_this_cell[j]);
-                                                             sparsity.add (dofs_on_other_cell[i],
-                                                                                   dofs_on_other_cell[j]);
-                                                           }
-                                                     else if (flux_dof_mask(i,j) == nonzero)
-                                                           {
-                                                             if (i_non_zero_i && j_non_zero_e)
-                                                               sparsity.add (dofs_on_this_cell[i],
-                                                                                     dofs_on_other_cell[j]);
-                                                             if (i_non_zero_e && j_non_zero_i)
-                                                               sparsity.add (dofs_on_other_cell[i],
-                                                                                     dofs_on_this_cell[j]);
-                                                             if (i_non_zero_i && j_non_zero_i)
-                                                               sparsity.add (dofs_on_this_cell[i],
-                                                                                     dofs_on_this_cell[j]);
-                                                             if (i_non_zero_e && j_non_zero_e)
-                                                               sparsity.add (dofs_on_other_cell[i],
-                                                                                     dofs_on_other_cell[j]);
-                                                           }
-                                                     if (flux_dof_mask(j,i) == always)
-                                                           {
-                                                             sparsity.add (dofs_on_this_cell[j],
-                                                                                   dofs_on_other_cell[i]);
-                                                             sparsity.add (dofs_on_other_cell[j],
-                                                                                   dofs_on_this_cell[i]);
-                                                             sparsity.add (dofs_on_this_cell[j],
-                                                                                   dofs_on_this_cell[i]);
-                                                             sparsity.add (dofs_on_other_cell[j],
-                                                                                   dofs_on_other_cell[i]);
-                                                           }
-                                                     else if (flux_dof_mask(j,i) == nonzero)
-                                                           {
-                                                             if (j_non_zero_i && i_non_zero_e)
-                                                               sparsity.add (dofs_on_this_cell[j],
-                                                                                     dofs_on_other_cell[i]);
-                                                             if (j_non_zero_e && i_non_zero_i)
-                                                               sparsity.add (dofs_on_other_cell[j],
-                                                                                     dofs_on_this_cell[i]);
-                                                             if (j_non_zero_i && i_non_zero_i)
-                                                               sparsity.add (dofs_on_this_cell[j],
-                                                                                     dofs_on_this_cell[i]);
-                                                             if (j_non_zero_e && i_non_zero_e)
-                                                               sparsity.add (dofs_on_other_cell[j],
-                                                                                     dofs_on_other_cell[i]);
-                                                           }
-                                                   }
-                                               }
-                                         sub_neighbor->face(neighbor_face)->set_user_flag ();
-                                       }
-                                   }
-                             else
-                                   {
-                                     neighbor->get_dof_indices (dofs_on_other_cell);
-                                     for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
-                                       {
-                                         const bool i_non_zero_i = support_on_face (i, face);
-                                         const bool i_non_zero_e = support_on_face (i, neighbor_face);
-                                         for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
-                                               {
-                                                 const bool j_non_zero_i = support_on_face (j, face);
-                                                 const bool j_non_zero_e = support_on_face (j, neighbor_face);
-                                                 if (flux_dof_mask(i,j) == always)
-                                                   {
-                                                     sparsity.add (dofs_on_this_cell[i],
-                                                                           dofs_on_other_cell[j]);
-                                                     sparsity.add (dofs_on_other_cell[i],
-                                                                           dofs_on_this_cell[j]);
-                                                     sparsity.add (dofs_on_this_cell[i],
-                                                                           dofs_on_this_cell[j]);
-                                                     sparsity.add (dofs_on_other_cell[i],
-                                                                           dofs_on_other_cell[j]);
-                                                   }
-                                                 if (flux_dof_mask(i,j) == nonzero)
-                                                   {
-                                                     if (i_non_zero_i && j_non_zero_e)
-                                                           sparsity.add (dofs_on_this_cell[i],
-                                                                             dofs_on_other_cell[j]);
-                                                     if (i_non_zero_e && j_non_zero_i)
-                                                           sparsity.add (dofs_on_other_cell[i],
-                                                                             dofs_on_this_cell[j]);
-                                                     if (i_non_zero_i && j_non_zero_i)
-                                                           sparsity.add (dofs_on_this_cell[i],
-                                                                             dofs_on_this_cell[j]);
-                                                     if (i_non_zero_e && j_non_zero_e)
-                                                       sparsity.add (dofs_on_other_cell[i],
-                                                                             dofs_on_other_cell[j]);
-                                                   }
-                                                 if (flux_dof_mask(j,i) == always)
-                                                   {
-                                                     sparsity.add (dofs_on_this_cell[j],
-                                                                           dofs_on_other_cell[i]);
-                                                     sparsity.add (dofs_on_other_cell[j],
-                                                                           dofs_on_this_cell[i]);
-                                                     sparsity.add (dofs_on_this_cell[j],
-                                                                           dofs_on_this_cell[i]);
-                                                     sparsity.add (dofs_on_other_cell[j],
-                                                                           dofs_on_other_cell[i]);
-                                                   }
-                                                 if (flux_dof_mask(j,i) == nonzero)
-                                                   {
-                                                     if (j_non_zero_i && i_non_zero_e)
-                                                           sparsity.add (dofs_on_this_cell[j],
-                                                                             dofs_on_other_cell[i]);
-                                                     if (j_non_zero_e && i_non_zero_i)
-                                                           sparsity.add (dofs_on_other_cell[j],
-                                                                             dofs_on_this_cell[i]);
-                                                     if (j_non_zero_i && i_non_zero_i)
-                                                           sparsity.add (dofs_on_this_cell[j],
-                                                                             dofs_on_this_cell[i]);
-                                                     if (j_non_zero_e && i_non_zero_e)
-                                                           sparsity.add (dofs_on_other_cell[j],
-                                                                             dofs_on_other_cell[i]);
-                                                   }
-                                               }
-                                       }
-                                     neighbor->face(neighbor_face)->set_user_flag ();
-                                   }
-                           }
-                       }
+                       if (cell->neighbor_is_coarser(face))
+                         continue;
+                       typename DH::face_iterator cell_face = cell->face(face);
+                       const unsigned int
+                         neighbor_face = cell->neighbor_of_neighbor(face);
+                       if (cell_face->has_children())
+                         {
+                           for (unsigned int sub_nr = 0;
+                                sub_nr != cell_face->n_children();
+                                ++sub_nr)
+                             {
+                               const typename DH::cell_iterator
+                                 sub_neighbor
+                                 = cell->neighbor_child_on_subface (face, sub_nr);
+                               sub_neighbor->get_dof_indices (dofs_on_other_cell);
+                               for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+                                 {
+                                   const bool i_non_zero_i = support_on_face (i, face);
+                                   const bool i_non_zero_e = support_on_face (i, neighbor_face);
+                                   for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
+                                     {
+                                       const bool j_non_zero_i = support_on_face (j, face);
+                                       const bool j_non_zero_e = support_on_face (j, neighbor_face);
+                                       if (flux_dof_mask(i,j) == always)
+                                         {
+                                           sparsity.add (dofs_on_this_cell[i],
+                                                         dofs_on_other_cell[j]);
+                                           sparsity.add (dofs_on_other_cell[i],
+                                                         dofs_on_this_cell[j]);
+                                           sparsity.add (dofs_on_this_cell[i],
+                                                         dofs_on_this_cell[j]);
+                                           sparsity.add (dofs_on_other_cell[i],
+                                                         dofs_on_other_cell[j]);
+                                         }
+                                       else if (flux_dof_mask(i,j) == nonzero)
+                                         {
+                                           if (i_non_zero_i && j_non_zero_e)
+                                             sparsity.add (dofs_on_this_cell[i],
+                                                           dofs_on_other_cell[j]);
+                                           if (i_non_zero_e && j_non_zero_i)
+                                             sparsity.add (dofs_on_other_cell[i],
+                                                           dofs_on_this_cell[j]);
+                                           if (i_non_zero_i && j_non_zero_i)
+                                             sparsity.add (dofs_on_this_cell[i],
+                                                           dofs_on_this_cell[j]);
+                                           if (i_non_zero_e && j_non_zero_e)
+                                             sparsity.add (dofs_on_other_cell[i],
+                                                           dofs_on_other_cell[j]);
+                                         }
+                                       if (flux_dof_mask(j,i) == always)
+                                         {
+                                           sparsity.add (dofs_on_this_cell[j],
+                                                         dofs_on_other_cell[i]);
+                                           sparsity.add (dofs_on_other_cell[j],
+                                                         dofs_on_this_cell[i]);
+                                           sparsity.add (dofs_on_this_cell[j],
+                                                         dofs_on_this_cell[i]);
+                                           sparsity.add (dofs_on_other_cell[j],
+                                                         dofs_on_other_cell[i]);
+                                         }
+                                       else if (flux_dof_mask(j,i) == nonzero)
+                                         {
+                                           if (j_non_zero_i && i_non_zero_e)
+                                             sparsity.add (dofs_on_this_cell[j],
+                                                           dofs_on_other_cell[i]);
+                                           if (j_non_zero_e && i_non_zero_i)
+                                             sparsity.add (dofs_on_other_cell[j],
+                                                           dofs_on_this_cell[i]);
+                                           if (j_non_zero_i && i_non_zero_i)
+                                             sparsity.add (dofs_on_this_cell[j],
+                                                           dofs_on_this_cell[i]);
+                                           if (j_non_zero_e && i_non_zero_e)
+                                             sparsity.add (dofs_on_other_cell[j],
+                                                           dofs_on_other_cell[i]);
+                                         }
+                                     }
+                                 }
+                               sub_neighbor->face(neighbor_face)->set_user_flag ();
+                             }
+                         }
+                       else
+                         {
+                           neighbor->get_dof_indices (dofs_on_other_cell);
+                           for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+                             {
+                               const bool i_non_zero_i = support_on_face (i, face);
+                               const bool i_non_zero_e = support_on_face (i, neighbor_face);
+                               for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
+                                 {
+                                   const bool j_non_zero_i = support_on_face (j, face);
+                                   const bool j_non_zero_e = support_on_face (j, neighbor_face);
+                                   if (flux_dof_mask(i,j) == always)
+                                     {
+                                       sparsity.add (dofs_on_this_cell[i],
+                                                     dofs_on_other_cell[j]);
+                                       sparsity.add (dofs_on_other_cell[i],
+                                                     dofs_on_this_cell[j]);
+                                       sparsity.add (dofs_on_this_cell[i],
+                                                     dofs_on_this_cell[j]);
+                                       sparsity.add (dofs_on_other_cell[i],
+                                                     dofs_on_other_cell[j]);
+                                     }
+                                   if (flux_dof_mask(i,j) == nonzero)
+                                     {
+                                       if (i_non_zero_i && j_non_zero_e)
+                                         sparsity.add (dofs_on_this_cell[i],
+                                                       dofs_on_other_cell[j]);
+                                       if (i_non_zero_e && j_non_zero_i)
+                                         sparsity.add (dofs_on_other_cell[i],
+                                                       dofs_on_this_cell[j]);
+                                       if (i_non_zero_i && j_non_zero_i)
+                                         sparsity.add (dofs_on_this_cell[i],
+                                                       dofs_on_this_cell[j]);
+                                       if (i_non_zero_e && j_non_zero_e)
+                                         sparsity.add (dofs_on_other_cell[i],
+                                                       dofs_on_other_cell[j]);
+                                     }
+                                   if (flux_dof_mask(j,i) == always)
+                                     {
+                                       sparsity.add (dofs_on_this_cell[j],
+                                                     dofs_on_other_cell[i]);
+                                       sparsity.add (dofs_on_other_cell[j],
+                                                     dofs_on_this_cell[i]);
+                                       sparsity.add (dofs_on_this_cell[j],
+                                                     dofs_on_this_cell[i]);
+                                       sparsity.add (dofs_on_other_cell[j],
+                                                     dofs_on_other_cell[i]);
+                                     }
+                                   if (flux_dof_mask(j,i) == nonzero)
+                                     {
+                                       if (j_non_zero_i && i_non_zero_e)
+                                         sparsity.add (dofs_on_this_cell[j],
+                                                       dofs_on_other_cell[i]);
+                                       if (j_non_zero_e && i_non_zero_i)
+                                         sparsity.add (dofs_on_other_cell[j],
+                                                       dofs_on_this_cell[i]);
+                                       if (j_non_zero_i && i_non_zero_i)
+                                         sparsity.add (dofs_on_this_cell[j],
+                                                       dofs_on_this_cell[i]);
+                                       if (j_non_zero_e && i_non_zero_e)
+                                         sparsity.add (dofs_on_other_cell[j],
+                                                       dofs_on_other_cell[i]);
+                                     }
+                                 }
+                             }
+                           neighbor->face(neighbor_face)->set_user_flag ();
+                         }
+                     }
+                 }
              }
        }
  
                                           // probably less efficient but at least
                                           // readable...
  
-           const dealii::hp::FECollection<dim,spacedim> &fe = dof.get_fe();
+         const dealii::hp::FECollection<dim,spacedim> &fe = dof.get_fe();
  
-           std::vector<types::global_dof_index> dofs_on_this_cell(DoFTools::max_dofs_per_cell(dof));
-           std::vector<types::global_dof_index> dofs_on_other_cell(DoFTools::max_dofs_per_cell(dof));
 -        std::vector<unsigned int> dofs_on_this_cell(DoFTools::max_dofs_per_cell(dof));
 -        std::vector<unsigned int> dofs_on_other_cell(DoFTools::max_dofs_per_cell(dof));
++      std::vector<types::global_dof_index> dofs_on_this_cell(DoFTools::max_dofs_per_cell(dof));
++      std::vector<types::global_dof_index> dofs_on_other_cell(DoFTools::max_dofs_per_cell(dof));
  
-           const std::vector<Table<2,Coupling> >
-             int_dof_mask
-             = dof_couplings_from_component_couplings(fe, int_mask);
+         const std::vector<Table<2,Coupling> >
+           int_dof_mask
+           = dof_couplings_from_component_couplings(fe, int_mask);
  
-           typename dealii::hp::DoFHandler<dim,spacedim>::active_cell_iterator
-             cell = dof.begin_active(),
-             endc = dof.end();
-           for (; cell!=endc; ++cell)
-             {
-               dofs_on_this_cell.resize (cell->get_fe().dofs_per_cell);
-               cell->get_dof_indices (dofs_on_this_cell);
+         typename dealii::hp::DoFHandler<dim,spacedim>::active_cell_iterator
+           cell = dof.begin_active(),
+           endc = dof.end();
+         for (; cell!=endc; ++cell)
+           {
+             dofs_on_this_cell.resize (cell->get_fe().dofs_per_cell);
+             cell->get_dof_indices (dofs_on_this_cell);
                                               // make sparsity pattern for this cell
-               for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
-                 for (unsigned int j=0; j<cell->get_fe().dofs_per_cell; ++j)
-                       if (int_dof_mask[cell->active_fe_index()](i,j) != none)
-                         sparsity.add (dofs_on_this_cell[i],
-                                               dofs_on_this_cell[j]);
+             for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
+               for (unsigned int j=0; j<cell->get_fe().dofs_per_cell; ++j)
+                 if (int_dof_mask[cell->active_fe_index()](i,j) != none)
+                   sparsity.add (dofs_on_this_cell[i],
+                                 dofs_on_this_cell[j]);
  
                                               // Loop over all interior neighbors
-               for (unsigned int face = 0;
-                        face < GeometryInfo<dim>::faces_per_cell;
-                        ++face)
-                 {
-                       const typename dealii::hp::DoFHandler<dim,spacedim>::face_iterator
-                         cell_face = cell->face(face);
-                       if (cell_face->user_flag_set ())
-                         continue;
-                       if (cell->at_boundary (face) )
-                         {
-                           for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
-                             for (unsigned int j=0; j<cell->get_fe().dofs_per_cell; ++j)
-                                   if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
-                                                      cell->get_fe().system_to_component_index(j).first)
-                                        == always)
-                                       ||
-                                       (flux_mask(cell->get_fe().system_to_component_index(i).first,
-                                                      cell->get_fe().system_to_component_index(j).first)
-                                        == nonzero))
-                                     sparsity.add (dofs_on_this_cell[i],
-                                                           dofs_on_this_cell[j]);
-                         }
-                       else
-                         {
-                           typename dealii::hp::DoFHandler<dim,spacedim>::cell_iterator
-                             neighbor = cell->neighbor(face);
+             for (unsigned int face = 0;
+                  face < GeometryInfo<dim>::faces_per_cell;
+                  ++face)
+               {
+                 const typename dealii::hp::DoFHandler<dim,spacedim>::face_iterator
+                   cell_face = cell->face(face);
+                 if (cell_face->user_flag_set ())
+                   continue;
+                 if (cell->at_boundary (face) )
+                   {
+                     for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
+                       for (unsigned int j=0; j<cell->get_fe().dofs_per_cell; ++j)
+                         if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
+                                        cell->get_fe().system_to_component_index(j).first)
+                              == always)
+                             ||
+                             (flux_mask(cell->get_fe().system_to_component_index(i).first,
+                                        cell->get_fe().system_to_component_index(j).first)
+                              == nonzero))
+                           sparsity.add (dofs_on_this_cell[i],
+                                         dofs_on_this_cell[j]);
+                   }
+                 else
+                   {
+                     typename dealii::hp::DoFHandler<dim,spacedim>::cell_iterator
+                       neighbor = cell->neighbor(face);
                                                       // Refinement edges are taken care of
                                                       // by coarser cells
-                           if (cell->neighbor_is_coarser(face))
-                             continue;
-                           typename dealii::hp::DoFHandler<dim,spacedim>::face_iterator
-                             cell_face = cell->face(face);
-                           const unsigned int
-                             neighbor_face = cell->neighbor_of_neighbor(face);
-                           if (cell_face->has_children())
-                             {
-                                   for (unsigned int sub_nr = 0;
-                                        sub_nr != cell_face->n_children();
-                                        ++sub_nr)
-                                     {
-                                       const typename dealii::hp::DoFHandler<dim,spacedim>::cell_iterator
-                                         sub_neighbor
-                                         = cell->neighbor_child_on_subface (face, sub_nr);
-                                       dofs_on_other_cell.resize (sub_neighbor->get_fe().dofs_per_cell);
-                                       sub_neighbor->get_dof_indices (dofs_on_other_cell);
-                                       for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
-                                         {
-                                               for (unsigned int j=0; j<sub_neighbor->get_fe().dofs_per_cell;
-                                                    ++j)
-                                                 {
-                                                   if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
-                                                                          sub_neighbor->get_fe().system_to_component_index(j).first)
-                                                            == always)
-                                                           ||
-                                                           (flux_mask(cell->get_fe().system_to_component_index(i).first,
-                                                                          sub_neighbor->get_fe().system_to_component_index(j).first)
-                                                            == nonzero))
-                                                     {
-                                                           sparsity.add (dofs_on_this_cell[i],
-                                                                             dofs_on_other_cell[j]);
-                                                           sparsity.add (dofs_on_other_cell[i],
-                                                                             dofs_on_this_cell[j]);
-                                                           sparsity.add (dofs_on_this_cell[i],
-                                                                             dofs_on_this_cell[j]);
-                                                           sparsity.add (dofs_on_other_cell[i],
-                                                                             dofs_on_other_cell[j]);
-                                                     }
-                                                   if ((flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first,
-                                                                          cell->get_fe().system_to_component_index(i).first)
-                                                            == always)
-                                                           ||
-                                                           (flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first,
-                                                                          cell->get_fe().system_to_component_index(i).first)
-                                                            == nonzero))
-                                                     {
-                                                           sparsity.add (dofs_on_this_cell[j],
-                                                                             dofs_on_other_cell[i]);
-                                                           sparsity.add (dofs_on_other_cell[j],
-                                                                             dofs_on_this_cell[i]);
-                                                           sparsity.add (dofs_on_this_cell[j],
-                                                                             dofs_on_this_cell[i]);
-                                                           sparsity.add (dofs_on_other_cell[j],
-                                                                             dofs_on_other_cell[i]);
-                                                     }
-                                                 }
-                                         }
-                                       sub_neighbor->face(neighbor_face)->set_user_flag ();
-                                     }
-                             }
-                           else
-                             {
-                                   dofs_on_other_cell.resize (neighbor->get_fe().dofs_per_cell);
-                                   neighbor->get_dof_indices (dofs_on_other_cell);
-                                   for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
-                                     {
-                                       for (unsigned int j=0; j<neighbor->get_fe().dofs_per_cell; ++j)
-                                         {
-                                               if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
-                                                                  neighbor->get_fe().system_to_component_index(j).first)
-                                                    == always)
-                                                   ||
-                                                   (flux_mask(cell->get_fe().system_to_component_index(i).first,
-                                                                  neighbor->get_fe().system_to_component_index(j).first)
-                                                    == nonzero))
-                                                 {
-                                                   sparsity.add (dofs_on_this_cell[i],
-                                                                         dofs_on_other_cell[j]);
-                                                   sparsity.add (dofs_on_other_cell[i],
-                                                                         dofs_on_this_cell[j]);
-                                                   sparsity.add (dofs_on_this_cell[i],
-                                                                         dofs_on_this_cell[j]);
-                                                   sparsity.add (dofs_on_other_cell[i],
-                                                                         dofs_on_other_cell[j]);
-                                                 }
-                                               if ((flux_mask(neighbor->get_fe().system_to_component_index(j).first,
-                                                                  cell->get_fe().system_to_component_index(i).first)
-                                                    == always)
-                                                   ||
-                                                   (flux_mask(neighbor->get_fe().system_to_component_index(j).first,
-                                                                  cell->get_fe().system_to_component_index(i).first)
-                                                    == nonzero))
-                                                 {
-                                                   sparsity.add (dofs_on_this_cell[j],
-                                                                         dofs_on_other_cell[i]);
-                                                   sparsity.add (dofs_on_other_cell[j],
-                                                                         dofs_on_this_cell[i]);
-                                                   sparsity.add (dofs_on_this_cell[j],
-                                                                         dofs_on_this_cell[i]);
-                                                   sparsity.add (dofs_on_other_cell[j],
-                                                                         dofs_on_other_cell[i]);
-                                                 }
-                                         }
-                                     }
-                                   neighbor->face(neighbor_face)->set_user_flag ();
-                             }
-                         }
-                 }
-             }
+                     if (cell->neighbor_is_coarser(face))
+                       continue;
+                     typename dealii::hp::DoFHandler<dim,spacedim>::face_iterator
+                       cell_face = cell->face(face);
+                     const unsigned int
+                       neighbor_face = cell->neighbor_of_neighbor(face);
+                     if (cell_face->has_children())
+                       {
+                         for (unsigned int sub_nr = 0;
+                              sub_nr != cell_face->n_children();
+                              ++sub_nr)
+                           {
+                             const typename dealii::hp::DoFHandler<dim,spacedim>::cell_iterator
+                               sub_neighbor
+                               = cell->neighbor_child_on_subface (face, sub_nr);
+                             dofs_on_other_cell.resize (sub_neighbor->get_fe().dofs_per_cell);
+                             sub_neighbor->get_dof_indices (dofs_on_other_cell);
+                             for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
+                               {
+                                 for (unsigned int j=0; j<sub_neighbor->get_fe().dofs_per_cell;
+                                      ++j)
+                                   {
+                                     if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
+                                                    sub_neighbor->get_fe().system_to_component_index(j).first)
+                                          == always)
+                                         ||
+                                         (flux_mask(cell->get_fe().system_to_component_index(i).first,
+                                                    sub_neighbor->get_fe().system_to_component_index(j).first)
+                                          == nonzero))
+                                       {
+                                         sparsity.add (dofs_on_this_cell[i],
+                                                       dofs_on_other_cell[j]);
+                                         sparsity.add (dofs_on_other_cell[i],
+                                                       dofs_on_this_cell[j]);
+                                         sparsity.add (dofs_on_this_cell[i],
+                                                       dofs_on_this_cell[j]);
+                                         sparsity.add (dofs_on_other_cell[i],
+                                                       dofs_on_other_cell[j]);
+                                       }
+                                     if ((flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first,
+                                                    cell->get_fe().system_to_component_index(i).first)
+                                          == always)
+                                         ||
+                                         (flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first,
+                                                    cell->get_fe().system_to_component_index(i).first)
+                                          == nonzero))
+                                       {
+                                         sparsity.add (dofs_on_this_cell[j],
+                                                       dofs_on_other_cell[i]);
+                                         sparsity.add (dofs_on_other_cell[j],
+                                                       dofs_on_this_cell[i]);
+                                         sparsity.add (dofs_on_this_cell[j],
+                                                       dofs_on_this_cell[i]);
+                                         sparsity.add (dofs_on_other_cell[j],
+                                                       dofs_on_other_cell[i]);
+                                       }
+                                   }
+                               }
+                             sub_neighbor->face(neighbor_face)->set_user_flag ();
+                           }
+                       }
+                     else
+                       {
+                         dofs_on_other_cell.resize (neighbor->get_fe().dofs_per_cell);
+                         neighbor->get_dof_indices (dofs_on_other_cell);
+                         for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
+                           {
+                             for (unsigned int j=0; j<neighbor->get_fe().dofs_per_cell; ++j)
+                               {
+                                 if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
+                                                neighbor->get_fe().system_to_component_index(j).first)
+                                      == always)
+                                     ||
+                                     (flux_mask(cell->get_fe().system_to_component_index(i).first,
+                                                neighbor->get_fe().system_to_component_index(j).first)
+                                      == nonzero))
+                                   {
+                                     sparsity.add (dofs_on_this_cell[i],
+                                                   dofs_on_other_cell[j]);
+                                     sparsity.add (dofs_on_other_cell[i],
+                                                   dofs_on_this_cell[j]);
+                                     sparsity.add (dofs_on_this_cell[i],
+                                                   dofs_on_this_cell[j]);
+                                     sparsity.add (dofs_on_other_cell[i],
+                                                   dofs_on_other_cell[j]);
+                                   }
+                                 if ((flux_mask(neighbor->get_fe().system_to_component_index(j).first,
+                                                cell->get_fe().system_to_component_index(i).first)
+                                      == always)
+                                     ||
+                                     (flux_mask(neighbor->get_fe().system_to_component_index(j).first,
+                                                cell->get_fe().system_to_component_index(i).first)
+                                      == nonzero))
+                                   {
+                                     sparsity.add (dofs_on_this_cell[j],
+                                                   dofs_on_other_cell[i]);
+                                     sparsity.add (dofs_on_other_cell[j],
+                                                   dofs_on_this_cell[i]);
+                                     sparsity.add (dofs_on_this_cell[j],
+                                                   dofs_on_this_cell[i]);
+                                     sparsity.add (dofs_on_other_cell[j],
+                                                   dofs_on_other_cell[i]);
+                                   }
+                               }
+                           }
+                         neighbor->face(neighbor_face)->set_user_flag ();
+                       }
+                   }
+               }
+           }
        }
      }
  
        inline
        bool
        check_master_dof_list (const FullMatrix<double> &face_interpolation_matrix,
-                                        const std::vector<types::global_dof_index> &master_dof_list)
 -                             const std::vector<unsigned int> &master_dof_list)
++                           const std::vector<types::global_dof_index> &master_dof_list)
        {
-           const unsigned int N = master_dof_list.size();
+         const unsigned int N = master_dof_list.size();
  
-           FullMatrix<double> tmp (N,N);
-           for (unsigned int i=0; i<N; ++i)
-             for (unsigned int j=0; j<N; ++j)
-               tmp(i,j) = face_interpolation_matrix (master_dof_list[i], j);
+         FullMatrix<double> tmp (N,N);
+         for (unsigned int i=0; i<N; ++i)
+           for (unsigned int j=0; j<N; ++j)
+             tmp(i,j) = face_interpolation_matrix (master_dof_list[i], j);
  
                                           // then use the algorithm
                                           // from
                                           // the other one. this latter case
                                           // shows up when running
                                           // hp/hp_constraints_q_system_06
-           std::vector<types::global_dof_index> master_dof_list;
-           unsigned int index = 0;
-           for (int v=0;
-                v<static_cast<signed int>(GeometryInfo<dim>::vertices_per_face);
-                ++v)
 -        std::vector<unsigned int> master_dof_list;
 -        unsigned int index = 0;
 -        for (int v=0;
 -             v<static_cast<signed int>(GeometryInfo<dim>::vertices_per_face);
 -             ++v)
 -          {
 -            unsigned int dofs_added = 0;
 -            unsigned int i          = 0;
 -            while (dofs_added < fe2.dofs_per_vertex)
 -              {
++      std::vector<types::global_dof_index> master_dof_list;
++      unsigned int index = 0;
++      for (int v=0;
++           v<static_cast<signed int>(GeometryInfo<dim>::vertices_per_face);
++           ++v)
++        {
++          unsigned int dofs_added = 0;
++          unsigned int i          = 0;
++          while (dofs_added < fe2.dofs_per_vertex)
 +            {
-               unsigned int dofs_added = 0;
-               unsigned int i          = 0;
-               while (dofs_added < fe2.dofs_per_vertex)
-                 {
                                                   // make sure that we
                                                   // were able to find
                                                   // a set of master
  
                                           // finally copy the list into the
                                           // mask
-           std::fill (master_dof_mask.begin(), master_dof_mask.end(), false);
-           for (std::vector<types::global_dof_index>::const_iterator i=master_dof_list.begin();
-                i!=master_dof_list.end(); ++i)
-             master_dof_mask[*i] = true;
 -        std::fill (master_dof_mask.begin(), master_dof_mask.end(), false);
 -        for (std::vector<unsigned int>::const_iterator i=master_dof_list.begin();
 -             i!=master_dof_list.end(); ++i)
 -          master_dof_mask[*i] = true;
++      std::fill (master_dof_mask.begin(), master_dof_mask.end(), false);
++      for (std::vector<types::global_dof_index>::const_iterator i=master_dof_list.begin();
++           i!=master_dof_list.end(); ++i)
++        master_dof_mask[*i] = true;
        }
  
  
                                          * fuller than necessary.
                                          */
        void
 -      filter_constraints (const std::vector<unsigned int> &master_dofs,
 -                          const std::vector<unsigned int> &slave_dofs,
 -                          const FullMatrix<double> &face_constraints,
 -                          ConstraintMatrix &constraints)
 +      filter_constraints (const std::vector<types::global_dof_index> &master_dofs,
-                                     const std::vector<types::global_dof_index> &slave_dofs,
-                                     const FullMatrix<double> &face_constraints,
-                                     ConstraintMatrix &constraints)
++                        const std::vector<types::global_dof_index> &slave_dofs,
++                        const FullMatrix<double> &face_constraints,
++                        ConstraintMatrix &constraints)
        {
-           Assert (face_constraints.n () == master_dofs.size (),
-                       ExcDimensionMismatch(master_dofs.size (),
-                                                    face_constraints.n()));
-           Assert (face_constraints.m () == slave_dofs.size (),
-                       ExcDimensionMismatch(slave_dofs.size (),
-                                                    face_constraints.m()));
+         Assert (face_constraints.n () == master_dofs.size (),
+                 ExcDimensionMismatch(master_dofs.size (),
+                                      face_constraints.n()));
+         Assert (face_constraints.m () == slave_dofs.size (),
+                 ExcDimensionMismatch(slave_dofs.size (),
+                                      face_constraints.m()));
  
-           const unsigned int n_master_dofs = master_dofs.size ();
-           const unsigned int n_slave_dofs = slave_dofs.size ();
+         const unsigned int n_master_dofs = master_dofs.size ();
+         const unsigned int n_slave_dofs = slave_dofs.size ();
  
                                           // check for a couple
                                           // conditions that happened
        }
        return;
      }
--                                   // .. otherwise we should be in the case
--                                   // were both faces are active and have
--                                   // no children ..
++                                     // .. otherwise we should be in the case
++                                     // were both faces are active and have
++                                     // no children ..
      Assert (!face_1->has_children() && !face_2->has_children(),
              ExcNotImplemented());
  
      Assert (face_1->n_active_fe_indices() == 1 && face_2->n_active_fe_indices() == 1,
              ExcInternalError());
  
--                                   // .. then we match the
--                                   // corresponding DoFs of both faces ..
++                                     // .. then we match the
++                                     // corresponding DoFs of both faces ..
      const unsigned int face_1_index = face_1->nth_active_fe_index(0);
      const unsigned int face_2_index = face_2->nth_active_fe_index(0);
      Assert (   face_1->get_fe(face_1_index)
--            == face_2->get_fe(face_1_index),
--            ExcMessage ("Matching periodic cells need to use the same finite element"));
++               == face_2->get_fe(face_1_index),
++               ExcMessage ("Matching periodic cells need to use the same finite element"));
  
      const dealii::FiniteElement<dim> &fe = face_1->get_fe(face_1_index);
  
      face_1->get_dof_indices(dofs_1, face_1_index);
      face_2->get_dof_indices(dofs_2, face_2_index);
  
--                                   // .. and constrain them (respecting
--                                   // component_mask):
++                                     // .. and constrain them (respecting
++                                     // component_mask):
      for (unsigned int i = 0; i < dofs_per_face; ++i) {
-       if (component_mask.size() == 0 ||
-           component_mask[fe.face_system_to_component_index(i).first]) {
-         if(!constraint_matrix.is_constrained(dofs_1[i])) {
-           constraint_matrix.add_line(dofs_1[i]);
-           constraint_matrix.add_entry(dofs_1[i], dofs_2[i], 1.0);
+       if ((component_mask.n_selected_components(fe.n_components()) == fe.n_components())
+           ||
+           (component_mask[fe.face_system_to_component_index(i).first] == true))
+         {
+           if(!constraint_matrix.is_constrained(dofs_1[i]))
+             {
+             constraint_matrix.add_line(dofs_1[i]);
+             constraint_matrix.add_entry(dofs_1[i], dofs_2[i], 1.0);
+             }
          }
-       }
      }
    }
  
                                  const types::boundary_id     boundary_component,
                                  const int                      direction,
                                  dealii::Tensor<1,DH::space_dimension>
--                                                               &offset,
++                                &offset,
                                  dealii::ConstraintMatrix       &constraint_matrix,
-                                 const std::vector<bool>        &component_mask)
+                                 const ComponentMask            &component_mask)
    {
      static const int space_dim = DH::space_dimension;
      Assert (0<=direction && direction<space_dim,
  
      typedef typename DH::cell_iterator CellIterator;
  
--                                   // We collect matching periodic cells on
--                                   // the coarsest level:
++                                     // We collect matching periodic cells on
++                                     // the coarsest level:
      std::map<CellIterator, CellIterator>
        matched_cells =
--        GridTools::collect_periodic_cell_pairs(dof_handler.begin(0),
--                                               dof_handler.end(0),
--                                               boundary_component,
--                                               direction,
--                                               offset);
--
--                                   // And apply the low level
--                                   // make_periodicity_constraints function
--                                   // to every matching pair:
++      GridTools::collect_periodic_cell_pairs(dof_handler.begin(0),
++                                             dof_handler.end(0),
++                                             boundary_component,
++                                             direction,
++                                             offset);
++
++                                     // And apply the low level
++                                     // make_periodicity_constraints function
++                                     // to every matching pair:
      for (typename std::map<CellIterator, CellIterator>::iterator it = matched_cells.begin();
-        it != matched_cells.end(); ++it)
+          it != matched_cells.end(); ++it)
        {
-       typedef typename DH::face_iterator FaceIterator;
-       FaceIterator face_1 = it->first->face(2*direction);
-       FaceIterator face_2 = it->second->face(2*direction+1);
+         typedef typename DH::face_iterator FaceIterator;
+         FaceIterator face_1 = it->first->face(2*direction);
+         FaceIterator face_2 = it->second->face(2*direction+1);
  
-       Assert(face_1->at_boundary() && face_2->at_boundary(),
-              ExcInternalError());
+         Assert(face_1->at_boundary() && face_2->at_boundary(),
+                ExcInternalError());
  
-       Assert (face_1->boundary_indicator() == boundary_component &&
-               face_2->boundary_indicator() == boundary_component,
-               ExcInternalError());
+         Assert (face_1->boundary_indicator() == boundary_component &&
+                 face_2->boundary_indicator() == boundary_component,
+                 ExcInternalError());
  
-       make_periodicity_constraints(face_1,
-                                    face_2,
-                                    constraint_matrix,
-                                    component_mask);
+         make_periodicity_constraints(face_1,
+                                      face_2,
+                                      constraint_matrix,
+                                      component_mask);
        }
    }
  
        for (unsigned int f=0; f<fe_collection.size(); ++f)
          {
            const FiniteElement<DH::dimension,DH::space_dimension> &fe =
-             fe_collection[f];
-           local_component_association[f].resize(fe.dofs_per_cell);
-           if (sort_by_blocks == true)
-                                            // compute the block each
-                                            // local dof belongs to
-             {
-               for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
-                 local_component_association[f][i]
-                   = fe.system_to_block_index(i).first;
-             }
-           else
-                                            // compute the component each
-                                            // local dof belongs to
-             for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
-               if (fe.is_primitive(i))
-                 local_component_association[f][i] =
-                   fe.system_to_component_index(i).first;
-               else
-                                                  // if this shape function is
-                                                  // not primitive, then we have
-                                                  // to work harder. we have to
-                                                  // find out whether _any_ of
-                                                  // the vector components of
-                                                  // this element is selected or
-                                                  // not
-                                                  //
-                                                  // to do so, get the a list of
-                                                  // nonzero elements and see which are
-                                                  // actually active
-                       {
-                         const unsigned int first_comp =
-                           (std::find(fe.get_nonzero_components(i).begin(),
-                                          fe.get_nonzero_components(i).end(),
-                                          true) -
-                            fe.get_nonzero_components(i).begin());
-                         const unsigned int end_comp =
-                           (std::find(fe.get_nonzero_components(i).begin()+first_comp,
-                                          fe.get_nonzero_components(i).end(),
-                                          false)-
-                            fe.get_nonzero_components(i).begin());
-                                                    // now check whether any of
-                                                    // the components in between
-                                                    // is set
-                         if (component_select.size() == 0 ||
-                             (component_select[first_comp] == true ||
-                              std::count(component_select.begin()+first_comp,
-                                                 component_select.begin()+end_comp, true) == 0))
-                           local_component_association[f][i] = first_comp;
-                         else
-                           for (unsigned int c=first_comp; c<end_comp; ++c)
-                             if (component_select[c] == true)
-                                   {
-                                     local_component_association[f][i] = c;
-                                     break;
-                                   }
-                       }
-           }
-                                        // then loop over all cells and do
-                                        // the work
+               fe_collection[f];
+           local_component_association[f]
+                                       = get_local_component_association (fe, component_mask);
+         }
+       // then loop over all cells and do
+       // the work
+       std::vector<unsigned int> indices;
+       for (typename DH::active_cell_iterator c=dof.begin_active();
+           c!=dof.end(); ++ c)
+         if (c->is_locally_owned())
+           {
+             const unsigned int fe_index = c->active_fe_index();
+             const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell;
+             indices.resize(dofs_per_cell);
+             c->get_dof_indices(indices);
+             for (unsigned int i=0; i<dofs_per_cell; ++i)
+               if (dof.locally_owned_dofs().is_element(indices[i]))
+                 dofs_by_component[dof.locally_owned_dofs().index_within_set(indices[i])]
+                                   = local_component_association[fe_index][i];
+           }
+     }
+     // this is the function corresponding to the one above but working
+     // on blocks instead of components.
+     //
+     // the output array dofs_by_block
+     // lists for each dof the corresponding
+     // vector block. if the DoFHandler is
+     // based on a parallel distributed
+     // triangulation then the output array is
+     // index by
+     // dof.locally_owned_dofs().index_within_set(indices[i])
+     template <class DH>
+     inline
+     void
+     get_block_association (const DH                   &dof,
+                            std::vector<unsigned char> &dofs_by_block)
+     {
+       const dealii::hp::FECollection<DH::dimension,DH::space_dimension>
+       fe_collection (dof.get_fe());
+       Assert (fe_collection.n_components() < 256, ExcNotImplemented());
+       Assert (dofs_by_block.size() == dof.n_locally_owned_dofs(),
+           ExcDimensionMismatch(dofs_by_block.size(),
+               dof.n_locally_owned_dofs()));
+       // next set up a table for the degrees
+       // of freedom on each of the cells
+       // (regardless of the fact whether it
+       // is listed in the component_select
+       // argument or not)
+       //
+       // for each element 'f' of the
+       // FECollection,
+       // local_block_association[f][d]
+       // then returns the vector block
+       // that degree of freedom 'd' belongs
+       // to
+       std::vector<std::vector<unsigned char> > local_block_association
+       (fe_collection.size());
+       for (unsigned int f=0; f<fe_collection.size(); ++f)
+         {
+           const FiniteElement<DH::dimension,DH::space_dimension> &fe =
+               fe_collection[f];
+           local_block_association[f].resize(fe.dofs_per_cell,
+               (unsigned char)(-1));
+           for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+             local_block_association[f][i] = fe.system_to_block_index(i).first;
+           Assert (std::find (local_block_association[f].begin(),
+               local_block_association[f].end(),
+               (unsigned char)(-1))
+               ==
+               local_block_association[f].end(),
+               ExcInternalError());
+         }
+       // then loop over all cells and do
+       // the work
 -      std::vector<unsigned int> indices;
 +      std::vector<types::global_dof_index> indices;
        for (typename DH::active_cell_iterator c=dof.begin_active();
-              c!=dof.end(); ++ c)
-           if (c->is_locally_owned())
-             {
-               const unsigned int fe_index = c->active_fe_index();
-               const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell;
-               indices.resize(dofs_per_cell);
-               c->get_dof_indices(indices);
-               for (unsigned int i=0; i<dofs_per_cell; ++i)
-                 if (dof.locally_owned_dofs().is_element(indices[i]))
-                       dofs_by_component[dof.locally_owned_dofs().index_within_set(indices[i])]
-                         = local_component_association[fe_index][i];
-             }
+           c!=dof.end(); ++ c)
+         if (c->is_locally_owned())
+           {
+             const unsigned int fe_index = c->active_fe_index();
+             const unsigned int dofs_per_cell = c->get_fe().dofs_per_cell;
+             indices.resize(dofs_per_cell);
+             c->get_dof_indices(indices);
+             for (unsigned int i=0; i<dofs_per_cell; ++i)
+               if (dof.locally_owned_dofs().is_element(indices[i]))
+                 dofs_by_block[dof.locally_owned_dofs().index_within_set(indices[i])]
+                               = local_block_association[fe_index][i];
+           }
      }
    }
  
      std::vector<unsigned char> touch_count (dof_handler.n_dofs(), 0);
  
      typename DH::active_cell_iterator cell = dof_handler.begin_active(),
-                                                     endc = dof_handler.end();
+                                       endc = dof_handler.end();
 -    std::vector<unsigned int> dof_indices;
 +    std::vector<types::global_dof_index> dof_indices;
      dof_indices.reserve (max_dofs_per_cell(dof_handler));
  
      for (unsigned int present_cell = 0; cell!=endc; ++cell, ++present_cell)
  
  
  
 -  template<int dim, int spacedim>
 +  template<class DH>
    void
-   extract_level_dofs(
-     const unsigned int       level,
-     const DH &dof,
-     const std::vector<bool> &component_select,
-     std::vector<bool>       &selected_dofs,
-     const bool               count_by_blocks)
+   extract_level_dofs(const unsigned int       level,
 -                     const MGDoFHandler<dim,spacedim> &dof,
++                     const DH &dof,
+                      const ComponentMask &component_mask,
+                      std::vector<bool>       &selected_dofs)
    {
 -    const FiniteElement<dim,spacedim>& fe = dof.get_fe();
 +    const FiniteElement<DH::dimension,DH::space_dimension>& fe = dof.get_fe();
  
-     if (count_by_blocks == true)
-       {
-           Assert(component_select.size() == fe.n_blocks(),
-                  ExcDimensionMismatch(component_select.size(), fe.n_blocks()));
-       }
-     else
-       {
-           Assert(component_select.size() == fe.n_components(),
-                  ExcDimensionMismatch(component_select.size(), fe.n_components()));
-       }
+     Assert(component_mask.represents_n_components(n_components(dof)),
+            ExcMessage ("The given component mask is not sized correctly to represent the "
+                        "components of the given finite element."));
      Assert(selected_dofs.size() == dof.n_dofs(level),
-              ExcDimensionMismatch(selected_dofs.size(), dof.n_dofs(level)));
+            ExcDimensionMismatch(selected_dofs.size(), dof.n_dofs(level)));
  
                                       // two special cases: no component
                                       // is selected, and all components
  
                                       // then loop over all cells and do
                                       // work
 -    std::vector<unsigned int> indices(fe.dofs_per_cell);
 -    typename MGDoFHandler<dim,spacedim>::cell_iterator c;
 +    std::vector<types::global_dof_index> indices(fe.dofs_per_cell);
 +    typename DH::cell_iterator c;
      for (c = dof.begin(level) ; c != dof.end(level) ; ++ c)
        {
-           c->get_mg_dof_indices(indices);
-           for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
-             selected_dofs[indices[i]] = local_selected_dofs[i];
+         c->get_mg_dof_indices(indices);
+         for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+           selected_dofs[indices[i]] = local_selected_dofs[i];
        }
    }
  
  
  
 -  template<int dim, int spacedim>
++  template<class DH>
+   void
+   extract_level_dofs(const unsigned int       level,
 -                     const MGDoFHandler<dim,spacedim> &dof,
++                     const DH &dof,
+                      const BlockMask         &block_mask,
+                      std::vector<bool>       &selected_dofs)
+   {
+     // simply defer to the other extract_level_dofs() function
+     extract_level_dofs (level, dof, dof.get_fe().component_mask(block_mask),
+                         selected_dofs);
+   }
    template <class DH>
    void
    extract_boundary_dofs (const DH                      &dof_handler,
                          "See the documentation for more information."));
  
      IndexSet indices;
-     extract_boundary_dofs (dof_handler, component_select,
+     extract_boundary_dofs (dof_handler, component_mask,
                             indices, boundary_indicators);
  
--    // clear and reset array by default values
++                                     // clear and reset array by default values
      selected_dofs.clear ();
      selected_dofs.resize (dof_handler.n_dofs(), false);
  
--    // then convert the values computed above to the binary vector
++                                     // then convert the values computed above to the binary vector
      indices.fill_binary_vector(selected_dofs);
    }
  
              ExcInvalidBoundaryIndicator());
      const unsigned int dim=DH::dimension;
  
--    // first reset output argument
++                                     // first reset output argument
      selected_dofs.clear ();
      selected_dofs.set_size(dof_handler.n_dofs());
  
                                       // check whether a certain vector
                                       // component is selected, or all
      const bool check_vector_component
-       = (component_select != std::vector<bool>(component_select.size(),
-                                                true));
+     = ((component_mask.represents_the_all_selected_mask() == false)
+         ||
+         (component_mask.n_selected_components(n_components(dof_handler)) !=
+             n_components(dof_handler)));
  
 -    std::vector<unsigned int> face_dof_indices;
 +    std::vector<types::global_dof_index> face_dof_indices;
      face_dof_indices.reserve (max_dofs_per_face(dof_handler));
  
                                       // now loop over all cells and
                                       // sooner or later
      for (typename DH::active_cell_iterator cell=dof_handler.begin_active();
           cell!=dof_handler.end(); ++cell)
--      // only work on cells that are either locally owned or at
--      // least ghost cells
++                                       // only work on cells that are either locally owned or at
++                                       // least ghost cells
        if (cell->is_artificial() == false)
          for (unsigned int face=0;
--            face<GeometryInfo<DH::dimension>::faces_per_cell; ++face)
++             face<GeometryInfo<DH::dimension>::faces_per_cell; ++face)
            if (cell->at_boundary(face))
              if (! check_boundary_indicator ||
                  (boundary_indicators.find (cell->face(face)->boundary_indicator())
--                    != boundary_indicators.end()))
++                 != boundary_indicators.end()))
                {
                  const FiniteElement<DH::dimension, DH::space_dimension> &fe = cell->get_fe();
  
                    if (!check_vector_component)
                      selected_dofs.add_index (face_dof_indices[i]);
                    else
--                    // check for
--                    // component is
--                    // required. somewhat
--                    // tricky as usual
--                    // for the case that
--                    // the shape function
--                    // is non-primitive,
--                    // but use usual
--                    // convention (see
--                    // docs)
++                                                     // check for
++                                                     // component is
++                                                     // required. somewhat
++                                                     // tricky as usual
++                                                     // for the case that
++                                                     // the shape function
++                                                     // is non-primitive,
++                                                     // but use usual
++                                                     // convention (see
++                                                     // docs)
                      {
--                      // first get at the
--                      // cell-global
--                      // number of a face
--                      // dof, to ask the
--                      // fe certain
--                      // questions
++                                                       // first get at the
++                                                       // cell-global
++                                                       // number of a face
++                                                       // dof, to ask the
++                                                       // fe certain
++                                                       // questions
                        const unsigned int cell_index
--                      = (dim == 1 ?
--                          i
--                          :
--                          (dim == 2 ?
--                              (i<2*fe.dofs_per_vertex ? i : i+2*fe.dofs_per_vertex)
++                        = (dim == 1 ?
++                           i
++                           :
++                           (dim == 2 ?
++                            (i<2*fe.dofs_per_vertex ? i : i+2*fe.dofs_per_vertex)
++                            :
++                            (dim == 3 ?
++                             (i<4*fe.dofs_per_vertex ?
++                              i
                                :
--                              (dim == 3 ?
--                                  (i<4*fe.dofs_per_vertex ?
--                                      i
--                                      :
--                                      (i<4*fe.dofs_per_vertex+4*fe.dofs_per_line ?
--                                          i+4*fe.dofs_per_vertex
--                                          :
--                                          i+4*fe.dofs_per_vertex+8*fe.dofs_per_line))
--                                          :
--                                          numbers::invalid_unsigned_int)));
++                              (i<4*fe.dofs_per_vertex+4*fe.dofs_per_line ?
++                               i+4*fe.dofs_per_vertex
++                               :
++                               i+4*fe.dofs_per_vertex+8*fe.dofs_per_line))
++                             :
++                             numbers::invalid_unsigned_int)));
                        if (fe.is_primitive (cell_index))
                          {
-                           if (component_select[fe.face_system_to_component_index(i).first]
-                                                == true)
+                           if (component_mask[fe.face_system_to_component_index(i).first]
 -                                               == true)
++                              == true)
                              selected_dofs.add_index (face_dof_indices[i]);
                          }
                        else // not primitive
                                       // because we can't be sure that the dof
                                       // range of locally_owned_dofs is really
                                       // contiguous.
 -    std::vector<unsigned int> dof_indices;
 -    std::set<unsigned int> global_dof_indices;
 +    std::vector<types::global_dof_index> dof_indices;
 +    std::set<types::global_dof_index> global_dof_indices;
  
      typename DH::active_cell_iterator cell = dof_handler.begin_active(),
-                                                     endc = dof_handler.end();
+                                       endc = dof_handler.end();
      for (; cell!=endc; ++cell)
        if (cell->is_locally_owned())
-           {
-             dof_indices.resize(cell->get_fe().dofs_per_cell);
-             cell->get_dof_indices(dof_indices);
+         {
+           dof_indices.resize(cell->get_fe().dofs_per_cell);
+           cell->get_dof_indices(dof_indices);
  
-             for (std::vector<types::global_dof_index>::iterator it=dof_indices.begin();
-                  it!=dof_indices.end();
-                  ++it)
-               if (!dof_set.is_element(*it))
-                 global_dof_indices.insert(*it);
-           }
 -          for (std::vector<unsigned int>::iterator it=dof_indices.begin();
 -               it!=dof_indices.end();
 -               ++it)
 -            if (!dof_set.is_element(*it))
 -              global_dof_indices.insert(*it);
 -        }
++        for (std::vector<types::global_dof_index>::iterator it=dof_indices.begin();
++             it!=dof_indices.end();
++             ++it)
++          if (!dof_set.is_element(*it))
++            global_dof_indices.insert(*it);
++      }
  
      dof_set.add_indices(global_dof_indices.begin(), global_dof_indices.end());
  
                                       // because we can't be sure that the dof
                                       // range of locally_owned_dofs is really
                                       // contiguous.
 -    std::vector<unsigned int> dof_indices;
 -    std::set<unsigned int> global_dof_indices;
 +    std::vector<types::global_dof_index> dof_indices;
 +    std::set<types::global_dof_index> global_dof_indices;
  
      typename DH::active_cell_iterator cell = dof_handler.begin_active(),
-                                                     endc = dof_handler.end();
+                                       endc = dof_handler.end();
      for (; cell!=endc; ++cell)
        if (cell->is_ghost())
-           {
-             dof_indices.resize(cell->get_fe().dofs_per_cell);
-             cell->get_dof_indices(dof_indices);
+         {
+           dof_indices.resize(cell->get_fe().dofs_per_cell);
+           cell->get_dof_indices(dof_indices);
  
-             for (std::vector<types::global_dof_index>::iterator it=dof_indices.begin();
-                  it!=dof_indices.end();
-                  ++it)
-               if (!dof_set.is_element(*it))
-                 global_dof_indices.insert(*it);
-           }
 -          for (std::vector<unsigned int>::iterator it=dof_indices.begin();
 -               it!=dof_indices.end();
 -               ++it)
 -            if (!dof_set.is_element(*it))
 -              global_dof_indices.insert(*it);
 -        }
++        for (std::vector<types::global_dof_index>::iterator it=dof_indices.begin();
++             it!=dof_indices.end();
++             ++it)
++          if (!dof_set.is_element(*it))
++            global_dof_indices.insert(*it);
++      }
  
      dof_set.add_indices(global_dof_indices.begin(), global_dof_indices.end());
  
  
                                       // preset all values by an invalid value
      std::fill_n (subdomain_association.begin(), dof_handler.n_dofs(),
-                        types::invalid_subdomain_id);
+                  types::invalid_subdomain_id);
  
 -    std::vector<unsigned int> local_dof_indices;
 +    std::vector<types::global_dof_index> local_dof_indices;
      local_dof_indices.reserve (max_dofs_per_cell(dof_handler));
  
                                       // pseudo-randomly assign variables
  
      IndexSet index_set (dof_handler.n_dofs());
  
 -    std::vector<unsigned int> local_dof_indices;
 +    std::vector<types::global_dof_index> local_dof_indices;
      local_dof_indices.reserve (max_dofs_per_cell(dof_handler));
  
--                                // first generate an unsorted list of all
--                                // indices which we fill from the back. could
--                                // also insert them directly into the
--                                // IndexSet, but that inserts indices in the
--                                // middle, which is an O(n^2) algorithm and
--                                // hence too expensive. Could also use
--                                // std::set, but that is in general more
--                                // expensive than a vector
 -    std::vector<unsigned int> subdomain_indices;
++                                     // first generate an unsorted list of all
++                                     // indices which we fill from the back. could
++                                     // also insert them directly into the
++                                     // IndexSet, but that inserts indices in the
++                                     // middle, which is an O(n^2) algorithm and
++                                     // hence too expensive. Could also use
++                                     // std::set, but that is in general more
++                                     // expensive than a vector
 +    std::vector<types::global_dof_index> subdomain_indices;
  
      typename DH::active_cell_iterator
        cell = dof_handler.begin_active(),
                                     local_dof_indices.begin(),
                                     local_dof_indices.end());
          }
--                                // sort indices and remove duplicates
++                                     // sort indices and remove duplicates
      std::sort (subdomain_indices.begin(), subdomain_indices.end());
      subdomain_indices.erase (std::unique(subdomain_indices.begin(),
                                           subdomain_indices.end()),
                               subdomain_indices.end());
  
--                                // insert into IndexSet
++                                     // insert into IndexSet
      index_set.add_indices (subdomain_indices.begin(), subdomain_indices.end());
      index_set.compress ();
  
      template <int dim, int spacedim>
      void
      resolve_components (const FiniteElement<dim,spacedim>&fe,
-                                   const std::vector<unsigned char> &dofs_by_component,
-                                   const std::vector<unsigned int>  &target_component,
-                                   const bool                        only_once,
-                                   std::vector<types::global_dof_index>        &dofs_per_component,
-                                   unsigned int                     &component)
 -                        const std::vector<unsigned char> &dofs_by_component,
 -                        const std::vector<unsigned int>  &target_component,
 -                        const bool                        only_once,
 -                        std::vector<unsigned int>        &dofs_per_component,
 -                        unsigned int                     &component)
++                      const std::vector<unsigned char> &dofs_by_component,
++                      const std::vector<unsigned int>  &target_component,
++                      const bool                        only_once,
++                      std::vector<types::global_dof_index>        &dofs_per_component,
++                      unsigned int                     &component)
      {
        for (unsigned int b=0;b<fe.n_base_elements();++b)
-           {
-             const FiniteElement<dim,spacedim>& base = fe.base_element(b);
+         {
+           const FiniteElement<dim,spacedim>& base = fe.base_element(b);
                                             // Dimension of base element
-             unsigned int d = base.n_components();
-             for (unsigned int m=0;m<fe.element_multiplicity(b);++m)
-               {
-                 if (base.n_base_elements() > 1)
-                       resolve_components(base, dofs_by_component, target_component,
-                                                  only_once, dofs_per_component, component);
-                 else
-                       {
-                         for (unsigned int dd=0;dd<d;++dd,++component)
-                           dofs_per_component[target_component[component]]
-                             += std::count(dofs_by_component.begin(),
-                                                   dofs_by_component.end(),
-                                                   component);
+           unsigned int d = base.n_components();
+           for (unsigned int m=0;m<fe.element_multiplicity(b);++m)
+             {
+               if (base.n_base_elements() > 1)
+                 resolve_components(base, dofs_by_component, target_component,
+                                    only_once, dofs_per_component, component);
+               else
+                 {
+                   for (unsigned int dd=0;dd<d;++dd,++component)
+                     dofs_per_component[target_component[component]]
+                       += std::count(dofs_by_component.begin(),
+                                     dofs_by_component.end(),
+                                     component);
  
                                                     // if we have non-primitive FEs and want all
                                                     // components to show the number of dofs, need
                          const std::vector<unsigned char> &dofs_by_component,
                          const std::vector<unsigned int>  &target_component,
                          const bool                        only_once,
 -                        std::vector<unsigned int>        &dofs_per_component,
 +                        std::vector<types::global_dof_index>        &dofs_per_component,
                          unsigned int                     &component)
      {
--      // assert that all elements in the collection have the same
--      // structure (base elements and multiplicity, components per base
--      // element) and then simply call the function above
++                                       // assert that all elements in the collection have the same
++                                       // structure (base elements and multiplicity, components per base
++                                       // element) and then simply call the function above
        for (unsigned int fe=1; fe<fe_collection.size(); ++fe)
--      {
--        Assert (fe_collection[fe].n_components() == fe_collection[0].n_components(),
--                ExcNotImplemented());
--        Assert (fe_collection[fe].n_base_elements() == fe_collection[0].n_base_elements(),
--                ExcNotImplemented());
--        for (unsigned int b=0;b<fe_collection[0].n_base_elements();++b)
          {
--          Assert (fe_collection[fe].base_element(b).n_components() == fe_collection[0].base_element(b).n_components(),
++          Assert (fe_collection[fe].n_components() == fe_collection[0].n_components(),
                    ExcNotImplemented());
--          Assert (fe_collection[fe].base_element(b).n_base_elements() == fe_collection[0].base_element(b).n_base_elements(),
++          Assert (fe_collection[fe].n_base_elements() == fe_collection[0].n_base_elements(),
                    ExcNotImplemented());
++          for (unsigned int b=0;b<fe_collection[0].n_base_elements();++b)
++            {
++              Assert (fe_collection[fe].base_element(b).n_components() == fe_collection[0].base_element(b).n_components(),
++                      ExcNotImplemented());
++              Assert (fe_collection[fe].base_element(b).n_base_elements() == fe_collection[0].base_element(b).n_base_elements(),
++                      ExcNotImplemented());
++            }
          }
--      }
  
        resolve_components (fe_collection[0], dofs_by_component,
                            target_component, only_once, dofs_per_component,
    namespace internal
    {
      namespace {
--      /**
--       * Return true if the given element is primitive.
--       */
++                                       /**
++                                        * Return true if the given element is primitive.
++                                        */
        template <int dim, int spacedim>
        bool all_elements_are_primitive (const FiniteElement<dim,spacedim> &fe)
        {
        }
  
  
--      /**
--       * Return true if each element of the given element collection is primitive.
--       */
++                                       /**
++                                        * Return true if each element of the given element collection is primitive.
++                                        */
        template <int dim, int spacedim>
        bool all_elements_are_primitive (const dealii::hp::FECollection<dim,spacedim> &fe_collection)
        {
    template <int dim, int spacedim>
    void
    count_dofs_per_component (const DoFHandler<dim,spacedim> &dof_handler,
-                                       std::vector<types::global_dof_index>      &dofs_per_component,
-                                       std::vector<unsigned int>       target_component)
 -                            std::vector<unsigned int>      &dofs_per_component,
 -                            std::vector<unsigned int>       target_component)
++                          std::vector<types::global_dof_index>      &dofs_per_component,
++                          std::vector<unsigned int>       target_component)
    {
      count_dofs_per_component (dof_handler, dofs_per_component,
-                                         false, target_component);
+                               false, target_component);
    }
  
  
                                           // a single degree of freedom on the
                                           // coarse grid (for the selected fe)
                                           // on the fine grid
-           const unsigned int n_fine_dofs = weight_mapping.size();
-           dealii::Vector<double> global_parameter_representation (n_fine_dofs);
+         const unsigned int n_fine_dofs = weight_mapping.size();
+         dealii::Vector<double> global_parameter_representation (n_fine_dofs);
  
-           typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator cell;
-           std::vector<types::global_dof_index> parameter_dof_indices (coarse_fe.dofs_per_cell);
 -        typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator cell;
 -        std::vector<unsigned int> parameter_dof_indices (coarse_fe.dofs_per_cell);
++      typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator cell;
++      std::vector<types::global_dof_index> parameter_dof_indices (coarse_fe.dofs_per_cell);
  
-           for (cell=begin; cell!=end; ++cell)
-             {
+         for (cell=begin; cell!=end; ++cell)
+           {
                                               // get the global indices of the
                                               // parameter dofs on this parameter
                                               // grid cell
                                               // to true if this is an
                                               // interesting dof. finally count
                                               // how many true's there
-               std::vector<bool> dof_is_interesting (fine_grid.n_dofs(), false);
-               std::vector<types::global_dof_index>  local_dof_indices (fine_fe.dofs_per_cell);
 -            std::vector<bool> dof_is_interesting (fine_grid.n_dofs(), false);
 -            std::vector<unsigned int>  local_dof_indices (fine_fe.dofs_per_cell);
++          std::vector<bool> dof_is_interesting (fine_grid.n_dofs(), false);
++          std::vector<types::global_dof_index>  local_dof_indices (fine_fe.dofs_per_cell);
  
-               for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
-                          cell=fine_grid.begin_active();
-                        cell!=fine_grid.end(); ++cell)
-                 {
-                       cell->get_dof_indices (local_dof_indices);
-                       for (unsigned int i=0; i<fine_fe.dofs_per_cell; ++i)
-                         if (fine_fe.system_to_component_index(i).first == fine_component)
-                           dof_is_interesting[local_dof_indices[i]] = true;
-                 };
+             for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
+                    cell=fine_grid.begin_active();
+                  cell!=fine_grid.end(); ++cell)
+               {
+                 cell->get_dof_indices (local_dof_indices);
+                 for (unsigned int i=0; i<fine_fe.dofs_per_cell; ++i)
+                   if (fine_fe.system_to_component_index(i).first == fine_component)
+                     dof_is_interesting[local_dof_indices[i]] = true;
+               };
  
-               n_parameters_on_fine_grid = std::count (dof_is_interesting.begin(),
-                                                                           dof_is_interesting.end(),
-                                                                           true);
-             };
+             n_parameters_on_fine_grid = std::count (dof_is_interesting.begin(),
+                                                     dof_is_interesting.end(),
+                                                     true);
+           };
  
  
                                           // set up the weights mapping
-           weights.clear ();
-           weights.resize (n_coarse_dofs);
+         weights.clear ();
+         weights.resize (n_coarse_dofs);
  
-           weight_mapping.clear ();
-           weight_mapping.resize (n_fine_dofs, -1);
+         weight_mapping.clear ();
+         weight_mapping.resize (n_fine_dofs, -1);
  
-           if (true)
 -        if (true)
 -          {
 -            std::vector<unsigned int> local_dof_indices(fine_fe.dofs_per_cell);
 -            unsigned int next_free_index=0;
 -            for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
 -                   cell=fine_grid.begin_active();
 -                 cell != fine_grid.end(); ++cell)
 -              {
 -                cell->get_dof_indices (local_dof_indices);
 -                for (unsigned int i=0; i<fine_fe.dofs_per_cell; ++i)
++      if (true)
++        {
++          std::vector<types::global_dof_index> local_dof_indices(fine_fe.dofs_per_cell);
++          unsigned int next_free_index=0;
++          for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
++                 cell=fine_grid.begin_active();
++               cell != fine_grid.end(); ++cell)
 +            {
-               std::vector<types::global_dof_index> local_dof_indices(fine_fe.dofs_per_cell);
-               unsigned int next_free_index=0;
-               for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
-                          cell=fine_grid.begin_active();
-                        cell != fine_grid.end(); ++cell)
-                 {
-                       cell->get_dof_indices (local_dof_indices);
-                       for (unsigned int i=0; i<fine_fe.dofs_per_cell; ++i)
++              cell->get_dof_indices (local_dof_indices);
++              for (unsigned int i=0; i<fine_fe.dofs_per_cell; ++i)
++
                                                     // if this DoF is a
                                                     // parameter dof and has
                                                     // not yet been numbered,
  
  
                                             // otherwise enter all constraints
-             constraints.add_line (global_dof);
-             constraint_line.clear ();
-             for (unsigned int row=first_used_row; row<n_coarse_dofs; ++row)
-               {
-                 const std::map<unsigned int,float>::const_iterator
-                       j = weights[row].find(col);
-                 if ((j != weights[row].end()) && (j->second != 0))
-                       constraint_line.push_back (std::pair<unsigned int,double>(representants[row],
-                                                                                     j->second));
-               };
-             constraints.add_entries (global_dof, constraint_line);
-           };
+           constraints.add_line (global_dof);
+           constraint_line.clear ();
+           for (unsigned int row=first_used_row; row<n_coarse_dofs; ++row)
+             {
+               const std::map<unsigned int,float>::const_iterator
+                 j = weights[row].find(col);
+               if ((j != weights[row].end()) && (j->second != 0))
+                 constraint_line.push_back (std::pair<unsigned int,double>(representants[row],
 -                                                                        j->second));
++                                                                          j->second));
+             };
+           constraints.add_entries (global_dof, constraint_line);
+         };
    }
  
  
    template <class DH>
    void
    map_dof_to_boundary_indices (const DH                  &dof_handler,
-                                          std::vector<types::global_dof_index> &mapping)
 -                               std::vector<unsigned int> &mapping)
++                             std::vector<types::global_dof_index> &mapping)
    {
      Assert (&dof_handler.get_fe() != 0, ExcNoFESelected());
  
      mapping.clear ();
      mapping.insert (mapping.end(), dof_handler.n_dofs(),
-                           DH::invalid_dof_index);
+                     DH::invalid_dof_index);
  
 -    std::vector<unsigned int> dofs_on_face;
 +    std::vector<types::global_dof_index> dofs_on_face;
      dofs_on_face.reserve (max_dofs_per_face(dof_handler));
      unsigned int next_boundary_index = 0;
  
        void
        map_dofs_to_support_points(const hp::MappingCollection<DH::dimension, DH::space_dimension> & mapping,
                                   const DH  &dof_handler,
 -                                 std::map<unsigned int,Point<DH::space_dimension> >  &support_points)
 +                                 std::map<types::global_dof_index,Point<DH::space_dimension> >  &support_points)
        {
--          const unsigned int dim = DH::dimension;
--          const unsigned int spacedim = DH::space_dimension;
 -
 -          hp::FECollection<dim, spacedim> fe_collection(dof_handler.get_fe());
 -          hp::QCollection<dim> q_coll_dummy;
 -
 -          for (unsigned int fe_index = 0; fe_index < fe_collection.size(); ++fe_index)
 -            {
 -              // check whether every fe in the collection
 -              // has support points
 -              Assert(fe_collection[fe_index].has_support_points(),
 -                     typename FiniteElement<dim>::ExcFEHasNoSupportPoints());
 -              q_coll_dummy.push_back(
 -                  Quadrature<dim> (
 -                      fe_collection[fe_index].get_unit_support_points()));
 -            }
++        const unsigned int dim = DH::dimension;
++        const unsigned int spacedim = DH::space_dimension;
  
-           hp::FECollection<dim, spacedim> fe_collection(dof_handler.get_fe());
-           hp::QCollection<dim> q_coll_dummy;
 -          // now loop over all cells and
 -          // enquire the support points on
 -          // each of these. we use dummy
 -          // quadrature formulas where the
 -          // quadrature points are located at
 -          // the unit support points to
 -          // enquire the location of the
 -          // support points in real space
 -          //
 -          // the weights of the quadrature
 -          // rule have been set to invalid values
 -          // by the used constructor.
 -          hp::FEValues<dim, spacedim> hp_fe_values(mapping, fe_collection,
 -                                                   q_coll_dummy, update_quadrature_points);
 -          typename DH::active_cell_iterator cell =
 -              dof_handler.begin_active(), endc = dof_handler.end();
 -
 -          std::vector<unsigned int> local_dof_indices;
 -          for (; cell != endc; ++cell)
 -            // only work on locally relevant cells
 -            if (cell->is_artificial() == false)
 -              {
 -                hp_fe_values.reinit(cell);
 -                const FEValues<dim, spacedim> &fe_values = hp_fe_values.get_present_fe_values();
++        hp::FECollection<dim, spacedim> fe_collection(dof_handler.get_fe());
++        hp::QCollection<dim> q_coll_dummy;
  
-           for (unsigned int fe_index = 0; fe_index < fe_collection.size(); ++fe_index)
-             {
-               // check whether every fe in the collection
-               // has support points
-               Assert(fe_collection[fe_index].has_support_points(),
-                      typename FiniteElement<dim>::ExcFEHasNoSupportPoints());
-               q_coll_dummy.push_back(
-                   Quadrature<dim> (
-                       fe_collection[fe_index].get_unit_support_points()));
-             }
 -                local_dof_indices.resize(cell->get_fe().dofs_per_cell);
 -                cell->get_dof_indices(local_dof_indices);
++        for (unsigned int fe_index = 0; fe_index < fe_collection.size(); ++fe_index)
++          {
++                                             // check whether every fe in the collection
++                                             // has support points
++            Assert(fe_collection[fe_index].has_support_points(),
++                   typename FiniteElement<dim>::ExcFEHasNoSupportPoints());
++            q_coll_dummy.push_back(
++              Quadrature<dim> (
++                fe_collection[fe_index].get_unit_support_points()));
++          }
  
-           // now loop over all cells and
-           // enquire the support points on
-           // each of these. we use dummy
-           // quadrature formulas where the
-           // quadrature points are located at
-           // the unit support points to
-           // enquire the location of the
-           // support points in real space
-           //
-           // the weights of the quadrature
-           // rule have been set to invalid values
-           // by the used constructor.
-           hp::FEValues<dim, spacedim> hp_fe_values(mapping, fe_collection,
-                                                    q_coll_dummy, update_quadrature_points);
-           typename DH::active_cell_iterator cell =
-               dof_handler.begin_active(), endc = dof_handler.end();
-           std::vector<types::global_dof_index> local_dof_indices;
-           for (; cell != endc; ++cell)
-             // only work on locally relevant cells
-             if (cell->is_artificial() == false)
-               {
-                 hp_fe_values.reinit(cell);
-                 const FEValues<dim, spacedim> &fe_values = hp_fe_values.get_present_fe_values();
 -                const std::vector<Point<spacedim> > & points =
 -                    fe_values.get_quadrature_points();
 -                for (unsigned int i = 0; i < cell->get_fe().dofs_per_cell; ++i)
 -                  // insert the values into the map
 -                  support_points[local_dof_indices[i]] = points[i];
 -              }
++                                         // now loop over all cells and
++                                         // enquire the support points on
++                                         // each of these. we use dummy
++                                         // quadrature formulas where the
++                                         // quadrature points are located at
++                                         // the unit support points to
++                                         // enquire the location of the
++                                         // support points in real space
++                                         //
++                                         // the weights of the quadrature
++                                         // rule have been set to invalid values
++                                         // by the used constructor.
++        hp::FEValues<dim, spacedim> hp_fe_values(mapping, fe_collection,
++                                                 q_coll_dummy, update_quadrature_points);
++        typename DH::active_cell_iterator cell =
++          dof_handler.begin_active(), endc = dof_handler.end();
++
++      std::vector<types::global_dof_index> local_dof_indices;
++      for (; cell != endc; ++cell)
++                                         // only work on locally relevant cells
++        if (cell->is_artificial() == false)
++          {
++            hp_fe_values.reinit(cell);
++            const FEValues<dim, spacedim> &fe_values = hp_fe_values.get_present_fe_values();
 +
-                 local_dof_indices.resize(cell->get_fe().dofs_per_cell);
-                 cell->get_dof_indices(local_dof_indices);
++              local_dof_indices.resize(cell->get_fe().dofs_per_cell);
++              cell->get_dof_indices(local_dof_indices);
 +
-                 const std::vector<Point<spacedim> > & points =
-                   fe_values.get_quadrature_points();
-                 for (unsigned int i = 0; i < cell->get_fe().dofs_per_cell; ++i)
-                   // insert the values into the map
-                   support_points[local_dof_indices[i]] = points[i];
-               }
++              const std::vector<Point<spacedim> > & points =
++                fe_values.get_quadrature_points();
++              for (unsigned int i = 0; i < cell->get_fe().dofs_per_cell; ++i)
++                                                 // insert the values into the map
++                support_points[local_dof_indices[i]] = points[i];
++            }
        }
  
  
        map_dofs_to_support_points(const hp::MappingCollection<DH::dimension, DH::space_dimension> & mapping,
                                   const DH  &dof_handler,
                                   std::vector<Point<DH::space_dimension> >  &support_points)
--        {
--          // get the data in the form of the map as above
-           std::map<types::global_dof_index,Point<DH::space_dimension> >  x_support_points;
 -          std::map<unsigned int,Point<DH::space_dimension> >  x_support_points;
--          map_dofs_to_support_points(mapping, dof_handler, x_support_points);
++      {
++                                       // get the data in the form of the map as above
++      std::map<types::global_dof_index,Point<DH::space_dimension> >  x_support_points;
++      map_dofs_to_support_points(mapping, dof_handler, x_support_points);
  
--          // now convert from the map to the linear vector. make sure every
--          // entry really appeared in the map
--          for (unsigned int i=0; i<dof_handler.n_dofs(); ++i)
--            {
--              Assert (x_support_points.find(i) != x_support_points.end(),
--                      ExcInternalError());
--              support_points[i] = x_support_points[i];
--            }
--        }
++                                         // now convert from the map to the linear vector. make sure every
++                                         // entry really appeared in the map
++        for (unsigned int i=0; i<dof_handler.n_dofs(); ++i)
++          {
++            Assert (x_support_points.find(i) != x_support_points.end(),
++                    ExcInternalError());
++            support_points[i] = x_support_points[i];
++          }
++      }
      }
    }
  
    template <int dim, int spacedim>
    void
    map_dofs_to_support_points (const Mapping<dim,spacedim>       &mapping,
--      const DoFHandler<dim,spacedim>    &dof_handler,
--      std::vector<Point<spacedim> > &support_points)
++                              const DoFHandler<dim,spacedim>    &dof_handler,
++                              std::vector<Point<spacedim> > &support_points)
    {
      AssertDimension(support_points.size(), dof_handler.n_dofs());
      Assert ((dynamic_cast<const parallel::distributed::Triangulation<dim,spacedim>*>
              ExcMessage ("This function can not be used with distributed triangulations."
                          "See the documentation for more information."));
  
--    //Let the internal function do all the work,
--    //just make sure that it gets a MappingCollection
++                                     //Let the internal function do all the work,
++                                     //just make sure that it gets a MappingCollection
      const hp::MappingCollection<dim, spacedim> mapping_collection(mapping);
  
      internal::map_dofs_to_support_points (mapping_collection,
              ExcMessage ("This function can not be used with distributed triangulations."
                          "See the documentation for more information."));
  
--    //Let the internal function do all the work,
--    //just make sure that it gets a MappingCollection
++                                     //Let the internal function do all the work,
++                                     //just make sure that it gets a MappingCollection
      internal::map_dofs_to_support_points (mapping,
                                            dof_handler,
                                            support_points);
    {
      support_points.clear();
  
--    //Let the internal function do all the work,
--    //just make sure that it gets a MappingCollection
++                                     //Let the internal function do all the work,
++                                     //just make sure that it gets a MappingCollection
      const hp::MappingCollection<dim, spacedim> mapping_collection(mapping);
  
      internal::map_dofs_to_support_points (mapping_collection,
    {
      support_points.clear();
  
--    //Let the internal function do all the work,
--    //just make sure that it gets a MappingCollection
++                                     //Let the internal function do all the work,
++                                     //just make sure that it gets a MappingCollection
      internal::map_dofs_to_support_points (mapping,
                                            dof_handler,
                                            support_points);
  
      const unsigned int n_components = DoFTools::n_components (dof);
  
-                                      // set the component mask to either
-                                      // the original value or a vector
-                                      // of trues
-     const std::vector<bool> component_mask ((component_mask_.size() == 0) ?
-                                                               std::vector<bool> (n_components, true) :
-                                                               component_mask_);
-     Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0,
-               VectorTools::ExcNoComponentSelected());
+     Assert (component_mask.n_selected_components(n_components) > 0,
+             VectorTools::ExcNoComponentSelected());
  
                                       // a field to store the indices
 -    std::vector<unsigned int> face_dofs;
 +    std::vector<types::global_dof_index> face_dofs;
      face_dofs.reserve (max_dofs_per_face(dof));
  
      typename DH<dim,spacedim>::active_cell_iterator
  
    template <class DH, class Sparsity>
    void make_cell_patches(
--      Sparsity& block_list,
--      const DH& dof_handler,
--      const unsigned int level,
--      const std::vector<bool>& selected_dofs,
-       types::global_dof_index offset)
 -      unsigned int offset)
++    Sparsity& block_list,
++    const DH& dof_handler,
++    const unsigned int level,
++    const std::vector<bool>& selected_dofs,
++    types::global_dof_index offset)
    {
      typename DH::cell_iterator cell;
      typename DH::cell_iterator endc = dof_handler.end(level);
            AssertDimension(indices.size(), selected_dofs.size());
  
          for (unsigned int j=0;j<indices.size();++j)
--        {
--          if(selected_dofs.size() == 0)
--            block_list.add(i,indices[j]-offset);
--          else
            {
--            if(selected_dofs[j])
++            if(selected_dofs.size() == 0)
                block_list.add(i,indices[j]-offset);
++            else
++              {
++                if(selected_dofs[j])
++                  block_list.add(i,indices[j]-offset);
++              }
            }
--        }
        }
    }
  
      const DH& dof_handler,
      const unsigned int level,
      const bool interior_only)
--    {
--      const FiniteElement<DH::dimension>& fe = dof_handler.get_fe();
--      block_list.reinit(1, dof_handler.n_dofs(level), dof_handler.n_dofs(level));
--      typename DH::cell_iterator cell;
--      typename DH::cell_iterator endc = dof_handler.end(level);
++  {
++    const FiniteElement<DH::dimension>& fe = dof_handler.get_fe();
++    block_list.reinit(1, dof_handler.n_dofs(level), dof_handler.n_dofs(level));
++    typename DH::cell_iterator cell;
++    typename DH::cell_iterator endc = dof_handler.end(level);
  
--      std::vector<unsigned int> indices;
--      std::vector<bool> exclude;
++    std::vector<unsigned int> indices;
++    std::vector<bool> exclude;
  
--      for (cell=dof_handler.begin(level); cell != endc;++cell)
++    for (cell=dof_handler.begin(level); cell != endc;++cell)
        {
          indices.resize(cell->get_fe().dofs_per_cell);
          cell->get_mg_dof_indices(indices);
                block_list.add(0, indices[j]);
            }
        }
--    }
++  }
  
  
    template <class DH>
index 4f3d9e3eea1ba6173d6cdfeea4ede36d212e30af,b0f889f3f6e41730c68491d420de0b17e7031c26..9d6f34d4f8908bc4a10310c0ac8ca2dd1060972c
@@@ -425,15 -436,20 +436,32 @@@ template void DoFTools::extract_dofs<de
  
  template void DoFTools::extract_dofs<deal_II_dimension>
  (const hp::DoFHandler<deal_II_dimension>&,
-  const std::vector<bool>&, std::vector<bool>&, bool);
+  const BlockMask &,
+  std::vector<bool>&);
  
 -template void DoFTools::extract_level_dofs<deal_II_dimension>
 +template void DoFTools::extract_level_dofs<DoFHandler<deal_II_dimension> >
- (const unsigned int, const DoFHandler<deal_II_dimension>&,
-  const std::vector<bool>&, std::vector<bool>&, bool);
++(const unsigned int level,
++ const DoFHandler<deal_II_dimension>&,
++ const ComponentMask &,
++ std::vector<bool>&);
++
++template void DoFTools::extract_level_dofs<DoFHandler<deal_II_dimension> >
++(const unsigned int level,
++ const DoFHandler<deal_II_dimension>&,
++ const BlockMask &,
++ std::vector<bool>&);
++
++template void DoFTools::extract_level_dofs<MGDoFHandler<deal_II_dimension> >
+ (const unsigned int level,
+  const MGDoFHandler<deal_II_dimension>&,
+  const ComponentMask &,
+  std::vector<bool>&);
  
 -template void DoFTools::extract_level_dofs<deal_II_dimension>
 +template void DoFTools::extract_level_dofs<MGDoFHandler<deal_II_dimension> >
- (const unsigned int, const MGDoFHandler<deal_II_dimension>&,
-  const std::vector<bool>&, std::vector<bool>&, bool);
+ (const unsigned int level,
+  const MGDoFHandler<deal_II_dimension>&,
+  const BlockMask &,
+  std::vector<bool>&);
  
  template
  void
@@@ -731,18 -747,22 +759,22 @@@ voi
  DoFTools::count_dofs_per_component<hp::DoFHandler<deal_II_dimension, deal_II_dimension+1> > (
    const hp::DoFHandler<deal_II_dimension, deal_II_dimension+1>&,
    std::vector<unsigned int>&, bool, std::vector<unsigned int>);
-   
  template
  void
 -DoFTools::extract_level_dofs<deal_II_dimension, deal_II_dimension+1>
 +DoFTools::extract_level_dofs<DoFHandler<deal_II_dimension, deal_II_dimension+1> >
- (const unsigned int, const DoFHandler<deal_II_dimension, deal_II_dimension+1>&,
-  const std::vector<bool>&, std::vector<bool>&, bool);
-   
- template 
- void 
+ (const unsigned int level,
 - const MGDoFHandler<deal_II_dimension, deal_II_dimension+1>&,
++ const DoFHandler<deal_II_dimension, deal_II_dimension+1>&,
+  const ComponentMask&,
+  std::vector<bool>&);
+ template
+ void
 -DoFTools::extract_level_dofs<deal_II_dimension, deal_II_dimension+1>
 +DoFTools::extract_level_dofs<MGDoFHandler<deal_II_dimension, deal_II_dimension+1> >
- (const unsigned int, const MGDoFHandler<deal_II_dimension, deal_II_dimension+1>&,
-  const std::vector<bool>&, std::vector<bool>&, bool);
+ (const unsigned int level,
+  const MGDoFHandler<deal_II_dimension, deal_II_dimension+1>&,
+  const BlockMask&,
+  std::vector<bool>&);
  
  #endif
  
@@@ -762,15 -782,19 +794,19 @@@ DoFTools::count_dofs_per_component<hp::
  
  template
  void
 -DoFTools::extract_level_dofs<1,3>
 +DoFTools::extract_level_dofs<DoFHandler<1, 3> >
- (const unsigned int, const DoFHandler<1, 3>&,
-  const std::vector<bool>&, std::vector<bool>&, bool);
-   
- template 
- void 
+ (const unsigned int level,
 - const MGDoFHandler<1,3>&,
++ const DoFHandler<1,3>&,
+  const ComponentMask &,
+  std::vector<bool>&);
+ template
+ void
 -DoFTools::extract_level_dofs<1,3>
 +DoFTools::extract_level_dofs<MGDoFHandler<1, 3> >
- (const unsigned int, const MGDoFHandler<1, 3>&,
-  const std::vector<bool>&, std::vector<bool>&, bool);
+ (const unsigned int level,
+  const MGDoFHandler<1,3>&,
+  const BlockMask &,
+  std::vector<bool>&);
  
  #endif
  
Simple merge
index c81d6320326b5bb475e593663a542d6b2a469d99,15d96c3c86e6e7ed781d24bf6a456991facf3a8b..7d2e640eba55b255344fd047ac22915386dbe5fc
  #include <deal.II/multigrid/mg_tools.h>
  #include <deal.II/multigrid/mg_base.h>
  #include <deal.II/base/mg_level_object.h>
 +#include <deal.II/dofs/dof_handler.h>
  #include <deal.II/dofs/dof_tools.h>
  #include <deal.II/fe/fe.h>
+ #include <deal.II/fe/component_mask.h>
  
  #include <vector>
  #include <algorithm>
@@@ -977,60 -978,61 +978,61 @@@ namespace MGTool
                                             // otherwise determine the number
                                             // of dofs in each component
                                             // separately. do so in parallel
-             std::vector<std::vector<bool> >
-               dofs_in_component (n_components,
-                                          std::vector<bool>(dof_handler.n_dofs(l),
-                                                                        false));
-             std::vector<std::vector<bool> >
-               component_select (n_components,
-                                         std::vector<bool>(n_components, false));
-             Threads::TaskGroup<> tasks;
-             for (unsigned int i=0; i<n_components; ++i)
-               {
-                 void (*fun_ptr) (const unsigned int       level,
-                                          const MGDoFHandler<dim,spacedim>    &,
-                                          const std::vector<bool>    &,
-                                          std::vector<bool>          &,
-                                          bool)
-                       = &DoFTools::template extract_level_dofs<MGDoFHandler<dim, spacedim> >;
-                 component_select[i][i] = true;
-                 tasks += Threads::new_task (fun_ptr,
-                                                             l, dof_handler,
-                                                             component_select[i],
-                                                             dofs_in_component[i], false);
-               }
-             tasks.join_all();
+           std::vector<std::vector<bool> >
+             dofs_in_component (n_components,
+                                std::vector<bool>(dof_handler.n_dofs(l),
+                                                  false));
+           std::vector<ComponentMask> component_select (n_components);
+           Threads::TaskGroup<> tasks;
+           for (unsigned int i=0; i<n_components; ++i)
+             {
+               void (*fun_ptr) (const unsigned int       level,
+                                const MGDoFHandler<dim,spacedim>    &,
+                                const ComponentMask    &,
+                                std::vector<bool>          &)
 -                = &DoFTools::template extract_level_dofs<dim>;
++                = &DoFTools::template extract_level_dofs<MGDoFHandler<dim,spacedim> >;
+             std::vector<bool> tmp(n_components, false);
+             tmp[i] = true;
+             component_select[i] = ComponentMask(tmp);
+               tasks += Threads::new_task (fun_ptr,
+                                           l, dof_handler,
+                                           component_select[i],
+                                           dofs_in_component[i]);
+             }
+           tasks.join_all();
  
                                             // next count what we got
 -          unsigned int component = 0;
 -          for (unsigned int b=0;b<fe.n_base_elements();++b)
 -            {
 -              const FiniteElement<dim>& base = fe.base_element(b);
 +            unsigned int component = 0;
 +            for (unsigned int b=0;b<fe.n_base_elements();++b)
 +              {
 +                const FiniteElement<dim>& base = fe.base_element(b);
                                                 // Dimension of base element
 -              unsigned int d = base.n_components();
 -
 -              for (unsigned int m=0;m<fe.element_multiplicity(b);++m)
 -                {
 -                  for (unsigned int dd=0;dd<d;++dd)
 -                    {
 -                      if (base.is_primitive() || (!only_once || dd==0))
 -                        result[l][target_component[component]]
 -                          += std::count(dofs_in_component[component].begin(),
 -                                        dofs_in_component[component].end(),
 -                                        true);
 -                      ++component;
 -                    }
 -                }
 -            }
 +                unsigned int d = base.n_components();
 +
 +                for (unsigned int m=0;m<fe.element_multiplicity(b);++m)
 +                      {
 +                        for (unsigned int dd=0;dd<d;++dd)
 +                          {
 +                            if (base.is_primitive() || (!only_once || dd==0))
 +                                  result[l][target_component[component]]
 +                                    += std::count(dofs_in_component[component].begin(),
 +                                                          dofs_in_component[component].end(),
 +                                                          true);
 +                            ++component;
 +                          }
 +                      }
 +              }
                                             // finally sanity check
 -          Assert (!dof_handler.get_fe().is_primitive()
 -                  ||
 -                  std::accumulate (result[l].begin(),
 -                                   result[l].end(), 0U)
 -                  ==
 -                  dof_handler.n_dofs(l),
 -                  ExcInternalError());
 -        }
 +            Assert (!dof_handler.get_fe().is_primitive()
 +                        ||
 +                        std::accumulate (result[l].begin(),
 +                                                 result[l].end(), 0U)
 +                        ==
 +                        dof_handler.n_dofs(l),
 +                        ExcInternalError());
 +          }
        }
    }
  
      for (unsigned int l=0;l<n_levels;++l)
        {
          std::vector<std::vector<bool> >
 -          dofs_in_block (n_blocks, std::vector<bool>(dof_handler.n_dofs(l), false));
 +            dofs_in_block (n_blocks, std::vector<bool>(dof_handler.n_dofs(l), false));
-         std::vector<std::vector<bool> >
-             block_select (n_blocks, std::vector<bool>(n_blocks, false));
+         std::vector<BlockMask> block_select (n_blocks);
          Threads::TaskGroup<> tasks;
          for (unsigned int i=0; i<n_blocks; ++i)
-             {
-               void (*fun_ptr) (const unsigned int level,
-                                        const DH&,
-                                        const std::vector<bool>&,
-                                        std::vector<bool>&,
-                                        bool)
-                 = &DoFTools::template extract_level_dofs<DH>;
-               block_select[i][i] = true;
-               tasks += Threads::new_task (fun_ptr,
-                                                       l, dof_handler, block_select[i],
-                                                       dofs_in_block[i], true);
-             };
+           {
+             void (*fun_ptr) (const unsigned int level,
 -                             const MGDoFHandler<dim,spacedim>&,
++                             const DH&,
+                              const BlockMask &,
+                              std::vector<bool>&)
 -              = &DoFTools::template extract_level_dofs<dim>;
++              = &DoFTools::template extract_level_dofs<DH>;
+             std::vector<bool> tmp(n_blocks, false);
+           tmp[i] = true;
+           block_select[i] = tmp;
+             tasks += Threads::new_task (fun_ptr,
+                                         l, dof_handler, block_select[i],
+                                         dofs_in_block[i]);
+           }
          tasks.join_all ();
  
                                           // next count what we got
  
      std::vector<unsigned int> local_dofs;
      local_dofs.reserve (DoFTools::max_dofs_per_face(dof));
-     std::fill (local_dofs.begin (), local_dofs.end (),
+     std::fill (local_dofs.begin (),
+                  local_dofs.end (),
 -               DoFHandler<dim,spacedim>::invalid_dof_index);
 +                 DoFHandler<dim,spacedim>::invalid_dof_index);
  
                                       // First, deal with the simpler
                                       // case when we have to identify
                                       // all boundary dofs
-     if (component_mask.size() == 0)
+     if (component_mask.n_selected_components(n_components) == n_components)
        {
          typename MGDoFHandler<dim,spacedim>::cell_iterator
 -          cell = dof.begin(),
 -          endc = dof.end();
 +            cell = dof.begin(),
 +            endc = dof.end();
          for (; cell!=endc; ++cell)
 -          {
 -            const FiniteElement<dim> &fe = cell->get_fe();
 -            const unsigned int level = cell->level();
 -            local_dofs.resize(fe.dofs_per_face);
 -
 -            for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
 -                 ++face_no)
 -              if (cell->at_boundary(face_no) == true)
 -                {
 -                  const typename MGDoFHandler<dim,spacedim>::face_iterator
 -                    face = cell->face(face_no);
 -                  const types::boundary_id bi = face->boundary_indicator();
 +            {
 +              const FiniteElement<dim> &fe = cell->get_fe();
 +              const unsigned int level = cell->level();
 +              local_dofs.resize(fe.dofs_per_face);
 +
 +              for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
 +                   ++face_no)
 +                if (cell->at_boundary(face_no) == true)
 +                  {
 +                        const typename MGDoFHandler<dim,spacedim>::face_iterator
 +                          face = cell->face(face_no);
 +                        const types::boundary_id bi = face->boundary_indicator();
                                                     // Face is listed in
                                                     // boundary map
 -                  if (function_map.find(bi) != function_map.end())
 -                    {
 -                      face->get_mg_dof_indices(level, local_dofs);
 -                      for (unsigned int i=0;i<fe.dofs_per_face;++i)
 -                        boundary_indices[level].insert(local_dofs[i]);
 -                    }
 -                }
 -          }
 +                        if (function_map.find(bi) != function_map.end())
 +                          {
 +                            face->get_mg_dof_indices(level, local_dofs);
 +                            for (unsigned int i=0;i<fe.dofs_per_face;++i)
 +                              boundary_indices[level].insert(local_dofs[i]);
 +                          }
 +                  }
 +            }
        }
      else
        {
-         Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0,
+         Assert (component_mask.n_selected_components(n_components) > 0,
 -                ExcMessage("It's probably worthwhile to select at least one component."));
 +                  ExcMessage("It's probably worthwhile to select at least one component."));
  
          typename MGDoFHandler<dim,spacedim>::cell_iterator
 -          cell = dof.begin(),
 -          endc = dof.end();
 +            cell = dof.begin(),
 +            endc = dof.end();
          for (; cell!=endc; ++cell)
 -          for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
 -               ++face_no)
 -            {
 -              if (cell->at_boundary(face_no) == false)
 -                continue;
 +            for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
 +                 ++face_no)
 +              {
 +                if (cell->at_boundary(face_no) == false)
 +                  continue;
  
 -              const FiniteElement<dim> &fe = cell->get_fe();
 -              const unsigned int level = cell->level();
 +                const FiniteElement<dim> &fe = cell->get_fe();
 +                const unsigned int level = cell->level();
  
                                                 // we can presently deal only with
                                                 // primitive elements for boundary
                                                 // that are non-zero for the
                                                 // components we are interested in,
                                                 // are in fact primitive
-                 for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
-                   {
-                         const std::vector<bool> &nonzero_component_array
-                           = cell->get_fe().get_nonzero_components (i);
-                         for (unsigned int c=0; c<n_components; ++c)
-                           if ((nonzero_component_array[c] == true)
-                               &&
-                               (component_mask[c] == true))
-                             Assert (cell->get_fe().is_primitive (i),
-                                         ExcMessage ("This function can only deal with requested boundary "
-                                                             "values that correspond to primitive (scalar) base "
-                                                             "elements"));
-                   }
+               for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
+                 {
+                   const ComponentMask &nonzero_component_array
+                     = cell->get_fe().get_nonzero_components (i);
+                   for (unsigned int c=0; c<n_components; ++c)
+                     if ((nonzero_component_array[c] == true)
+                         &&
+                         (component_mask[c] == true))
+                       Assert (cell->get_fe().is_primitive (i),
+                               ExcMessage ("This function can only deal with requested boundary "
+                                           "values that correspond to primitive (scalar) base "
+                                           "elements"));
+                 }
  
 -              typename MGDoFHandler<dim,spacedim>::face_iterator face = cell->face(face_no);
 -              const types::boundary_id boundary_component = face->boundary_indicator();
 -              if (function_map.find(boundary_component) != function_map.end())
 +                typename MGDoFHandler<dim,spacedim>::face_iterator face = cell->face(face_no);
 +                const types::boundary_id boundary_component = face->boundary_indicator();
 +                if (function_map.find(boundary_component) != function_map.end())
                                                   // face is of the right component
 -                {
 +                  {
                                                     // get indices, physical location and
                                                     // boundary values of dofs on this
                                                     // face
  // components. if shape function is non-primitive, then we will ignore
  // the result in the following anyway, otherwise there's only one
  // non-zero component which we will use
-                                         component = (std::find (fe.get_nonzero_components(cell_i).begin(),
-                                                                             fe.get_nonzero_components(cell_i).end(),
-                                                                             true)
-                                                              -
-                                                              fe.get_nonzero_components(cell_i).begin());
-                                       }
+                               component = fe.get_nonzero_components(cell_i).first_selected_component();
+                             }
  
 -                          if (component_mask[component] == true)
 -                            boundary_indices[level].insert(local_dofs[i]);
 -                        }
 -                    }
 -                  else
 -                    for (unsigned int i=0; i<local_dofs.size(); ++i)
 -                      boundary_indices[level].insert(local_dofs[i]);
 -                }
 -            }
 +                                    if (component_mask[component] == true)
 +                                      boundary_indices[level].insert(local_dofs[i]);
 +                              }
 +                          }
 +                        else
 +                          for (unsigned int i=0; i<local_dofs.size(); ++i)
 +                            boundary_indices[level].insert(local_dofs[i]);
 +                  }
 +              }
        }
    }
  
  
    template <int dim, int spacedim>
    void
 +  make_boundary_list(
 +    const DoFHandler<dim,spacedim>& dof,
 +    const typename FunctionMap<dim>::type& function_map,
 +    std::vector<std::set<unsigned int> >& boundary_indices,
 +    const std::vector<bool>& component_mask)
 +  {
 +                                   // if for whatever reason we were
 +                                   // passed an empty map, return
 +                                   // immediately
 +    if (function_map.size() == 0)
 +      return;
 +
 +    const unsigned int n_levels = dof.get_tria().n_levels();
 +
 +
  
-                 const std::vector<bool> &nonzero_component_array
-                   = cell->get_fe().get_nonzero_components (i);
 +    const unsigned int n_components = DoFTools::n_components(dof);
 +    const bool          fe_is_system = (n_components != 1);
 +
 +    AssertDimension (boundary_indices.size(), n_levels);
 +
 +    std::vector<unsigned int> local_dofs;
 +    local_dofs.reserve (DoFTools::max_dofs_per_face(dof));
 +    std::fill (local_dofs.begin (), local_dofs.end (),
 +             DoFHandler<dim,spacedim>::invalid_dof_index);
 +
 +                                 // First, deal with the simpler
 +                                 // case when we have to identify
 +                                 // all boundary dofs
 +    if (component_mask.size() == 0)
 +      {
 +        typename DoFHandler<dim,spacedim>::cell_iterator
 +        cell = dof.begin(),
 +        endc = dof.end();
 +        for (; cell!=endc; ++cell)
 +        {
 +          const FiniteElement<dim> &fe = cell->get_fe();
 +          const unsigned int level = cell->level();
 +          local_dofs.resize(fe.dofs_per_face);
 +
 +          for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
 +               ++face_no)
 +            if (cell->at_boundary(face_no))
 +              {
 +                const typename DoFHandler<dim,spacedim>::face_iterator
 +                  face = cell->face(face_no);
 +                const unsigned char bi = face->boundary_indicator();
 +                                               // Face is listed in
 +                                               // boundary map
 +                if (function_map.find(bi) != function_map.end())
 +                  {
 +                    face->get_mg_dof_indices(level, local_dofs);
 +                    for (unsigned int i=0;i<fe.dofs_per_face;++i)
 +                      boundary_indices[level].insert(local_dofs[i]);
 +                  }
 +              }
 +        }
 +      }
 +    else
 +      {
 +        Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0,
 +              ExcMessage("It's probably worthwhile to select at least one component."));
 +
 +        typename DoFHandler<dim,spacedim>::cell_iterator
 +        cell = dof.begin(),
 +        endc = dof.end();
 +        for (; cell!=endc; ++cell)
 +        for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
 +             ++face_no)
 +          {
 +            if (!(cell->at_boundary(face_no)))
 +              continue;
 +
 +            const FiniteElement<dim> &fe = cell->get_fe();
 +            const unsigned int level = cell->level();
 +
 +                                           // we can presently deal only with
 +                                           // primitive elements for boundary
 +                                           // values. this does not preclude
 +                                           // us using non-primitive elements
 +                                           // in components that we aren't
 +                                           // interested in, however. make
 +                                           // sure that all shape functions
 +                                           // that are non-zero for the
 +                                           // components we are interested in,
 +                                           // are in fact primitive
 +            for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
 +              {
-                             component = (std::find (fe.get_nonzero_components(cell_i).begin(),
-                                                     fe.get_nonzero_components(cell_i).end(),
-                                                     true)
-                                          -
-                                          fe.get_nonzero_components(cell_i).begin());
++                  const ComponentMask &nonzero_component_array
++                    = cell->get_fe().get_nonzero_components (i);
 +                for (unsigned int c=0; c<n_components; ++c)
 +                  if ((nonzero_component_array[c] == true)
 +                      &&
 +                      (component_mask[c] == true))
 +                    Assert (cell->get_fe().is_primitive (i),
 +                            ExcMessage ("This function can only deal with requested boundary "
 +                                        "values that correspond to primitive (scalar) base "
 +                                        "elements"));
 +              }
 +
 +            typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_no);
 +            const unsigned char boundary_component = face->boundary_indicator();
 +            if (function_map.find(boundary_component) != function_map.end())
 +                                             // face is of the right component
 +              {
 +                                               // get indices, physical location and
 +                                               // boundary values of dofs on this
 +                                               // face
 +                local_dofs.resize (fe.dofs_per_face);
 +                face->get_mg_dof_indices (level, local_dofs);
 +                if (fe_is_system)
 +                  {
 +                                                   // enter those dofs
 +                                                   // into the list that
 +                                                   // match the
 +                                                   // component
 +                                                   // signature. avoid
 +                                                   // the usual
 +                                                   // complication that
 +                                                   // we can't just use
 +                                                   // *_system_to_component_index
 +                                                   // for non-primitive
 +                                                   // FEs
 +                    for (unsigned int i=0; i<local_dofs.size(); ++i)
 +                      {
 +                        unsigned int component;
 +                        if (fe.is_primitive())
 +                          component = fe.face_system_to_component_index(i).first;
 +                        else
 +                          {
 +                                                           // non-primitive
 +                                                           // case. make
 +                                                           // sure that
 +                                                           // this
 +                                                           // particular
 +                                                           // shape
 +                                                           // function
 +                                                           // _is_
 +                                                           // primitive,
 +                                                           // and get at
 +                                                           // it's
 +                                                           // component. use
 +                                                           // usual
 +                                                           // trick to
 +                                                           // transfer
 +                                                           // face dof
 +                                                           // index to
 +                                                           // cell dof
 +
 +                                                           // index
 +                            const unsigned int cell_i
 +                              = (dim == 1 ?
 +                                 i
 +                                 :
 +                                 (dim == 2 ?
 +                                  (i<2*fe.dofs_per_vertex ? i : i+2*fe.dofs_per_vertex)
 +                                  :
 +                                  (dim == 3 ?
 +                                   (i<4*fe.dofs_per_vertex ?
 +                                    i
 +                                    :
 +                                    (i<4*fe.dofs_per_vertex+4*fe.dofs_per_line ?
 +                                     i+4*fe.dofs_per_vertex
 +                                     :
 +                                     i+4*fe.dofs_per_vertex+8*fe.dofs_per_line))
 +                                   :
 +                                   numbers::invalid_unsigned_int)));
 +                            Assert (cell_i < fe.dofs_per_cell, ExcInternalError());
 +
 +                                                           // make sure
 +                                                           // that if
 +                                                           // this is
 +                                                           // not a
 +                                                           // primitive
 +                                                           // shape function,
 +                                                           // then all
 +                                                           // the
 +                                                           // corresponding
 +                                                           // components
 +                                                           // in the
 +                                                           // mask are
 +                                                           // not set
 +//                         if (!fe.is_primitive(cell_i))
 +//                           for (unsigned int c=0; c<n_components; ++c)
 +//                             if (fe.get_nonzero_components(cell_i)[c])
 +//                               Assert (component_mask[c] == false,
 +//                                       ExcFENotPrimitive());
 +
 +// let's pick the first of possibly more than one non-zero
 +// components. if shape function is non-primitive, then we will ignore
 +// the result in the following anyway, otherwise there's only one
 +// non-zero component which we will use
++                              component = fe.get_nonzero_components(cell_i).first_selected_component();
 +                          }
 +
 +                        if (component_mask[component] == true)
 +                          boundary_indices[level].insert(local_dofs[i]);
 +                      }
 +                  }
 +                else
 +                  for (unsigned int i=0; i<local_dofs.size(); ++i)
 +                    boundary_indices[level].insert(local_dofs[i]);
 +              }
 +          }
 +      }
 +  }
 +
 +
 +
 +  template <int dim, int spacedim>
 +  void
    make_boundary_list(const MGDoFHandler<dim,spacedim>& dof,
-                            const typename FunctionMap<dim>::type& function_map,
-                            std::vector<IndexSet>& boundary_indices,
-                            const std::vector<bool>& component_mask)
+                      const typename FunctionMap<dim>::type& function_map,
+                      std::vector<IndexSet>& boundary_indices,
+                      const ComponentMask & component_mask)
    {
      Assert (boundary_indices.size() == dof.get_tria().n_levels(),
 -            ExcDimensionMismatch (boundary_indices.size(),
 -                                  dof.get_tria().n_levels()));
 +              ExcDimensionMismatch (boundary_indices.size(),
 +                                                dof.get_tria().n_levels()));
  
      std::vector<std::set<unsigned int> >
        my_boundary_indices (dof.get_tria().n_levels());
index 4f657ada477438a209e89889d2b1063a0cbfeffb,9ec731c1e78881e046208fd035105cb80be7f6b6..24932ea63edde341e8c1ff86a286420b9a211473
@@@ -101,16 -92,10 +101,16 @@@ for (deal_II_dimension : DIMENSIONS
        const MGDoFHandler<deal_II_dimension>&,
        const FunctionMap<deal_II_dimension>::type&,
        std::vector<std::set<unsigned int> >&,
-       const std::vector<bool>&);
+       const ComponentMask &);
 +
 +      template void make_boundary_list(
 +      const DoFHandler<deal_II_dimension>&,
 +      const FunctionMap<deal_II_dimension>::type&,
 +      std::vector<std::set<unsigned int> >&,
 +      const std::vector<bool>&);
  #endif
  
-       template void make_boundary_list(
+     template void make_boundary_list(
        const MGDoFHandler<deal_II_dimension>&,
        const FunctionMap<deal_II_dimension>::type&,
        std::vector<IndexSet>&,
        extract_inner_interface_dofs (const MGDoFHandler<deal_II_dimension> &mg_dof_handler,
                                      std::vector<std::vector<bool> >  &interface_dofs,
                                      std::vector<std::vector<bool> >  &boundary_interface_dofs);
-       template
+     template
 +      void
 +      extract_inner_interface_dofs (const DoFHandler<deal_II_dimension> &mg_dof_handler,
 +                                    std::vector<std::vector<bool> >  &interface_dofs,
 +                                    std::vector<std::vector<bool> >  &boundary_interface_dofs);
 +      template
        void
        extract_inner_interface_dofs (const MGDoFHandler<deal_II_dimension> &mg_dof_handler,
                                      std::vector<std::vector<bool> >  &interface_dofs);

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.