]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add merge.
authorbuerg <buerg@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 8 Aug 2012 17:06:35 +0000 (17:06 +0000)
committerbuerg <buerg@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 8 Aug 2012 17:06:35 +0000 (17:06 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_merge_mg_into_dof_handler@25783 0785d39b-7218-0410-832d-ea1e28bc413d

22 files changed:
deal.II/include/deal.II/dofs/block_info.h
deal.II/include/deal.II/dofs/dof_accessor.h
deal.II/include/deal.II/dofs/dof_accessor.templates.h
deal.II/include/deal.II/dofs/dof_handler.h
deal.II/include/deal.II/dofs/dof_tools.h
deal.II/include/deal.II/hp/dof_handler.h
deal.II/include/deal.II/multigrid/mg_constrained_dofs.h
deal.II/include/deal.II/multigrid/mg_transfer.h
deal.II/include/deal.II/multigrid/mg_transfer.templates.h
deal.II/include/deal.II/multigrid/multigrid.h
deal.II/source/dofs/block_info.cc
deal.II/source/dofs/block_info.inst.in
deal.II/source/dofs/dof_accessor.cc
deal.II/source/dofs/dof_handler.cc
deal.II/source/dofs/dof_handler.inst.in
deal.II/source/dofs/dof_tools.cc
deal.II/source/dofs/dof_tools.inst.in
deal.II/source/hp/dof_handler.cc
deal.II/source/hp/dof_handler.inst.in
deal.II/source/multigrid/mg_tools.cc
deal.II/source/multigrid/mg_transfer_prebuilt.cc
deal.II/source/multigrid/mg_transfer_prebuilt.inst.in

index 68448578e392971f49eddd4be197a3e0aca1687e..a8a874055a984f8c605dca1c01872ec940c0bf05 100644 (file)
@@ -98,7 +98,7 @@ class BlockInfo : public Subscriptor
                                       * the local() indices.
                                       */
     template <int dim, int spacedim>
-    void initialize(const DoFHandler<dim, spacedim>&);
+    void initialize(const DoFHandler<dim, spacedim>&, bool levels_only = false, bool multigrid = false);
 
                                      /**
                                       * @brief Fill the object with values
@@ -180,7 +180,7 @@ class BlockInfo : public Subscriptor
     template <class OS>
     void
     print(OS& stream) const;
-
+    
                                      /**
                                       * Determine an estimate for the
                                       * memory consumption (in bytes)
@@ -305,15 +305,15 @@ BlockInfo::print (OS& os) const
     {
       os << "local    dofs " << std::setw(5) << local().total_size() << " blocks";
       for (unsigned int i=0;i<local().size();++i)
-        os << ' '  << std::setw(5) << local().block_size(i);
+           os << ' '  << std::setw(5) << local().block_size(i);
       os << std::endl;
     }
-
+  
   for (unsigned int l=0;l<levels.size();++l)
     {
       os << "level " << std::setw(2) << l << " dofs " << std::setw(5) << level(l).total_size() << " blocks";
       for (unsigned int i=0;i<level(l).size();++i)
-        os << ' '  << std::setw(5) << level(l).block_size(i);
+           os << ' '  << std::setw(5) << level(l).block_size(i);
       os << std::endl;
     }
 }
@@ -324,9 +324,9 @@ std::size_t
 BlockInfo::memory_consumption () const
 {
   return (MemoryConsumption::memory_consumption (bi_global) +
-          MemoryConsumption::memory_consumption (levels) +
-          MemoryConsumption::memory_consumption (bi_local) +
-          MemoryConsumption::memory_consumption (base_elements));
+             MemoryConsumption::memory_consumption (levels) +
+             MemoryConsumption::memory_consumption (bi_local) +
+             MemoryConsumption::memory_consumption (base_elements));
 }
 
 
index 80e764059c091eea14943ca2da39093acc576924..a58ba09acc33a0b04c77a6de56baec8c76fc1ea2 100644 (file)
@@ -92,7 +92,7 @@ namespace internal
                                           * See the full documentation for
                                           * more information.
                                           */
-        typedef dealii::TriaAccessor<structdim,dim,spacedim> BaseClass;
+           typedef dealii::TriaAccessor<structdim,dim,spacedim> BaseClass;
     };
 
 
@@ -109,7 +109,7 @@ namespace internal
                                           * See the full documentation for
                                           * more information.
                                           */
-        typedef dealii::CellAccessor<dim,spacedim> BaseClass;
+           typedef dealii::CellAccessor<dim,spacedim> BaseClass;
     };
   }
 }
@@ -223,9 +223,9 @@ class DoFAccessor : public dealii::internal::DoFAccessor::Inheritance<structdim,
                                       * Constructor
                                       */
     DoFAccessor (const Triangulation<DH::dimension,DH::space_dimension> *tria,
-                 const int                 level,
-                 const int                 index,
-                 const DH                 *local_data);
+                        const int                 level,
+                        const int                 index,
+                        const DH                 *local_data);
 
                                      /**
                                       * Conversion constructor. This
@@ -405,7 +405,9 @@ class DoFAccessor : public dealii::internal::DoFAccessor::Inheritance<structdim,
                                       * as last argument.
                                       */
     void get_dof_indices (std::vector<unsigned int> &dof_indices,
-                          const unsigned int fe_index = DH::default_fe_index) const;
+                                     const unsigned int fe_index = DH::default_fe_index) const;
+    
+    void get_mg_dof_indices (const int level, std::vector<unsigned int>& dof_indices, const unsigned int fe_index = DH::default_fe_index) const;
 
                                      /**
                                       * Global DoF index of the <i>i</i>
@@ -444,8 +446,10 @@ class DoFAccessor : public dealii::internal::DoFAccessor::Inheritance<structdim,
                                       * active_fe_index().
                                       */
     unsigned int vertex_dof_index (const unsigned int vertex,
-                                   const unsigned int i,
-                                   const unsigned int fe_index = DH::default_fe_index) const;
+                                                  const unsigned int i,
+                                                  const unsigned int fe_index = DH::default_fe_index) const;
+       
+       unsigned int mg_vertex_dof_index (const int level, const unsigned int vertex, const unsigned int i, const unsigned int fe_index = DH::default_fe_index) const;
 
                                      /**
                                       * Index of the <i>i</i>th degree
@@ -502,7 +506,9 @@ class DoFAccessor : public dealii::internal::DoFAccessor::Inheritance<structdim,
                                      * the face.
                                       */
     unsigned int dof_index (const unsigned int i,
-                            const unsigned int fe_index = DH::default_fe_index) const;
+                                       const unsigned int fe_index = DH::default_fe_index) const;
+       
+       unsigned int mg_dof_index (const int level, const unsigned int i) const;
 
                                      /**
                                       * @}
@@ -689,8 +695,10 @@ class DoFAccessor : public dealii::internal::DoFAccessor::Inheritance<structdim,
                                       * active_fe_index().
                                       */
     void set_dof_index (const unsigned int i,
-                        const unsigned int index,
-                        const unsigned int fe_index = DH::default_fe_index) const;
+                                   const unsigned int index,
+                                   const unsigned int fe_index = DH::default_fe_index) const;
+    
+    void set_mg_dof_index (const int level, const unsigned int i, const unsigned int index) const;
 
                                      /**
                                       * Set the global index of the <i>i</i>
@@ -729,9 +737,11 @@ class DoFAccessor : public dealii::internal::DoFAccessor::Inheritance<structdim,
                                       * active_fe_index().
                                       */
     void set_vertex_dof_index (const unsigned int vertex,
-                               const unsigned int i,
-                               const unsigned int index,
-                               const unsigned int fe_index = DH::default_fe_index) const;
+                                          const unsigned int i,
+                                          const unsigned int index,
+                                          const unsigned int fe_index = DH::default_fe_index) const;
+       
+       void set_mg_vertex_dof_index (const int level, const unsigned int vertex, const unsigned int i, const unsigned int index, const unsigned int fe_index = DH::default_fe_index) const;
 
                                      /**
                                       * Iterator classes need to be friends
@@ -867,9 +877,9 @@ class DoFAccessor<0,DH<1,spacedim> > : public TriaAccessor<0,1,spacedim>
                                       * triangulations.
                                       */
     DoFAccessor (const Triangulation<1,spacedim> * tria,
-                 const typename TriaAccessor<0,1,spacedim>::VertexKind vertex_kind,
-                 const unsigned int    vertex_index,
-                 const DH<1,spacedim> * dof_handler);
+                        const typename TriaAccessor<0,1,spacedim>::VertexKind vertex_kind,
+                        const unsigned int    vertex_index,
+                        const DH<1,spacedim> * dof_handler);
 
                                      /**
                                       * Constructor. This constructor
@@ -881,9 +891,9 @@ class DoFAccessor<0,DH<1,spacedim> > : public TriaAccessor<0,1,spacedim>
                                       * may not actually be called.
                                       */
     DoFAccessor (const Triangulation<1,spacedim> *,
-                 const int = 0,
-                 const int = 0,
-                 const DH<1,spacedim> * = 0);
+                        const int = 0,
+                        const int = 0,
+                        const DH<1,spacedim> * = 0);
 
                                      /**
                                       * Conversion constructor. This
@@ -1069,7 +1079,7 @@ class DoFAccessor<0,DH<1,spacedim> > : public TriaAccessor<0,1,spacedim>
                                       * as last argument.
                                       */
     void get_dof_indices (std::vector<unsigned int> &dof_indices,
-                          const unsigned int fe_index = AccessorData::default_fe_index) const;
+                                     const unsigned int fe_index = AccessorData::default_fe_index) const;
 
                                      /**
                                       * Global DoF index of the <i>i</i>
@@ -1108,8 +1118,8 @@ class DoFAccessor<0,DH<1,spacedim> > : public TriaAccessor<0,1,spacedim>
                                       * active_fe_index().
                                       */
     unsigned int vertex_dof_index (const unsigned int vertex,
-                                   const unsigned int i,
-                                   const unsigned int fe_index = AccessorData::default_fe_index) const;
+                                                  const unsigned int i,
+                                                  const unsigned int fe_index = AccessorData::default_fe_index) const;
 
                                      /**
                                       * Index of the <i>i</i>th degree
@@ -1166,7 +1176,7 @@ class DoFAccessor<0,DH<1,spacedim> > : public TriaAccessor<0,1,spacedim>
                                      * the face.
                                       */
     unsigned int dof_index (const unsigned int i,
-                            const unsigned int fe_index = AccessorData::default_fe_index) const;
+                                       const unsigned int fe_index = AccessorData::default_fe_index) const;
 
                                      /**
                                       * @}
@@ -1353,8 +1363,8 @@ class DoFAccessor<0,DH<1,spacedim> > : public TriaAccessor<0,1,spacedim>
                                       * active_fe_index().
                                       */
     void set_dof_index (const unsigned int i,
-                        const unsigned int index,
-                        const unsigned int fe_index = AccessorData::default_fe_index) const;
+                                   const unsigned int index,
+                                   const unsigned int fe_index = AccessorData::default_fe_index) const;
 
                                      /**
                                       * Set the global index of the <i>i</i>
@@ -1393,9 +1403,9 @@ class DoFAccessor<0,DH<1,spacedim> > : public TriaAccessor<0,1,spacedim>
                                       * active_fe_index().
                                       */
     void set_vertex_dof_index (const unsigned int vertex,
-                               const unsigned int i,
-                               const unsigned int index,
-                               const unsigned int fe_index = AccessorData::default_fe_index) const;
+                                          const unsigned int i,
+                                          const unsigned int index,
+                                          const unsigned int fe_index = AccessorData::default_fe_index) const;
 
                                      /**
                                       * Iterator classes need to be friends
@@ -1482,9 +1492,9 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
                                       * Constructor
                                       */
     DoFCellAccessor (const Triangulation<DH::dimension,DH::space_dimension> *tria,
-                     const int                 level,
-                     const int                 index,
-                     const AccessorData       *local_data);
+                            const int                 level,
+                            const int                 index,
+                            const AccessorData       *local_data);
 
                                      /**
                                       * Conversion constructor. This
@@ -1523,7 +1533,7 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
                                       * @}
                                       */
 
-                                 /**
+                                     /**
                                       * Return the parent as a DoF
                                       * cell iterator. This
                                       * function is needed since the
@@ -1633,7 +1643,7 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
                                       */
     template <class InputVector, typename number>
     void get_dof_values (const InputVector &values,
-                         Vector<number>    &local_values) const;
+                                    Vector<number>    &local_values) const;
 
                                      /**
                                       * Return the values of the given vector
@@ -1665,8 +1675,8 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
                                       */
     template <class InputVector, typename ForwardIterator>
     void get_dof_values (const InputVector &values,
-                         ForwardIterator    local_values_begin,
-                         ForwardIterator    local_values_end) const;
+                                    ForwardIterator    local_values_begin,
+                                    ForwardIterator    local_values_end) const;
 
                                      /**
                                       * Return the values of the given vector
@@ -1701,9 +1711,9 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
                                       */
     template <class InputVector, typename ForwardIterator>
     void get_dof_values (const ConstraintMatrix &constraints,
-                         const InputVector      &values,
-                         ForwardIterator         local_values_begin,
-                         ForwardIterator         local_values_end) const;
+                                    const InputVector      &values,
+                                    ForwardIterator         local_values_begin,
+                                    ForwardIterator         local_values_end) const;
 
                                      /**
                                       * This function is the counterpart to
@@ -1741,7 +1751,7 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
                                       */
     template <class OutputVector, typename number>
     void set_dof_values (const Vector<number> &local_values,
-                         OutputVector         &values) const;
+                                    OutputVector         &values) const;
 
                                      /**
                                       * Return the interpolation of
@@ -1777,7 +1787,7 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
                                       */
     template <class InputVector, typename number>
     void get_interpolated_dof_values (const InputVector &values,
-                                      Vector<number>    &interpolated_values) const;
+                                                     Vector<number>    &interpolated_values) const;
 
                                      /**
                                       * This, again, is the
@@ -1870,7 +1880,7 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
                                       */
     template <class OutputVector, typename number>
     void set_dof_values_by_interpolation (const Vector<number> &local_values,
-                                          OutputVector         &values) const;
+                                                             OutputVector         &values) const;
 
                                      /**
                                       * Distribute a local (cell
@@ -1909,8 +1919,8 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
     template <typename ForwardIterator, typename OutputVector>
     void
     distribute_local_to_global (ForwardIterator   local_source_begin,
-                                ForwardIterator   local_source_end,
-                                OutputVector     &global_destination) const;
+                                               ForwardIterator   local_source_end,
+                                               OutputVector     &global_destination) const;
 
                                      /**
                                       * Distribute a local (cell based)
@@ -1934,8 +1944,8 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
     void
     distribute_local_to_global (const ConstraintMatrix &constraints,
                                 ForwardIterator         local_source_begin,
-                                ForwardIterator         local_source_end,
-                                OutputVector           &global_destination) const;
+                                               ForwardIterator         local_source_end,
+                                               OutputVector           &global_destination) const;
 
                                      /**
                                       * This function does much the
@@ -1962,9 +1972,9 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
     template <typename number, typename OutputMatrix, typename OutputVector>
     void
     distribute_local_to_global (const FullMatrix<number> &local_matrix,
-                                const Vector<number>     &local_vector,
+                                               const Vector<number>     &local_vector,
                                 OutputMatrix             &global_matrix,
-                                OutputVector             &global_vector) const;
+                                               OutputVector             &global_vector) const;
 
                                      /**
                                       * @}
@@ -2023,6 +2033,8 @@ class DoFCellAccessor :  public DoFAccessor<DH::dimension,DH>
                                       * with them at all.
                                       */
     void get_dof_indices (std::vector<unsigned int> &dof_indices) const;
+    
+    void get_mg_dof_indices (std::vector<unsigned int>& dof_indices) const;
 
                                      /**
                                       * @}
index dedeae99682708ba998074bf1de33ef6f734a8aa..07360dc63a4a6a53eb1ec16e64475f5bd060fefd 100644 (file)
@@ -47,11 +47,11 @@ DoFAccessor<structdim,DH>::DoFAccessor (
   const int                 level,
   const int                 index,
   const DH                 *dof_handler)
-                :
-                dealii::internal::DoFAccessor::Inheritance<structdim,DH::dimension,
+                       :
+                       dealii::internal::DoFAccessor::Inheritance<structdim,DH::dimension,
                                                            DH::space_dimension>::BaseClass (tria,
-                                                                                            level,
-                                                                                            index),
+                                                                                                                                   level,
+                                                                                                                                   index),
                 dof_handler(const_cast<DH*>(dof_handler))
 {}
 
@@ -157,17 +157,17 @@ DoFAccessor<structdim,DH>::child (const unsigned int i) const
     next_level = 0;
 
   TriaIterator<DoFAccessor<structdim,DH> > q (this->tria,
-                                              next_level,
-                                              this->child_index (i),
-                                              this->dof_handler);
+                                                                 next_level,
+                                                                 this->child_index (i),
+                                                                 this->dof_handler);
 
                                    // make sure that we either created
                                    // a past-the-end iterator or one
                                    // pointing to a used cell
   Assert ((q.state() == IteratorState::past_the_end)
-          ||
-          q->used(),
-          TriaAccessorExceptions::ExcUnusedCellAsChild());
+             ||
+             q->used(),
+             TriaAccessorExceptions::ExcUnusedCellAsChild());
 
   return q;
 }
@@ -192,9 +192,9 @@ DoFAccessor<structdim,DH>::parent () const
     previous_level = 0;
 
   TriaIterator<DoFAccessor<structdim,DH> > q (this->tria,
-                                              previous_level,
-                                              this->parent_index (),
-                                              this->dof_handler);
+                                                                 previous_level,
+                                                                 this->parent_index (),
+                                                                 this->dof_handler);
 
   return q;
 }
@@ -216,510 +216,510 @@ namespace internal
                                           * Implementations of the
                                           * get_dof_index/set_dof_index functions.
                                           */
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::DoFHandler<1,spacedim>   &dof_handler,
-                       const unsigned int                      obj_level,
-                       const unsigned int                      obj_index,
-                       const unsigned int                      fe_index,
-                       const unsigned int                      local_index,
-                       dealii::internal::int2type<1>)
-          {
-            return dof_handler.levels[obj_level]->lines.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::DoFHandler<1,spacedim>   &dof_handler,
-                       const unsigned int              obj_level,
-                       const unsigned int              obj_index,
-                       const unsigned int              fe_index,
-                       const unsigned int              local_index,
-                       dealii::internal::int2type<1>,
-                       const unsigned int              global_index)
-          {
-            dof_handler.levels[obj_level]->lines.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::DoFHandler<2,spacedim>   &dof_handler,
-                       const unsigned int              obj_level,
-                       const unsigned int              obj_index,
-                       const unsigned int              fe_index,
-                       const unsigned int              local_index,
-                       dealii::internal::int2type<1>)
-          {
+           template <int spacedim>
+           static
+           unsigned int
+           get_dof_index (const dealii::DoFHandler<1,spacedim>   &dof_handler,
+                              const unsigned int                      obj_level,
+                              const unsigned int                      obj_index,
+                              const unsigned int                      fe_index,
+                              const unsigned int                      local_index,
+                              dealii::internal::int2type<1>)
+             {
+               return dof_handler.levels[obj_level]->lines.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index);
+             }
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_index (const dealii::DoFHandler<1,spacedim>   &dof_handler,
+                              const unsigned int              obj_level,
+                              const unsigned int              obj_index,
+                              const unsigned int              fe_index,
+                              const unsigned int              local_index,
+                              dealii::internal::int2type<1>,
+                              const unsigned int              global_index)
+             {
+               dof_handler.levels[obj_level]->lines.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           get_dof_index (const dealii::DoFHandler<2,spacedim>   &dof_handler,
+                              const unsigned int              obj_level,
+                              const unsigned int              obj_index,
+                              const unsigned int              fe_index,
+                              const unsigned int              local_index,
+                              dealii::internal::int2type<1>)
+             {
                                              // faces have no levels
-            Assert (obj_level == 0, ExcInternalError());
-            return dof_handler.faces->lines.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::DoFHandler<2,spacedim>   &dof_handler,
-                       const unsigned int              obj_level,
-                       const unsigned int              obj_index,
-                       const unsigned int              fe_index,
-                       const unsigned int              local_index,
-                       dealii::internal::int2type<1>,
-                       const unsigned int              global_index)
-          {
+               Assert (obj_level == 0, ExcInternalError());
+               return dof_handler.faces->lines.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index);
+             }
+
+
+           template <int spacedim>
+           static
+       void
+           set_dof_index (const dealii::DoFHandler<2,spacedim>   &dof_handler,
+                              const unsigned int              obj_level,
+                              const unsigned int              obj_index,
+                              const unsigned int              fe_index,
+                              const unsigned int              local_index,
+                              dealii::internal::int2type<1>,
+                              const unsigned int              global_index)
+             {
                                              // faces have no levels
-            Assert (obj_level == 0, ExcInternalError());
-            dof_handler.faces->lines.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::DoFHandler<2,spacedim>   &dof_handler,
-                       const unsigned int              obj_level,
-                       const unsigned int              obj_index,
-                       const unsigned int              fe_index,
-                       const unsigned int              local_index,
-                       dealii::internal::int2type<2>)
-          {
-            return dof_handler.levels[obj_level]->quads.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::DoFHandler<2,spacedim>   &dof_handler,
-                       const unsigned int              obj_level,
-                       const unsigned int              obj_index,
-                       const unsigned int              fe_index,
-                       const unsigned int              local_index,
-                       dealii::internal::int2type<2>,
-                       const unsigned int              global_index)
-          {
-            dof_handler.levels[obj_level]->quads.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
-                       const unsigned int              obj_level,
-                       const unsigned int              obj_index,
-                       const unsigned int              fe_index,
-                       const unsigned int              local_index,
-                       dealii::internal::int2type<1>)
-          {
+               Assert (obj_level == 0, ExcInternalError());
+               dof_handler.faces->lines.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index);
+             }
+
+
+           template <int spacedim>
+           static
+       unsigned int
+           get_dof_index (const dealii::DoFHandler<2,spacedim>   &dof_handler,
+                              const unsigned int              obj_level,
+                              const unsigned int              obj_index,
+                              const unsigned int              fe_index,
+                              const unsigned int              local_index,
+                              dealii::internal::int2type<2>)
+             {
+               return dof_handler.levels[obj_level]->quads.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index);
+             }
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_index (const dealii::DoFHandler<2,spacedim>   &dof_handler,
+                              const unsigned int              obj_level,
+                              const unsigned int              obj_index,
+                              const unsigned int              fe_index,
+                              const unsigned int              local_index,
+                              dealii::internal::int2type<2>,
+                              const unsigned int              global_index)
+             {
+               dof_handler.levels[obj_level]->quads.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           get_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
+                              const unsigned int              obj_level,
+                              const unsigned int              obj_index,
+                              const unsigned int              fe_index,
+                              const unsigned int              local_index,
+                              dealii::internal::int2type<1>)
+             {
                                              // faces have no levels
-            Assert (obj_level == 0, ExcInternalError());
-            return dof_handler.faces->lines.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
-                       const unsigned int              obj_level,
-                       const unsigned int              obj_index,
-                       const unsigned int              fe_index,
-                       const unsigned int              local_index,
-                       dealii::internal::int2type<1>,
-                       const unsigned int              global_index)
-          {
+               Assert (obj_level == 0, ExcInternalError());
+               return dof_handler.faces->lines.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index);
+             }
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
+                              const unsigned int              obj_level,
+                              const unsigned int              obj_index,
+                              const unsigned int              fe_index,
+                              const unsigned int              local_index,
+                              dealii::internal::int2type<1>,
+                              const unsigned int              global_index)
+             {
                                              // faces have no levels
-            Assert (obj_level == 0, ExcInternalError());
-            dof_handler.faces->lines.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index);
-          }
-
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
-                       const unsigned int              obj_level,
-                       const unsigned int              obj_index,
-                       const unsigned int              fe_index,
-                       const unsigned int              local_index,
-                       dealii::internal::int2type<2>)
-          {
+               Assert (obj_level == 0, ExcInternalError());
+               dof_handler.faces->lines.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index);
+             }
+
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           get_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
+                              const unsigned int              obj_level,
+                              const unsigned int              obj_index,
+                              const unsigned int              fe_index,
+                              const unsigned int              local_index,
+                              dealii::internal::int2type<2>)
+             {
                                              // faces have no levels
-            Assert (obj_level == 0, ExcInternalError());
-            return dof_handler.faces->quads.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
-                       const unsigned int              obj_level,
-                       const unsigned int              obj_index,
-                       const unsigned int              fe_index,
-                       const unsigned int              local_index,
-                       dealii::internal::int2type<2>,
-                       const unsigned int              global_index)
-          {
+               Assert (obj_level == 0, ExcInternalError());
+               return dof_handler.faces->quads.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index);
+             }
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
+                              const unsigned int              obj_level,
+                              const unsigned int              obj_index,
+                              const unsigned int              fe_index,
+                              const unsigned int              local_index,
+                              dealii::internal::int2type<2>,
+                              const unsigned int              global_index)
+             {
                                              // faces have no levels
-            Assert (obj_level == 0, ExcInternalError());
-            dof_handler.faces->quads.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index);
-          }
-
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
-                       const unsigned int              obj_level,
-                       const unsigned int              obj_index,
-                       const unsigned int              fe_index,
-                       const unsigned int              local_index,
-                       dealii::internal::int2type<3>)
-          {
-            return dof_handler.levels[obj_level]->hexes.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
-                       const unsigned int              obj_level,
-                       const unsigned int              obj_index,
-                       const unsigned int              fe_index,
-                       const unsigned int              local_index,
-                       dealii::internal::int2type<3>,
-                       const unsigned int              global_index)
-          {
-            dof_handler.levels[obj_level]->hexes.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.levels[obj_level]->lines.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<1> &,
-                       const unsigned int       global_index)
-          {
-            dof_handler.levels[obj_level]->lines.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index,
-                             obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.faces->lines.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<1> &,
-                       const unsigned int       global_index)
-          {
-            dof_handler.faces->lines.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index,
-                             obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<2> &)
-          {
-            return dof_handler.levels[obj_level]->quads.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<2> &,
-                       const unsigned int       global_index)
-          {
-            dof_handler.levels[obj_level]->quads.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index,
-                             obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.faces->lines.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<1> &,
-                       const unsigned int       global_index)
-          {
-            dof_handler.faces->lines.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index,
-                             obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<2> &)
-          {
-            return dof_handler.faces->quads.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<2> &,
-                       const unsigned int       global_index)
-          {
-            dof_handler.faces->quads.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index,
-                             obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<3> &)
-          {
-            return dof_handler.levels[obj_level]->hexes.
-              get_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                       const unsigned int       obj_level,
-                       const unsigned int       obj_index,
-                       const unsigned int       fe_index,
-                       const unsigned int       local_index,
-                       const dealii::internal::int2type<3> &,
-                       const unsigned int       global_index)
-          {
-            dof_handler.levels[obj_level]->hexes.
-              set_dof_index (dof_handler,
-                             obj_index,
-                             fe_index,
-                             local_index,
-                             global_index,
-                             obj_level);
-          }
-
-
-        template <int structdim, int dim, int spacedim>
-        static
-        bool
-        fe_index_is_active (const dealii::DoFHandler<dim,spacedim> &,
-                            const unsigned int,
-                            const unsigned int,
-                            const unsigned int fe_index,
-                            const dealii::internal::int2type<structdim> &)
-          {
-            return (fe_index == 0);
-          }
-
-
-
-        template <int structdim, int dim, int spacedim>
-        static
-        unsigned int
-        n_active_fe_indices (const dealii::DoFHandler<dim,spacedim> &dof_handler,
-                             const unsigned int obj_level,
-                             const unsigned int obj_index,
-                             const dealii::internal::int2type<structdim> &)
-          {
+               Assert (obj_level == 0, ExcInternalError());
+               dof_handler.faces->quads.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index);
+             }
+
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           get_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
+                              const unsigned int              obj_level,
+                              const unsigned int              obj_index,
+                              const unsigned int              fe_index,
+                              const unsigned int              local_index,
+                              dealii::internal::int2type<3>)
+             {
+               return dof_handler.levels[obj_level]->hexes.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index);
+             }
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_index (const dealii::DoFHandler<3,spacedim>   &dof_handler,
+                              const unsigned int              obj_level,
+                              const unsigned int              obj_index,
+                              const unsigned int              fe_index,
+                              const unsigned int              local_index,
+                              dealii::internal::int2type<3>,
+                              const unsigned int              global_index)
+             {
+               dof_handler.levels[obj_level]->hexes.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           get_dof_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.levels[obj_level]->lines.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+       void
+           set_dof_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<1> &,
+                              const unsigned int       global_index)
+             {
+               dof_handler.levels[obj_level]->lines.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index,
+                                        obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           get_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.faces->lines.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<1> &,
+                              const unsigned int       global_index)
+             {
+               dof_handler.faces->lines.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index,
+                                        obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           get_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<2> &)
+             {
+               return dof_handler.levels[obj_level]->quads.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<2> &,
+                              const unsigned int       global_index)
+             {
+               dof_handler.levels[obj_level]->quads.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index,
+                                        obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.faces->lines.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<1> &,
+                              const unsigned int       global_index)
+             {
+               dof_handler.faces->lines.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index,
+                                        obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<2> &)
+             {
+               return dof_handler.faces->quads.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<2> &,
+                              const unsigned int       global_index)
+             {
+               dof_handler.faces->quads.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index,
+                                        obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           get_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<3> &)
+             {
+               return dof_handler.levels[obj_level]->hexes.
+                 get_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                              const unsigned int       obj_level,
+                              const unsigned int       obj_index,
+                              const unsigned int       fe_index,
+                              const unsigned int       local_index,
+                              const dealii::internal::int2type<3> &,
+                              const unsigned int       global_index)
+             {
+               dof_handler.levels[obj_level]->hexes.
+                 set_dof_index (dof_handler,
+                                        obj_index,
+                                        fe_index,
+                                        local_index,
+                                        global_index,
+                                        obj_level);
+             }
+
+
+           template <int structdim, int dim, int spacedim>
+           static
+       bool
+           fe_index_is_active (const dealii::DoFHandler<dim,spacedim> &,
+                                       const unsigned int,
+                                       const unsigned int,
+                                       const unsigned int fe_index,
+                                       const dealii::internal::int2type<structdim> &)
+             {
+               return (fe_index == 0);
+             }
+
+
+
+           template <int structdim, int dim, int spacedim>
+           static
+           unsigned int
+           n_active_fe_indices (const dealii::DoFHandler<dim,spacedim> &dof_handler,
+                                        const unsigned int obj_level,
+                                        const unsigned int obj_index,
+                                        const dealii::internal::int2type<structdim> &)
+             {
                                              // check that the object we look
                                              // at is in fact active. the
                                              // problem is that we have
@@ -734,42 +734,42 @@ namespace internal
                                              // leaves out is faces in 3d --
                                              // let's hope that this never is
                                              // a problem
-            Assert ((dim==structdim
-                     ?
-                     typename
-                     dealii::DoFHandler<dim,spacedim>::
-                     raw_cell_iterator (&dof_handler.get_tria(),
-                                        obj_level,
-                                        obj_index,
-                                        &dof_handler)->used()
-                     :
-                     (structdim==1
-                      ?
-                      typename
-                      dealii::DoFHandler<dim,spacedim>::
-                      raw_line_iterator (&dof_handler.get_tria(),
-                                         obj_level,
-                                         obj_index,
-                                         &dof_handler)->used()
-                      :
-                      true))
-                    == true,
-                    ExcMessage ("This cell is not active and therefore can't be "
-                                "queried for its active FE indices"));
-            return 1;
-          }
-
-
-
-        template <int structdim, int dim, int spacedim>
-        static
-        unsigned int
-        nth_active_fe_index (const dealii::DoFHandler<dim,spacedim> &dof_handler,
-                             const unsigned int obj_level,
-                             const unsigned int obj_index,
-                             const unsigned int n,
-                             const dealii::internal::int2type<structdim> &)
-          {
+               Assert ((dim==structdim
+                            ?
+                            typename
+                            dealii::DoFHandler<dim,spacedim>::
+                            raw_cell_iterator (&dof_handler.get_tria(),
+                                                           obj_level,
+                                                           obj_index,
+                                                           &dof_handler)->used()
+                            :
+                            (structdim==1
+                             ?
+                             typename
+                             dealii::DoFHandler<dim,spacedim>::
+                             raw_line_iterator (&dof_handler.get_tria(),
+                                                            obj_level,
+                                                            obj_index,
+                                                            &dof_handler)->used()
+                             :
+                             true))
+                           == true,
+                           ExcMessage ("This cell is not active and therefore can't be "
+                                               "queried for its active FE indices"));
+               return 1;
+             }
+
+
+
+           template <int structdim, int dim, int spacedim>
+           static
+           unsigned int
+           nth_active_fe_index (const dealii::DoFHandler<dim,spacedim> &dof_handler,
+                                        const unsigned int obj_level,
+                                        const unsigned int obj_index,
+                                        const unsigned int n,
+                                        const dealii::internal::int2type<structdim> &)
+             {
                                              // check that the object we look
                                              // at is in fact active. the
                                              // problem is that we have
@@ -784,310 +784,310 @@ namespace internal
                                              // leaves out is faces in 3d --
                                              // let's hope that this never is
                                              // a problem
-            Assert ((dim==structdim
-                     ?
-                     typename
-                     dealii::DoFHandler<dim,spacedim>::
-                     raw_cell_iterator (&dof_handler.get_tria(),
-                                        obj_level,
-                                        obj_index,
-                                        &dof_handler)->used()
-                     :
-                     (structdim==1
-                      ?
-                      typename
-                      dealii::DoFHandler<dim,spacedim>::
-                      raw_line_iterator (&dof_handler.get_tria(),
-                                         obj_level,
-                                         obj_index,
-                                         &dof_handler)->used()
-                      :
-                      true))
-                    == true,
-                    ExcMessage ("This cell is not active and therefore can't be "
-                                "queried for its active FE indices"));
-            Assert (n == 0, ExcIndexRange (n, 0, 1));
-
-            return dealii::DoFHandler<dim,spacedim>::default_fe_index;
-          }
-
-
-        template <int spacedim>
-        static
-        bool
-        fe_index_is_active (const dealii::hp::DoFHandler<1,spacedim> &dof_handler,
-                            const unsigned int obj_level,
-                            const unsigned int obj_index,
-                            const unsigned int fe_index,
-                            const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.levels[obj_level]->lines.fe_index_is_active(dof_handler,
-                                                                           obj_index,
-                                                                           fe_index,
-                                                                           obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        n_active_fe_indices (const dealii::hp::DoFHandler<1,spacedim> &dof_handler,
-                             const unsigned int obj_level,
-                             const unsigned int obj_index,
-                             const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.levels[obj_level]->lines.n_active_fe_indices (dof_handler,
-                                                                             obj_index);
-          }
-
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        nth_active_fe_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler,
-                             const unsigned int obj_level,
-                             const unsigned int obj_index,
-                             const unsigned int n,
-                             const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.levels[obj_level]->lines.nth_active_fe_index (dof_handler,
-                                                                             obj_level,
-                                                                             obj_index,
-                                                                             n);
-          }
-
-
-        template <int spacedim>
-        static
-        bool
-        fe_index_is_active (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
-                            const unsigned int obj_level,
-                            const unsigned int obj_index,
-                            const unsigned int fe_index,
-                            const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.faces->lines.fe_index_is_active(dof_handler,
-                                                               obj_index,
-                                                               fe_index,
-                                                               obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        n_active_fe_indices (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
-                             const unsigned int ,
-                             const unsigned int obj_index,
-                             const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.faces->lines.n_active_fe_indices (dof_handler,
-                                                                 obj_index);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        nth_active_fe_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
-                             const unsigned int obj_level,
-                             const unsigned int obj_index,
-                             const unsigned int n,
-                             const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.faces->lines.nth_active_fe_index (dof_handler,
-                                                                 obj_level,
-                                                                 obj_index,
-                                                                 n);
-          }
-
-
-
-        template <int spacedim>
-        static
-        bool
-        fe_index_is_active (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
-                            const unsigned int obj_level,
-                            const unsigned int obj_index,
-                            const unsigned int fe_index,
-                            const dealii::internal::int2type<2> &)
-          {
-            return dof_handler.levels[obj_level]->quads.fe_index_is_active(dof_handler,
-                                                                           obj_index,
-                                                                           fe_index,
-                                                                           obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        n_active_fe_indices (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
-                             const unsigned int obj_level,
-                             const unsigned int obj_index,
-                             const dealii::internal::int2type<2> &)
-          {
-            return dof_handler.levels[obj_level]->quads.n_active_fe_indices (dof_handler,
-                                                                             obj_index);
-          }
-
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        nth_active_fe_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
-                             const unsigned int obj_level,
-                             const unsigned int obj_index,
-                             const unsigned int n,
-                             const dealii::internal::int2type<2> &)
-          {
-            return dof_handler.levels[obj_level]->quads.nth_active_fe_index (dof_handler,
-                                                                             obj_level,
-                                                                             obj_index,
-                                                                             n);
-          }
-
-
-
-        template <int spacedim>
-        static
-        bool
-        fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                            const unsigned int obj_level,
-                            const unsigned int obj_index,
-                            const unsigned int fe_index,
-                            const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.faces->lines.fe_index_is_active(dof_handler,
-                                                               obj_index,
-                                                               fe_index,
-                                                               obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                             const unsigned int,
-                             const unsigned int obj_index,
-                             const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.faces->lines.n_active_fe_indices (dof_handler,
-                                                                 obj_index);
-          }
-
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                             const unsigned int obj_level,
-                             const unsigned int obj_index,
-                             const unsigned int n,
-                             const dealii::internal::int2type<1> &)
-          {
-            return dof_handler.faces->lines.nth_active_fe_index (dof_handler,
-                                                                 obj_level,
-                                                                 obj_index,
-                                                                 n);
-          }
-
-
-
-        template <int spacedim>
-        static
-        bool
-        fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                            const unsigned int obj_level,
-                            const unsigned int obj_index,
-                            const unsigned int fe_index,
-                            const dealii::internal::int2type<2> &)
-          {
-            return dof_handler.faces->quads.fe_index_is_active(dof_handler,
-                                                               obj_index,
-                                                               fe_index,
-                                                               obj_level);
-          }
-
-        template <int spacedim>
-        static
-        bool
-        fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                            const unsigned int obj_level,
-                            const unsigned int obj_index,
-                            const unsigned int fe_index,
-                            const dealii::internal::int2type<3> &)
-          {
-            return dof_handler.levels[obj_level]->hexes.fe_index_is_active(dof_handler,
-                                                                           obj_index,
-                                                                           fe_index,
-                                                                           obj_level);
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                             const unsigned int ,
-                             const unsigned int obj_index,
-                             const dealii::internal::int2type<2> &)
-          {
-            return dof_handler.faces->quads.n_active_fe_indices (dof_handler,
-                                                                 obj_index);
-          }
-
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                             const unsigned int obj_level,
-                             const unsigned int obj_index,
-                             const unsigned int n,
-                             const dealii::internal::int2type<2> &)
-          {
-            return dof_handler.faces->quads.nth_active_fe_index (dof_handler,
-                                                                 obj_level,
-                                                                 obj_index,
-                                                                 n);
-          }
-
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                             const unsigned int obj_level,
-                             const unsigned int obj_index,
-                             const dealii::internal::int2type<3> &)
-          {
-            return dof_handler.levels[obj_level]->hexes.n_active_fe_indices (dof_handler,
-                                                                             obj_index);
-          }
-
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
-                             const unsigned int obj_level,
-                             const unsigned int obj_index,
-                             const unsigned int n,
-                             const dealii::internal::int2type<3> &)
-          {
-            return dof_handler.levels[obj_level]->hexes.nth_active_fe_index (dof_handler,
-                                                                             obj_level,
-                                                                             obj_index,
-                                                                             n);
-          }
+               Assert ((dim==structdim
+                            ?
+                            typename
+                            dealii::DoFHandler<dim,spacedim>::
+                            raw_cell_iterator (&dof_handler.get_tria(),
+                                                           obj_level,
+                                                           obj_index,
+                                                           &dof_handler)->used()
+                            :
+                            (structdim==1
+                             ?
+                             typename
+                             dealii::DoFHandler<dim,spacedim>::
+                             raw_line_iterator (&dof_handler.get_tria(),
+                                                            obj_level,
+                                                            obj_index,
+                                                            &dof_handler)->used()
+                             :
+                             true))
+                           == true,
+                           ExcMessage ("This cell is not active and therefore can't be "
+                                               "queried for its active FE indices"));
+               Assert (n == 0, ExcIndexRange (n, 0, 1));
+
+               return dealii::DoFHandler<dim,spacedim>::default_fe_index;
+             }
+
+
+           template <int spacedim>
+           static
+       bool
+           fe_index_is_active (const dealii::hp::DoFHandler<1,spacedim> &dof_handler,
+                                       const unsigned int obj_level,
+                                       const unsigned int obj_index,
+                                       const unsigned int fe_index,
+                                       const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.levels[obj_level]->lines.fe_index_is_active(dof_handler,
+                                                                                                              obj_index,
+                                                                                                              fe_index,
+                                                                                                              obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           n_active_fe_indices (const dealii::hp::DoFHandler<1,spacedim> &dof_handler,
+                                        const unsigned int obj_level,
+                                        const unsigned int obj_index,
+                                        const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.levels[obj_level]->lines.n_active_fe_indices (dof_handler,
+                                                                                                                obj_index);
+             }
+
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           nth_active_fe_index (const dealii::hp::DoFHandler<1,spacedim> &dof_handler,
+                                        const unsigned int obj_level,
+                                        const unsigned int obj_index,
+                                        const unsigned int n,
+                                        const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.levels[obj_level]->lines.nth_active_fe_index (dof_handler,
+                                                                                                                obj_level,
+                                                                                                                obj_index,
+                                                                                                                n);
+             }
+
+
+           template <int spacedim>
+           static
+       bool
+           fe_index_is_active (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
+                                       const unsigned int obj_level,
+                                       const unsigned int obj_index,
+                                       const unsigned int fe_index,
+                                       const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.faces->lines.fe_index_is_active(dof_handler,
+                                                                                          obj_index,
+                                                                                          fe_index,
+                                                                                          obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           n_active_fe_indices (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
+                                        const unsigned int ,
+                                        const unsigned int obj_index,
+                                        const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.faces->lines.n_active_fe_indices (dof_handler,
+                                                                                                obj_index);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           nth_active_fe_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
+                                        const unsigned int obj_level,
+                                        const unsigned int obj_index,
+                                        const unsigned int n,
+                                        const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.faces->lines.nth_active_fe_index (dof_handler,
+                                                                                                obj_level,
+                                                                                                obj_index,
+                                                                                                n);
+             }
+
+
+
+           template <int spacedim>
+           static
+           bool
+           fe_index_is_active (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
+                                       const unsigned int obj_level,
+                                       const unsigned int obj_index,
+                                       const unsigned int fe_index,
+                                       const dealii::internal::int2type<2> &)
+             {
+               return dof_handler.levels[obj_level]->quads.fe_index_is_active(dof_handler,
+                                                                                                              obj_index,
+                                                                                                              fe_index,
+                                                                                                              obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           n_active_fe_indices (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
+                                        const unsigned int obj_level,
+                                        const unsigned int obj_index,
+                                        const dealii::internal::int2type<2> &)
+             {
+               return dof_handler.levels[obj_level]->quads.n_active_fe_indices (dof_handler,
+                                                                                                                obj_index);
+             }
+
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           nth_active_fe_index (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
+                                        const unsigned int obj_level,
+                                        const unsigned int obj_index,
+                                        const unsigned int n,
+                                        const dealii::internal::int2type<2> &)
+             {
+               return dof_handler.levels[obj_level]->quads.nth_active_fe_index (dof_handler,
+                                                                                                                obj_level,
+                                                                                                                obj_index,
+                                                                                                                n);
+             }
+
+
+
+           template <int spacedim>
+           static
+           bool
+           fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                                       const unsigned int obj_level,
+                                       const unsigned int obj_index,
+                                       const unsigned int fe_index,
+                                       const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.faces->lines.fe_index_is_active(dof_handler,
+                                                                                          obj_index,
+                                                                                          fe_index,
+                                                                                          obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                                        const unsigned int,
+                                        const unsigned int obj_index,
+                                        const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.faces->lines.n_active_fe_indices (dof_handler,
+                                                                                                obj_index);
+             }
+
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                                        const unsigned int obj_level,
+                                        const unsigned int obj_index,
+                                        const unsigned int n,
+                                        const dealii::internal::int2type<1> &)
+             {
+               return dof_handler.faces->lines.nth_active_fe_index (dof_handler,
+                                                                                                obj_level,
+                                                                                                obj_index,
+                                                                                                n);
+             }
+
+
+
+           template <int spacedim>
+           static
+           bool
+           fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                                       const unsigned int obj_level,
+                                       const unsigned int obj_index,
+                                       const unsigned int fe_index,
+                                       const dealii::internal::int2type<2> &)
+             {
+               return dof_handler.faces->quads.fe_index_is_active(dof_handler,
+                                                                                          obj_index,
+                                                                                          fe_index,
+                                                                                          obj_level);
+             }
+
+           template <int spacedim>
+           static
+           bool
+           fe_index_is_active (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                                       const unsigned int obj_level,
+                                       const unsigned int obj_index,
+                                       const unsigned int fe_index,
+                                       const dealii::internal::int2type<3> &)
+             {
+               return dof_handler.levels[obj_level]->hexes.fe_index_is_active(dof_handler,
+                                                                                                              obj_index,
+                                                                                                              fe_index,
+                                                                                                              obj_level);
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                                        const unsigned int ,
+                                        const unsigned int obj_index,
+                                        const dealii::internal::int2type<2> &)
+             {
+               return dof_handler.faces->quads.n_active_fe_indices (dof_handler,
+                                                                                                obj_index);
+             }
+
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                                        const unsigned int obj_level,
+                                        const unsigned int obj_index,
+                                        const unsigned int n,
+                                        const dealii::internal::int2type<2> &)
+             {
+               return dof_handler.faces->quads.nth_active_fe_index (dof_handler,
+                                                                                                obj_level,
+                                                                                                obj_index,
+                                                                                                n);
+             }
+
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                                        const unsigned int obj_level,
+                                        const unsigned int obj_index,
+                                        const dealii::internal::int2type<3> &)
+             {
+               return dof_handler.levels[obj_level]->hexes.n_active_fe_indices (dof_handler,
+                                                                                                                obj_index);
+             }
+
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           nth_active_fe_index (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+                                        const unsigned int obj_level,
+                                        const unsigned int obj_index,
+                                        const unsigned int n,
+                                        const dealii::internal::int2type<3> &)
+             {
+               return dof_handler.levels[obj_level]->hexes.nth_active_fe_index (dof_handler,
+                                                                                                                obj_level,
+                                                                                                                obj_index,
+                                                                                                                n);
+             }
 
                                          /**
                                           * Set the @p local_index-th
@@ -1099,54 +1099,54 @@ namespace internal
                                           * vertex_index to @p
                                           * global_index.
                                           */
-        template <int dim, int spacedim>
-        static
-        void
-        set_vertex_dof_index (dealii::DoFHandler<dim,spacedim> &dof_handler,
-                              const unsigned int vertex_index,
-                              const unsigned int fe_index,
-                              const unsigned int local_index,
-                              const unsigned int global_index)
-          {
-            Assert ((fe_index == dealii::DoFHandler<dim,spacedim>::default_fe_index),
-                    ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects"));
-            Assert (dof_handler.selected_fe != 0,
-                    ExcMessage ("No finite element collection is associated with "
-                                "this DoFHandler"));
-            Assert (local_index < dof_handler.selected_fe->dofs_per_vertex,
-                    ExcIndexRange(local_index, 0,
-                                  dof_handler.selected_fe->dofs_per_vertex));
-
-            dof_handler.vertex_dofs[vertex_index *
-                                    dof_handler.selected_fe->dofs_per_vertex
-                                    + local_index]
-              = global_index;
-          }
-
-
-        template <int dim, int spacedim>
-        static
-        void
-        set_vertex_dof_index (dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
-                              const unsigned int vertex_index,
-                              const unsigned int fe_index,
-                              const unsigned int local_index,
-                              const unsigned int global_index)
-          {
-            Assert ( (fe_index != dealii::hp::DoFHandler<dim,spacedim>::default_fe_index),
-                     ExcMessage ("You need to specify a FE index when working "
-                                 "with hp DoFHandlers"));
-            Assert (dof_handler.finite_elements != 0,
-                    ExcMessage ("No finite element collection is associated with "
-                                "this DoFHandler"));
-            Assert (local_index < (*dof_handler.finite_elements)[fe_index].dofs_per_vertex,
-                    ExcIndexRange(local_index, 0,
-                                  (*dof_handler.finite_elements)[fe_index].dofs_per_vertex));
-            Assert (fe_index < dof_handler.finite_elements->size(),
-                    ExcInternalError());
-            Assert (dof_handler.vertex_dofs_offsets[vertex_index] !=
-                    numbers::invalid_unsigned_int,
-                    ExcMessage ("This vertex is unused and has no DoFs associated with it"));
+           template <int dim, int spacedim>
+           static
+           void
+           set_vertex_dof_index (dealii::DoFHandler<dim,spacedim> &dof_handler,
+                                         const unsigned int vertex_index,
+                                         const unsigned int fe_index,
+                                         const unsigned int local_index,
+                                         const unsigned int global_index)
+             {
+               Assert ((fe_index == dealii::DoFHandler<dim,spacedim>::default_fe_index),
+                           ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects"));
+               Assert (dof_handler.selected_fe != 0,
+                           ExcMessage ("No finite element collection is associated with "
+                                               "this DoFHandler"));
+               Assert (local_index < dof_handler.selected_fe->dofs_per_vertex,
+                           ExcIndexRange(local_index, 0,
+                                                 dof_handler.selected_fe->dofs_per_vertex));
+
+               dof_handler.vertex_dofs[vertex_index *
+                                                   dof_handler.selected_fe->dofs_per_vertex
+                                                   + local_index]
+                 = global_index;
+             }
+
+
+           template <int dim, int spacedim>
+           static
+           void
+           set_vertex_dof_index (dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+                                         const unsigned int vertex_index,
+                                         const unsigned int fe_index,
+                                         const unsigned int local_index,
+                                         const unsigned int global_index)
+             {
+               Assert ( (fe_index != dealii::hp::DoFHandler<dim,spacedim>::default_fe_index),
+                            ExcMessage ("You need to specify a FE index when working "
+                                                "with hp DoFHandlers"));
+               Assert (dof_handler.finite_elements != 0,
+                           ExcMessage ("No finite element collection is associated with "
+                                               "this DoFHandler"));
+               Assert (local_index < (*dof_handler.finite_elements)[fe_index].dofs_per_vertex,
+                           ExcIndexRange(local_index, 0,
+                                                 (*dof_handler.finite_elements)[fe_index].dofs_per_vertex));
+               Assert (fe_index < dof_handler.finite_elements->size(),
+                           ExcInternalError());
+               Assert (dof_handler.vertex_dofs_offsets[vertex_index] !=
+                           numbers::invalid_unsigned_int,
+                           ExcMessage ("This vertex is unused and has no DoFs associated with it"));
 
                                              // hop along the list of index
                                              // sets until we find the one
@@ -1155,28 +1155,28 @@ namespace internal
                                              // part. trigger an exception if
                                              // we can't find a set for this
                                              // particular fe_index
-            const unsigned int starting_offset = dof_handler.vertex_dofs_offsets[vertex_index];
-            unsigned int *pointer              = &dof_handler.vertex_dofs[starting_offset];
-            while (true)
-              {
-                Assert (pointer <= &dof_handler.vertex_dofs.back(), ExcInternalError());
-
-                const unsigned int this_fe_index = *pointer;
-
-                Assert (this_fe_index != numbers::invalid_unsigned_int,
-                        ExcInternalError());
-                Assert (this_fe_index < dof_handler.finite_elements->size(),
-                        ExcInternalError());
-
-                if (this_fe_index == fe_index)
-                  {
-                    *(pointer + 1 + local_index) = global_index;
-                    return;
-                  }
-                else
-                  pointer += (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1;
-              }
-          }
+               const unsigned int starting_offset = dof_handler.vertex_dofs_offsets[vertex_index];
+               unsigned int *pointer              = &dof_handler.vertex_dofs[starting_offset];
+               while (true)
+                 {
+                       Assert (pointer <= &dof_handler.vertex_dofs.back(), ExcInternalError());
+
+                       const unsigned int this_fe_index = *pointer;
+
+                       Assert (this_fe_index != numbers::invalid_unsigned_int,
+                                   ExcInternalError());
+                       Assert (this_fe_index < dof_handler.finite_elements->size(),
+                                   ExcInternalError());
+
+                       if (this_fe_index == fe_index)
+                         {
+                           *(pointer + 1 + local_index) = global_index;
+                           return;
+                         }
+                       else
+                         pointer += (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1;
+                 }
+             }
 
 
                                          /**
@@ -1190,53 +1190,53 @@ namespace internal
                                           * global_index.
                                           */
 
-        template <int dim, int spacedim>
-        static
-        unsigned int
-        get_vertex_dof_index (const dealii::DoFHandler<dim,spacedim> &dof_handler,
-                              const unsigned int vertex_index,
-                              const unsigned int fe_index,
-                              const unsigned int local_index)
-          {
-            Assert ((fe_index == dealii::DoFHandler<dim,spacedim>::default_fe_index),
-                    ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects"));
-            Assert (dof_handler.selected_fe != 0,
-                    ExcMessage ("No finite element collection is associated with "
-                                "this DoFHandler"));
-            Assert (local_index < dof_handler.selected_fe->dofs_per_vertex,
-                    ExcIndexRange(local_index, 0,
-                                  dof_handler.selected_fe->dofs_per_vertex));
-
-            return
-              dof_handler.vertex_dofs[vertex_index *
-                                      dof_handler.selected_fe->dofs_per_vertex
-                                      + local_index];
-          }
-
-
-        template<int dim, int spacedim>
-        static
-        unsigned int
-        get_vertex_dof_index (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
-                              const unsigned int vertex_index,
-                              const unsigned int fe_index,
-                              const unsigned int local_index)
-          {
-            Assert ( (fe_index != dealii::hp::DoFHandler<dim,spacedim>::default_fe_index),
-                     ExcMessage ("You need to specify a FE index when working "
-                                 "with hp DoFHandlers"));
-            Assert (dof_handler.finite_elements != 0,
-                    ExcMessage ("No finite element collection is associated with "
-                                "this DoFHandler"));
-            Assert (local_index < (*dof_handler.finite_elements)[fe_index].dofs_per_vertex,
-                    ExcIndexRange(local_index, 0,
-                                  (*dof_handler.finite_elements)[fe_index].dofs_per_vertex));
-            Assert (vertex_index < dof_handler.vertex_dofs_offsets.size(),
-                    ExcIndexRange (vertex_index, 0,
-                                   dof_handler.vertex_dofs_offsets.size()));
-            Assert (dof_handler.vertex_dofs_offsets[vertex_index] !=
-                    numbers::invalid_unsigned_int,
-                    ExcMessage ("This vertex is unused and has no DoFs associated with it"));
+           template <int dim, int spacedim>
+           static
+           unsigned int
+           get_vertex_dof_index (const dealii::DoFHandler<dim,spacedim> &dof_handler,
+                                         const unsigned int vertex_index,
+                                         const unsigned int fe_index,
+                                         const unsigned int local_index)
+             {
+               Assert ((fe_index == dealii::DoFHandler<dim,spacedim>::default_fe_index),
+                           ExcMessage ("Only the default FE index is allowed for non-hp DoFHandler objects"));
+               Assert (dof_handler.selected_fe != 0,
+                           ExcMessage ("No finite element collection is associated with "
+                                               "this DoFHandler"));
+               Assert (local_index < dof_handler.selected_fe->dofs_per_vertex,
+                           ExcIndexRange(local_index, 0,
+                                                 dof_handler.selected_fe->dofs_per_vertex));
+
+               return
+                 dof_handler.vertex_dofs[vertex_index *
+                                                     dof_handler.selected_fe->dofs_per_vertex
+                                                     + local_index];
+             }
+
+
+           template<int dim, int spacedim>
+           static
+           unsigned int
+           get_vertex_dof_index (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+                                         const unsigned int vertex_index,
+                                         const unsigned int fe_index,
+                                         const unsigned int local_index)
+             {
+               Assert ( (fe_index != dealii::hp::DoFHandler<dim,spacedim>::default_fe_index),
+                            ExcMessage ("You need to specify a FE index when working "
+                                                "with hp DoFHandlers"));
+               Assert (dof_handler.finite_elements != 0,
+                           ExcMessage ("No finite element collection is associated with "
+                                               "this DoFHandler"));
+               Assert (local_index < (*dof_handler.finite_elements)[fe_index].dofs_per_vertex,
+                           ExcIndexRange(local_index, 0,
+                                                 (*dof_handler.finite_elements)[fe_index].dofs_per_vertex));
+               Assert (vertex_index < dof_handler.vertex_dofs_offsets.size(),
+                           ExcIndexRange (vertex_index, 0,
+                                                  dof_handler.vertex_dofs_offsets.size()));
+               Assert (dof_handler.vertex_dofs_offsets[vertex_index] !=
+                           numbers::invalid_unsigned_int,
+                           ExcMessage ("This vertex is unused and has no DoFs associated with it"));
 
                                              // hop along the list of index
                                              // sets until we find the one
@@ -1245,25 +1245,25 @@ namespace internal
                                              // part. trigger an exception if
                                              // we can't find a set for this
                                              // particular fe_index
-            const unsigned int starting_offset = dof_handler.vertex_dofs_offsets[vertex_index];
-            const unsigned int *pointer        = &dof_handler.vertex_dofs[starting_offset];
-            while (true)
-              {
-                Assert (pointer <= &dof_handler.vertex_dofs.back(), ExcInternalError());
+               const unsigned int starting_offset = dof_handler.vertex_dofs_offsets[vertex_index];
+               const unsigned int *pointer        = &dof_handler.vertex_dofs[starting_offset];
+               while (true)
+                 {
+                       Assert (pointer <= &dof_handler.vertex_dofs.back(), ExcInternalError());
 
-                const unsigned int this_fe_index = *pointer;
+                       const unsigned int this_fe_index = *pointer;
 
-                Assert (this_fe_index != numbers::invalid_unsigned_int,
-                        ExcInternalError());
-                Assert (this_fe_index < dof_handler.finite_elements->size(),
-                        ExcInternalError());
+                       Assert (this_fe_index != numbers::invalid_unsigned_int,
+                                   ExcInternalError());
+                       Assert (this_fe_index < dof_handler.finite_elements->size(),
+                                   ExcInternalError());
 
-                if (this_fe_index == fe_index)
-                  return *(pointer + 1 + local_index);
-                else
-                  pointer += (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1;
-              }
-          }
+                       if (this_fe_index == fe_index)
+                         return *(pointer + 1 + local_index);
+                       else
+                         pointer += (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1;
+                 }
+             }
 
 
                                          /**
@@ -1272,45 +1272,45 @@ namespace internal
                                           * that are active on a given
                                           * vertex.
                                           */
-        template<int dim, int spacedim>
-        static
-        unsigned int
-        n_active_vertex_fe_indices (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
-                                    const unsigned int vertex_index)
-          {
-            Assert (dof_handler.finite_elements != 0,
-                    ExcMessage ("No finite element collection is associated with "
-                                "this DoFHandler"));
+           template<int dim, int spacedim>
+           static
+           unsigned int
+           n_active_vertex_fe_indices (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+                                                   const unsigned int vertex_index)
+             {
+               Assert (dof_handler.finite_elements != 0,
+                           ExcMessage ("No finite element collection is associated with "
+                                               "this DoFHandler"));
 
                                              // if this vertex is unused, return 0
-            if (dof_handler.vertex_dofs_offsets[vertex_index] == numbers::invalid_unsigned_int)
-              return 0;
+               if (dof_handler.vertex_dofs_offsets[vertex_index] == numbers::invalid_unsigned_int)
+                 return 0;
 
                                              // hop along the list of index
                                              // sets and count the number of
                                              // hops
-            const unsigned int starting_offset = dof_handler.vertex_dofs_offsets[vertex_index];
-            const unsigned int *pointer        = &dof_handler.vertex_dofs[starting_offset];
+               const unsigned int starting_offset = dof_handler.vertex_dofs_offsets[vertex_index];
+               const unsigned int *pointer        = &dof_handler.vertex_dofs[starting_offset];
 
-            Assert (*pointer != numbers::invalid_unsigned_int,
-                    ExcInternalError());
+               Assert (*pointer != numbers::invalid_unsigned_int,
+                           ExcInternalError());
 
-            unsigned int counter = 0;
-            while (true)
-              {
-                Assert (pointer <= &dof_handler.vertex_dofs.back(), ExcInternalError());
+               unsigned int counter = 0;
+               while (true)
+                 {
+                       Assert (pointer <= &dof_handler.vertex_dofs.back(), ExcInternalError());
 
-                const unsigned int this_fe_index = *pointer;
+                       const unsigned int this_fe_index = *pointer;
 
-                if (this_fe_index == numbers::invalid_unsigned_int)
-                  return counter;
-                else
-                  {
-                    pointer += (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1;
-                    ++counter;
-                  }
-              }
-          }
+                       if (this_fe_index == numbers::invalid_unsigned_int)
+                         return counter;
+                       else
+                         {
+                           pointer += (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1;
+                           ++counter;
+                         }
+                 }
+             }
 
 
 
@@ -1319,54 +1319,54 @@ namespace internal
                                           * n-th finite element active
                                           * on a given vertex.
                                           */
-        template<int dim, int spacedim>
-        static
-        unsigned int
-        nth_active_vertex_fe_index (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
-                                    const unsigned int vertex_index,
-                                    const unsigned int n)
-          {
-            Assert (dof_handler.finite_elements != 0,
-                    ExcMessage ("No finite element collection is associated with "
-                                "this DoFHandler"));
-            Assert (n < n_active_vertex_fe_indices(dof_handler, vertex_index),
-                    ExcIndexRange (n, 0, n_active_vertex_fe_indices(dof_handler,
-                                                                    vertex_index)));
+           template<int dim, int spacedim>
+           static
+           unsigned int
+           nth_active_vertex_fe_index (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+                                                   const unsigned int vertex_index,
+                                                   const unsigned int n)
+             {
+               Assert (dof_handler.finite_elements != 0,
+                           ExcMessage ("No finite element collection is associated with "
+                                               "this DoFHandler"));
+               Assert (n < n_active_vertex_fe_indices(dof_handler, vertex_index),
+                           ExcIndexRange (n, 0, n_active_vertex_fe_indices(dof_handler,
+                                                                                                   vertex_index)));
                                              // make sure we don't ask on
                                              // unused vertices
-            Assert (dof_handler.vertex_dofs_offsets[vertex_index] !=
-                    numbers::invalid_unsigned_int,
-                    ExcInternalError());
+               Assert (dof_handler.vertex_dofs_offsets[vertex_index] !=
+                           numbers::invalid_unsigned_int,
+                           ExcInternalError());
 
                                              // hop along the list of index
                                              // sets and count the number of
                                              // hops
-            const unsigned int starting_offset = dof_handler.vertex_dofs_offsets[vertex_index];
-            const unsigned int *pointer        = &dof_handler.vertex_dofs[starting_offset];
+               const unsigned int starting_offset = dof_handler.vertex_dofs_offsets[vertex_index];
+               const unsigned int *pointer        = &dof_handler.vertex_dofs[starting_offset];
 
-            Assert (*pointer != numbers::invalid_unsigned_int,
-                    ExcInternalError());
+               Assert (*pointer != numbers::invalid_unsigned_int,
+                           ExcInternalError());
 
-            unsigned int counter = 0;
-            while (true)
-              {
-                Assert (pointer <= &dof_handler.vertex_dofs.back(), ExcInternalError());
+               unsigned int counter = 0;
+               while (true)
+                 {
+                       Assert (pointer <= &dof_handler.vertex_dofs.back(), ExcInternalError());
 
-                const unsigned int this_fe_index = *pointer;
+                       const unsigned int this_fe_index = *pointer;
 
-                Assert (this_fe_index < dof_handler.finite_elements->size(),
-                        ExcInternalError());
+                       Assert (this_fe_index < dof_handler.finite_elements->size(),
+                                   ExcInternalError());
 
-                if (counter == n)
-                  return this_fe_index;
+                       if (counter == n)
+                         return this_fe_index;
 
-                Assert (this_fe_index != numbers::invalid_unsigned_int,
-                        ExcInternalError());
+                       Assert (this_fe_index != numbers::invalid_unsigned_int,
+                                   ExcInternalError());
 
-                pointer += (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1;
-                ++counter;
-              }
-          }
+                       pointer += (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1;
+                       ++counter;
+                 }
+             }
 
 
 
@@ -1376,55 +1376,55 @@ namespace internal
                                           * active on the specified
                                           * vertex.
                                           */
-        template<int dim, int spacedim>
-        static
-        bool
-        fe_is_active_on_vertex (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
-                                const unsigned int vertex_index,
-                                const unsigned int fe_index)
-          {
-            Assert ( (fe_index != dealii::hp::DoFHandler<dim,spacedim>::default_fe_index),
-                     ExcMessage ("You need to specify a FE index when working "
-                                 "with hp DoFHandlers"));
-            Assert (dof_handler.finite_elements != 0,
-                    ExcMessage ("No finite element collection is associated with "
-                                "this DoFHandler"));
-            Assert (fe_index < dof_handler.finite_elements->size(),
-                    ExcInternalError());
+           template<int dim, int spacedim>
+           static
+           bool
+           fe_is_active_on_vertex (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+                                               const unsigned int vertex_index,
+                                               const unsigned int fe_index)
+             {
+               Assert ( (fe_index != dealii::hp::DoFHandler<dim,spacedim>::default_fe_index),
+                            ExcMessage ("You need to specify a FE index when working "
+                                                "with hp DoFHandlers"));
+               Assert (dof_handler.finite_elements != 0,
+                           ExcMessage ("No finite element collection is associated with "
+                                               "this DoFHandler"));
+               Assert (fe_index < dof_handler.finite_elements->size(),
+                           ExcInternalError());
 
                                              // make sure we don't ask on
                                              // unused vertices
-            Assert (dof_handler.vertex_dofs_offsets[vertex_index] !=
-                    numbers::invalid_unsigned_int,
-                    ExcInternalError());
+               Assert (dof_handler.vertex_dofs_offsets[vertex_index] !=
+                           numbers::invalid_unsigned_int,
+                           ExcInternalError());
 
                                              // hop along the list of index
                                              // sets and see whether we find
                                              // the given index
-            const unsigned int starting_offset = dof_handler.vertex_dofs_offsets[vertex_index];
-            const unsigned int *pointer        = &dof_handler.vertex_dofs[starting_offset];
+               const unsigned int starting_offset = dof_handler.vertex_dofs_offsets[vertex_index];
+               const unsigned int *pointer        = &dof_handler.vertex_dofs[starting_offset];
 
-            Assert (*pointer != numbers::invalid_unsigned_int,
-                    ExcInternalError());
+               Assert (*pointer != numbers::invalid_unsigned_int,
+                           ExcInternalError());
 
-            while (true)
-              {
-                Assert (pointer <= &dof_handler.vertex_dofs.back(), ExcInternalError());
+               while (true)
+                 {
+                       Assert (pointer <= &dof_handler.vertex_dofs.back(), ExcInternalError());
 
-                const unsigned int this_fe_index = *pointer;
+                       const unsigned int this_fe_index = *pointer;
 
-                Assert (this_fe_index < dof_handler.finite_elements->size(),
-                        ExcInternalError());
+                       Assert (this_fe_index < dof_handler.finite_elements->size(),
+                               ExcInternalError());
 
-                if (this_fe_index == numbers::invalid_unsigned_int)
-                  return false;
-                else
-                  if (this_fe_index == fe_index)
-                    return true;
-                  else
-                    pointer += (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1;
-              }
-          }
+                       if (this_fe_index == numbers::invalid_unsigned_int)
+                         return false;
+                       else
+                         if (this_fe_index == fe_index)
+                           return true;
+                         else
+                           pointer += (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1;
+                 }
+             }
 
     };
   }
@@ -1436,34 +1436,40 @@ template <int dim, class DH>
 inline
 unsigned int
 DoFAccessor<dim,DH>::dof_index (const unsigned int i,
-                                const unsigned int fe_index) const
+                                               const unsigned int fe_index) const
 {
                                    // access the respective DoF
   return dealii::internal::DoFAccessor::Implementation::get_dof_index (*this->dof_handler,
-                                                                       this->level(),
-                                                                       this->present_index,
-                                                                       fe_index,
-                                                                       i,
-                                                                       dealii::internal::int2type<dim>());
+                                                                                                  this->level(),
+                                                                                                  this->present_index,
+                                                                                                  fe_index,
+                                                                                                  i,
+                                                                                                  dealii::internal::int2type<dim>());
 }
 
 
+template<int structdim, class DH>
+inline
+unsigned int DoFAccessor<structdim, DH>::mg_dof_index (const int level, const unsigned int i) const {
+  return this->dof_handler->template get_dof_index<structdim> (level, this->present_index, 0, i);
+}
+
 
 template <int dim, class DH>
 inline
 void
 DoFAccessor<dim,DH>::set_dof_index (const unsigned int i,
-                                    const unsigned int index,
-                                    const unsigned int fe_index) const
+                                                   const unsigned int index,
+                                                   const unsigned int fe_index) const
 {
                                    // access the respective DoF
   dealii::internal::DoFAccessor::Implementation::set_dof_index (*this->dof_handler,
-                                                                this->level(),
-                                                                this->present_index,
-                                                                fe_index,
-                                                                i,
-                                                                dealii::internal::int2type<dim>(),
-                                                                index);
+                                                                                           this->level(),
+                                                                                           this->present_index,
+                                                                                           fe_index,
+                                                                                           i,
+                                                                                           dealii::internal::int2type<dim>(),
+                                                                                           index);
 }
 
 
@@ -1477,9 +1483,9 @@ DoFAccessor<dim,DH>::n_active_fe_indices () const
   return
     dealii::internal::DoFAccessor::Implementation::
     n_active_fe_indices (*this->dof_handler,
-                         this->level(),
-                         this->present_index,
-                         dealii::internal::int2type<dim>());
+                                    this->level(),
+                                    this->present_index,
+                                    dealii::internal::int2type<dim>());
 }
 
 
@@ -1493,10 +1499,10 @@ DoFAccessor<dim,DH>::nth_active_fe_index (const unsigned int n) const
   return
     dealii::internal::DoFAccessor::Implementation::
     nth_active_fe_index (*this->dof_handler,
-                         this->level(),
-                         this->present_index,
-                         n,
-                         dealii::internal::int2type<dim>());
+                                    this->level(),
+                                    this->present_index,
+                                    n,
+                                    dealii::internal::int2type<dim>());
 }
 
 
@@ -1510,10 +1516,10 @@ DoFAccessor<dim,DH>::fe_index_is_active (const unsigned int fe_index) const
   return
     dealii::internal::DoFAccessor::Implementation::
     fe_index_is_active (*this->dof_handler,
-                        this->level(),
-                        this->present_index,
-                        fe_index,
-                        dealii::internal::int2type<dim>());
+                                   this->level(),
+                                   this->present_index,
+                                   fe_index,
+                                   dealii::internal::int2type<dim>());
 }
 
 
@@ -1522,8 +1528,8 @@ template <int structdim, class DH>
 inline
 unsigned int
 DoFAccessor<structdim, DH>::vertex_dof_index (const unsigned int vertex,
-                                              const unsigned int i,
-                                              const unsigned int fe_index) const
+                                                                 const unsigned int i,
+                                                                 const unsigned int fe_index) const
 {
   return
     dealii::internal::DoFAccessor::Implementation::get_vertex_dof_index
@@ -1534,14 +1540,25 @@ DoFAccessor<structdim, DH>::vertex_dof_index (const unsigned int vertex,
 }
 
 
+template<int structdim, class DH>
+inline
+unsigned
+DoFAccessor<structdim, DH>::mg_vertex_dof_index (const int level, const unsigned int vertex, const unsigned int i, const unsigned int fe_index) const {
+  Assert (this->dof_handler != 0, ExcInvalidObject ());
+  Assert (&this->dof_handler->get_fe () != 0, ExcInvalidObject ());
+  Assert (vertex < GeometryInfo<structdim>::vertices_per_cell, ExcIndexRange (vertex, 0, GeometryInfo<structdim>::vertices_per_cell));
+  Assert (i < this->dof_handler->get_fe ()[fe_index].dofs_per_vertex, ExcIndexRange (i, 0, this->dof_handler->get_fe ()[fe_index].dofs_per_vertex));
+  return this->dof_handler->mg_vertex_dofs[this->vertex_index (vertex)].get_index (level, i);
+}
+
 
 template <int structdim, class DH>
 inline
 void
 DoFAccessor<structdim, DH>::set_vertex_dof_index (const unsigned int vertex,
-                                                  const unsigned int i,
-                                                  const unsigned int index,
-                                                  const unsigned int fe_index) const
+                                                                         const unsigned int i,
+                                                                         const unsigned int index,
+                                                                         const unsigned int fe_index) const
 {
   dealii::internal::DoFAccessor::Implementation::set_vertex_dof_index
     (*this->dof_handler,
@@ -1552,8 +1569,24 @@ DoFAccessor<structdim, DH>::set_vertex_dof_index (const unsigned int vertex,
 }
 
 
+template<int structdim, class DH>
+inline
+void
+DoFAccessor<structdim, DH>::set_mg_vertex_dof_index (const int level, const unsigned int vertex, const unsigned int i, const unsigned int index, const unsigned int fe_index) const {
+  Assert (this->dof_handler != 0, ExcInvalidObject ());
+  Assert (&this->dof_handler->get_fe () != 0, ExcInvalidObject ());
+  Assert (vertex < GeometryInfo<structdim>::vertices_per_cell, ExcIndexRange (vertex, 0, GeometryInfo<structdim>::vertices_per_cell));
+  Assert (i < this->dof_handler->get_fe ()[fe_index].dofs_per_vertex, ExcIndexRange (i, 0, this->dof_handler->get_fe ()[fe_index].dofs_per_vertex));
+  this->dof_handler->mg_vertex_dofs[this->vertex_index (vertex)].set_index (level, i, index);
+}
 
 
+template<int structdim, class DH>
+inline
+void
+DoFAccessor<structdim, DH>::set_mg_dof_index (const int level, const unsigned int i, const unsigned int index) const {
+  this->dof_handler->template set_dof_index<structdim> (level, this->present_index, 0, i, index);
+}
 
 
 namespace internal
@@ -1564,7 +1597,7 @@ namespace internal
     inline
     const FiniteElement<dim,spacedim> &
     get_fe (const FiniteElement<dim,spacedim> &fe,
-            const unsigned int)
+               const unsigned int)
     {
       return fe;
     }
@@ -1575,7 +1608,7 @@ namespace internal
     inline
     const FiniteElement<dim,spacedim> &
     get_fe (const dealii::hp::FECollection<dim,spacedim> &fe,
-            const unsigned int                            index)
+               const unsigned int                            index)
     {
       return fe[index];
     }
@@ -1589,7 +1622,7 @@ const FiniteElement<DH::dimension,DH::space_dimension> &
 DoFAccessor<dim,DH>::get_fe (const unsigned int fe_index) const
 {
   Assert (fe_index_is_active (fe_index) == true,
-          ExcMessage ("This function can only be called for active fe indices"));
+             ExcMessage ("This function can only be called for active fe indices"));
 
   return dealii::internal::DoFAccessor::get_fe (this->dof_handler->get_fe(), fe_index);
 }
@@ -1602,33 +1635,33 @@ namespace internal
   {
     template <class DH>
     void get_dof_indices (const dealii::DoFAccessor<1,DH>   &accessor,
-                          std::vector<unsigned int> &dof_indices,
-                          const unsigned int         fe_index)
+                                     std::vector<unsigned int> &dof_indices,
+                                     const unsigned int         fe_index)
     {
       const unsigned int dofs_per_vertex = accessor.get_fe(fe_index).dofs_per_vertex,
-                         dofs_per_line   = accessor.get_fe(fe_index).dofs_per_line;
+                                    dofs_per_line   = accessor.get_fe(fe_index).dofs_per_line;
       std::vector<unsigned int>::iterator next = dof_indices.begin();
       for (unsigned int vertex=0; vertex<2; ++vertex)
-        for (unsigned int d=0; d<dofs_per_vertex; ++d)
-          *next++ = accessor.vertex_dof_index(vertex,d,fe_index);
+           for (unsigned int d=0; d<dofs_per_vertex; ++d)
+             *next++ = accessor.vertex_dof_index(vertex,d,fe_index);
       for (unsigned int d=0; d<dofs_per_line; ++d)
-        *next++ = accessor.dof_index(d,fe_index);
+           *next++ = accessor.dof_index(d,fe_index);
     }
 
 
 
     template <class DH>
     void get_dof_indices (const dealii::DoFAccessor<2,DH>   &accessor,
-                          std::vector<unsigned int> &dof_indices,
-                          const unsigned int         fe_index)
+                                     std::vector<unsigned int> &dof_indices,
+                                     const unsigned int         fe_index)
     {
       const unsigned int dofs_per_vertex = accessor.get_fe(fe_index).dofs_per_vertex,
-                         dofs_per_line   = accessor.get_fe(fe_index).dofs_per_line,
-                         dofs_per_quad   = accessor.get_fe(fe_index).dofs_per_quad;
+                                    dofs_per_line   = accessor.get_fe(fe_index).dofs_per_line,
+                                    dofs_per_quad   = accessor.get_fe(fe_index).dofs_per_quad;
       std::vector<unsigned int>::iterator next = dof_indices.begin();
       for (unsigned int vertex=0; vertex<4; ++vertex)
-        for (unsigned int d=0; d<dofs_per_vertex; ++d)
-          *next++ = accessor.vertex_dof_index(vertex,d,fe_index);
+           for (unsigned int d=0; d<dofs_per_vertex; ++d)
+             *next++ = accessor.vertex_dof_index(vertex,d,fe_index);
                                        // now copy dof numbers from the line. for
                                        // lines with the wrong orientation (which
                                        // might occur in 3d), we have already made
@@ -1641,30 +1674,30 @@ namespace internal
                                        // we see to correspond to the correct
                                        // (face-local) ordering.
       for (unsigned int line=0; line<4; ++line)
-        for (unsigned int d=0; d<dofs_per_line; ++d)
-          *next++ = accessor.line(line)->dof_index(accessor.get_fe(fe_index).
-                                                   adjust_line_dof_index_for_line_orientation(d,
-                                                                                              accessor.line_orientation(line)),
-                                                   fe_index);
+           for (unsigned int d=0; d<dofs_per_line; ++d)
+             *next++ = accessor.line(line)->dof_index(accessor.get_fe(fe_index).
+                                                                          adjust_line_dof_index_for_line_orientation(d,
+                                                                                                                                         accessor.line_orientation(line)),
+                                                                          fe_index);
       for (unsigned int d=0; d<dofs_per_quad; ++d)
-        *next++ = accessor.dof_index(d,fe_index);
+           *next++ = accessor.dof_index(d,fe_index);
     }
 
 
 
     template <class DH>
     void get_dof_indices (const dealii::DoFAccessor<3,DH>   &accessor,
-                          std::vector<unsigned int> &dof_indices,
-                          const unsigned int         fe_index)
+                                     std::vector<unsigned int> &dof_indices,
+                                     const unsigned int         fe_index)
     {
       const unsigned int dofs_per_vertex = accessor.get_fe(fe_index).dofs_per_vertex,
-                         dofs_per_line   = accessor.get_fe(fe_index).dofs_per_line,
-                         dofs_per_quad   = accessor.get_fe(fe_index).dofs_per_quad,
-                         dofs_per_hex    = accessor.get_fe(fe_index).dofs_per_hex;
+                                    dofs_per_line   = accessor.get_fe(fe_index).dofs_per_line,
+                                    dofs_per_quad   = accessor.get_fe(fe_index).dofs_per_quad,
+                                    dofs_per_hex    = accessor.get_fe(fe_index).dofs_per_hex;
       std::vector<unsigned int>::iterator next = dof_indices.begin();
       for (unsigned int vertex=0; vertex<8; ++vertex)
-        for (unsigned int d=0; d<dofs_per_vertex; ++d)
-          *next++ = accessor.vertex_dof_index(vertex,d,fe_index);
+           for (unsigned int d=0; d<dofs_per_vertex; ++d)
+             *next++ = accessor.vertex_dof_index(vertex,d,fe_index);
                                        // now copy dof numbers from the line. for
                                        // lines with the wrong orientation, we have
                                        // already made sure that we're ok by picking
@@ -1677,10 +1710,10 @@ namespace internal
                                        // see to correspond to the correct
                                        // (cell-local) ordering.
       for (unsigned int line=0; line<12; ++line)
-        for (unsigned int d=0; d<dofs_per_line; ++d)
-          *next++ = accessor.line(line)->dof_index(accessor.get_fe(fe_index).
-                                                   adjust_line_dof_index_for_line_orientation(d,
-                                                                                              accessor.line_orientation(line)),fe_index);
+           for (unsigned int d=0; d<dofs_per_line; ++d)
+             *next++ = accessor.line(line)->dof_index(accessor.get_fe(fe_index).
+                                                                          adjust_line_dof_index_for_line_orientation(d,
+                                                                                                                                         accessor.line_orientation(line)),fe_index);
                                        // now copy dof numbers from the face. for
                                        // faces with the wrong orientation, we
                                        // have already made sure that we're ok by
@@ -1695,15 +1728,72 @@ namespace internal
                                        // applies, if the face_rotation or
                                        // face_orientation is non-standard
       for (unsigned int quad=0; quad<6; ++quad)
-        for (unsigned int d=0; d<dofs_per_quad; ++d)
-          *next++ = accessor.quad(quad)->dof_index(accessor.get_fe(fe_index).
-                                                   adjust_quad_dof_index_for_face_orientation(d,
-                                                                                              accessor.face_orientation(quad),
-                                                                                              accessor.face_flip(quad),
-                                                                                              accessor.face_rotation(quad)),
-                                                   fe_index);
+           for (unsigned int d=0; d<dofs_per_quad; ++d)
+             *next++ = accessor.quad(quad)->dof_index(accessor.get_fe(fe_index).
+                                                                          adjust_quad_dof_index_for_face_orientation(d,
+                                                                                                                                         accessor.face_orientation(quad),
+                                                                                                                                         accessor.face_flip(quad),
+                                                                                                                                         accessor.face_rotation(quad)),
+                                                                          fe_index);
       for (unsigned int d=0; d<dofs_per_hex; ++d)
-        *next++ = accessor.dof_index(d,fe_index);
+           *next++ = accessor.dof_index(d,fe_index);
+    }
+    
+    template<class DH>
+    void get_mg_dof_indices (const dealii::DoFAccessor<1, DH>& accessor, const int level, std::vector<unsigned int>& dof_indices, const unsigned int fe_index) {
+      const FiniteElement<DH::dimension, DH::space_dimension>& fe = accessor.get_dof_handler ().get_fe ()[fe_index];
+      std::vector<unsigned int>::iterator next = dof_indices.begin ();
+      
+      for (unsigned int vertex = 0; vertex < GeometryInfo<1>::vertices_per_cell; ++vertex)
+        for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof)
+          *next++ = accessor.mg_vertex_dof_index (level, vertex, dof);
+      
+      for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof)
+        *next++ = accessor.mg_dof_index (level, dof);
+      
+      Assert (next == dof_indices.end (), ExcInternalError ());
+    }
+    
+    template<class DH>
+    void get_mg_dof_indices (const dealii::DoFAccessor<2, DH>& accessor, const int level, std::vector<unsigned int>& dof_indices, const unsigned int fe_index) {
+      const FiniteElement<DH::dimension, DH::space_dimension>& fe = accessor.get_dof_handler ().get_fe ()[fe_index];
+      std::vector<unsigned int>::iterator next = dof_indices.begin ();
+      
+      for (unsigned int vertex = 0; vertex < GeometryInfo<2>::vertices_per_cell; ++vertex)
+        for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof)
+          *next++ = accessor.mg_vertex_dof_index (level, vertex, dof);
+      
+      for (unsigned int line = 0; line < GeometryInfo<2>::lines_per_cell; ++line)
+        for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof)
+          *next++ = accessor.line (line)->mg_dof_index (level, dof);
+      
+      for (unsigned int dof = 0; dof < fe.dofs_per_quad; ++dof)
+        *next++ = accessor.mg_dof_index (level, dof);
+      
+      Assert (next == dof_indices.end (), ExcInternalError ());
+    }
+    
+    template<class DH>
+    void get_mg_dof_indices (const dealii::DoFAccessor<3, DH>& accessor, const int level, std::vector<unsigned int>& dof_indices, const unsigned int fe_index) {
+      const FiniteElement<DH::dimension, DH::space_dimension>& fe = accessor.get_dof_handler ().get_fe ()[fe_index];
+      std::vector<unsigned int>::iterator next = dof_indices.begin ();
+      
+      for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_cell; ++vertex)
+        for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof)
+          *next++ = accessor.mg_vertex_dof_index (level, vertex, dof);
+      
+      for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_cell; ++line)
+        for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof)
+          *next++ = accessor.line (line)->mg_dof_index (level, dof);
+      
+      for (unsigned int quad = 0; quad < GeometryInfo<3>::quads_per_cell; ++quad)
+        for (unsigned int dof = 0; dof < fe.dofs_per_quad; ++dof)
+          *next++ = accessor.quad (quad)->mg_dof_index (level, dof);
+      
+      for (unsigned int dof = 0; dof < fe.dofs_per_hex; ++dof)
+        *next++ = accessor.mg_dof_index (level, dof);
+      
+      Assert (next == dof_indices.end (), ExcInternalError ());
     }
   }
 }
@@ -1713,7 +1803,7 @@ template <int structdim, class DH>
 inline
 void
 DoFAccessor<structdim,DH>::get_dof_indices (std::vector<unsigned int> &dof_indices,
-                                            const unsigned int         fe_index) const
+                                                               const unsigned int         fe_index) const
 {
   Assert (static_cast<unsigned int>(this->level()) < this->dof_handler->levels.size(),
           ExcMessage ("DoFHandler not initialized"));
@@ -1726,28 +1816,28 @@ DoFAccessor<structdim,DH>::get_dof_indices (std::vector<unsigned int> &dof_indic
   switch (structdim)
     {
       case 1:
-            Assert (dof_indices.size() ==
-                    (2*this->dof_handler->get_fe()[fe_index].dofs_per_vertex +
-                     this->dof_handler->get_fe()[fe_index].dofs_per_line),
-                    ExcVectorDoesNotMatch());
-            break;
+               Assert (dof_indices.size() ==
+                           (2*this->dof_handler->get_fe()[fe_index].dofs_per_vertex +
+                            this->dof_handler->get_fe()[fe_index].dofs_per_line),
+                           ExcVectorDoesNotMatch());
+               break;
       case 2:
-            Assert (dof_indices.size() ==
-                    (4*this->dof_handler->get_fe()[fe_index].dofs_per_vertex +
-                     4*this->dof_handler->get_fe()[fe_index].dofs_per_line +
-                     this->dof_handler->get_fe()[fe_index].dofs_per_quad),
-                    ExcVectorDoesNotMatch());
-            break;
+               Assert (dof_indices.size() ==
+                           (4*this->dof_handler->get_fe()[fe_index].dofs_per_vertex +
+                            4*this->dof_handler->get_fe()[fe_index].dofs_per_line +
+                            this->dof_handler->get_fe()[fe_index].dofs_per_quad),
+                           ExcVectorDoesNotMatch());
+               break;
       case 3:
-            Assert (dof_indices.size() ==
-                    (8*this->dof_handler->get_fe()[fe_index].dofs_per_vertex +
-                     12*this->dof_handler->get_fe()[fe_index].dofs_per_line +
-                     6*this->dof_handler->get_fe()[fe_index].dofs_per_quad +
-                     this->dof_handler->get_fe()[fe_index].dofs_per_hex),
-                    ExcVectorDoesNotMatch());
-            break;
+               Assert (dof_indices.size() ==
+                           (8*this->dof_handler->get_fe()[fe_index].dofs_per_vertex +
+                            12*this->dof_handler->get_fe()[fe_index].dofs_per_line +
+                            6*this->dof_handler->get_fe()[fe_index].dofs_per_quad +
+                            this->dof_handler->get_fe()[fe_index].dofs_per_hex),
+                           ExcVectorDoesNotMatch());
+               break;
       default:
-            Assert (false, ExcNotImplemented());
+               Assert (false, ExcNotImplemented());
     }
 
 
@@ -1763,19 +1853,44 @@ DoFAccessor<structdim,DH>::get_dof_indices (std::vector<unsigned int> &dof_indic
                                    // not allocated for this
                                    // non-active thing
   Assert (this->fe_index_is_active (fe_index)
-          ||
-          (this->dof_handler->get_fe()[fe_index].dofs_per_cell ==
-           GeometryInfo<structdim>::vertices_per_cell *
-           this->dof_handler->get_fe()[fe_index].dofs_per_vertex),
-          ExcInternalError());
+             ||
+             (this->dof_handler->get_fe()[fe_index].dofs_per_cell ==
+              GeometryInfo<structdim>::vertices_per_cell *
+              this->dof_handler->get_fe()[fe_index].dofs_per_vertex),
+             ExcInternalError());
 
                                    // now do the actual work
   dealii::internal::DoFAccessor::get_dof_indices (*this, dof_indices, fe_index);
 }
 
-
-
-
+template<int structdim, class DH>
+inline
+void DoFAccessor<structdim, DH>::get_mg_dof_indices (const int level, std::vector<unsigned int>& dof_indices, const unsigned int fe_index) const {
+  Assert (this->dof_handler != 0, ExcInvalidObject ());
+  Assert (&this->dof_handler->get_fe () != 0, ExcInvalidObject ());
+  
+  switch (structdim) {
+    case 1: {
+         Assert (dof_indices.size () == 2 * this->dof_handler->get_fe ()[fe_index].dofs_per_vertex + this->dof_handler->get_fe ()[fe_index].dofs_per_line, ExcVectorDoesNotMatch ());
+         break;
+    }
+    
+    case 2: {
+         Assert (dof_indices.size () == 4 * (this->dof_handler->get_fe ()[fe_index].dofs_per_vertex + this->dof_handler->get_fe ()[fe_index].dofs_per_line) + this->dof_handler->get_fe ()[fe_index].dofs_per_quad, ExcVectorDoesNotMatch ());
+         break;
+    }
+    
+    case 3: {
+         Assert (dof_indices.size () == 8 * this->dof_handler->get_fe ()[fe_index].dofs_per_vertex + 12 * this->dof_handler->get_fe ()[fe_index].dofs_per_line + 6 * this->dof_handler->get_fe ()[fe_index].dofs_per_quad + this->dof_handler->get_fe ()[fe_index].dofs_per_hex, ExcVectorDoesNotMatch ());
+         break;
+    }
+    
+    default:
+         Assert (false, ExcNotImplemented ());
+  }
+  
+  internal::DoFAccessor::get_mg_dof_indices (*this, level, dof_indices, fe_index);
+}
 
 template <int structdim, class DH>
 inline
@@ -1831,13 +1946,13 @@ template <template <int, int> class DH, int spacedim>
 inline
 DoFAccessor<0,DH<1,spacedim> >::
 DoFAccessor (const Triangulation<1,spacedim> *tria,
-             const typename TriaAccessor<0,1,spacedim>::VertexKind vertex_kind,
-             const unsigned int    vertex_index,
-             const DH<1,spacedim> * dof_handler)
-                :
-                BaseClass (tria,
-                           vertex_kind,
-                           vertex_index),
+                const typename TriaAccessor<0,1,spacedim>::VertexKind vertex_kind,
+                const unsigned int    vertex_index,
+                const DH<1,spacedim> * dof_handler)
+                       :
+                       BaseClass (tria,
+                                      vertex_kind,
+                                      vertex_index),
                 dof_handler(const_cast<DH<1,spacedim>*>(dof_handler))
 {}
 
@@ -1847,14 +1962,14 @@ template <template <int, int> class DH, int spacedim>
 inline
 DoFAccessor<0,DH<1,spacedim> >::
 DoFAccessor (const Triangulation<1,spacedim> *,
-             const int                 ,
-             const int                 ,
-             const DH<1,spacedim>     *)
-                :
+                const int                 ,
+                const int                 ,
+                const DH<1,spacedim>     *)
+                       :
                 dof_handler(0)
 {
   Assert (false,
-          ExcMessage ("This constructor can not be called for face iterators in 1d."));
+             ExcMessage ("This constructor can not be called for face iterators in 1d."));
 }
 
 
@@ -1904,15 +2019,15 @@ inline
 void
 DoFAccessor<0,DH<1,spacedim> >::
 get_dof_indices (std::vector<unsigned int> &dof_indices,
-                 const unsigned int fe_index) const
+                        const unsigned int fe_index) const
 {
   for (unsigned int i=0; i<dof_indices.size(); ++i)
     dof_indices[i]
       = dealii::internal::DoFAccessor::Implementation::
       get_vertex_dof_index (*dof_handler,
-                            this->global_vertex_index,
-                            fe_index,
-                            i);
+                                       this->global_vertex_index,
+                                       fe_index,
+                                       i);
 }
 
 
@@ -1922,15 +2037,15 @@ inline
 unsigned int
 DoFAccessor<0,DH<1,spacedim> >::
 vertex_dof_index (const unsigned int vertex,
-                  const unsigned int i,
-                  const unsigned int fe_index) const
+                         const unsigned int i,
+                         const unsigned int fe_index) const
 {
   Assert (vertex == 0, ExcIndexRange (vertex, 0, 1));
   return dealii::internal::DoFAccessor::Implementation::
     get_vertex_dof_index (*dof_handler,
-                          this->global_vertex_index,
-                          fe_index,
-                          i);
+                                     this->global_vertex_index,
+                                     fe_index,
+                                     i);
 }
 
 
@@ -1990,7 +2105,7 @@ namespace internal
                                      // make sure we refer to class
                                      // dealii::DoFCellAccessor, not
                                      // namespace
-                                     // dealii::internal::DoFCellAccessor
+                                     // internal::DoFCellAccessor
     using dealii::DoFCellAccessor;
     using dealii::DoFHandler;
 
@@ -2006,11 +2121,11 @@ namespace internal
                                           * implemented for hp::DoFHandler
                                           * objects.
                                           */
-        template <int spacedim>
-        static
-        void
-        update_cell_dof_indices_cache (const DoFCellAccessor<DoFHandler<1,spacedim> > &accessor)
-          {
+           template <int spacedim>
+           static
+           void
+           update_cell_dof_indices_cache (const DoFCellAccessor<DoFHandler<1,spacedim> > &accessor)
+             {
                                              // check as in documentation that
                                              // cell is either active, or dofs
                                              // are only in vertices. otherwise
@@ -2018,44 +2133,44 @@ namespace internal
                                              // all. the get_dof_indices
                                              // function will then make sure we
                                              // don't access the invalid data
-            if (accessor.has_children()
-                &&
-                (accessor.get_fe().dofs_per_cell !=
-                 accessor.get_fe().dofs_per_vertex * GeometryInfo<1>::vertices_per_cell))
-              return;
+               if (accessor.has_children()
+                       &&
+                       (accessor.get_fe().dofs_per_cell !=
+                        accessor.get_fe().dofs_per_vertex * GeometryInfo<1>::vertices_per_cell))
+                 return;
 
-            const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
-                               dofs_per_line   = accessor.get_fe().dofs_per_line,
-                               dofs_per_cell   = accessor.get_fe().dofs_per_cell;
+               const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
+                                          dofs_per_line   = accessor.get_fe().dofs_per_line,
+                                          dofs_per_cell   = accessor.get_fe().dofs_per_cell;
 
                                              // make sure the cache is at least
                                              // as big as we need it when
                                              // writing to the last element of
                                              // this cell
-            Assert (accessor.present_index * dofs_per_cell + dofs_per_cell
-                    <=
-                    accessor.dof_handler->levels[accessor.present_level]
-                    ->cell_dof_indices_cache.size(),
-                    ExcInternalError());
-
-            std::vector<unsigned int>::iterator next
-              = (accessor.dof_handler->levels[accessor.present_level]
-                 ->cell_dof_indices_cache.begin() + accessor.present_index * dofs_per_cell);
-
-            for (unsigned int vertex=0; vertex<2; ++vertex)
-              for (unsigned int d=0; d<dofs_per_vertex; ++d)
-                *next++ = accessor.vertex_dof_index(vertex,d);
-            for (unsigned int d=0; d<dofs_per_line; ++d)
-              *next++ = accessor.dof_index(d);
-          }
-
-
-
-        template <int spacedim>
-        static
-        void
-        update_cell_dof_indices_cache (const DoFCellAccessor<DoFHandler<2,spacedim> > &accessor)
-          {
+               Assert (accessor.present_index * dofs_per_cell + dofs_per_cell
+                           <=
+                           accessor.dof_handler->levels[accessor.present_level]
+                           ->cell_dof_indices_cache.size(),
+                           ExcInternalError());
+
+               std::vector<unsigned int>::iterator next
+                 = (accessor.dof_handler->levels[accessor.present_level]
+                        ->cell_dof_indices_cache.begin() + accessor.present_index * dofs_per_cell);
+
+               for (unsigned int vertex=0; vertex<2; ++vertex)
+                 for (unsigned int d=0; d<dofs_per_vertex; ++d)
+                       *next++ = accessor.vertex_dof_index(vertex,d);
+               for (unsigned int d=0; d<dofs_per_line; ++d)
+                 *next++ = accessor.dof_index(d);
+             }
+
+
+
+           template <int spacedim>
+           static
+           void
+           update_cell_dof_indices_cache (const DoFCellAccessor<DoFHandler<2,spacedim> > &accessor)
+             {
                                              // check as in documentation that
                                              // cell is either active, or dofs
                                              // are only in vertices. otherwise
@@ -2063,48 +2178,48 @@ namespace internal
                                              // all. the get_dof_indices
                                              // function will then make sure we
                                              // don't access the invalid data
-            if (accessor.has_children()
-                &&
-                (accessor.get_fe().dofs_per_cell !=
-                 accessor.get_fe().dofs_per_vertex * GeometryInfo<2>::vertices_per_cell))
-              return;
+               if (accessor.has_children()
+                       &&
+                       (accessor.get_fe().dofs_per_cell !=
+                        accessor.get_fe().dofs_per_vertex * GeometryInfo<2>::vertices_per_cell))
+                 return;
 
-            const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
-                               dofs_per_line   = accessor.get_fe().dofs_per_line,
-                               dofs_per_quad   = accessor.get_fe().dofs_per_quad,
-                               dofs_per_cell   = accessor.get_fe().dofs_per_cell;
+               const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
+                                          dofs_per_line   = accessor.get_fe().dofs_per_line,
+                                          dofs_per_quad   = accessor.get_fe().dofs_per_quad,
+                                          dofs_per_cell   = accessor.get_fe().dofs_per_cell;
 
                                              // make sure the cache is at least
                                              // as big as we need it when
                                              // writing to the last element of
                                              // this cell
-            Assert (accessor.present_index * dofs_per_cell + dofs_per_cell
-                    <=
-                    accessor.dof_handler->levels[accessor.present_level]
-                    ->cell_dof_indices_cache.size(),
-                    ExcInternalError());
-
-            std::vector<unsigned int>::iterator next
-              = (accessor.dof_handler->levels[accessor.present_level]
-                 ->cell_dof_indices_cache.begin() + accessor.present_index * dofs_per_cell);
-
-            for (unsigned int vertex=0; vertex<4; ++vertex)
-              for (unsigned int d=0; d<dofs_per_vertex; ++d)
-                *next++ = accessor.vertex_dof_index(vertex,d);
-            for (unsigned int line=0; line<4; ++line)
-              for (unsigned int d=0; d<dofs_per_line; ++d)
-                *next++ = accessor.line(line)->dof_index(d);
-            for (unsigned int d=0; d<dofs_per_quad; ++d)
-              *next++ = accessor.dof_index(d);
-          }
-
-
-
-        template <int spacedim>
-        static
-        void
-        update_cell_dof_indices_cache (const DoFCellAccessor<DoFHandler<3,spacedim> > &accessor)
-          {
+               Assert (accessor.present_index * dofs_per_cell + dofs_per_cell
+                           <=
+                           accessor.dof_handler->levels[accessor.present_level]
+                           ->cell_dof_indices_cache.size(),
+                           ExcInternalError());
+
+               std::vector<unsigned int>::iterator next
+                 = (accessor.dof_handler->levels[accessor.present_level]
+                        ->cell_dof_indices_cache.begin() + accessor.present_index * dofs_per_cell);
+
+               for (unsigned int vertex=0; vertex<4; ++vertex)
+                 for (unsigned int d=0; d<dofs_per_vertex; ++d)
+                       *next++ = accessor.vertex_dof_index(vertex,d);
+               for (unsigned int line=0; line<4; ++line)
+                 for (unsigned int d=0; d<dofs_per_line; ++d)
+                       *next++ = accessor.line(line)->dof_index(d);
+               for (unsigned int d=0; d<dofs_per_quad; ++d)
+                 *next++ = accessor.dof_index(d);
+             }
+
+
+
+           template <int spacedim>
+           static
+           void
+           update_cell_dof_indices_cache (const DoFCellAccessor<DoFHandler<3,spacedim> > &accessor)
+             {
                                              // check as in documentation that
                                              // cell is either active, or dofs
                                              // are only in vertices. otherwise
@@ -2112,35 +2227,35 @@ namespace internal
                                              // all. the get_dof_indices
                                              // function will then make sure we
                                              // don't access the invalid data
-            if (accessor.has_children()
-                &&
-                (accessor.get_fe().dofs_per_cell !=
-                 accessor.get_fe().dofs_per_vertex * GeometryInfo<3>::vertices_per_cell))
-              return;
-
-            const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
-                               dofs_per_line   = accessor.get_fe().dofs_per_line,
-                               dofs_per_quad   = accessor.get_fe().dofs_per_quad,
-                               dofs_per_hex    = accessor.get_fe().dofs_per_hex,
-                               dofs_per_cell   = accessor.get_fe().dofs_per_cell;
+               if (accessor.has_children()
+                       &&
+                       (accessor.get_fe().dofs_per_cell !=
+                        accessor.get_fe().dofs_per_vertex * GeometryInfo<3>::vertices_per_cell))
+                 return;
+
+               const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
+                                          dofs_per_line   = accessor.get_fe().dofs_per_line,
+                                          dofs_per_quad   = accessor.get_fe().dofs_per_quad,
+                                          dofs_per_hex    = accessor.get_fe().dofs_per_hex,
+                                          dofs_per_cell   = accessor.get_fe().dofs_per_cell;
 
                                              // make sure the cache is at least
                                              // as big as we need it when
                                              // writing to the last element of
                                              // this cell
-            Assert (accessor.present_index * dofs_per_cell + dofs_per_cell
-                    <=
-                    accessor.dof_handler->levels[accessor.present_level]
-                    ->cell_dof_indices_cache.size(),
-                    ExcInternalError());
-
-            std::vector<unsigned int>::iterator next
-              = (accessor.dof_handler->levels[accessor.present_level]
-                 ->cell_dof_indices_cache.begin() + accessor.present_index * dofs_per_cell);
-
-            for (unsigned int vertex=0; vertex<8; ++vertex)
-              for (unsigned int d=0; d<dofs_per_vertex; ++d)
-                *next++ = accessor.vertex_dof_index(vertex,d);
+               Assert (accessor.present_index * dofs_per_cell + dofs_per_cell
+                           <=
+                           accessor.dof_handler->levels[accessor.present_level]
+                           ->cell_dof_indices_cache.size(),
+                           ExcInternalError());
+
+               std::vector<unsigned int>::iterator next
+                 = (accessor.dof_handler->levels[accessor.present_level]
+                        ->cell_dof_indices_cache.begin() + accessor.present_index * dofs_per_cell);
+
+               for (unsigned int vertex=0; vertex<8; ++vertex)
+                 for (unsigned int d=0; d<dofs_per_vertex; ++d)
+                       *next++ = accessor.vertex_dof_index(vertex,d);
                                              // now copy dof numbers from the line. for
                                              // lines with the wrong orientation, we have
                                              // already made sure that we're ok by picking
@@ -2152,11 +2267,11 @@ namespace internal
                                              // adjust the shape function indices that we
                                              // see to correspond to the correct
                                              // (cell-local) ordering.
-            for (unsigned int line=0; line<12; ++line)
-              for (unsigned int d=0; d<dofs_per_line; ++d)
-                *next++ = accessor.line(line)->dof_index(accessor.dof_handler->get_fe().
-                                                         adjust_line_dof_index_for_line_orientation(d,
-                                                                                                    accessor.line_orientation(line)));
+               for (unsigned int line=0; line<12; ++line)
+                 for (unsigned int d=0; d<dofs_per_line; ++d)
+                       *next++ = accessor.line(line)->dof_index(accessor.dof_handler->get_fe().
+                                                                                    adjust_line_dof_index_for_line_orientation(d,
+                                                                                                                                                   accessor.line_orientation(line)));
                                              // now copy dof numbers from the face. for
                                              // faces with the wrong orientation, we
                                              // have already made sure that we're ok by
@@ -2170,33 +2285,33 @@ namespace internal
                                              // correct (cell-local) ordering. The same
                                              // applies, if the face_rotation or
                                              // face_orientation is non-standard
-            for (unsigned int quad=0; quad<6; ++quad)
-              for (unsigned int d=0; d<dofs_per_quad; ++d)
-                *next++ = accessor.quad(quad)->dof_index(accessor.dof_handler->get_fe().
-                                                         adjust_quad_dof_index_for_face_orientation(d,
-                                                                                                    accessor.face_orientation(quad),
-                                                                                                    accessor.face_flip(quad),
-                                                                                                    accessor.face_rotation(quad)));
-            for (unsigned int d=0; d<dofs_per_hex; ++d)
-              *next++ = accessor.dof_index(d);
-          }
+               for (unsigned int quad=0; quad<6; ++quad)
+                 for (unsigned int d=0; d<dofs_per_quad; ++d)
+                       *next++ = accessor.quad(quad)->dof_index(accessor.dof_handler->get_fe().
+                                                                                    adjust_quad_dof_index_for_face_orientation(d,
+                                                                                                                                                   accessor.face_orientation(quad),
+                                                                                                                                                   accessor.face_flip(quad),
+                                                                                                                                                   accessor.face_rotation(quad)));
+               for (unsigned int d=0; d<dofs_per_hex; ++d)
+                 *next++ = accessor.dof_index(d);
+             }
 
 
                                          // implementation for the case of
                                          // hp::DoFHandler objects. it's
                                          // not implemented there, for no
                                          // space dimension
-        template <int dim, int spacedim>
-        static
-        void
-        update_cell_dof_indices_cache (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &)
-          {
+           template <int dim, int spacedim>
+           static
+           void
+           update_cell_dof_indices_cache (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &)
+             {
 //TODO[WB]: should implement a dof indices cache for hp as well
 
                                              // not implemented, but should also
                                              // not be called
-            Assert (false, ExcNotImplemented());
-          }
+               Assert (false, ExcNotImplemented());
+             }
 
                                          /**
                                           * Implement setting dof
@@ -2205,97 +2320,97 @@ namespace internal
                                           * implemented for
                                           * hp::DoFHandler objects.
                                           */
-        template <int spacedim>
-        static
-        void
-        set_dof_indices (DoFCellAccessor<DoFHandler<1,spacedim> > &accessor,
-                         const std::vector<unsigned int>          &local_dof_indices)
-          {
-            Assert (accessor.has_children() == false,
-                    ExcInternalError());
-
-            const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
-                               dofs_per_line   = accessor.get_fe().dofs_per_line,
-                               dofs_per_cell   = accessor.get_fe().dofs_per_cell;
-
-            Assert (local_dof_indices.size() == dofs_per_cell,
-                    ExcInternalError());
-
-            unsigned int index = 0;
-
-            for (unsigned int vertex=0; vertex<2; ++vertex)
-              for (unsigned int d=0; d<dofs_per_vertex; ++d, ++index)
-                accessor.set_vertex_dof_index(vertex,d,
-                                              local_dof_indices[index]);
-            for (unsigned int d=0; d<dofs_per_line; ++d, ++index)
-              accessor.dof_index(d, local_dof_indices[index]);
-
-            Assert (index == dofs_per_cell,
-                    ExcInternalError());
-          }
-
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_indices (DoFCellAccessor<DoFHandler<2,spacedim> > &accessor,
-                         const std::vector<unsigned int>          &local_dof_indices)
-          {
-            Assert (accessor.has_children() == false,
-                    ExcInternalError());
-
-            const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
-                               dofs_per_line   = accessor.get_fe().dofs_per_line,
-                               dofs_per_quad   = accessor.get_fe().dofs_per_quad,
-                               dofs_per_cell   = accessor.get_fe().dofs_per_cell;
-
-            Assert (local_dof_indices.size() == dofs_per_cell,
-                    ExcInternalError());
-
-            unsigned int index = 0;
-
-            for (unsigned int vertex=0; vertex<4; ++vertex)
-              for (unsigned int d=0; d<dofs_per_vertex; ++d, ++index)
-                accessor.set_vertex_dof_index(vertex,d,
-                                              local_dof_indices[index]);
-            for (unsigned int line=0; line<4; ++line)
-              for (unsigned int d=0; d<dofs_per_line; ++d, ++index)
-                accessor.line(line)->set_dof_index(d, local_dof_indices[index]);
-
-            for (unsigned int d=0; d<dofs_per_quad; ++d, ++index)
-              accessor.set_dof_index(d, local_dof_indices[index]);
-
-            Assert (index == dofs_per_cell,
-                    ExcInternalError());
-          }
-
-
-
-        template <int spacedim>
-        static
-        void
-        set_dof_indices (DoFCellAccessor<DoFHandler<3,spacedim> > &accessor,
-                         const std::vector<unsigned int>          &local_dof_indices)
-          {
-            Assert (accessor.has_children() == false,
-                    ExcInternalError());
-
-            const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
-                               dofs_per_line   = accessor.get_fe().dofs_per_line,
-                               dofs_per_quad   = accessor.get_fe().dofs_per_quad,
-                               dofs_per_hex    = accessor.get_fe().dofs_per_hex,
-                               dofs_per_cell   = accessor.get_fe().dofs_per_cell;
-
-            Assert (local_dof_indices.size() == dofs_per_cell,
-                    ExcInternalError());
-
-            unsigned int index = 0;
-
-            for (unsigned int vertex=0; vertex<8; ++vertex)
-              for (unsigned int d=0; d<dofs_per_vertex; ++d, ++index)
-                accessor.set_vertex_dof_index(vertex,d,
-                                              local_dof_indices[index]);
+           template <int spacedim>
+           static
+           void
+           set_dof_indices (DoFCellAccessor<DoFHandler<1,spacedim> > &accessor,
+                                    const std::vector<unsigned int>          &local_dof_indices)
+             {
+               Assert (accessor.has_children() == false,
+                           ExcInternalError());
+
+               const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
+                                          dofs_per_line   = accessor.get_fe().dofs_per_line,
+                                          dofs_per_cell   = accessor.get_fe().dofs_per_cell;
+
+               Assert (local_dof_indices.size() == dofs_per_cell,
+                           ExcInternalError());
+
+               unsigned int index = 0;
+
+               for (unsigned int vertex=0; vertex<2; ++vertex)
+                 for (unsigned int d=0; d<dofs_per_vertex; ++d, ++index)
+                       accessor.set_vertex_dof_index(vertex,d,
+                                                                 local_dof_indices[index]);
+               for (unsigned int d=0; d<dofs_per_line; ++d, ++index)
+                 accessor.dof_index(d, local_dof_indices[index]);
+
+               Assert (index == dofs_per_cell,
+                           ExcInternalError());
+             }
+
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_indices (DoFCellAccessor<DoFHandler<2,spacedim> > &accessor,
+                                    const std::vector<unsigned int>          &local_dof_indices)
+             {
+               Assert (accessor.has_children() == false,
+                           ExcInternalError());
+
+               const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
+                                          dofs_per_line   = accessor.get_fe().dofs_per_line,
+                                          dofs_per_quad   = accessor.get_fe().dofs_per_quad,
+                                          dofs_per_cell   = accessor.get_fe().dofs_per_cell;
+
+               Assert (local_dof_indices.size() == dofs_per_cell,
+                           ExcInternalError());
+
+               unsigned int index = 0;
+
+               for (unsigned int vertex=0; vertex<4; ++vertex)
+                 for (unsigned int d=0; d<dofs_per_vertex; ++d, ++index)
+                       accessor.set_vertex_dof_index(vertex,d,
+                                                                 local_dof_indices[index]);
+               for (unsigned int line=0; line<4; ++line)
+                 for (unsigned int d=0; d<dofs_per_line; ++d, ++index)
+                       accessor.line(line)->set_dof_index(d, local_dof_indices[index]);
+
+               for (unsigned int d=0; d<dofs_per_quad; ++d, ++index)
+                 accessor.set_dof_index(d, local_dof_indices[index]);
+
+               Assert (index == dofs_per_cell,
+                           ExcInternalError());
+             }
+
+
+
+           template <int spacedim>
+           static
+           void
+           set_dof_indices (DoFCellAccessor<DoFHandler<3,spacedim> > &accessor,
+                                    const std::vector<unsigned int>          &local_dof_indices)
+             {
+               Assert (accessor.has_children() == false,
+                           ExcInternalError());
+
+               const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
+                                          dofs_per_line   = accessor.get_fe().dofs_per_line,
+                                          dofs_per_quad   = accessor.get_fe().dofs_per_quad,
+                                          dofs_per_hex    = accessor.get_fe().dofs_per_hex,
+                                          dofs_per_cell   = accessor.get_fe().dofs_per_cell;
+
+               Assert (local_dof_indices.size() == dofs_per_cell,
+                           ExcInternalError());
+
+               unsigned int index = 0;
+
+               for (unsigned int vertex=0; vertex<8; ++vertex)
+                 for (unsigned int d=0; d<dofs_per_vertex; ++d, ++index)
+                       accessor.set_vertex_dof_index(vertex,d,
+                                                                 local_dof_indices[index]);
                                              // now copy dof numbers into the line. for
                                              // lines with the wrong orientation, we have
                                              // already made sure that we're ok by picking
@@ -2307,12 +2422,12 @@ namespace internal
                                              // adjust the shape function indices that we
                                              // see to correspond to the correct
                                              // (cell-local) ordering.
-            for (unsigned int line=0; line<12; ++line)
-              for (unsigned int d=0; d<dofs_per_line; ++d, ++index)
-                accessor.line(line)->set_dof_index(accessor.dof_handler->get_fe().
-                                                   adjust_line_dof_index_for_line_orientation(d,
-                                                                                              accessor.line_orientation(line)),
-                                                   local_dof_indices[index]);
+               for (unsigned int line=0; line<12; ++line)
+                 for (unsigned int d=0; d<dofs_per_line; ++d, ++index)
+                       accessor.line(line)->set_dof_index(accessor.dof_handler->get_fe().
+                                                                          adjust_line_dof_index_for_line_orientation(d,
+                                                                                                                                         accessor.line_orientation(line)),
+                                                                          local_dof_indices[index]);
                                              // now copy dof numbers into the face. for
                                              // faces with the wrong orientation, we
                                              // have already made sure that we're ok by
@@ -2326,34 +2441,34 @@ namespace internal
                                              // correct (cell-local) ordering. The same
                                              // applies, if the face_rotation or
                                              // face_orientation is non-standard
-            for (unsigned int quad=0; quad<6; ++quad)
-              for (unsigned int d=0; d<dofs_per_quad; ++d, ++index)
-                accessor.quad(quad)->set_dof_index(accessor.dof_handler->get_fe().
-                                                   adjust_quad_dof_index_for_face_orientation(d,
-                                                                                              accessor.face_orientation(quad),
-                                                                                              accessor.face_flip(quad),
-                                                                                              accessor.face_rotation(quad)),
-                                                   local_dof_indices[index]);
-            for (unsigned int d=0; d<dofs_per_hex; ++d, ++index)
-              accessor.set_dof_index(d, local_dof_indices[index]);
-
-            Assert (index == dofs_per_cell,
-                    ExcInternalError());
-          }
+               for (unsigned int quad=0; quad<6; ++quad)
+                 for (unsigned int d=0; d<dofs_per_quad; ++d, ++index)
+                       accessor.quad(quad)->set_dof_index(accessor.dof_handler->get_fe().
+                                                                          adjust_quad_dof_index_for_face_orientation(d,
+                                                                                                                                         accessor.face_orientation(quad),
+                                                                                                                                         accessor.face_flip(quad),
+                                                                                                                                         accessor.face_rotation(quad)),
+                                                                          local_dof_indices[index]);
+               for (unsigned int d=0; d<dofs_per_hex; ++d, ++index)
+                 accessor.set_dof_index(d, local_dof_indices[index]);
+
+               Assert (index == dofs_per_cell,
+                           ExcInternalError());
+             }
 
 
                                          // implementation for the case of
                                          // hp::DoFHandler objects. it's
                                          // not implemented there, for no
                                          // space dimension
-        template <int dim, int spacedim>
-        static
-        void
-        set_dof_indices (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &,
-                         const std::vector<unsigned int> &)
-          {
-            Assert (false, ExcNotImplemented());
-          }
+           template <int dim, int spacedim>
+           static
+           void
+           set_dof_indices (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &,
+                                    const std::vector<unsigned int> &)
+             {
+               Assert (false, ExcNotImplemented());
+             }
 
 
                                          /**
@@ -2365,32 +2480,32 @@ namespace internal
                                           * the data out of the cache that
                                           * we hold for each cell.
                                           */
-        template <int dim, int spacedim>
-        static
-        void
-        get_dof_indices (const DoFCellAccessor<DoFHandler<dim,spacedim> > &accessor,
-                         std::vector<unsigned int>                        &dof_indices)
-          {
-            typedef
-              dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> >
-              BaseClass;
-            Assert (dof_indices.size() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
+           template <int dim, int spacedim>
+           static
+           void
+           get_dof_indices (const DoFCellAccessor<DoFHandler<dim,spacedim> > &accessor,
+                                    std::vector<unsigned int>                        &dof_indices)
+             {
+               typedef
+                 dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> >
+                 BaseClass;
+               Assert (dof_indices.size() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
 
                                              // check as in documentation that
                                              // cell is either active, or dofs
                                              // are only in vertices
-            Assert (!accessor.has_children()
-                    ||
-                    (accessor.get_fe().dofs_per_cell ==
-                     accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
-                    ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
-
-            unsigned int *cache = &accessor.dof_handler->levels[accessor.level()]
-                                  ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell];
-            for (unsigned int i=0; i<accessor.get_fe().dofs_per_cell; ++i, ++cache)
-              dof_indices[i] = *cache;
-          }
+               Assert (!accessor.has_children()
+                           ||
+                           (accessor.get_fe().dofs_per_cell ==
+                            accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
+                           ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
+
+               unsigned int *cache = &accessor.dof_handler->levels[accessor.level()]
+                                                 ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell];
+               for (unsigned int i=0; i<accessor.get_fe().dofs_per_cell; ++i, ++cache)
+                 dof_indices[i] = *cache;
+             }
 
                                          /**
                                           * Same function as above except
@@ -2399,21 +2514,21 @@ namespace internal
                                           * not have a cache for the local
                                           * DoF indices.
                                           */
-        template <int dim, int spacedim>
-        static
-        void
-        get_dof_indices (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
-                         std::vector<unsigned int>                            &dof_indices)
-          {
+           template <int dim, int spacedim>
+           static
+           void
+           get_dof_indices (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
+                                    std::vector<unsigned int>                            &dof_indices)
+             {
                                              // no caching for
                                              // hp::DoFHandler
                                              // implemented
             typedef
               dealii::DoFAccessor<dim,dealii::hp::DoFHandler<dim,spacedim> >
               DoFAccessor;
-            accessor.DoFAccessor::get_dof_indices (dof_indices,
-                                                   accessor.active_fe_index());
-          }
+               accessor.DoFAccessor::get_dof_indices (dof_indices,
+                                                                                          accessor.active_fe_index());
+             }
 
 
                                          /**
@@ -2425,36 +2540,36 @@ namespace internal
                                           * indices that we hold for each
                                           * cell.
                                           */
-        template <int dim, int spacedim, class InputVector, typename ForwardIterator>
-        static
-        void
-        get_dof_values (const DoFCellAccessor<DoFHandler<dim,spacedim> > &accessor,
-                        const InputVector &values,
-                        ForwardIterator    local_values_begin,
-                        ForwardIterator    local_values_end)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
-                    == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (values.size() == accessor.get_dof_handler().n_dofs(),
-                    typename BaseClass::ExcVectorDoesNotMatch());
+           template <int dim, int spacedim, class InputVector, typename ForwardIterator>
+           static
+           void
+           get_dof_values (const DoFCellAccessor<DoFHandler<dim,spacedim> > &accessor,
+                                   const InputVector &values,
+                                   ForwardIterator    local_values_begin,
+                                   ForwardIterator    local_values_end)
+             {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
+                           == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (values.size() == accessor.get_dof_handler().n_dofs(),
+                           typename BaseClass::ExcVectorDoesNotMatch());
 
                                              // check as in documentation that
                                              // cell is either active, or dofs
                                              // are only in vertices
-            Assert (!accessor.has_children()
-                    ||
-                    (accessor.get_fe().dofs_per_cell ==
-                     accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
-                    ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
-
-            unsigned int *cache = &accessor.dof_handler->levels[accessor.level()]
-                                  ->cell_dof_indices_cache[accessor.present_index *
-                                                           accessor.get_fe().dofs_per_cell];
-            for ( ; local_values_begin != local_values_end; ++local_values_begin, ++cache)
-              *local_values_begin = values(*cache);
-          }
+               Assert (!accessor.has_children()
+                           ||
+                           (accessor.get_fe().dofs_per_cell ==
+                            accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
+                           ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
+
+               unsigned int *cache = &accessor.dof_handler->levels[accessor.level()]
+                                                 ->cell_dof_indices_cache[accessor.present_index *
+                                                                                      accessor.get_fe().dofs_per_cell];
+               for ( ; local_values_begin != local_values_end; ++local_values_begin, ++cache)
+                 *local_values_begin = values(*cache);
+             }
 
                                          /**
                                           * Same function as above except
@@ -2463,29 +2578,29 @@ namespace internal
                                           * not have a cache for the local
                                           * DoF indices.
                                           */
-        template <int dim, int spacedim, class InputVector, typename ForwardIterator>
-        static
-        void
-        get_dof_values (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
-                        const InputVector &values,
-                        ForwardIterator    local_values_begin,
-                        ForwardIterator    local_values_end)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+           template <int dim, int spacedim, class InputVector, typename ForwardIterator>
+           static
+           void
+           get_dof_values (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
+                                   const InputVector &values,
+                                   ForwardIterator    local_values_begin,
+                                   ForwardIterator    local_values_end)
+             {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
 
                                              // no caching for hp::DoFHandler
                                              // implemented
-            Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
-                    == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell;
+               Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
+                           == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell;
 
-            std::vector<unsigned int> local_dof_indices (dofs_per_cell);
-            get_dof_indices (accessor, local_dof_indices);
+               std::vector<unsigned int> local_dof_indices (dofs_per_cell);
+               get_dof_indices (accessor, local_dof_indices);
 
-            for (unsigned int i=0; i<dofs_per_cell; ++i, ++local_values_begin)
-              *local_values_begin = values(local_dof_indices[i]);
-          }
+               for (unsigned int i=0; i<dofs_per_cell; ++i, ++local_values_begin)
+                 *local_values_begin = values(local_dof_indices[i]);
+             }
 
 
                                          /**
@@ -2497,37 +2612,37 @@ namespace internal
                                           * indices that we hold for each
                                           * cell.
                                           */
-        template <int dim, int spacedim, class InputVector, typename ForwardIterator>
-        static
-        void
-        get_dof_values (const DoFCellAccessor<DoFHandler<dim,spacedim> > &accessor,
-                        const ConstraintMatrix &constraints,
-                        const InputVector      &values,
-                        ForwardIterator         local_values_begin,
-                        ForwardIterator         local_values_end)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
-                    == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (values.size() == accessor.get_dof_handler().n_dofs(),
-                    typename BaseClass::ExcVectorDoesNotMatch());
+           template <int dim, int spacedim, class InputVector, typename ForwardIterator>
+           static
+           void
+           get_dof_values (const DoFCellAccessor<DoFHandler<dim,spacedim> > &accessor,
+                                   const ConstraintMatrix &constraints,
+                                   const InputVector      &values,
+                                   ForwardIterator         local_values_begin,
+                                   ForwardIterator         local_values_end)
+             {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
+                           == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (values.size() == accessor.get_dof_handler().n_dofs(),
+                           typename BaseClass::ExcVectorDoesNotMatch());
 
                                              // check as in documentation that
                                              // cell is either active, or dofs
                                              // are only in vertices
-            Assert (!accessor.has_children()
-                    ||
-                    (accessor.get_fe().dofs_per_cell ==
-                     accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
-                    ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
-
-            unsigned int *cache = &accessor.dof_handler->levels[accessor.level()]
-                                  ->cell_dof_indices_cache[accessor.present_index *
-                                                           accessor.get_fe().dofs_per_cell];
-            constraints.get_dof_values(values, *cache, local_values_begin,
-                                       local_values_end);
-          }
+               Assert (!accessor.has_children()
+                           ||
+                           (accessor.get_fe().dofs_per_cell ==
+                            accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
+                           ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
+
+               unsigned int *cache = &accessor.dof_handler->levels[accessor.level()]
+                                                 ->cell_dof_indices_cache[accessor.present_index *
+                                                                                      accessor.get_fe().dofs_per_cell];
+               constraints.get_dof_values(values, *cache, local_values_begin,
+                                                      local_values_end);
+             }
 
                                          /**
                                           * Same function as above except
@@ -2536,29 +2651,29 @@ namespace internal
                                           * not have a cache for the local
                                           * DoF indices.
                                           */
-        template <int dim, int spacedim, class InputVector, typename ForwardIterator>
-        static
-        void
-        get_dof_values (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
-                        const ConstraintMatrix &constraints,
-                        const InputVector      &values,
-                        ForwardIterator         local_values_begin,
-                        ForwardIterator         local_values_end)
-          {
+           template <int dim, int spacedim, class InputVector, typename ForwardIterator>
+           static
+           void
+           get_dof_values (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
+                                   const ConstraintMatrix &constraints,
+                                   const InputVector      &values,
+                                   ForwardIterator         local_values_begin,
+                                   ForwardIterator         local_values_end)
+             {
                                              // no caching for hp::DoFHandler
                                              // implemented
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
-                    == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell;
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
+                           == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell;
 
-            std::vector<unsigned int> local_dof_indices (dofs_per_cell);
-            get_dof_indices (accessor, local_dof_indices);
+               std::vector<unsigned int> local_dof_indices (dofs_per_cell);
+               get_dof_indices (accessor, local_dof_indices);
 
-            constraints.get_dof_values (values, local_dof_indices.begin(),
-                                        local_values_begin, local_values_end);
-          }
+               constraints.get_dof_values (values, local_dof_indices.begin(),
+                                                           local_values_begin, local_values_end);
+             }
 
 
                                          /**
@@ -2566,53 +2681,53 @@ namespace internal
                                           * except that it sets rather than
                                           * gets values
                                           */
-        template <int dim, int spacedim, class OutputVector, typename number>
-        static
-        void
-        set_dof_values (const DoFCellAccessor<DoFHandler<dim,spacedim> > &accessor,
-                        const dealii::Vector<number> &local_values,
-                        OutputVector &values)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (local_values.size() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (values.size() == accessor.get_dof_handler().n_dofs(),
-                    typename BaseClass::ExcVectorDoesNotMatch());
+           template <int dim, int spacedim, class OutputVector, typename number>
+           static
+           void
+           set_dof_values (const DoFCellAccessor<DoFHandler<dim,spacedim> > &accessor,
+                                   const dealii::Vector<number> &local_values,
+                                   OutputVector &values)
+             {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (local_values.size() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (values.size() == accessor.get_dof_handler().n_dofs(),
+                           typename BaseClass::ExcVectorDoesNotMatch());
 
                                              // check as in documentation that
                                              // cell is either active, or dofs
                                              // are only in vertices
-            Assert (!accessor.has_children()
-                    ||
-                    (accessor.get_fe().dofs_per_cell ==
-                     accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
-                    ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
-
-            unsigned int *cache = &accessor.dof_handler->levels[accessor.level()]
-                                  ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell];
-            for (unsigned int i=0; i<accessor.get_fe().dofs_per_cell; ++i, ++cache)
-              values(*cache) = local_values(i);
-          }
-
-
-
-        template <int dim, int spacedim, class OutputVector, typename number>
-        static
-        void
-        set_dof_values (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
-                        const dealii::Vector<number> &local_values,
-                        OutputVector &values)
-          {
+               Assert (!accessor.has_children()
+                           ||
+                           (accessor.get_fe().dofs_per_cell ==
+                            accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
+                           ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
+
+               unsigned int *cache = &accessor.dof_handler->levels[accessor.level()]
+                                                 ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell];
+               for (unsigned int i=0; i<accessor.get_fe().dofs_per_cell; ++i, ++cache)
+                 values(*cache) = local_values(i);
+             }
+
+
+
+           template <int dim, int spacedim, class OutputVector, typename number>
+           static
+           void
+           set_dof_values (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
+                                   const dealii::Vector<number> &local_values,
+                                   OutputVector &values)
+             {
                                              // no caching for hp::DoFHandler
                                              // implemented
-            const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell;
+               const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell;
 
-            std::vector<unsigned int> local_dof_indices (dofs_per_cell);
-            get_dof_indices (accessor, local_dof_indices);
+               std::vector<unsigned int> local_dof_indices (dofs_per_cell);
+               get_dof_indices (accessor, local_dof_indices);
 
-            for (unsigned int i=0; i<dofs_per_cell; ++i)
-              values(local_dof_indices[i]) = local_values(i);
-          }
+               for (unsigned int i=0; i<dofs_per_cell; ++i)
+                 values(local_dof_indices[i]) = local_values(i);
+             }
 
 
                                          /**
@@ -2620,33 +2735,33 @@ namespace internal
                                           * function in the parent class
                                           * is supposed to do.
                                           */
-        template <int dim, int spacedim>
-        static
-        unsigned int
-        active_fe_index (const DoFCellAccessor<DoFHandler<dim,spacedim> > &)
-          {
+           template <int dim, int spacedim>
+           static
+           unsigned int
+           active_fe_index (const DoFCellAccessor<DoFHandler<dim,spacedim> > &)
+             {
                                              // ::DoFHandler only supports a
                                              // single active fe with index
                                              // zero
-            return 0;
-          }
+               return 0;
+             }
 
 
 
-        template <int dim, int spacedim>
-        static
-        unsigned int
-        active_fe_index (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor)
-          {
-            Assert (static_cast<unsigned int>(accessor.level()) < accessor.dof_handler->levels.size(),
-                    ExcMessage ("DoFHandler not initialized"));
-            Assert (static_cast<std::vector<unsigned int>::size_type>(accessor.present_index) <
-                    accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size (),
-                    ExcIndexRange (accessor.present_index, 0,
-                                   accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size ()));
-            return accessor.dof_handler->levels[accessor.level()]
-              ->active_fe_indices[accessor.present_index];
-          }
+           template <int dim, int spacedim>
+           static
+           unsigned int
+           active_fe_index (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor)
+             {
+               Assert (static_cast<unsigned int>(accessor.level()) < accessor.dof_handler->levels.size(),
+                           ExcMessage ("DoFHandler not initialized"));
+               Assert (static_cast<std::vector<unsigned int>::size_type>(accessor.present_index) <
+                           accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size (),
+                           ExcIndexRange (accessor.present_index, 0,
+                                                  accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size ()));
+               return accessor.dof_handler->levels[accessor.level()]
+                 ->active_fe_indices[accessor.present_index];
+             }
 
 
 
@@ -2656,358 +2771,358 @@ namespace internal
                                           * in the parent class is
                                           * supposed to do.
                                           */
-        template <int dim, int spacedim>
-        static
-        void
-        set_active_fe_index (const DoFCellAccessor<DoFHandler<dim,spacedim> > &,
-                             const unsigned int                                i)
-          {
+           template <int dim, int spacedim>
+           static
+           void
+           set_active_fe_index (const DoFCellAccessor<DoFHandler<dim,spacedim> > &,
+                                        const unsigned int                                i)
+             {
                                              // ::DoFHandler only supports a
                                              // single active fe with index
                                              // zero
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (i == 0, typename BaseClass::ExcInvalidObject());
-          }
-
-
-
-        template <int dim, int spacedim>
-        static
-        void
-        set_active_fe_index (DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
-                             const unsigned int                                      i)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (accessor.dof_handler != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (static_cast<unsigned int>(accessor.level()) <
-                    accessor.dof_handler->levels.size(),
-                    ExcMessage ("DoFHandler not initialized"));
-            Assert (static_cast<std::vector<unsigned int>::size_type>(accessor.present_index) <
-                    accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size (),
-                    ExcIndexRange (accessor.present_index, 0,
-                                   accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size ()));
-            accessor.dof_handler->levels[accessor.level()]
-              ->active_fe_indices[accessor.present_index] = i;
-          }
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (i == 0, typename BaseClass::ExcInvalidObject());
+             }
+
+
+
+           template <int dim, int spacedim>
+           static
+           void
+           set_active_fe_index (DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
+                                        const unsigned int                                      i)
+             {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (accessor.dof_handler != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (static_cast<unsigned int>(accessor.level()) <
+                           accessor.dof_handler->levels.size(),
+                           ExcMessage ("DoFHandler not initialized"));
+               Assert (static_cast<std::vector<unsigned int>::size_type>(accessor.present_index) <
+                           accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size (),
+                           ExcIndexRange (accessor.present_index, 0,
+                                                  accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size ()));
+               accessor.dof_handler->levels[accessor.level()]
+                 ->active_fe_indices[accessor.present_index] = i;
+             }
 
 
 
         template <int dim, int spacedim, typename ForwardIterator, class OutputVector>
-        static
-        void
-        distribute_local_to_global (const DoFCellAccessor<dealii::DoFHandler<dim,spacedim> > &accessor,
-                                    ForwardIterator local_source_begin,
-                                    ForwardIterator local_source_end,
-                                    OutputVector   &global_destination)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (accessor.dof_handler != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (&accessor.get_fe() != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (static_cast<unsigned int>(local_source_end-local_source_begin)
-                    ==
-                    accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_destination.size(),
-                    typename BaseClass::ExcVectorDoesNotMatch());
+           static
+           void
+           distribute_local_to_global (const DoFCellAccessor<dealii::DoFHandler<dim,spacedim> > &accessor,
+                                                   ForwardIterator local_source_begin,
+                                                   ForwardIterator local_source_end,
+                                                   OutputVector   &global_destination)
+          {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (accessor.dof_handler != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (&accessor.get_fe() != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (static_cast<unsigned int>(local_source_end-local_source_begin)
+                           ==
+                           accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_destination.size(),
+                           typename BaseClass::ExcVectorDoesNotMatch());
 
                                              // check as in documentation that
                                              // cell is either active, or dofs
                                              // are only in vertices
-            Assert (!accessor.has_children()
-                    ||
-                    (accessor.get_fe().dofs_per_cell ==
-                     accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
-                    ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
+               Assert (!accessor.has_children()
+                           ||
+                           (accessor.get_fe().dofs_per_cell ==
+                            accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
+                           ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
 
-            const unsigned int n_dofs = local_source_end - local_source_begin;
+               const unsigned int n_dofs = local_source_end - local_source_begin;
 
-            unsigned int * dofs = &accessor.dof_handler->levels[accessor.level()]
-                                  ->cell_dof_indices_cache[accessor.present_index * n_dofs];
+               unsigned int * dofs = &accessor.dof_handler->levels[accessor.level()]
+                                     ->cell_dof_indices_cache[accessor.present_index * n_dofs];
 
                                              // distribute cell vector
-            global_destination.add(n_dofs, dofs, local_source_begin);
-          }
+               global_destination.add(n_dofs, dofs, local_source_begin);
+             }
 
 
 
         template <int dim, int spacedim, typename ForwardIterator, class OutputVector>
-        static
-        void
-        distribute_local_to_global (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
-                                    ForwardIterator local_source_begin,
-                                    ForwardIterator local_source_end,
-                                    OutputVector   &global_destination)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (accessor.dof_handler != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (&accessor.get_fe() != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (local_source_end-local_source_begin == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_destination.size(),
-                    typename BaseClass::ExcVectorDoesNotMatch());
-
-            const unsigned int n_dofs = local_source_end - local_source_begin;
+           static
+           void
+           distribute_local_to_global (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
+                                                   ForwardIterator local_source_begin,
+                                                   ForwardIterator local_source_end,
+                                                   OutputVector   &global_destination)
+          {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (accessor.dof_handler != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (&accessor.get_fe() != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (local_source_end-local_source_begin == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_destination.size(),
+                           typename BaseClass::ExcVectorDoesNotMatch());
+
+               const unsigned int n_dofs = local_source_end - local_source_begin;
 
 //TODO[WB/MK]: This function could me made more efficient because it allocates memory, which could be avoided by passing in another argument as a scratch array. This should be fixed eventually
 
                                              // get indices of dofs
-            std::vector<unsigned int> dofs (n_dofs);
-            accessor.get_dof_indices (dofs);
+               std::vector<unsigned int> dofs (n_dofs);
+               accessor.get_dof_indices (dofs);
 
                                              // distribute cell vector
-            global_destination.add (n_dofs, dofs.begin(), local_source_begin);
-          }
+               global_destination.add (n_dofs, dofs.begin(), local_source_begin);
+             }
 
 
 
         template <int dim, int spacedim, typename ForwardIterator, class OutputVector>
-        static
-        void
-        distribute_local_to_global (const DoFCellAccessor<dealii::DoFHandler<dim,spacedim> > &accessor,
-                                    const ConstraintMatrix &constraints,
-                                    ForwardIterator         local_source_begin,
-                                    ForwardIterator         local_source_end,
-                                    OutputVector           &global_destination)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (accessor.dof_handler != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (&accessor.get_fe() != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (local_source_end-local_source_begin == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_destination.size(),
-                    typename BaseClass::ExcVectorDoesNotMatch());
+           static
+           void
+           distribute_local_to_global (const DoFCellAccessor<dealii::DoFHandler<dim,spacedim> > &accessor,
+                                                   const ConstraintMatrix &constraints,
+                                                   ForwardIterator         local_source_begin,
+                                                   ForwardIterator         local_source_end,
+                                                   OutputVector           &global_destination)
+          {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (accessor.dof_handler != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (&accessor.get_fe() != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (local_source_end-local_source_begin == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_destination.size(),
+                           typename BaseClass::ExcVectorDoesNotMatch());
 
                                              // check as in documentation that
                                              // cell is either active, or dofs
                                              // are only in vertices
-            Assert (!accessor.has_children()
-                    ||
-                    (accessor.get_fe().dofs_per_cell ==
-                     accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
-                    ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
+               Assert (!accessor.has_children()
+                           ||
+                           (accessor.get_fe().dofs_per_cell ==
+                            accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
+                           ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
 
-            const unsigned int n_dofs = local_source_end - local_source_begin;
+               const unsigned int n_dofs = local_source_end - local_source_begin;
 
-            unsigned int * dofs = &accessor.dof_handler->levels[accessor.level()]
-                                  ->cell_dof_indices_cache[accessor.present_index * n_dofs];
+               unsigned int * dofs = &accessor.dof_handler->levels[accessor.level()]
+                                     ->cell_dof_indices_cache[accessor.present_index * n_dofs];
 
                                              // distribute cell vector
-            constraints.distribute_local_to_global (local_source_begin, local_source_end,
-                                                    dofs, global_destination);
-          }
+               constraints.distribute_local_to_global (local_source_begin, local_source_end,
+                                                                           dofs, global_destination);
+             }
 
 
 
         template <int dim, int spacedim, typename ForwardIterator, class OutputVector>
-        static
-        void
-        distribute_local_to_global (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
-                                    const ConstraintMatrix &constraints,
-                                    ForwardIterator         local_source_begin,
-                                    ForwardIterator         local_source_end,
-                                    OutputVector           &global_destination)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (accessor.dof_handler != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (&accessor.get_fe() != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (local_source_end-local_source_begin == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_destination.size(),
-                    typename BaseClass::ExcVectorDoesNotMatch());
-
-            const unsigned int n_dofs = local_source_end - local_source_begin;
+           static
+           void
+           distribute_local_to_global (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
+                                                   const ConstraintMatrix &constraints,
+                                                   ForwardIterator         local_source_begin,
+                                                   ForwardIterator         local_source_end,
+                                                   OutputVector           &global_destination)
+          {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (accessor.dof_handler != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (&accessor.get_fe() != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (local_source_end-local_source_begin == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_destination.size(),
+                           typename BaseClass::ExcVectorDoesNotMatch());
+
+               const unsigned int n_dofs = local_source_end - local_source_begin;
 
 //TODO[WB/MK]: This function could me made more efficient because it allocates memory, which could be avoided by passing in another argument as a scratch array. This should be fixed eventually
 
                                              // get indices of dofs
-            std::vector<unsigned int> dofs (n_dofs);
-            accessor.get_dof_indices (dofs);
+               std::vector<unsigned int> dofs (n_dofs);
+               accessor.get_dof_indices (dofs);
 
                                              // distribute cell vector
-            constraints.distribute_local_to_global (local_source_begin, local_source_end,
-                                                    dofs.begin(), global_destination);
-          }
+               constraints.distribute_local_to_global (local_source_begin, local_source_end,
+                                                                           dofs.begin(), global_destination);
+             }
 
 
 
         template <int dim, int spacedim, typename number, class OutputMatrix>
-        static
-        void
-        distribute_local_to_global (const DoFCellAccessor<dealii::DoFHandler<dim,spacedim> > &accessor,
-                                    const dealii::FullMatrix<number> &local_source,
-                                    OutputMatrix                     &global_destination)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (accessor.dof_handler != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (&accessor.get_fe() != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (local_source.m() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-            Assert (local_source.n() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_destination.m(),
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_destination.n(),
-                    typename BaseClass::ExcMatrixDoesNotMatch());
+           static
+           void
+           distribute_local_to_global (const DoFCellAccessor<dealii::DoFHandler<dim,spacedim> > &accessor,
+                                                   const dealii::FullMatrix<number> &local_source,
+                                                   OutputMatrix                     &global_destination)
+          {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (accessor.dof_handler != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (&accessor.get_fe() != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (local_source.m() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+               Assert (local_source.n() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_destination.m(),
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_destination.n(),
+                           typename BaseClass::ExcMatrixDoesNotMatch());
 
                                              // check as in documentation that
                                              // cell is either active, or dofs
                                              // are only in vertices
-            Assert (!accessor.has_children()
-                    ||
-                    (accessor.get_fe().dofs_per_cell ==
-                     accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
-                    ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
+               Assert (!accessor.has_children()
+                           ||
+                           (accessor.get_fe().dofs_per_cell ==
+                            accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
+                           ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
 
-            const unsigned int n_dofs = local_source.m();
+               const unsigned int n_dofs = local_source.m();
 
-            unsigned int * dofs = &accessor.dof_handler->levels[accessor.level()]
-                                  ->cell_dof_indices_cache[accessor.present_index * n_dofs];
+               unsigned int * dofs = &accessor.dof_handler->levels[accessor.level()]
+                                     ->cell_dof_indices_cache[accessor.present_index * n_dofs];
 
                                              // distribute cell matrix
-            for (unsigned int i=0; i<n_dofs; ++i)
-              global_destination.add(dofs[i], n_dofs, dofs,
-                                     &local_source(i,0));
-          }
+               for (unsigned int i=0; i<n_dofs; ++i)
+                 global_destination.add(dofs[i], n_dofs, dofs,
+                                                    &local_source(i,0));
+             }
 
 
 
         template <int dim, int spacedim, typename number, class OutputMatrix>
-        static
-        void
-        distribute_local_to_global (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
-                                    const dealii::FullMatrix<number> &local_source,
-                                    OutputMatrix                     &global_destination)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (accessor.dof_handler != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (&accessor.get_fe() != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (local_source.m() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-            Assert (local_source.n() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_destination.m(),
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_destination.n(),
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-
-            const unsigned int n_dofs = local_source.size();
+           static
+           void
+           distribute_local_to_global (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
+                                                   const dealii::FullMatrix<number> &local_source,
+                                                   OutputMatrix                     &global_destination)
+          {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (accessor.dof_handler != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (&accessor.get_fe() != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (local_source.m() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+               Assert (local_source.n() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_destination.m(),
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_destination.n(),
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+
+               const unsigned int n_dofs = local_source.size();
 
 //TODO[WB/MK]: This function could me made more efficient because it allocates memory, which could be avoided by passing in another argument as a scratch array.
 
                                              // get indices of dofs
-            std::vector<unsigned int> dofs (n_dofs);
-            accessor.get_dof_indices (dofs);
+               std::vector<unsigned int> dofs (n_dofs);
+               accessor.get_dof_indices (dofs);
 
                                              // distribute cell matrix
-            global_destination.add(dofs,local_source);
-          }
+               global_destination.add(dofs,local_source);
+             }
 
 
 
         template <int dim, int spacedim, typename number,
-                  class OutputMatrix, typename OutputVector>
-        static
-        void
-        distribute_local_to_global (const DoFCellAccessor<dealii::DoFHandler<dim,spacedim> > &accessor,
-                                    const dealii::FullMatrix<number> &local_matrix,
-                                    const dealii::Vector<number>     &local_vector,
-                                    OutputMatrix                     &global_matrix,
-                                    OutputVector                     &global_vector)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (accessor.dof_handler != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (&accessor.get_fe() != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (local_matrix.m() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-            Assert (local_matrix.n() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_matrix.m(),
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_matrix.n(),
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-            Assert (local_vector.size() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_vector.size(),
-                    typename BaseClass::ExcVectorDoesNotMatch());
+                     class OutputMatrix, typename OutputVector>
+        static
+           void
+           distribute_local_to_global (const DoFCellAccessor<dealii::DoFHandler<dim,spacedim> > &accessor,
+                                                   const dealii::FullMatrix<number> &local_matrix,
+                                                   const dealii::Vector<number>     &local_vector,
+                                                   OutputMatrix                     &global_matrix,
+                                                   OutputVector                     &global_vector)
+          {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (accessor.dof_handler != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (&accessor.get_fe() != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (local_matrix.m() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+               Assert (local_matrix.n() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_matrix.m(),
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_matrix.n(),
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+               Assert (local_vector.size() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_vector.size(),
+                           typename BaseClass::ExcVectorDoesNotMatch());
 
                                              // check as in documentation that
                                              // cell is either active, or dofs
                                              // are only in vertices
-            Assert (!accessor.has_children()
-                    ||
-                    (accessor.get_fe().dofs_per_cell ==
-                     accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
-                    ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
+               Assert (!accessor.has_children()
+                           ||
+                           (accessor.get_fe().dofs_per_cell ==
+                            accessor.get_fe().dofs_per_vertex * GeometryInfo<dim>::vertices_per_cell),
+                           ExcMessage ("Cell must either be active, or all DoFs must be in vertices"));
 
-            const unsigned int n_dofs = accessor.get_fe().dofs_per_cell;
-            unsigned int * dofs = &accessor.dof_handler->levels[accessor.level()]
-                                  ->cell_dof_indices_cache[accessor.present_index * n_dofs];
+               const unsigned int n_dofs = accessor.get_fe().dofs_per_cell;
+               unsigned int * dofs = &accessor.dof_handler->levels[accessor.level()]
+                                     ->cell_dof_indices_cache[accessor.present_index * n_dofs];
 
                                              // distribute cell matrices
-            for (unsigned int i=0; i<n_dofs; ++i)
-              {
-                global_matrix.add(dofs[i], n_dofs, dofs, &local_matrix(i,0));
-                global_vector(dofs[i]) += local_vector(i);
-              }
-          }
+               for (unsigned int i=0; i<n_dofs; ++i)
+                 {
+                       global_matrix.add(dofs[i], n_dofs, dofs, &local_matrix(i,0));
+                       global_vector(dofs[i]) += local_vector(i);
+                 }
+             }
 
 
 
         template <int dim, int spacedim, typename number,
-                  class OutputMatrix, typename OutputVector>
-        static
-        void
-        distribute_local_to_global (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
-                                    const dealii::FullMatrix<number> &local_matrix,
-                                    const dealii::Vector<number>     &local_vector,
-                                    OutputMatrix                     &global_matrix,
-                                    OutputVector                     &global_vector)
-          {
-            typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
-            Assert (accessor.dof_handler != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (&accessor.get_fe() != 0,
-                    typename BaseClass::ExcInvalidObject());
-            Assert (local_matrix.m() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-            Assert (local_matrix.n() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_matrix.m(),
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_matrix.n(),
-                    typename BaseClass::ExcMatrixDoesNotMatch());
-            Assert (local_vector.size() == accessor.get_fe().dofs_per_cell,
-                    typename BaseClass::ExcVectorDoesNotMatch());
-            Assert (accessor.dof_handler->n_dofs() == global_vector.size(),
-                    typename BaseClass::ExcVectorDoesNotMatch());
-
-            const unsigned int n_dofs = local_matrix.size();
+                     class OutputMatrix, typename OutputVector>
+           static
+           void
+           distribute_local_to_global (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim> > &accessor,
+                                                   const dealii::FullMatrix<number> &local_matrix,
+                                                   const dealii::Vector<number>     &local_vector,
+                                                   OutputMatrix                     &global_matrix,
+                                                   OutputVector                     &global_vector)
+          {
+               typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim> > BaseClass;
+               Assert (accessor.dof_handler != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (&accessor.get_fe() != 0,
+                           typename BaseClass::ExcInvalidObject());
+               Assert (local_matrix.m() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+               Assert (local_matrix.n() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_matrix.m(),
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_matrix.n(),
+                           typename BaseClass::ExcMatrixDoesNotMatch());
+               Assert (local_vector.size() == accessor.get_fe().dofs_per_cell,
+                           typename BaseClass::ExcVectorDoesNotMatch());
+               Assert (accessor.dof_handler->n_dofs() == global_vector.size(),
+                           typename BaseClass::ExcVectorDoesNotMatch());
+
+               const unsigned int n_dofs = local_matrix.size();
 
 //TODO[WB/MK]: This function could me made more efficient because it allocates memory, which could be avoided by passing in another argument as a scratch array.
 
                                              // get indices of dofs
-            std::vector<unsigned int> dofs (n_dofs);
-            accessor.get_dof_indices (dofs);
+               std::vector<unsigned int> dofs (n_dofs);
+               accessor.get_dof_indices (dofs);
 
                                              // distribute cell matrix and vector
-            global_matrix.add(dofs,local_matrix);
-            global_vector.add(dofs,local_vector);
-          }
+               global_matrix.add(dofs,local_matrix);
+               global_vector.add(dofs,local_vector);
+             }
     };
   }
 }
@@ -3110,22 +3225,22 @@ namespace internal
     inline
     typename dealii::internal::DoFHandler::Iterators<DH>::face_iterator
     get_face (const dealii::DoFCellAccessor<DH> &cell,
-              const unsigned int i,
-              const dealii::internal::int2type<1>)
+                 const unsigned int i,
+                 const dealii::internal::int2type<1>)
     {
       dealii::DoFAccessor<0, DH>
-        a (&cell.get_triangulation(),
-           ((i == 0) && cell.at_boundary(0)
-            ?
-            dealii::TriaAccessor<0, 1, DH::space_dimension>::left_vertex
-            :
-            ((i == 1) && cell.at_boundary(1)
-             ?
-             dealii::TriaAccessor<0, 1, DH::space_dimension>::right_vertex
-             :
-             dealii::TriaAccessor<0, 1, DH::space_dimension>::interior_vertex)),
-           cell.vertex_index(i),
-           &cell.get_dof_handler());
+           a (&cell.get_triangulation(),
+          ((i == 0) && cell.at_boundary(0)
+           ?
+           dealii::TriaAccessor<0, 1, DH::space_dimension>::left_vertex
+           :
+           ((i == 1) && cell.at_boundary(1)
+            ?
+            dealii::TriaAccessor<0, 1, DH::space_dimension>::right_vertex
+            :
+            dealii::TriaAccessor<0, 1, DH::space_dimension>::interior_vertex)),
+          cell.vertex_index(i),
+              &cell.get_dof_handler());
       return typename dealii::internal::DoFHandler::Iterators<DH>::face_iterator(a);
     }
 
@@ -3134,8 +3249,8 @@ namespace internal
     inline
     typename dealii::internal::DoFHandler::Iterators<DH>::face_iterator
     get_face (const dealii::DoFCellAccessor<DH> &cell,
-              const unsigned int i,
-              const dealii::internal::int2type<2>)
+                 const unsigned int i,
+                 const dealii::internal::int2type<2>)
     {
       return cell.line(i);
     }
@@ -3145,8 +3260,8 @@ namespace internal
     inline
     typename dealii::internal::DoFHandler::Iterators<DH>::face_iterator
     get_face (const dealii::DoFCellAccessor<DH> &cell,
-              const unsigned int i,
-              const dealii::internal::int2type<3>)
+                 const unsigned int i,
+                 const dealii::internal::int2type<3>)
     {
       return cell.quad(i);
     }
@@ -3163,7 +3278,7 @@ DoFCellAccessor<DH>::face (const unsigned int i) const
           ExcMessage ("DoFHandler not initialized"));
 
   const unsigned int dim = DH::dimension;
-  return dealii::internal::DoFCellAccessor::get_face (*this, i, dealii::internal::int2type<dim>());
+  return dealii::internal::DoFCellAccessor::get_face (*this, i, internal::int2type<dim>());
 }
 
 
@@ -3175,22 +3290,28 @@ DoFCellAccessor<DH>::
 get_dof_indices (std::vector<unsigned int> &dof_indices) const
 {
   Assert (this->is_artificial() == false,
-          ExcMessage ("Can't ask for DoF indices on artificial cells."));
+             ExcMessage ("Can't ask for DoF indices on artificial cells."));
   AssertDimension (dof_indices.size(), this->get_fe().dofs_per_cell);
 
   dealii::internal::DoFCellAccessor::Implementation::get_dof_indices (*this, dof_indices);
 }
 
 
+template<class DH>
+inline
+void DoFCellAccessor<DH>::get_mg_dof_indices (std::vector<unsigned int>& dof_indices) const {
+  DoFAccessor<dim, DH>::get_mg_dof_indices (this->level (), dof_indices);
+}
+
 
 template <class DH>
 template <class InputVector, typename number>
 void
 DoFCellAccessor<DH>::get_dof_values (const InputVector &values,
-                                     Vector<number>    &local_values) const
+                                                    Vector<number>    &local_values) const
 {
   Assert (this->is_artificial() == false,
-          ExcMessage ("Can't ask for DoF indices on artificial cells."));
+             ExcMessage ("Can't ask for DoF indices on artificial cells."));
   AssertDimension (local_values.size(), this->get_fe().dofs_per_cell);
 
   dealii::internal::DoFCellAccessor::Implementation
@@ -3203,11 +3324,11 @@ template <class DH>
 template <class InputVector, typename ForwardIterator>
 void
 DoFCellAccessor<DH>::get_dof_values (const InputVector &values,
-                                     ForwardIterator    local_values_begin,
-                                     ForwardIterator    local_values_end) const
+                                                    ForwardIterator    local_values_begin,
+                                                    ForwardIterator    local_values_end) const
 {
   Assert (this->is_artificial() == false,
-          ExcMessage ("Can't ask for DoF indices on artificial cells."));
+             ExcMessage ("Can't ask for DoF indices on artificial cells."));
   dealii::internal::DoFCellAccessor::Implementation
     ::get_dof_values (*this, values, local_values_begin, local_values_end);
 }
@@ -3218,15 +3339,15 @@ template <class DH>
 template <class InputVector, typename ForwardIterator>
 void
 DoFCellAccessor<DH>::get_dof_values (const ConstraintMatrix &constraints,
-                                     const InputVector      &values,
-                                     ForwardIterator         local_values_begin,
-                                     ForwardIterator         local_values_end) const
+                                                    const InputVector      &values,
+                                                    ForwardIterator         local_values_begin,
+                                                    ForwardIterator         local_values_end) const
 {
   Assert (this->is_artificial() == false,
-          ExcMessage ("Can't ask for DoF indices on artificial cells."));
+             ExcMessage ("Can't ask for DoF indices on artificial cells."));
   dealii::internal::DoFCellAccessor::Implementation
     ::get_dof_values (*this, constraints, values,
-                      local_values_begin, local_values_end);
+                             local_values_begin, local_values_end);
 }
 
 
@@ -3235,10 +3356,10 @@ template <class DH>
 template <class OutputVector, typename number>
 void
 DoFCellAccessor<DH>::set_dof_values (const Vector<number> &local_values,
-                                     OutputVector         &values) const
+                                                    OutputVector         &values) const
 {
   Assert (this->is_artificial() == false,
-          ExcMessage ("Can't ask for DoF indices on artificial cells."));
+             ExcMessage ("Can't ask for DoF indices on artificial cells."));
   dealii::internal::DoFCellAccessor::Implementation
     ::set_dof_values (*this, local_values, values);
 }
@@ -3282,11 +3403,11 @@ inline
 void
 DoFCellAccessor<DH>::
 distribute_local_to_global (const Vector<number> &local_source,
-                            OutputVector         &global_destination) const
+                                       OutputVector         &global_destination) const
 {
   dealii::internal::DoFCellAccessor::Implementation::
     distribute_local_to_global (*this, local_source.begin(),
-                                local_source.end(), global_destination);
+                                               local_source.end(), global_destination);
 }
 
 
@@ -3297,12 +3418,12 @@ inline
 void
 DoFCellAccessor<DH>::
 distribute_local_to_global (ForwardIterator  local_source_begin,
-                            ForwardIterator  local_source_end,
-                            OutputVector    &global_destination) const
+                                       ForwardIterator  local_source_end,
+                                       OutputVector    &global_destination) const
 {
   dealii::internal::DoFCellAccessor::Implementation::
     distribute_local_to_global (*this, local_source_begin,
-                                local_source_end, global_destination);
+                                               local_source_end, global_destination);
 }
 
 
@@ -3313,13 +3434,13 @@ inline
 void
 DoFCellAccessor<DH>::
 distribute_local_to_global (const ConstraintMatrix &constraints,
-                            ForwardIterator         local_source_begin,
-                            ForwardIterator         local_source_end,
-                            OutputVector           &global_destination) const
+                                       ForwardIterator         local_source_begin,
+                                       ForwardIterator         local_source_end,
+                                       OutputVector           &global_destination) const
 {
   dealii::internal::DoFCellAccessor::Implementation::
     distribute_local_to_global (*this, constraints, local_source_begin,
-                                local_source_end, global_destination);
+                                               local_source_end, global_destination);
 }
 
 
@@ -3330,7 +3451,7 @@ inline
 void
 DoFCellAccessor<DH>::
 distribute_local_to_global (const FullMatrix<number> &local_source,
-                            OutputMatrix             &global_destination) const
+                                       OutputMatrix             &global_destination) const
 {
   dealii::internal::DoFCellAccessor::Implementation::
     distribute_local_to_global (*this,local_source,global_destination);
@@ -3344,13 +3465,13 @@ inline
 void
 DoFCellAccessor<DH>::
 distribute_local_to_global (const FullMatrix<number> &local_matrix,
-                            const Vector<number>     &local_vector,
-                            OutputMatrix             &global_matrix,
-                            OutputVector             &global_vector) const
+                                       const Vector<number>     &local_vector,
+                                       OutputMatrix             &global_matrix,
+                                       OutputVector             &global_vector) const
 {
   dealii::internal::DoFCellAccessor::Implementation::
     distribute_local_to_global (*this,local_matrix,local_vector,
-                                global_matrix,global_vector);
+                                               global_matrix,global_vector);
 }
 
 
index 86fd9cbbe04bfc78e634bb36ea987f5802a87ff6..db1a7196fc39a776fb525e9dc59340682a3bb8eb 100644 (file)
@@ -282,7 +282,7 @@ class DoFHandler  :  public Subscriptor
                                       * freedom over the mesh.
                                       */
     void initialize(const Triangulation<dim,spacedim>& tria,
-                    const FiniteElement<dim,spacedim>& fe);
+                           const FiniteElement<dim,spacedim>& fe);
 
                                      /**
                                       * Go through the triangulation and
@@ -318,7 +318,9 @@ class DoFHandler  :  public Subscriptor
                                       * object to the finite element.
                                       */
     virtual void distribute_dofs (const FiniteElement<dim,spacedim> &fe,
-                                  const unsigned int        offset = 0);
+                                                 const unsigned int        offset = 0);
+    
+    virtual void distribute_mg_dofs (const FiniteElement<dim, spacedim>& fe, const unsigned int offset = 0);
 
                                      /**
                                       * After distribute_dofs() with
@@ -1041,6 +1043,8 @@ class DoFHandler  :  public Subscriptor
                                       * hanging nodes, see @ref constraints.
                                       */
     unsigned int n_dofs () const;
+    
+    unsigned int n_dofs (const unsigned int level) const;
 
                                      /**
                                       * Return the number of degrees of freedom
@@ -1287,9 +1291,9 @@ class DoFHandler  :  public Subscriptor
                                       * @ingroup Exceptions
                                       */
     DeclException1 (ExcEmptyLevel,
-                    int,
-                    << "You tried to do something on level " << arg1
-                    << ", but this level is empty.");
+                           int,
+                           << "You tried to do something on level " << arg1
+                           << ", but this level is empty.");
 
 
   protected:
@@ -1374,10 +1378,38 @@ class DoFHandler  :  public Subscriptor
                                       */
     DoFHandler & operator = (const DoFHandler &);
 
+    class MGVertexDoFs {
+      private:
+        unsigned int coarsest_level;
+        unsigned int finest_level;
+        unsigned int* indices;
+        unsigned int* indices_offset;
+      
+      public:
+        DeclException0 (ExcNoMemory);
+        MGVertexDoFs ();
+        ~MGVertexDoFs ();
+        unsigned int get_coarsest_level () const;
+        unsigned int get_finest_level () const;
+        unsigned int get_index (const unsigned int level, const unsigned int dof_number) const;
+        void init (const unsigned int coarsest_level, const unsigned int finest_level, const unsigned int dofs_per_vertex);
+        void set_index (const unsigned int level, const unsigned int dof_number, const unsigned int index);
+    };
+    
+    void clear_mg_space ();
+
                                      /**
                                       * Free all used memory.
                                       */
     void clear_space ();
+    
+    void reserve_space ();
+    
+    template <int structdim>
+    unsigned int get_dof_index (const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index) const;
+
+    template<int structdim>
+    void set_dof_index (const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index) const;
 
                                      /**
                                       * Space to store the DoF numbers
@@ -1387,6 +1419,8 @@ class DoFHandler  :  public Subscriptor
                                       * Triangulation objects.
                                       */
     std::vector<dealii::internal::DoFHandler::DoFLevel<dim>*> levels;
+    
+    std::vector<dealii::internal::DoFHandler::DoFLevel<dim>*> mg_levels;
 
                                      /**
                                       * Space to store DoF numbers of
@@ -1397,6 +1431,12 @@ class DoFHandler  :  public Subscriptor
                                       * array.
                                       */
     dealii::internal::DoFHandler::DoFFaces<dim> *faces;
+    
+    dealii::internal::DoFHandler::DoFFaces<dim>* mg_faces;
+    
+    std::vector<MGVertexDoFs> mg_vertex_dofs;
+    
+    std::vector<unsigned int> mg_used_dofs;
 
                                      /**
                                       * Make accessor objects friends.
@@ -1433,6 +1473,12 @@ DoFHandler<dim,spacedim>::n_dofs () const
   return number_cache.n_global_dofs;
 }
 
+template<int dim, int spacedim>
+inline
+unsigned int DoFHandler<dim, spacedim>::n_dofs (const unsigned int level) const {
+  Assert (level < mg_used_dofs.size (), ExcInvalidLevel (level));
+  return mg_used_dofs[level];
+}
 
 template <int dim, int spacedim>
 unsigned int
@@ -1559,6 +1605,21 @@ void DoFHandler<dim,spacedim>::load (Archive & ar,
 }
 
 
+template<int dim, int spacedim>
+inline
+unsigned int DoFHandler<dim, spacedim>::MGVertexDoFs::get_index (const unsigned int level, const unsigned int dof_number) const {
+  Assert ((level >= coarsest_level) && (level <= finest_level), ExcInvalidLevel (level));
+  return indices[indices_offset[level - coarsest_level] + dof_number];
+}
+
+
+template<int dim, int spacedim>
+inline
+void DoFHandler<dim, spacedim>::MGVertexDoFs::set_index (const unsigned int level, const unsigned int dof_number, const unsigned int index) {
+  Assert ((level >= coarsest_level) && (level <= finest_level), ExcInvalidLevel (level));
+  indices[indices_offset[level - coarsest_level] + dof_number] = index;
+}
+
 #endif // DOXYGEN
 
 DEAL_II_NAMESPACE_CLOSE
index 0f6212e786825aeed021b856e7735c6a132a6faa..dbf3c6d8718cfafebfd9dcf08a124360f64e393a 100644 (file)
@@ -201,11 +201,11 @@ namespace DoFTools
                                           * Two components do not
                                           * couple.
                                           */
-        none,
+           none,
                                          /**
                                           * Two components do couple.
                                           */
-        always,
+           always,
                                          /**
                                           * Two components couple only
                                           * if their shape functions are
@@ -214,7 +214,7 @@ namespace DoFTools
                                           * when computing integrals over
                                           * faces of cells.
                                           */
-        nonzero
+           nonzero
   };
 
                                    /**
@@ -493,10 +493,10 @@ namespace DoFTools
   template <class DH, class SparsityPattern>
   void
   make_sparsity_pattern (const DH               &dof,
-                         SparsityPattern        &sparsity_pattern,
-                         const ConstraintMatrix &constraints = ConstraintMatrix(),
-                         const bool              keep_constrained_dofs = true,
-                         const types::subdomain_id_t subdomain_id = types::invalid_subdomain_id);
+                                    SparsityPattern        &sparsity_pattern,
+                                    const ConstraintMatrix &constraints = ConstraintMatrix(),
+                                    const bool              keep_constrained_dofs = true,
+                                    const types::subdomain_id_t subdomain_id = types::invalid_subdomain_id);
 
                                    /**
                                     * Locate non-zero entries for
@@ -654,11 +654,11 @@ namespace DoFTools
   template <class DH, class SparsityPattern>
   void
   make_sparsity_pattern (const DH                 &dof,
-                         const Table<2, Coupling> &coupling,
-                         SparsityPattern          &sparsity_pattern,
-                         const ConstraintMatrix   &constraints = ConstraintMatrix(),
-                         const bool                keep_constrained_dofs = true,
-                         const types::subdomain_id_t subdomain_id = types::invalid_subdomain_id);
+                                    const Table<2, Coupling> &coupling,
+                                    SparsityPattern          &sparsity_pattern,
+                                    const ConstraintMatrix   &constraints = ConstraintMatrix(),
+                                    const bool                keep_constrained_dofs = true,
+                                    const types::subdomain_id_t subdomain_id = types::invalid_subdomain_id);
 
                                    /**
                                     * @deprecated This is the old
@@ -675,8 +675,8 @@ namespace DoFTools
   template <class DH, class SparsityPattern>
   void
   make_sparsity_pattern (const DH                              &dof,
-                         const std::vector<std::vector<bool> > &mask,
-                         SparsityPattern                       &sparsity_pattern);
+                                    const std::vector<std::vector<bool> > &mask,
+                                    SparsityPattern                       &sparsity_pattern);
 
                                    /**
                                     * Construct a sparsity pattern that
@@ -714,8 +714,8 @@ namespace DoFTools
   template <class DH, class SparsityPattern>
   void
   make_sparsity_pattern (const DH        &dof_row,
-                         const DH        &dof_col,
-                         SparsityPattern &sparsity);
+                                    const DH        &dof_col,
+                                    SparsityPattern &sparsity);
 
                                    /**
                                     * Create the sparsity pattern for
@@ -737,8 +737,8 @@ namespace DoFTools
   template <class DH, class SparsityPattern>
   void
   make_boundary_sparsity_pattern (const DH                        &dof,
-                                  const std::vector<unsigned int> &dof_to_boundary_mapping,
-                                  SparsityPattern                 &sparsity_pattern);
+                                                 const std::vector<unsigned int> &dof_to_boundary_mapping,
+                                                 SparsityPattern                 &sparsity_pattern);
 
                                    /**
                                     * Write the sparsity structure of the
@@ -773,9 +773,9 @@ namespace DoFTools
   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<unsigned int> &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);
 
                                    /**
                                     * Generate sparsity pattern for
@@ -796,7 +796,7 @@ namespace DoFTools
   template<class DH, class SparsityPattern>
   void
   make_flux_sparsity_pattern (const DH        &dof_handler,
-                              SparsityPattern &sparsity_pattern);
+                                         SparsityPattern &sparsity_pattern);
 
                                    /**
                                     * This function does the same as
@@ -812,10 +812,10 @@ namespace DoFTools
   template<class DH, class SparsityPattern>
   void
   make_flux_sparsity_pattern (const DH        &dof_handler,
-                              SparsityPattern &sparsity_pattern,
-                              const ConstraintMatrix   &constraints,
-                              const bool                keep_constrained_dofs = true,
-                              const types::subdomain_id_t  subdomain_id = numbers::invalid_unsigned_int);
+                                         SparsityPattern &sparsity_pattern,
+                                         const ConstraintMatrix   &constraints,
+                                         const bool                keep_constrained_dofs = true,
+                                         const types::subdomain_id_t  subdomain_id = numbers::invalid_unsigned_int);
 
                                    /**
                                     * This function does the same as
@@ -840,9 +840,9 @@ namespace DoFTools
   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);
 
                                    //@}
                                    /**
@@ -925,7 +925,7 @@ namespace DoFTools
   template <class DH>
   void
   make_hanging_node_constraints (const DH         &dof_handler,
-                                 ConstraintMatrix &constraints);
+                                                ConstraintMatrix &constraints);
                                    //@}
 
 
@@ -1170,9 +1170,9 @@ namespace DoFTools
   template <class DH, typename Number>
   void
   distribute_cell_to_dof_vector (const DH              &dof_handler,
-                                 const Vector<Number>  &cell_data,
-                                 Vector<double>        &dof_data,
-                                 const unsigned int     component = 0);
+                                                const Vector<Number>  &cell_data,
+                                                Vector<double>        &dof_data,
+                                                const unsigned int     component = 0);
 
                                    /**
                                     * Extract the indices of the
@@ -1223,9 +1223,9 @@ namespace DoFTools
   template <int dim, int spacedim>
   void
   extract_dofs (const DoFHandler<dim,spacedim>   &dof_handler,
-                const std::vector<bool> &select,
-                std::vector<bool>       &selected_dofs,
-                const bool               blocks = false);
+                       const std::vector<bool> &select,
+                       std::vector<bool>       &selected_dofs,
+                       const bool               blocks = false);
 
                                    /**
                                     * The same function as above,
@@ -1234,23 +1234,23 @@ namespace DoFTools
   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 std::vector<bool> &select,
+                       std::vector<bool>       &selected_dofs,
+                       const bool               blocks = false);
 
                                    /**
                                     * Do the same thing as
                                     * extract_dofs() 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 std::vector<bool> &select,
-                      std::vector<bool>       &selected_dofs,
-                      const bool               blocks = false);
-
+                             const DH &dof,
+                             const std::vector<bool> &select,
+                             std::vector<bool>       &selected_dofs,
+                             const bool               blocks = false);
+       
   /**
    * Extract all degrees of freedom
    * which are at the boundary and
@@ -1322,7 +1322,7 @@ namespace DoFTools
    *          will contain the indices of degrees of freedom that are
    *          located on the boundary (and correspond to the selected
    *          vector components and boundary indicators, depending on
-   *          the values of the @p component_mask and @p boundary_indicators
+   *          the values of the @p component_select and @p boundary_indicators
    *          arguments).
    * @param boundary_indicators If empty, this function extracts the
    *          indices of the degrees of freedom for all parts of the boundary.
@@ -1337,6 +1337,42 @@ namespace DoFTools
                          std::vector<bool>          &selected_dofs,
                          const std::set<types::boundary_id_t> &boundary_indicators = std::set<types::boundary_id_t>());
 
+  /**
+   * This function does the same as the previous one but it
+   * returns its result as an IndexSet rather than a std::vector@<bool@>.
+   * Thus, it can also be called for DoFHandler objects that are
+   * defined on parallel::distributed::Triangulation objects.
+   *
+   * @note If the DoFHandler object is indeed defined on a
+   * parallel::distributed::Triangulation, then the @p selected_dofs
+   * index set will contain only those degrees of freedom on the
+   * boundary that belong to the locally relevant set (see
+   * @ref GlossLocallyRelevantDof "locally relevant DoFs").
+   *
+   * @param dof_handler The object that describes which degrees of freedom
+   *          live on which cell
+   * @param component_mask A mask denoting the vector components of the
+   *          finite element that should be considered (see also
+   *          @ref GlossComponentMask).
+   * @param selected_dofs The IndexSet object that is returned and that
+   *          will contain the indices of degrees of freedom that are
+   *          located on the boundary (and correspond to the selected
+   *          vector components and boundary indicators, depending on
+   *          the values of the @p component_mask and @p boundary_indicators
+   *          arguments).
+   * @param boundary_indicators If empty, this function extracts the
+   *          indices of the degrees of freedom for all parts of the boundary.
+   *          If it is a non-empty list, then the function only considers
+   *          boundary faces with the boundary indicators listed in this
+   *          argument.
+   */
+  template <class DH>
+  void
+  extract_boundary_dofs (const DH                   &dof_handler,
+                         const std::vector<bool>    &component_mask,
+                         IndexSet                   &selected_dofs,
+                         const std::set<types::boundary_id_t> &boundary_indicators = std::set<types::boundary_id_t>());
+
   /**
    * This function does the same as the previous one but it
    * returns its result as an IndexSet rather than a std::vector@<bool@>.
@@ -1406,9 +1442,9 @@ namespace DoFTools
   template <class DH>
   void
   extract_dofs_with_support_on_boundary (const DH                   &dof_handler,
-                                         const std::vector<bool>    &component_mask,
-                                         std::vector<bool>          &selected_dofs,
-                                         const std::set<types::boundary_id_t> &boundary_indicators = std::set<types::boundary_id_t>());
+                                                            const std::vector<bool>    &component_mask,
+                                                            std::vector<bool>          &selected_dofs,
+                                                            const std::set<types::boundary_id_t> &boundary_indicators = std::set<types::boundary_id_t>());
 
                                    /**
                                     * @name Hanging Nodes
@@ -1430,7 +1466,7 @@ namespace DoFTools
   template <int dim, int spacedim>
   void
   extract_hanging_node_dofs (const DoFHandler<dim,spacedim> &dof_handler,
-                             std::vector<bool>              &selected_dofs);
+                                        std::vector<bool>              &selected_dofs);
                                    //@}
 
                                    /**
@@ -1458,8 +1494,8 @@ namespace DoFTools
   template <class DH>
   void
   extract_subdomain_dofs (const DH           &dof_handler,
-                          const types::subdomain_id_t subdomain_id,
-                          std::vector<bool>  &selected_dofs);
+                                     const types::subdomain_id_t subdomain_id,
+                                     std::vector<bool>  &selected_dofs);
 
 
                                    /**
@@ -1476,7 +1512,7 @@ namespace DoFTools
   template <class DH>
   void
   extract_locally_owned_dofs (const DH & dof_handler,
-                              IndexSet & dof_set);
+                                         IndexSet & dof_set);
 
 
                                    /**
@@ -1510,7 +1546,7 @@ namespace DoFTools
   template <class DH>
   void
   extract_locally_active_dofs (const DH & dof_handler,
-                               IndexSet & dof_set);
+                                          IndexSet & dof_set);
 
                                    /**
                                     * Extract the set of global DoF
@@ -1531,7 +1567,7 @@ namespace DoFTools
   template <class DH>
   void
   extract_locally_relevant_dofs (const DH & dof_handler,
-                                 IndexSet & dof_set);
+                                                IndexSet & dof_set);
 
                                    /**
                                     * For each DoF, return in the output
@@ -1589,7 +1625,7 @@ namespace DoFTools
   template <class DH>
   void
   get_subdomain_association (const DH                  &dof_handler,
-                             std::vector<types::subdomain_id_t> &subdomain);
+                                        std::vector<types::subdomain_id_t> &subdomain);
 
                                    /**
                                     * Count how many degrees of freedom are
@@ -1633,7 +1669,7 @@ namespace DoFTools
   template <class DH>
   unsigned int
   count_dofs_with_subdomain_association (const DH           &dof_handler,
-                                         const types::subdomain_id_t subdomain);
+                                                            const types::subdomain_id_t subdomain);
 
                                    /**
                                     * Count how many degrees of freedom are
@@ -1670,8 +1706,8 @@ namespace DoFTools
   template <class DH>
   void
   count_dofs_with_subdomain_association (const DH           &dof_handler,
-                                         const types::subdomain_id_t subdomain,
-                                         std::vector<unsigned int> &n_dofs_on_subdomain);
+                                                            const types::subdomain_id_t subdomain,
+                                                            std::vector<unsigned int> &n_dofs_on_subdomain);
 
                                    /**
                                     * Return a set of indices that denotes
@@ -1712,8 +1748,7 @@ namespace DoFTools
   template <class DH>
   IndexSet
   dof_indices_with_subdomain_association (const DH           &dof_handler,
-                                          const types::subdomain_id_t subdomain);
-
+                                                             const types::subdomain_id_t subdomain);
                                    // @}
                                    /**
                                     * @name Dof indices for patches
@@ -1957,8 +1992,8 @@ namespace DoFTools
   template <class DH>
   void
   extract_constant_modes (const DH                        &dof_handler,
-                          const std::vector<bool>         &component_mask,
-                          std::vector<std::vector<bool> > &constant_modes);
+                                     const std::vector<bool>         &component_mask,
+                                     std::vector<std::vector<bool> > &constant_modes);
 
                                    /**
                                     * For each active cell of a DoFHandler
@@ -1978,7 +2013,7 @@ namespace DoFTools
   template <class DH>
   void
   get_active_fe_indices (const DH                  &dof_handler,
-                         std::vector<unsigned int> &active_fe_indices);
+                                    std::vector<unsigned int> &active_fe_indices);
 
                                    /**
                                     * Count how many degrees of
@@ -2060,10 +2095,10 @@ namespace DoFTools
   template <class DH>
   void
   count_dofs_per_component (const DH &     dof_handler,
-                            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<unsigned int>& dofs_per_component,
+                                       const bool vector_valued_once = false,
+                                       std::vector<unsigned int>  target_component
+                                       = std::vector<unsigned int>());
 
                                    /**
                                     * Count the degrees of freedom
@@ -2114,8 +2149,8 @@ namespace DoFTools
   template <int dim, int spacedim>
   void
   count_dofs_per_component (const DoFHandler<dim,spacedim>&     dof_handler,
-                            std::vector<unsigned int>& dofs_per_component,
-                            std::vector<unsigned int>  target_component);
+                                       std::vector<unsigned int>& dofs_per_component,
+                                       std::vector<unsigned int>  target_component);
 
                                    /**
                                     * This function can be used when
@@ -2334,11 +2369,11 @@ namespace DoFTools
   template <int dim, int spacedim>
   void
   compute_intergrid_constraints (const DoFHandler<dim,spacedim>              &coarse_grid,
-                                 const unsigned int                  coarse_component,
-                                 const DoFHandler<dim,spacedim>              &fine_grid,
-                                 const unsigned int                  fine_component,
-                                 const InterGridMap<DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
-                                 ConstraintMatrix                   &constraints);
+                                                const unsigned int                  coarse_component,
+                                                const DoFHandler<dim,spacedim>              &fine_grid,
+                                                const unsigned int                  fine_component,
+                                                const InterGridMap<DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
+                                                ConstraintMatrix                   &constraints);
 
 
                                    /**
@@ -2367,11 +2402,11 @@ namespace DoFTools
   template <int dim, int spacedim>
   void
   compute_intergrid_transfer_representation (const DoFHandler<dim,spacedim>              &coarse_grid,
-                                             const unsigned int                  coarse_component,
-                                             const DoFHandler<dim,spacedim>              &fine_grid,
-                                             const unsigned int                  fine_component,
-                                             const InterGridMap<DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
-                                             std::vector<std::map<unsigned int, float> > &transfer_representation);
+                                                                const unsigned int                  coarse_component,
+                                                                const DoFHandler<dim,spacedim>              &fine_grid,
+                                                                const unsigned int                  fine_component,
+                                                                const InterGridMap<DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
+                                                                std::vector<std::map<unsigned int, float> > &transfer_representation);
 
                                    /**
                                     * Create a mapping from degree
@@ -2403,7 +2438,7 @@ namespace DoFTools
   template <class DH>
   void
   map_dof_to_boundary_indices (const DH                   &dof_handler,
-                               std::vector<unsigned int>  &mapping);
+                                          std::vector<unsigned int>  &mapping);
 
                                    /**
                                     * Same as the previous function,
@@ -2419,8 +2454,8 @@ namespace DoFTools
   template <class DH>
   void
   map_dof_to_boundary_indices (const DH                      &dof_handler,
-                               const std::set<types::boundary_id_t> &boundary_indicators,
-                               std::vector<unsigned int>     &mapping);
+                                          const std::set<types::boundary_id_t> &boundary_indicators,
+                                          std::vector<unsigned int>     &mapping);
 
                                    /**
                                     * Return a list of support
@@ -2437,77 +2472,26 @@ namespace DoFTools
                                     * or the like. Otherwise, an
                                     * exception is thrown.
                                     *
-                                    * @pre The given array must have a
+                                    * The given array must have a
                                     * length of as many elements as
                                     * there are degrees of freedom.
-                                    *
-                                    * @note The precondition to this function
-                                    * that the output argument needs to have
-                                    * size equal to the total number of degrees
-                                    * of freedom makes this function
-                                    * unsuitable for the case that the given
-                                    * DoFHandler object derives from a
-                                    * parallel::distributed::Triangulation object.
-                                    * Consequently, this function will produce an
-                                    * error if called with such a DoFHandler.
                                     */
   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,
         const hp::DoFHandler<dim,spacedim>    &dof_handler,
         std::vector<Point<spacedim> > &support_points);
 
-  /**
-   * This function is a version of the above map_dofs_to_support_points
-   * function that doesn't simply return a vector of support points (see
-   * this @ref GlossSupport "glossary entry") with one
-   * entry for each global degree of freedom, but instead a map that
-   * maps from the DoFs index to its location. The point of this
-   * function is that it is also usable in cases where the DoFHandler
-   * is based on a parallel::distributed::Triangulation object. In such cases,
-   * each processor will not be able to determine the support point location
-   * of all DoFs, and worse no processor may be able to hold a vector that
-   * would contain the locations of all DoFs even if they were known. As
-   * a consequence, this function constructs a map from those DoFs for which
-   * we can know the locations (namely, those DoFs that are
-   * locally relevant (see @ref GlossLocallyRelevantDof "locally relevant DoFs")
-   * to their locations.
-   *
-   * For non-distributed triangulations, the map returned as @p support_points
-   * is of course dense, i.e., every DoF is to be found in it.
-   *
-   * @param mapping The mapping from the reference cell to the real cell on
-   *        which DoFs are defined.
-   * @param dof_handler The object that describes which DoF indices live on
-   *        which cell of the triangulation.
-   * @param support_points A map that for every locally relevant DoF index
-   *        contains the corresponding location in real space coordinates.
-   *        Previous content of this object is deleted in this function.
-   */
-  template <int dim, int spacedim>
-  void
-  map_dofs_to_support_points (const Mapping<dim,spacedim>       &mapping,
-                              const DoFHandler<dim,spacedim>    &dof_handler,
-                              std::map<unsigned int, Point<spacedim> >     &support_points);
-
-            /**
-             * Same as the previous function but for the hp case.
-             */
-  template <int dim, int spacedim>
-  void
-  map_dofs_to_support_points (const dealii::hp::MappingCollection<dim,spacedim>   &mapping,
-                              const hp::DoFHandler<dim,spacedim>    &dof_handler,
-                              std::map<unsigned int, Point<spacedim> > &support_points);
-
                                    /**
                                     * This is the opposite function
                                     * to the one above. It generates
@@ -2540,8 +2524,8 @@ namespace DoFTools
   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>, unsigned int, Comp> &point_to_index_map);
+                                         const DH                                          &dof_handler,
+                                         std::map<Point<DH::space_dimension>, unsigned int, Comp> &point_to_index_map);
 
                                    /**
                                     * Map a coupling table from the
@@ -2561,8 +2545,8 @@ namespace DoFTools
   template <int dim, int spacedim>
   void
   convert_couplings_to_blocks (const hp::DoFHandler<dim,spacedim>& dof_handler,
-                               const Table<2, Coupling>& table_by_component,
-                               std::vector<Table<2,Coupling> >& tables_by_block);
+                                          const Table<2, Coupling>& table_by_component,
+                                          std::vector<Table<2,Coupling> >& tables_by_block);
 
                                    /**
                                     * Make a constraint matrix for the
@@ -2597,8 +2581,8 @@ namespace DoFTools
   template <int dim, int spacedim, template <int, int> class DH>
   void
   make_zero_boundary_constraints (const DH<dim,spacedim> &dof,
-                                  ConstraintMatrix        &zero_boundary_constraints,
-                                  const std::vector<bool> &component_mask_=std::vector<bool>());
+                                                 ConstraintMatrix        &zero_boundary_constraints,
+                                                 const std::vector<bool> &component_mask_=std::vector<bool>());
 
                                    /**
                                     * Map a coupling table from the
@@ -2618,8 +2602,8 @@ namespace DoFTools
   template <int dim, int spacedim>
   void
   convert_couplings_to_blocks (const DoFHandler<dim,spacedim>& dof_handler,
-                               const Table<2, Coupling>& table_by_component,
-                               std::vector<Table<2,Coupling> >& tables_by_block);
+                                          const Table<2, Coupling>& table_by_component,
+                                          std::vector<Table<2,Coupling> >& tables_by_block);
 
                                    /**
                                     * Given a finite element and a table how
@@ -2632,7 +2616,7 @@ namespace DoFTools
   template <int dim, int spacedim>
   Table<2,Coupling>
   dof_couplings_from_component_couplings (const FiniteElement<dim,spacedim> &fe,
-                                          const Table<2,Coupling> &component_couplings);
+                                                             const Table<2,Coupling> &component_couplings);
 
                                    /**
                                     * Same function as above for a
@@ -2646,7 +2630,7 @@ namespace DoFTools
   template <int dim, int spacedim>
   std::vector<Table<2,Coupling> >
   dof_couplings_from_component_couplings (const hp::FECollection<dim,spacedim> &fe,
-                                          const Table<2,Coupling> &component_couplings);
+                                                             const Table<2,Coupling> &component_couplings);
                                    /**
                                     * Exception
                                     * @ingroup Exceptions
@@ -2689,7 +2673,7 @@ namespace DoFTools
  */
   inline
   Coupling operator |= (Coupling& c1,
-                        const Coupling c2)
+                                   const Coupling c2)
   {
     if (c2 == always)
       c1 = always;
@@ -2706,7 +2690,7 @@ namespace DoFTools
  */
   inline
   Coupling operator | (const Coupling c1,
-                       const Coupling c2)
+                              const Coupling c2)
   {
     if (c1 == always || c2 == always)
       return always;
@@ -2813,24 +2797,24 @@ namespace DoFTools
   inline
   void
   make_sparsity_pattern (const DH                              &dof,
-                         const std::vector<std::vector<bool> > &mask,
-                         SparsityPattern                       &sparsity_pattern)
+                                    const std::vector<std::vector<bool> > &mask,
+                                    SparsityPattern                       &sparsity_pattern)
   {
     const unsigned int ncomp = dof.get_fe().n_components();
 
     Assert (mask.size() == ncomp,
-            ExcDimensionMismatch(mask.size(), ncomp));
+               ExcDimensionMismatch(mask.size(), ncomp));
     for (unsigned int i=0; i<mask.size(); ++i)
       Assert (mask[i].size() == ncomp,
-              ExcDimensionMismatch(mask[i].size(), ncomp));
+                 ExcDimensionMismatch(mask[i].size(), ncomp));
                                      // Create a coupling table out of the mask
     Table<2,DoFTools::Coupling> couplings(ncomp, ncomp);
     for (unsigned int i=0;i<ncomp;++i)
       for (unsigned int j=0;j<ncomp;++j)
-        if (mask[i][j])
-          couplings(i,j) = always;
-        else
-          couplings(i,j) = none;
+           if (mask[i][j])
+             couplings(i,j) = always;
+           else
+             couplings(i,j) = none;
 
                                      // Call the new function
     make_sparsity_pattern(dof, couplings, sparsity_pattern);
index e26959fca6d21ed8d049457345af794a1282d1af..46d232eb61dd5ea8a37b651e6ee329df1c752424 100644 (file)
 
 
 
-#include <deal.II/base/config.h>
-#include <deal.II/base/exceptions.h>
-#include <deal.II/base/template_constraints.h>
-#include <deal.II/base/smartpointer.h>
-#include <deal.II/dofs/function_map.h>
-#include <deal.II/dofs/dof_iterator_selector.h>
-#include <deal.II/dofs/number_cache.h>
-#include <deal.II/hp/fe_collection.h>
+#include <base/config.h>
+#include <base/exceptions.h>
+#include <base/template_constraints.h>
+#include <base/smartpointer.h>
+#include <dofs/function_map.h>
+#include <dofs/dof_iterator_selector.h>
+#include <dofs/number_cache.h>
+#include <hp/fe_collection.h>
 
 #include <vector>
 #include <map>
@@ -73,7 +73,8 @@ namespace hp
  * @ingroup hp
  */
   template <int dim, int spacedim=dim>
-  class DoFHandler : public Subscriptor
+  class DoFHandler : public Subscriptor,
+                     protected Triangulation<dim,spacedim>::RefinementListener
   {
       typedef dealii::internal::DoFHandler::Iterators<DoFHandler<dim,spacedim> > IteratorSelector;
     public:
@@ -1025,17 +1026,17 @@ namespace hp
                                         * Exception
                                         */
       DeclException2 (ExcInvalidFEIndex,
-                      int, int,
-                      << "The mesh contains a cell with an active_fe_index of "
-                      << arg1 << ", but the finite element collection only has "
-                      << arg2 << " elements");
+                             int, int,
+                             << "The mesh contains a cell with an active_fe_index of "
+                             << arg1 << ", but the finite element collection only has "
+                             << arg2 << " elements");
                                        /**
                                         *  Exception
                                         */
       DeclException1 (ExcInvalidLevel,
-                      int,
-                      << "The given level " << arg1
-                      << " is not in the valid range!");
+                             int,
+                             << "The given level " << arg1
+                             << " is not in the valid range!");
                                        /**
                                         * Exception
                                         */
@@ -1045,9 +1046,9 @@ namespace hp
                                         * accessed is empty.
                                         */
       DeclException1 (ExcEmptyLevel,
-                      int,
-                      << "You tried to do something on level " << arg1
-                      << ", but this level is empty.");
+                             int,
+                             << "You tried to do something on level " << arg1
+                             << ", but this level is empty.");
 
     protected:
 
@@ -1097,11 +1098,25 @@ namespace hp
                                         * copy such an object.
                                         */
       DoFHandler & operator = (const DoFHandler &);
+      
+      class MGVertexDoFs {
+        public:
+          MGVertexDoFs ();
+          ~MGVertexDoFs ();
+          unsigned int get_index (const unsigned int level, const unsigned int dof_number) const;
+          void set_index (const unsigned int level, const unsigned int dof_number, const unsigned int index);
+      };
 
                                        /**
                                         * Free all used memory.
                                         */
       void clear_space ();
+      
+      template<int structdim>
+      unsigned int get_dof_index (const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index) const;
+      
+      template<int structdim>
+      void set_dof_index (const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index) const;
 
                                        /**
                                         *  Create default tables for
@@ -1132,9 +1147,8 @@ namespace hp
                                         *  active_fe_fields during the
                                         *  spatial refinement.
                                         */
-      void pre_refinement_action ();
-      void post_refinement_action ();
-
+      virtual void pre_refinement_action ();
+      virtual void post_refinement_action ();
 
                                        /**
                                         * Compute identities between
@@ -1189,16 +1203,16 @@ namespace hp
                                         * entity.
                                         */
       void renumber_dofs_internal (const std::vector<unsigned int> &new_numbers,
-                                   dealii::internal::int2type<0>);
+                                                  dealii::internal::int2type<0>);
 
       void renumber_dofs_internal (const std::vector<unsigned int> &new_numbers,
-                                   dealii::internal::int2type<1>);
+                                                  dealii::internal::int2type<1>);
 
       void renumber_dofs_internal (const std::vector<unsigned int> &new_numbers,
-                                   dealii::internal::int2type<2>);
+                                                  dealii::internal::int2type<2>);
 
       void renumber_dofs_internal (const std::vector<unsigned int> &new_numbers,
-                                   dealii::internal::int2type<3>);
+                                                  dealii::internal::int2type<3>);
 
                                        /**
                                         * Space to store the DoF
@@ -1277,6 +1291,8 @@ namespace hp
                                         * the present class.
                                         */
       std::vector<unsigned int>      vertex_dofs_offsets;
+      
+      std::vector<MGVertexDoFs> mg_vertex_dofs;
 
                                        /**
                                         * Array to store the
@@ -1289,11 +1305,11 @@ namespace hp
                                         */
       std::vector<std::vector<bool> *> has_children;
 
-      /**
-       * A list of connections with which this object connects
-       * to the triangulation to get information about when the
-       * triangulation changes.
-       */
+                                       /**
+                                        * A list of connections with which this object connects
+                                        * to the triangulation to get information about when the
+                                        * triangulation changes.
+                                        */
       std::vector<boost::signals2::connection> tria_listeners;
 
                                        /**
@@ -1371,8 +1387,8 @@ namespace hp
   DoFHandler<dim,spacedim>::get_fe () const
   {
     Assert (finite_elements != 0,
-            ExcMessage ("No finite element collection is associated with "
-                        "this DoFHandler"));
+               ExcMessage ("No finite element collection is associated with "
+                                   "this DoFHandler"));
     return *finite_elements;
   }
 
@@ -1385,7 +1401,18 @@ namespace hp
     return *tria;
   }
 
-
+  template<int dim, int spacedim>
+  inline
+  unsigned int DoFHandler<dim, spacedim>::MGVertexDoFs::get_index (const unsigned int level, const unsigned int dof_number) const {
+    Assert (false, ExcNotImplemented ());
+    return invalid_dof_index;
+  }
+  
+  template<int dim, int spacedim>
+  inline
+  void DoFHandler<dim, spacedim>::MGVertexDoFs::set_index (const unsigned int level, const unsigned int dof_number, const unsigned int index) {
+    Assert (false, ExcNotImplemented ());
+  }
 
 
 #endif
index a5f929451c353c40362c0c77077abef822eb6798..4288c6d92ccc52e6cb0e91a91a6e6bd2c898a5ff 100644 (file)
@@ -22,6 +22,7 @@
 
 DEAL_II_NAMESPACE_OPEN
 
+template <int dim, int spacedim> class DoFHandler;
 template <int dim, int spacedim> class MGDoFHandler;
 template <int dim> struct FunctionMap;
 
@@ -58,8 +59,13 @@ class MGConstrainedDoFs : public Subscriptor
                                       */
     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 std::vector<bool>& component_mask = std::vector<bool>());
+
+    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.
@@ -72,7 +78,7 @@ class MGConstrainedDoFs : public Subscriptor
                                       * constraint.
                                       */
     bool is_boundary_index (const unsigned int level,
-                            const unsigned int index) const;
+                                       const unsigned int index) const;
 
                                      /**
                                       * Determine whether a dof index
@@ -80,14 +86,14 @@ class MGConstrainedDoFs : public Subscriptor
                                       * a refinement edge.
                                       */
     bool non_refinement_edge_index (const unsigned int level,
-                             const unsigned int index) const;
+                                    const unsigned int index) const;
 
                                      /**
                                       * Determine whether a dof index
                                       * is at the refinement edge.
                                       */
     bool at_refinement_edge (const unsigned int level,
-                             const unsigned int index) const;
+                                        const unsigned int index) const;
 
                                      /**
                                       * Determine whether a dof index
@@ -96,7 +102,7 @@ class MGConstrainedDoFs : public Subscriptor
                                       * constraint .
                                       */
     bool at_refinement_edge_boundary (const unsigned int level,
-                                      const unsigned int index) const;
+                                                     const unsigned int index) const;
 
                                      /**
                                       * Return the indices of dofs for each
@@ -197,7 +203,7 @@ MGConstrainedDoFs::initialize(const MGDoFHandler<dim,spacedim>& dof)
       refinement_edge_boundary_indices[l].resize(dof.n_dofs(l));
     }
   MGTools::extract_inner_interface_dofs (dof, refinement_edge_indices,
-                                         refinement_edge_boundary_indices);
+                                                            refinement_edge_boundary_indices);
 
   MGTools::extract_non_interface_dofs (dof, non_refinement_edge_indices);
 }
@@ -226,11 +232,37 @@ MGConstrainedDoFs::initialize(
 
   MGTools::make_boundary_list (dof, function_map, boundary_indices, component_mask);
   MGTools::extract_inner_interface_dofs (dof, refinement_edge_indices,
-                                         refinement_edge_boundary_indices);
+                                                            refinement_edge_boundary_indices);
   MGTools::extract_non_interface_dofs (dof, non_refinement_edge_indices);
 }
 
 
+template <int dim, int spacedim>
+inline
+void
+MGConstrainedDoFs::initialize(
+  const DoFHandler<dim,spacedim>& dof,
+  const typename FunctionMap<dim>::type& function_map,
+  const std::vector<bool>& component_mask)
+{
+  const unsigned int nlevels = dof.get_tria().n_levels();
+  boundary_indices.resize(nlevels);
+  refinement_edge_indices.resize(nlevels);
+  refinement_edge_boundary_indices.resize(nlevels);
+
+  for(unsigned int l=0; l<nlevels; ++l)
+    {
+      boundary_indices[l].clear();
+      refinement_edge_indices[l].resize(dof.n_dofs(l));
+      refinement_edge_boundary_indices[l].resize(dof.n_dofs(l));
+    }
+
+  MGTools::make_boundary_list (dof, function_map, boundary_indices, component_mask);
+  MGTools::extract_inner_interface_dofs (dof, refinement_edge_indices,
+                                        refinement_edge_boundary_indices);
+}
+
+
 inline
 void
 MGConstrainedDoFs::clear()
@@ -252,7 +284,7 @@ MGConstrainedDoFs::clear()
 inline
 bool
 MGConstrainedDoFs::is_boundary_index (const unsigned int level,
-                                  const unsigned int index) const
+                                                     const unsigned int index) const
 {
   AssertIndexRange(level, boundary_indices.size());
   if(boundary_indices[level].find(index) != boundary_indices[level].end())
@@ -264,7 +296,7 @@ MGConstrainedDoFs::is_boundary_index (const unsigned int level,
 inline
 bool
 MGConstrainedDoFs::non_refinement_edge_index (const unsigned int level,
-                             const unsigned int index) const
+                                              const unsigned int index) const
 {
   AssertIndexRange(level, non_refinement_edge_indices.size());
 
@@ -277,7 +309,7 @@ MGConstrainedDoFs::non_refinement_edge_index (const unsigned int level,
 inline
 bool
 MGConstrainedDoFs::at_refinement_edge (const unsigned int level,
-                                   const unsigned int index) const
+                                                      const unsigned int index) const
 {
   AssertIndexRange(level, refinement_edge_indices.size());
   AssertIndexRange(index, refinement_edge_indices[level].size());
@@ -289,7 +321,7 @@ MGConstrainedDoFs::at_refinement_edge (const unsigned int level,
 inline
 bool
 MGConstrainedDoFs::at_refinement_edge_boundary (const unsigned int level,
-                                            const unsigned int index) const
+                                                                   const unsigned int index) const
 {
   AssertIndexRange(level, refinement_edge_boundary_indices.size());
   AssertIndexRange(index, refinement_edge_boundary_indices[level].size());
index e4ae4006e3a93e0c9c80b3e82cc169cd6bcd0249..7f2f8f24f0afbcebf663be32f5827b78e64871ad 100644 (file)
@@ -39,6 +39,7 @@
 DEAL_II_NAMESPACE_OPEN
 
 
+template <int dim, int spacedim> class DoFHandler;
 template <int dim, int spacedim> class MGDoFHandler;
 
 /*
@@ -75,7 +76,7 @@ class MGTransferPrebuilt : public MGTransferBase<VECTOR>
                                      /**
                                       * Constructor with constraint matrices as well as mg_constrained_dofs.
                                       */
-    MGTransferPrebuilt (const ConstraintMatrix& constraints,
+    MGTransferPrebuilt (const ConstraintMatrix& constraints, 
         const MGConstrainedDoFs& mg_constrained_dofs);
                                      /**
                                       * Destructor.
@@ -88,13 +89,16 @@ class MGTransferPrebuilt : public MGTransferBase<VECTOR>
     template <int dim, int spacedim>
     void build_matrices (const MGDoFHandler<dim,spacedim> &mg_dof);
 
+    template <int dim, int spacedim>
+    void build_matrices (const DoFHandler<dim,spacedim> &dof_handler);
+
     virtual void prolongate (const unsigned int    to_level,
-                             VECTOR       &dst,
-                             const VECTOR &src) const;
+                                        VECTOR       &dst,
+                                        const VECTOR &src) const;
 
     virtual void restrict_and_add (const unsigned int    from_level,
-                                   VECTOR       &dst,
-                                   const VECTOR &src) const;
+                                                  VECTOR       &dst,
+                                                  const VECTOR &src) const;
 
                                      /**
                                       * Transfer from a vector on the
@@ -105,8 +109,14 @@ class MGTransferPrebuilt : public MGTransferBase<VECTOR>
     template <int dim, class InVector, int spacedim>
     void
     copy_to_mg (const MGDoFHandler<dim,spacedim>& mg_dof,
-                MGLevelObject<VECTOR>& dst,
-                const InVector& src) const;
+                       MGLevelObject<VECTOR>& dst,
+                       const InVector& src) const;
+
+    template <int dim, class InVector, int spacedim>
+    void
+    copy_to_mg (const DoFHandler<dim,spacedim>& dof_handler,
+               MGLevelObject<VECTOR>& dst,
+               const InVector& src) const;
 
                                      /**
                                       * Transfer from multi-level vector to
@@ -123,8 +133,14 @@ class MGTransferPrebuilt : public MGTransferBase<VECTOR>
     template <int dim, class OutVector, int spacedim>
     void
     copy_from_mg (const MGDoFHandler<dim,spacedim>& mg_dof,
-                  OutVector& dst,
-                  const MGLevelObject<VECTOR> &src) const;
+                         OutVector& dst,
+                         const MGLevelObject<VECTOR> &src) const;
+
+    template <int dim, class OutVector, int spacedim>
+    void
+    copy_from_mg (const DoFHandler<dim,spacedim>& dof_handler,
+                 OutVector& dst,
+                 const MGLevelObject<VECTOR> &src) const;
 
                                      /**
                                       * Add a multi-level vector to a
@@ -137,8 +153,14 @@ class MGTransferPrebuilt : public MGTransferBase<VECTOR>
     template <int dim, class OutVector, int spacedim>
     void
     copy_from_mg_add (const MGDoFHandler<dim,spacedim>& mg_dof,
-                      OutVector& dst,
-                      const MGLevelObject<VECTOR>& src) const;
+                             OutVector& dst,
+                             const MGLevelObject<VECTOR>& src) const;
+
+    template <int dim, class OutVector, int spacedim>
+    void
+    copy_from_mg_add (const DoFHandler<dim,spacedim>& dof_handler,
+                     OutVector& dst,
+                     const MGLevelObject<VECTOR>& src) const;
 
                                      /**
                                       * If this object operates on
@@ -219,7 +241,7 @@ class MGTransferPrebuilt : public MGTransferBase<VECTOR>
                                       * <tt>copy_to/from_mg</tt>-functions.
                                       * The data is first the global
                                       * index, then the level index.
-                                     */
+                                      */
     std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
       copy_indices;
 
index f8bbd965428fa0799ad91c8261c34dea4c68f722..bcd44fdf6e3b621e080560e3177da0b703e61dd6 100644 (file)
@@ -53,6 +53,21 @@ namespace
         v[level].reinit(n);
       }
 
+  }
+  
+  template <int dim, typename number, int spacedim>
+  void
+  reinit_vector (const dealii::DoFHandler<dim,spacedim> &mg_dof,
+                 std::vector<unsigned int> ,
+                 MGLevelObject<dealii::Vector<number> > &v)
+  {
+    for (unsigned int level=v.get_minlevel();
+         level<=v.get_maxlevel();++level)
+      {
+        unsigned int n = mg_dof.n_dofs (level);
+        v[level].reinit(n);
+      }
+
   }
 
 
@@ -100,6 +115,41 @@ namespace
         v[level].collect_sizes();
       }
   }
+  
+  template <int dim, typename number, int spacedim>
+  void
+  reinit_vector (const dealii::DoFHandler<dim,spacedim> &mg_dof,
+                 std::vector<unsigned int> target_component,
+                 MGLevelObject<BlockVector<number> > &v)
+  {
+    const unsigned int n_blocks = mg_dof.get_fe().n_blocks();
+    if (target_component.size()==0)
+      {
+        target_component.resize(n_blocks);
+        for (unsigned int i=0;i<n_blocks;++i)
+          target_component[i] = i;
+      }
+    Assert(target_component.size()==n_blocks,
+           ExcDimensionMismatch(target_component.size(),n_blocks));
+    const unsigned int max_block
+      = *std::max_element (target_component.begin(),
+                           target_component.end());
+    const unsigned int n_target_blocks = max_block + 1;
+
+    std::vector<std::vector<unsigned int> >
+      ndofs(mg_dof.get_tria().n_levels(),
+            std::vector<unsigned int>(n_target_blocks));
+    MGTools::count_dofs_per_block (mg_dof, ndofs, target_component);
+
+    for (unsigned int level=v.get_minlevel();
+         level<=v.get_maxlevel();++level)
+      {
+        v[level].reinit(n_target_blocks);
+        for (unsigned int b=0; b<n_target_blocks; ++b)
+          v[level].block(b).reinit(ndofs[level][b]);
+        v[level].collect_sizes();
+      }
+  }
 }
 
 
@@ -145,6 +195,41 @@ MGTransferPrebuilt<VECTOR>::copy_to_mg (
 
 
 
+template <class VECTOR>
+template <int dim, class InVector, int spacedim>
+void
+MGTransferPrebuilt<VECTOR>::copy_to_mg (
+  const DoFHandler<dim,spacedim>& dof_handler,
+  MGLevelObject<VECTOR>& dst,
+  const InVector& src) const
+{
+  reinit_vector(dof_handler, component_to_block_map, dst);
+  bool first = true;
+  for (unsigned int level=dof_handler.get_tria().n_levels();level != 0;)
+    {
+      --level;
+      VECTOR& dst_level = dst[level];
+
+      typedef std::vector<std::pair<unsigned int, unsigned int> >::const_iterator IT;
+      for (IT i= copy_indices[level].begin();
+          i != copy_indices[level].end();++i)
+       dst_level(i->second) = src(i->first);
+
+                                      // For non-DG: degrees of
+                                      // freedom in the refinement
+                                      // face may need special
+                                      // attention, since they belong
+                                      // to the coarse level, but
+                                      // have fine level basis
+                                      // functions
+      if (!first)
+       restrict_and_add (level+1, dst[level], dst[level+1]);
+      first = false;
+    }
+}
+
+
+
 template <class VECTOR>
 template <int dim, class OutVector, int spacedim>
 void
@@ -166,7 +251,37 @@ MGTransferPrebuilt<VECTOR>::copy_from_mg(
     typedef std::vector<std::pair<unsigned int, unsigned int> >::const_iterator IT;
 
     for (IT i= copy_indices[level].begin();
-         i != copy_indices[level].end();++i)
+            i != copy_indices[level].end();++i)
+      dst(i->first) = src[level](i->second);
+  }
+  if (constraints != 0)
+    constraints->condense(dst);
+}
+
+
+
+template <class VECTOR>
+template <int dim, class OutVector, int spacedim>
+void
+MGTransferPrebuilt<VECTOR>::copy_from_mg(
+  const DoFHandler<dim,spacedim>& dof_handler,
+  OutVector&                     dst,
+  const MGLevelObject<VECTOR>& src) const
+{
+                                      // For non-DG: degrees of
+                                      // freedom in the refinement
+                                      // face may need special
+                                      // attention, since they belong
+                                      // to the coarse level, but
+                                      // have fine level basis
+                                      // functions
+  dst = 0;
+  for (unsigned int level=0;level<dof_handler.get_tria().n_levels();++level)
+  {
+    typedef std::vector<std::pair<unsigned int, unsigned int> >::const_iterator IT;
+
+    for (IT i= copy_indices[level].begin();
+        i != copy_indices[level].end();++i)
       dst(i->first) = src[level](i->second);
   }
   if (constraints != 0)
@@ -194,7 +309,33 @@ MGTransferPrebuilt<VECTOR>::copy_from_mg_add (
   {
     typedef std::vector<std::pair<unsigned int, unsigned int> >::const_iterator IT;
     for (IT i= copy_indices[level].begin();
-         i != copy_indices[level].end();++i)
+            i != copy_indices[level].end();++i)
+      dst(i->first) += src[level](i->second);
+  }
+}
+
+
+
+template <class VECTOR>
+template <int dim, class OutVector, int spacedim>
+void
+MGTransferPrebuilt<VECTOR>::copy_from_mg_add (
+  const DoFHandler<dim,spacedim>& dof_handler,
+  OutVector                            &dst,
+  const MGLevelObject<VECTOR> &src) const
+{
+                                      // For non-DG: degrees of
+                                      // freedom in the refinement
+                                      // face may need special
+                                      // attention, since they belong
+                                      // to the coarse level, but
+                                      // have fine level basis
+                                      // functions
+  for (unsigned int level=0;level<dof_handler.get_tria().n_levels();++level)
+  {
+    typedef std::vector<std::pair<unsigned int, unsigned int> >::const_iterator IT;
+    for (IT i= copy_indices[level].begin();
+        i != copy_indices[level].end();++i)
       dst(i->first) += src[level](i->second);
   }
 }
@@ -223,7 +364,7 @@ MGTransferPrebuilt<VECTOR>::memory_consumption () const
 #else
   for (unsigned int i=0;i<prolongation_matrices.size();++i)
     result += prolongation_matrices[i]->memory_consumption()
-              + prolongation_sparsities[i]->memory_consumption();
+                 + prolongation_sparsities[i]->memory_consumption();
 #endif
   return result;
 }
index 108bf3ad38d418703cea6384c0fe36705b5dc88e..d3b20f401d304769ceda4d71783cb87c06dc3c10 100644 (file)
@@ -16,6 +16,7 @@
 #include <deal.II/base/config.h>
 #include <deal.II/base/subscriptor.h>
 #include <deal.II/base/smartpointer.h>
+#include <deal.II/dofs/dof_handler.h>
 #include <deal.II/numerics/data_out.h>
 #include <deal.II/lac/sparse_matrix.h>
 #include <deal.II/lac/vector.h>
@@ -69,16 +70,16 @@ class Multigrid : public Subscriptor
     enum Cycle
     {
                                            /// The V-cycle
-          v_cycle,
+             v_cycle,
                                            /// The W-cycle
-          w_cycle,
+             w_cycle,
                                            /// The F-cycle
-          f_cycle
+             f_cycle
     };
-
+    
     typedef VECTOR vector_type;
     typedef const VECTOR const_vector_type;
-
+  
                                      /**
                                       * Constructor. The
                                       * MGDoFHandler is used to
@@ -97,13 +98,22 @@ class Multigrid : public Subscriptor
                                       */
     template <int dim>
     Multigrid(const MGDoFHandler<dim>& mg_dof_handler,
-              const MGMatrixBase<VECTOR>& matrix,
-              const MGCoarseGridBase<VECTOR>& coarse,
-              const MGTransferBase<VECTOR>& transfer,
-              const MGSmootherBase<VECTOR>& pre_smooth,
-              const MGSmootherBase<VECTOR>& post_smooth,
-              Cycle cycle = v_cycle);
-
+                 const MGMatrixBase<VECTOR>& matrix,
+                 const MGCoarseGridBase<VECTOR>& coarse,
+                 const MGTransferBase<VECTOR>& transfer,
+                 const MGSmootherBase<VECTOR>& pre_smooth,
+                 const MGSmootherBase<VECTOR>& post_smooth,
+                 Cycle cycle = v_cycle);
+    
+    template <int dim>
+    Multigrid(const DoFHandler<dim>& mg_dof_handler,
+                 const MGMatrixBase<VECTOR>& matrix,
+                 const MGCoarseGridBase<VECTOR>& coarse,
+                 const MGTransferBase<VECTOR>& transfer,
+                 const MGSmootherBase<VECTOR>& pre_smooth,
+                 const MGSmootherBase<VECTOR>& post_smooth,
+                 Cycle cycle = v_cycle);
+    
                                      /**
                                       * Experimental constructor for
                                       * cases in which no MGDoFHandler
@@ -112,20 +122,20 @@ class Multigrid : public Subscriptor
                                       * @warning Not intended for general use.
                                       */
     Multigrid(const unsigned int minlevel,
-              const unsigned int maxlevel,
-              const MGMatrixBase<VECTOR>& matrix,
-              const MGCoarseGridBase<VECTOR>& coarse,
-              const MGTransferBase<VECTOR>& transfer,
-              const MGSmootherBase<VECTOR>& pre_smooth,
-              const MGSmootherBase<VECTOR>& post_smooth,
-              Cycle cycle = v_cycle);
+                 const unsigned int maxlevel,
+                 const MGMatrixBase<VECTOR>& matrix,
+                 const MGCoarseGridBase<VECTOR>& coarse,
+                 const MGTransferBase<VECTOR>& transfer,
+                 const MGSmootherBase<VECTOR>& pre_smooth,
+                 const MGSmootherBase<VECTOR>& post_smooth,
+                 Cycle cycle = v_cycle);
 
                                      /**
                                       * Reinit this class according to
                                       * #minlevel and #maxlevel.
                                       */
     void reinit (const unsigned int minlevel,
-                 const unsigned int maxlevel);
+                        const unsigned int maxlevel);
 
                                      /**
                                       * Execute one multigrid
@@ -135,7 +145,7 @@ class Multigrid : public Subscriptor
                                       * Cycle for available types.
                                       */
     void cycle ();
-
+    
                                      /**
                                       * Execute one step of the
                                       * V-cycle algorithm.  This
@@ -176,7 +186,7 @@ class Multigrid : public Subscriptor
                                       * object.
                                       */
     void vmult(VECTOR& dst, const VECTOR& src) const;
-
+    
                                      /**
                                       * @deprecated This function is
                                       * purely experimental and will
@@ -194,7 +204,7 @@ class Multigrid : public Subscriptor
                                       * object.
                                       */
     void vmult_add(VECTOR& dst, const VECTOR& src) const;
-
+    
                                      /**
                                       * @deprecated Even worse than
                                       * vmult(), this function is not
@@ -204,7 +214,7 @@ class Multigrid : public Subscriptor
                                       * constructed.
                                       */
     void Tvmult(VECTOR& dst, const VECTOR& src) const;
-
+    
                                      /**
                                       * @deprecated Even worse than
                                       * vmult(), this function is not
@@ -214,7 +224,7 @@ class Multigrid : public Subscriptor
                                       * constructed.
                                       */
     void Tvmult_add(VECTOR& dst, const VECTOR& src) const;
-
+    
                                      /**
                                       * Set additional matrices to
                                       * correct residual computation
@@ -244,7 +254,7 @@ class Multigrid : public Subscriptor
                                       * them.
                                       */
     void set_edge_matrices (const MGMatrixBase<VECTOR>& edge_out,
-                            const MGMatrixBase<VECTOR>& edge_in);
+                                       const MGMatrixBase<VECTOR>& edge_in);
 
                                      /**
                                       * Set additional matrices to
@@ -274,20 +284,20 @@ class Multigrid : public Subscriptor
                                       * them.
                                       */
     void set_edge_flux_matrices (const MGMatrixBase<VECTOR>& edge_down,
-                                 const MGMatrixBase<VECTOR>& edge_up);
+                                                const MGMatrixBase<VECTOR>& edge_up);
 
                                      /**
                                       * Return the finest level for
                                       * multigrid.
                                       */
     unsigned int get_maxlevel() const;
-
+    
                                      /**
                                       * Return the coarsest level for
                                       * multigrid.
                                       */
     unsigned int get_minlevel() const;
-
+    
                                      /**
                                       * Set the highest level for
                                       * which the multilevel method is
@@ -328,13 +338,13 @@ class Multigrid : public Subscriptor
                                       * solver!
                                       */
     void set_minlevel (const unsigned int level,
-                       bool relative = false);
+                              bool relative = false);
 
                                      /**
                                       * Chance #cycle_type used in cycle().
                                       */
     void set_cycle(Cycle);
-
+    
                                      /**
                                       * Set the debug level. Higher
                                       * values will create more
@@ -342,9 +352,9 @@ class Multigrid : public Subscriptor
                                       * multigrid cycles.
                                       */
     void set_debug (const unsigned int);
-
+    
   private:
-
+    
                                      /**
                                       * The V-cycle multigrid method.
                                       * <tt>level</tt> is the level the
@@ -379,7 +389,7 @@ class Multigrid : public Subscriptor
                                       * Cycle type performed by the method cycle().
                                       */
     Cycle cycle_type;
-
+    
                                      /**
                                       * Level for coarse grid solution.
                                       */
@@ -404,12 +414,12 @@ class Multigrid : public Subscriptor
                                       * multigrid step.
                                       */
     MGLevelObject<VECTOR> solution;
-
+    
   private:
                                      /**
                                       * Auxiliary vector.
                                       */
-    MGLevelObject<VECTOR> t;
+    MGLevelObject<VECTOR> t;    
 
                                      /**
                                       * Auxiliary vector for W- and
@@ -423,12 +433,12 @@ class Multigrid : public Subscriptor
                                       * The matrix for each level.
                                       */
     SmartPointer<const MGMatrixBase<VECTOR>,Multigrid<VECTOR> > matrix;
-
+    
                                      /**
                                       * The matrix for each level.
                                       */
     SmartPointer<const MGCoarseGridBase<VECTOR>,Multigrid<VECTOR> > coarse;
-
+    
                                      /**
                                       * Object for grid tranfer.
                                       */
@@ -443,7 +453,7 @@ class Multigrid : public Subscriptor
                                       * The post-smoothing object.
                                       */
     SmartPointer<const MGSmootherBase<VECTOR>,Multigrid<VECTOR> > post_smooth;
-
+    
                                      /**
                                       * Edge matrix from the interior
                                       * of the refined part to the
@@ -486,7 +496,7 @@ class Multigrid : public Subscriptor
                                       * can be set by set_debug().
                                       */
     unsigned int debug;
-
+    
     template<int dim, class VECTOR2, class TRANSFER> friend class PreconditionMG;
 };
 
@@ -512,15 +522,15 @@ class PreconditionMG : public Subscriptor
                                       * pre-smoother, post-smoother and
                                       * coarse grid solver.
                                       */
-    PreconditionMG(const MGDoFHandler<dim>&     mg_dof,
-                   Multigrid<VECTOR>&           mg,
-                   const TRANSFER& transfer);
+    PreconditionMG(const DoFHandler<dim>&     dof_handler,
+                          Multigrid<VECTOR>&           mg,
+                          const TRANSFER& transfer);
 
                                      /**
                                       * Dummy function needed by other classes.
                                       */
     bool empty () const;
-
+    
                                      /**
                                       * Preconditioning operator.
                                       * Calls the @p vcycle function
@@ -532,8 +542,8 @@ class PreconditionMG : public Subscriptor
                                       */
     template<class VECTOR2>
     void vmult (VECTOR2       &dst,
-                const VECTOR2 &src) const;
-
+                       const VECTOR2 &src) const;
+    
                                      /**
                                       * Preconditioning operator.
                                       * Calls the @p vcycle function
@@ -542,8 +552,8 @@ class PreconditionMG : public Subscriptor
                                       */
     template<class VECTOR2>
     void vmult_add (VECTOR2       &dst,
-                    const VECTOR2 &src) const;
-
+                           const VECTOR2 &src) const;
+    
                                      /**
                                       * Tranposed preconditioning operator.
                                       *
@@ -552,8 +562,8 @@ class PreconditionMG : public Subscriptor
                                       */
     template<class VECTOR2>
     void Tvmult (VECTOR2       &dst,
-                const VECTOR2 &src) const;
-
+                        const VECTOR2 &src) const;
+    
                                      /**
                                       * Tranposed preconditioning operator.
                                       *
@@ -562,23 +572,23 @@ class PreconditionMG : public Subscriptor
                                       */
     template<class VECTOR2>
     void Tvmult_add (VECTOR2       &dst,
-                     const VECTOR2 &src) const;
-
+                            const VECTOR2 &src) const;
+    
   private:
                                      /**
                                       * Associated @p MGDoFHandler.
                                       */
-    SmartPointer<const MGDoFHandler<dim>,PreconditionMG<dim,VECTOR,TRANSFER> > mg_dof_handler;
+    SmartPointer<const DoFHandler<dim>,PreconditionMG<dim,VECTOR,TRANSFER> > dof_handler;
 
                                      /**
                                       * The multigrid object.
                                       */
     SmartPointer<Multigrid<VECTOR>,PreconditionMG<dim,VECTOR,TRANSFER> > multigrid;
-
+    
                                      /**
                                       * Object for grid tranfer.
                                       */
-    SmartPointer<const TRANSFER,PreconditionMG<dim,VECTOR,TRANSFER> > transfer;
+    SmartPointer<const TRANSFER,PreconditionMG<dim,VECTOR,TRANSFER> > transfer;  
 };
 
 /*@}*/
@@ -590,28 +600,56 @@ class PreconditionMG : public Subscriptor
 template <class VECTOR>
 template <int dim>
 Multigrid<VECTOR>::Multigrid (const MGDoFHandler<dim>& mg_dof_handler,
-                              const MGMatrixBase<VECTOR>& matrix,
-                              const MGCoarseGridBase<VECTOR>& coarse,
-                              const MGTransferBase<VECTOR>& transfer,
-                              const MGSmootherBase<VECTOR>& pre_smooth,
-                              const MGSmootherBase<VECTOR>& post_smooth,
-                              Cycle                         cycle)
-                :
-                cycle_type(cycle),
-                minlevel(0),
-                maxlevel(mg_dof_handler.get_tria().n_levels()-1),
-                defect(minlevel,maxlevel),
-                solution(minlevel,maxlevel),
-                t(minlevel,maxlevel),
-                defect2(minlevel,maxlevel),
-                matrix(&matrix, typeid(*this).name()),
-                coarse(&coarse, typeid(*this).name()),
-                transfer(&transfer, typeid(*this).name()),
-                pre_smooth(&pre_smooth, typeid(*this).name()),
-                post_smooth(&post_smooth, typeid(*this).name()),
-                edge_down(0, typeid(*this).name()),
-                edge_up(0, typeid(*this).name()),
-                debug(0)
+                                         const MGMatrixBase<VECTOR>& matrix,
+                                         const MGCoarseGridBase<VECTOR>& coarse,
+                                         const MGTransferBase<VECTOR>& transfer,
+                                         const MGSmootherBase<VECTOR>& pre_smooth,
+                                         const MGSmootherBase<VECTOR>& post_smooth,
+                                         Cycle                         cycle)
+                       :
+                       cycle_type(cycle),
+                       minlevel(0),
+                       maxlevel(mg_dof_handler.get_tria().n_levels()-1),
+                       defect(minlevel,maxlevel),
+                       solution(minlevel,maxlevel),
+                       t(minlevel,maxlevel),
+                       defect2(minlevel,maxlevel),
+                       matrix(&matrix, typeid(*this).name()),
+                       coarse(&coarse, typeid(*this).name()),
+                       transfer(&transfer, typeid(*this).name()),
+                       pre_smooth(&pre_smooth, typeid(*this).name()),
+                       post_smooth(&post_smooth, typeid(*this).name()),
+                       edge_down(0, typeid(*this).name()),
+                       edge_up(0, typeid(*this).name()),
+                       debug(0)
+{}
+
+
+template <class VECTOR>
+template <int dim>
+Multigrid<VECTOR>::Multigrid (const DoFHandler<dim>& dof_handler,
+                                         const MGMatrixBase<VECTOR>& matrix,
+                                         const MGCoarseGridBase<VECTOR>& coarse,
+                                         const MGTransferBase<VECTOR>& transfer,
+                                         const MGSmootherBase<VECTOR>& pre_smooth,
+                                         const MGSmootherBase<VECTOR>& post_smooth,
+                                         Cycle                         cycle)
+                       :
+                       cycle_type(cycle),
+                       minlevel(0),
+                       maxlevel(dof_handler.get_tria().n_levels()-1),
+                       defect(minlevel,maxlevel),
+                       solution(minlevel,maxlevel),
+                       t(minlevel,maxlevel),
+                       defect2(minlevel,maxlevel),
+                       matrix(&matrix, typeid(*this).name()),
+                       coarse(&coarse, typeid(*this).name()),
+                       transfer(&transfer, typeid(*this).name()),
+                       pre_smooth(&pre_smooth, typeid(*this).name()),
+                       post_smooth(&post_smooth, typeid(*this).name()),
+                       edge_down(0, typeid(*this).name()),
+                       edge_up(0, typeid(*this).name()),
+                       debug(0)
 {}
 
 
@@ -640,13 +678,13 @@ Multigrid<VECTOR>::get_minlevel () const
 
 template<int dim, class VECTOR, class TRANSFER>
 PreconditionMG<dim, VECTOR, TRANSFER>
-::PreconditionMG(const MGDoFHandler<dim>&      mg_dof_handler,
-                 Multigrid<VECTOR>& mg,
-                 const TRANSFER&              transfer)
-                :
-  mg_dof_handler(&mg_dof_handler),
-  multigrid(&mg),
-  transfer(&transfer)
+::PreconditionMG(const DoFHandler<dim>&      dof_handler,
+                        Multigrid<VECTOR>& mg,
+                        const TRANSFER&              transfer)
+                       :
+                dof_handler(&dof_handler),
+                multigrid(&mg),
+                transfer(&transfer)
 {}
 
 template<int dim, class VECTOR, class TRANSFER>
@@ -663,14 +701,14 @@ PreconditionMG<dim, VECTOR, TRANSFER>::vmult (
   VECTOR2& dst,
   const VECTOR2& src) const
 {
-  transfer->copy_to_mg(*mg_dof_handler,
-                       multigrid->defect,
-                       src);
+  transfer->copy_to_mg(*dof_handler,
+                              multigrid->defect,
+                              src);
   multigrid->cycle();
 
-  transfer->copy_from_mg(*mg_dof_handler,
-                         dst,
-                         multigrid->solution);
+  transfer->copy_from_mg(*dof_handler,
+                                    dst,
+                                    multigrid->solution);
 }
 
 
@@ -681,13 +719,13 @@ PreconditionMG<dim, VECTOR, TRANSFER>::vmult_add (
   VECTOR2& dst,
   const VECTOR2& src) const
 {
-  transfer->copy_to_mg(*mg_dof_handler,
-                       multigrid->defect,
-                       src);
+  transfer->copy_to_mg(*dof_handler,
+                              multigrid->defect,
+                              src);
   multigrid->cycle();
-  transfer->copy_from_mg_add(*mg_dof_handler,
-                             dst,
-                             multigrid->solution);
+  transfer->copy_from_mg_add(*dof_handler,
+                                        dst,
+                                        multigrid->solution);
 }
 
 
index f74605a2bece7f6345e3260318fc64f60117812b..1ccaed45c6684844cc5b0d3069d992a70e29972a 100644 (file)
@@ -25,12 +25,27 @@ DEAL_II_NAMESPACE_OPEN
 
 template <int dim, int spacedim>
 void
-BlockInfo::initialize(const DoFHandler<dim, spacedim>& dof)
+BlockInfo::initialize(const DoFHandler<dim, spacedim>& dof, bool levels_only, bool multigrid)
 {
-  const FiniteElement<dim, spacedim>& fe = dof.get_fe();
-  std::vector<unsigned int> sizes(fe.n_blocks());
-  DoFTools::count_dofs_per_block(dof, sizes);
-  bi_global.reinit(sizes);
+  if (!levels_only) {
+    const FiniteElement<dim, spacedim>& fe = dof.get_fe();
+    std::vector<unsigned int> sizes(fe.n_blocks());
+    DoFTools::count_dofs_per_block(dof, sizes);
+    bi_global.reinit(sizes);
+  }
+  
+  if (multigrid) {
+    std::vector<std::vector<unsigned int> > sizes (dof.get_tria ().n_levels ());
+    
+    for (unsigned int i = 0; i < sizes.size (); ++i)
+      sizes[i].resize (dof.get_fe ().n_blocks ());
+    
+    MGTools::count_dofs_per_block (dof, sizes);
+    levels.resize (sizes.size ());
+    
+    for (unsigned int i = 0; i < sizes.size (); ++i)
+      levels[i].reinit (sizes[i]);
+  }
 }
 
 
@@ -48,8 +63,8 @@ BlockInfo::initialize_local(const DoFHandler<dim, spacedim>& dof)
 
   local_renumbering.resize(fe.n_dofs_per_cell());
   FETools::compute_block_renumbering(fe,
-                                     local_renumbering,
-                                     sizes, false);
+                                                    local_renumbering,
+                                                    sizes, false);
   bi_local.reinit(sizes);
 }
 
@@ -59,7 +74,7 @@ void
 BlockInfo::initialize(const MGDoFHandler<dim, spacedim>& dof, bool levels_only)
 {
   if (!levels_only)
-    initialize(static_cast<const DoFHandler<dim, spacedim>&>(dof));
+    initialize(static_cast<const DoFHandler<dim, spacedim>&> (dof));
 
   std::vector<std::vector<unsigned int> > sizes (dof.get_tria().n_levels());
   for (unsigned int i=0; i<sizes.size(); ++i)
index c3ad113ba76e4e4d670d66a65399a9854a6431cd..df24035ac974ca650aab815aeb2ca870b40e91e3 100644 (file)
 
 for (deal_II_dimension : DIMENSIONS)
   {
-    template void BlockInfo::initialize(const DoFHandler<deal_II_dimension,deal_II_dimension>&);
+    template void BlockInfo::initialize(const DoFHandler<deal_II_dimension,deal_II_dimension>&, bool, bool);
     template void BlockInfo::initialize(const MGDoFHandler<deal_II_dimension,deal_II_dimension>&, bool);
     template void BlockInfo::initialize_local(const DoFHandler<deal_II_dimension,deal_II_dimension>&);
 
 #if deal_II_dimension < 3
-    template void BlockInfo::initialize(const DoFHandler<deal_II_dimension,deal_II_dimension+1>&);
+    template void BlockInfo::initialize(const DoFHandler<deal_II_dimension,deal_II_dimension+1>&, bool, bool);
     template void BlockInfo::initialize(const MGDoFHandler<deal_II_dimension,deal_II_dimension+1>&, bool);
     template void BlockInfo::initialize_local(const DoFHandler<deal_II_dimension,deal_II_dimension+1>&);
 #endif
 
 #if deal_II_dimension == 3
-    template void BlockInfo::initialize(const DoFHandler<1,3>&);
+    template void BlockInfo::initialize(const DoFHandler<1,3>&, bool, bool);
     template void BlockInfo::initialize(const MGDoFHandler<1,3>&, bool);
     template void BlockInfo::initialize_local(const DoFHandler<1,3>&);
 #endif
index 49e76304e5a37a462bff8485d73e7ed69508a6fd..b9157eb7b7798c0446c9208f51ddb216feea098a 100644 (file)
@@ -77,15 +77,15 @@ DoFCellAccessor<DH>::set_dof_indices (const std::vector<unsigned int> &local_dof
 template <class DH>
 typename internal::DoFHandler::Iterators<DH>::cell_iterator
 DoFCellAccessor<DH>::neighbor_child_on_subface (const unsigned int face,
-                                                const unsigned int subface) const
+                                                                       const unsigned int subface) const
 {
   const TriaIterator<CellAccessor<dim,spacedim> > q
     = CellAccessor<dim,spacedim>::neighbor_child_on_subface (face, subface);
   return
     typename internal::DoFHandler::Iterators<DH>::cell_iterator (this->tria,
-                                                                 q->level (),
-                                                                 q->index (),
-                                                                 this->dof_handler);
+                                                                                                q->level (),
+                                                                                                q->index (),
+                                                                                                this->dof_handler);
 }
 
 
@@ -95,19 +95,19 @@ template <class InputVector, typename number>
 void
 DoFCellAccessor<DH>::
 get_interpolated_dof_values (const InputVector &values,
-                             Vector<number>    &interpolated_values) const
+                                        Vector<number>    &interpolated_values) const
 {
   const FiniteElement<dim,spacedim> &fe            = this->get_fe();
   const unsigned int        dofs_per_cell = fe.dofs_per_cell;
 
   Assert (this->dof_handler != 0,
-          typename BaseClass::ExcInvalidObject());
+             typename BaseClass::ExcInvalidObject());
   Assert (&fe != 0,
-          typename BaseClass::ExcInvalidObject());
+             typename BaseClass::ExcInvalidObject());
   Assert (interpolated_values.size() == dofs_per_cell,
-          typename BaseClass::ExcVectorDoesNotMatch());
+             typename BaseClass::ExcVectorDoesNotMatch());
   Assert (values.size() == this->dof_handler->n_dofs(),
-          typename BaseClass::ExcVectorDoesNotMatch());
+             typename BaseClass::ExcVectorDoesNotMatch());
 
   if (!this->has_children())
                                      // if this cell has no children: simply
@@ -183,25 +183,25 @@ get_interpolated_dof_values (const InputVector &values,
         restriction_is_additive[i] = fe.restriction_is_additive(i);
 
       for (unsigned int child=0; child<this->n_children(); ++child)
-        {
+           {
                                            // get the values from the present
                                            // child, if necessary by
                                            // interpolation itself
-          this->child(child)->get_interpolated_dof_values (values,
-                                                           tmp1);
+             this->child(child)->get_interpolated_dof_values (values,
+                                                                                      tmp1);
                                            // interpolate these to the mother
                                            // cell
-          fe.get_restriction_matrix(child, this->refinement_case()).vmult (tmp2, tmp1);
+             fe.get_restriction_matrix(child, this->refinement_case()).vmult (tmp2, tmp1);
 
                                            // and add up or set them
                                            // in the output vector
-          for (unsigned int i=0; i<dofs_per_cell; ++i)
+             for (unsigned int i=0; i<dofs_per_cell; ++i)
             if (restriction_is_additive[i])
               interpolated_values(i) += tmp2(i);
             else
               if (tmp2(i) != number())
                 interpolated_values(i) = tmp2(i);
-        }
+           }
     }
 }
 
@@ -212,18 +212,18 @@ template <class OutputVector, typename number>
 void
 DoFCellAccessor<DH>::
 set_dof_values_by_interpolation (const Vector<number> &local_values,
-                                 OutputVector         &values) const
+                                                OutputVector         &values) const
 {
   const unsigned int dofs_per_cell = this->get_fe().dofs_per_cell;
 
   Assert (this->dof_handler != 0,
-          typename BaseClass::ExcInvalidObject());
+             typename BaseClass::ExcInvalidObject());
   Assert (&this->get_fe() != 0,
-          typename BaseClass::ExcInvalidObject());
+             typename BaseClass::ExcInvalidObject());
   Assert (local_values.size() == dofs_per_cell,
-          typename BaseClass::ExcVectorDoesNotMatch());
+             typename BaseClass::ExcVectorDoesNotMatch());
   Assert (values.size() == this->dof_handler->n_dofs(),
-          typename BaseClass::ExcVectorDoesNotMatch());
+             typename BaseClass::ExcVectorDoesNotMatch());
 
   if (!this->has_children())
                                      // if this cell has no children: simply
@@ -235,7 +235,7 @@ set_dof_values_by_interpolation (const Vector<number> &local_values,
       Vector<number> tmp(dofs_per_cell);
 
       for (unsigned int child=0; child<this->n_children(); ++child)
-        {
+           {
          Assert (this->child(child)->get_fe().dofs_per_cell == dofs_per_cell,
                  ExcNotImplemented());
 
index fb4a98ac97cf5e95c0520ca44cf00cd56088b941..a7d769c0df690298ff472f098e76ce9452b01aef 100644 (file)
@@ -81,23 +81,23 @@ namespace internal
                                           * Implement the function of same name in
                                           * the mother class.
                                           */
-        template <int spacedim>
-        static
-        unsigned int
-        max_couplings_between_dofs (const DoFHandler<1,spacedim> &dof_handler)
-          {
-            return std::min(3*dof_handler.selected_fe->dofs_per_vertex +
-                            2*dof_handler.selected_fe->dofs_per_line,
-                            dof_handler.n_dofs());
-          }
+           template <int spacedim>
+           static
+           unsigned int
+           max_couplings_between_dofs (const DoFHandler<1,spacedim> &dof_handler)
+             {
+               return std::min(3*dof_handler.selected_fe->dofs_per_vertex +
+                                       2*dof_handler.selected_fe->dofs_per_line,
+                                       dof_handler.n_dofs());
+             }
 
 
 
-        template <int spacedim>
-        static
-        unsigned int
-        max_couplings_between_dofs (const DoFHandler<2,spacedim> &dof_handler)
-          {
+           template <int spacedim>
+           static
+           unsigned int
+           max_couplings_between_dofs (const DoFHandler<2,spacedim> &dof_handler)
+             {
 
                                              // get these numbers by drawing pictures
                                              // and counting...
@@ -120,34 +120,34 @@ namespace internal
                                              // nodes)
                                              // count lines -> 28 (don't forget to count
                                              // mother and children separately!)
-            unsigned int max_couplings;
-            switch (dof_handler.tria->max_adjacent_cells())
-              {
-                case 4:
-                      max_couplings=19*dof_handler.selected_fe->dofs_per_vertex +
-                                    28*dof_handler.selected_fe->dofs_per_line +
-                                    8*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-                case 5:
-                      max_couplings=21*dof_handler.selected_fe->dofs_per_vertex +
-                                    31*dof_handler.selected_fe->dofs_per_line +
-                                    9*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-                case 6:
-                      max_couplings=28*dof_handler.selected_fe->dofs_per_vertex +
-                                    42*dof_handler.selected_fe->dofs_per_line +
-                                    12*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-                case 7:
-                      max_couplings=30*dof_handler.selected_fe->dofs_per_vertex +
-                                    45*dof_handler.selected_fe->dofs_per_line +
-                                    13*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-                case 8:
-                      max_couplings=37*dof_handler.selected_fe->dofs_per_vertex +
-                                    56*dof_handler.selected_fe->dofs_per_line +
-                                    16*dof_handler.selected_fe->dofs_per_quad;
-                      break;
+               unsigned int max_couplings;
+               switch (dof_handler.tria->max_adjacent_cells())
+                 {
+                       case 4:
+                             max_couplings=19*dof_handler.selected_fe->dofs_per_vertex +
+                                                   28*dof_handler.selected_fe->dofs_per_line +
+                                                   8*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+                       case 5:
+                             max_couplings=21*dof_handler.selected_fe->dofs_per_vertex +
+                                                   31*dof_handler.selected_fe->dofs_per_line +
+                                                   9*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+                       case 6:
+                             max_couplings=28*dof_handler.selected_fe->dofs_per_vertex +
+                                                   42*dof_handler.selected_fe->dofs_per_line +
+                                                   12*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+                       case 7:
+                             max_couplings=30*dof_handler.selected_fe->dofs_per_vertex +
+                                                   45*dof_handler.selected_fe->dofs_per_line +
+                                                   13*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+                       case 8:
+                             max_couplings=37*dof_handler.selected_fe->dofs_per_vertex +
+                                                   56*dof_handler.selected_fe->dofs_per_line +
+                                                   16*dof_handler.selected_fe->dofs_per_quad;
+                             break;
 
                                                        // the following
                                                        // numbers are not
@@ -162,60 +162,60 @@ namespace internal
                                                        // is 19, 21, 28, 30,
                                                        // 37, and is continued
                                                        // as follows):
-                case 9:
-                      max_couplings=39*dof_handler.selected_fe->dofs_per_vertex +
-                                    59*dof_handler.selected_fe->dofs_per_line +
-                                    17*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-                case 10:
-                      max_couplings=46*dof_handler.selected_fe->dofs_per_vertex +
-                                    70*dof_handler.selected_fe->dofs_per_line +
-                                    20*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-                case 11:
-                      max_couplings=48*dof_handler.selected_fe->dofs_per_vertex +
-                                    73*dof_handler.selected_fe->dofs_per_line +
-                                    21*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-                case 12:
-                      max_couplings=55*dof_handler.selected_fe->dofs_per_vertex +
-                                    84*dof_handler.selected_fe->dofs_per_line +
-                                    24*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-                case 13:
-                      max_couplings=57*dof_handler.selected_fe->dofs_per_vertex +
-                                    87*dof_handler.selected_fe->dofs_per_line +
-                                    25*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-                case 14:
-                      max_couplings=63*dof_handler.selected_fe->dofs_per_vertex +
-                                    98*dof_handler.selected_fe->dofs_per_line +
-                                    28*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-                case 15:
-                      max_couplings=65*dof_handler.selected_fe->dofs_per_vertex +
-                                    103*dof_handler.selected_fe->dofs_per_line +
-                                    29*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-                case 16:
-                      max_couplings=72*dof_handler.selected_fe->dofs_per_vertex +
-                                    114*dof_handler.selected_fe->dofs_per_line +
-                                    32*dof_handler.selected_fe->dofs_per_quad;
-                      break;
-
-                default:
-                      Assert (false, ExcNotImplemented());
-                      max_couplings=0;
-              }
-            return std::min(max_couplings,dof_handler.n_dofs());
-          }
-
-
-        template <int spacedim>
-        static
-        unsigned int
-        max_couplings_between_dofs (const DoFHandler<3,spacedim> &dof_handler)
-          {
+                       case 9:
+                             max_couplings=39*dof_handler.selected_fe->dofs_per_vertex +
+                                                   59*dof_handler.selected_fe->dofs_per_line +
+                                                   17*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+                       case 10:
+                             max_couplings=46*dof_handler.selected_fe->dofs_per_vertex +
+                                                   70*dof_handler.selected_fe->dofs_per_line +
+                                                   20*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+                       case 11:
+                             max_couplings=48*dof_handler.selected_fe->dofs_per_vertex +
+                                                   73*dof_handler.selected_fe->dofs_per_line +
+                                                   21*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+                       case 12:
+                             max_couplings=55*dof_handler.selected_fe->dofs_per_vertex +
+                                                   84*dof_handler.selected_fe->dofs_per_line +
+                                                   24*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+                       case 13:
+                             max_couplings=57*dof_handler.selected_fe->dofs_per_vertex +
+                                                   87*dof_handler.selected_fe->dofs_per_line +
+                                                   25*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+                       case 14:
+                             max_couplings=63*dof_handler.selected_fe->dofs_per_vertex +
+                                                   98*dof_handler.selected_fe->dofs_per_line +
+                                                   28*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+                       case 15:
+                             max_couplings=65*dof_handler.selected_fe->dofs_per_vertex +
+                                                   103*dof_handler.selected_fe->dofs_per_line +
+                                                   29*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+                       case 16:
+                             max_couplings=72*dof_handler.selected_fe->dofs_per_vertex +
+                                                   114*dof_handler.selected_fe->dofs_per_line +
+                                                   32*dof_handler.selected_fe->dofs_per_quad;
+                             break;
+
+                       default:
+                             Assert (false, ExcNotImplemented());
+                             max_couplings=0;
+                 }
+               return std::min(max_couplings,dof_handler.n_dofs());
+             }
+
+
+           template <int spacedim>
+           static
+           unsigned int
+           max_couplings_between_dofs (const DoFHandler<3,spacedim> &dof_handler)
+             {
 //TODO:[?] Invent significantly better estimates than the ones in this function
 
                                              // doing the same thing here is a
@@ -229,23 +229,23 @@ namespace internal
                                              //
                                              // can anyone give better estimate
                                              // here?
-            const unsigned int max_adjacent_cells
-              = dof_handler.tria->max_adjacent_cells();
+               const unsigned int max_adjacent_cells
+                 = dof_handler.tria->max_adjacent_cells();
 
-            unsigned int max_couplings;
-            if (max_adjacent_cells <= 8)
-              max_couplings=7*7*7*dof_handler.selected_fe->dofs_per_vertex +
-                            7*6*7*3*dof_handler.selected_fe->dofs_per_line +
-                            9*4*7*3*dof_handler.selected_fe->dofs_per_quad +
-                            27*dof_handler.selected_fe->dofs_per_hex;
-            else
-              {
-                Assert (false, ExcNotImplemented());
-                max_couplings=0;
-              }
+               unsigned int max_couplings;
+               if (max_adjacent_cells <= 8)
+                 max_couplings=7*7*7*dof_handler.selected_fe->dofs_per_vertex +
+                                       7*6*7*3*dof_handler.selected_fe->dofs_per_line +
+                                       9*4*7*3*dof_handler.selected_fe->dofs_per_quad +
+                                       27*dof_handler.selected_fe->dofs_per_hex;
+               else
+                 {
+                       Assert (false, ExcNotImplemented());
+                       max_couplings=0;
+                 }
 
-            return std::min(max_couplings,dof_handler.n_dofs());
-          }
+               return std::min(max_couplings,dof_handler.n_dofs());
+             }
 
 
                                          /**
@@ -257,99 +257,427 @@ namespace internal
                                           * was selected when calling
                                           * @p distribute_dofs the last time.
                                           */
-        template <int spacedim>
-        static
-        void reserve_space (DoFHandler<1,spacedim> &dof_handler)
-          {
-            dof_handler.vertex_dofs
-              .resize(dof_handler.tria->n_vertices() *
-                      dof_handler.selected_fe->dofs_per_vertex,
-                      DoFHandler<1,spacedim>::invalid_dof_index);
-
-            for (unsigned int i=0; i<dof_handler.tria->n_levels(); ++i)
-              {
-                dof_handler.levels
-                  .push_back (new internal::DoFHandler::DoFLevel<1>);
-
-                dof_handler.levels.back()->lines.dofs
-                  .resize (dof_handler.tria->n_raw_lines(i) *
-                           dof_handler.selected_fe->dofs_per_line,
-                           DoFHandler<1,spacedim>::invalid_dof_index);
-
-                dof_handler.levels.back()->cell_dof_indices_cache
-                  .resize (dof_handler.tria->n_raw_lines(i) *
-                           dof_handler.selected_fe->dofs_per_cell,
-                           DoFHandler<1,spacedim>::invalid_dof_index);
-              }
-          }
-
-
-        template <int spacedim>
-        static
-        void reserve_space (DoFHandler<2,spacedim> &dof_handler)
-          {
-            dof_handler.vertex_dofs
-              .resize(dof_handler.tria->n_vertices() *
-                      dof_handler.selected_fe->dofs_per_vertex,
-                      DoFHandler<2,spacedim>::invalid_dof_index);
-
-            for (unsigned int i=0; i<dof_handler.tria->n_levels(); ++i)
-              {
-                dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<2>);
-
-                dof_handler.levels.back()->quads.dofs
-                  .resize (dof_handler.tria->n_raw_quads(i) *
-                           dof_handler.selected_fe->dofs_per_quad,
-                           DoFHandler<2,spacedim>::invalid_dof_index);
-
-                dof_handler.levels.back()->cell_dof_indices_cache
-                  .resize (dof_handler.tria->n_raw_quads(i) *
-                           dof_handler.selected_fe->dofs_per_cell,
-                           DoFHandler<2,spacedim>::invalid_dof_index);
-              }
-
-            dof_handler.faces = new internal::DoFHandler::DoFFaces<2>;
-            dof_handler.faces->lines.dofs
-              .resize (dof_handler.tria->n_raw_lines() *
-                       dof_handler.selected_fe->dofs_per_line,
-                       DoFHandler<2,spacedim>::invalid_dof_index);
-          }
-
-
-        template <int spacedim>
-        static
-        void reserve_space (DoFHandler<3,spacedim> &dof_handler)
-          {
-            dof_handler.vertex_dofs
-              .resize(dof_handler.tria->n_vertices() *
-                      dof_handler.selected_fe->dofs_per_vertex,
-                      DoFHandler<3,spacedim>::invalid_dof_index);
-
-            for (unsigned int i=0; i<dof_handler.tria->n_levels(); ++i)
-              {
-                dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<3>);
-
-                dof_handler.levels.back()->hexes.dofs
-                  .resize (dof_handler.tria->n_raw_hexs(i) *
-                           dof_handler.selected_fe->dofs_per_hex,
-                           DoFHandler<3,spacedim>::invalid_dof_index);
-
-                dof_handler.levels.back()->cell_dof_indices_cache
-                  .resize (dof_handler.tria->n_raw_hexs(i) *
-                           dof_handler.selected_fe->dofs_per_cell,
-                           DoFHandler<3,spacedim>::invalid_dof_index);
-              }
-            dof_handler.faces = new internal::DoFHandler::DoFFaces<3>;
-
-            dof_handler.faces->lines.dofs
-              .resize (dof_handler.tria->n_raw_lines() *
-                       dof_handler.selected_fe->dofs_per_line,
-                       DoFHandler<3,spacedim>::invalid_dof_index);
-            dof_handler.faces->quads.dofs
-              .resize (dof_handler.tria->n_raw_quads() *
-                       dof_handler.selected_fe->dofs_per_quad,
-                       DoFHandler<3,spacedim>::invalid_dof_index);
-          }
+           template <int spacedim>
+           static
+           void reserve_space (DoFHandler<1,spacedim> &dof_handler)
+             {
+               dof_handler.vertex_dofs
+                 .resize(dof_handler.tria->n_vertices() *
+                             dof_handler.selected_fe->dofs_per_vertex,
+                             DoFHandler<1,spacedim>::invalid_dof_index);
+
+               for (unsigned int i=0; i<dof_handler.tria->n_levels(); ++i)
+                 {
+                       dof_handler.levels
+                         .push_back (new internal::DoFHandler::DoFLevel<1>);
+
+                       dof_handler.levels.back()->lines.dofs
+                         .resize (dof_handler.tria->n_raw_lines(i) *
+                                      dof_handler.selected_fe->dofs_per_line,
+                                      DoFHandler<1,spacedim>::invalid_dof_index);
+
+                       dof_handler.levels.back()->cell_dof_indices_cache
+                         .resize (dof_handler.tria->n_raw_lines(i) *
+                                      dof_handler.selected_fe->dofs_per_cell,
+                                      DoFHandler<1,spacedim>::invalid_dof_index);
+                 }
+             }
+
+
+           template <int spacedim>
+           static
+           void reserve_space (DoFHandler<2,spacedim> &dof_handler)
+             {
+               dof_handler.vertex_dofs
+                 .resize(dof_handler.tria->n_vertices() *
+                             dof_handler.selected_fe->dofs_per_vertex,
+                             DoFHandler<2,spacedim>::invalid_dof_index);
+
+               for (unsigned int i=0; i<dof_handler.tria->n_levels(); ++i)
+                 {
+                       dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<2>);
+
+                       dof_handler.levels.back()->quads.dofs
+                         .resize (dof_handler.tria->n_raw_quads(i) *
+                                      dof_handler.selected_fe->dofs_per_quad,
+                                      DoFHandler<2,spacedim>::invalid_dof_index);
+
+                       dof_handler.levels.back()->cell_dof_indices_cache
+                         .resize (dof_handler.tria->n_raw_quads(i) *
+                                      dof_handler.selected_fe->dofs_per_cell,
+                                      DoFHandler<2,spacedim>::invalid_dof_index);
+                 }
+
+               dof_handler.faces = new internal::DoFHandler::DoFFaces<2>;
+               dof_handler.faces->lines.dofs
+                 .resize (dof_handler.tria->n_raw_lines() *
+                              dof_handler.selected_fe->dofs_per_line,
+                              DoFHandler<2,spacedim>::invalid_dof_index);
+             }
+
+
+           template <int spacedim>
+           static
+           void reserve_space (DoFHandler<3,spacedim> &dof_handler)
+             {
+               dof_handler.vertex_dofs
+                 .resize(dof_handler.tria->n_vertices() *
+                             dof_handler.selected_fe->dofs_per_vertex,
+                             DoFHandler<3,spacedim>::invalid_dof_index);
+
+               for (unsigned int i=0; i<dof_handler.tria->n_levels(); ++i)
+                 {
+                       dof_handler.levels.push_back (new internal::DoFHandler::DoFLevel<3>);
+
+                       dof_handler.levels.back()->hexes.dofs
+                         .resize (dof_handler.tria->n_raw_hexs(i) *
+                                      dof_handler.selected_fe->dofs_per_hex,
+                                      DoFHandler<3,spacedim>::invalid_dof_index);
+
+                       dof_handler.levels.back()->cell_dof_indices_cache
+                         .resize (dof_handler.tria->n_raw_hexs(i) *
+                                      dof_handler.selected_fe->dofs_per_cell,
+                                      DoFHandler<3,spacedim>::invalid_dof_index);
+                 }
+               dof_handler.faces = new internal::DoFHandler::DoFFaces<3>;
+
+               dof_handler.faces->lines.dofs
+                 .resize (dof_handler.tria->n_raw_lines() *
+                              dof_handler.selected_fe->dofs_per_line,
+                              DoFHandler<3,spacedim>::invalid_dof_index);
+               dof_handler.faces->quads.dofs
+                 .resize (dof_handler.tria->n_raw_quads() *
+                              dof_handler.selected_fe->dofs_per_quad,
+                              DoFHandler<3,spacedim>::invalid_dof_index);
+             }
+         
+           template<int spacedim>
+           static
+           void reserve_space_mg (DoFHandler<1, spacedim>& dof_handler) {
+             Assert (dof_handler.get_tria ().n_levels () > 0, ExcMessage ("Invalid triangulation"));
+             dof_handler.clear_mg_space ();
+           
+             const dealii::Triangulation<1, spacedim>& tria = dof_handler.get_tria ();
+             const unsigned int& dofs_per_line = dof_handler.get_fe ().dofs_per_line;
+          const unsigned int& n_levels = tria.n_levels ();
+           
+             for (unsigned int i = 0; i < n_levels; ++i) {
+               dof_handler.mg_levels.push_back (new internal::DoFHandler::DoFLevel<1>);
+               dof_handler.mg_levels.back ()->lines.dofs = std::vector<unsigned int> (tria.n_raw_lines (i) * dofs_per_line, DoFHandler<1>::invalid_dof_index);
+             }
+           
+             const unsigned int& n_vertices = tria.n_vertices ();
+           
+             dof_handler.mg_vertex_dofs.resize (n_vertices);
+           
+             std::vector<unsigned int> max_level (n_vertices, 0);
+             std::vector<unsigned int> min_level (n_vertices, n_levels);
+           
+             for (typename dealii::Triangulation<1, spacedim>::cell_iterator cell = tria.begin (); cell != tria.end (); ++cell) {
+               const unsigned int level = cell->level ();
+             
+               for (unsigned int vertex = 0; vertex < GeometryInfo<1>::vertices_per_cell; ++vertex) {
+                 const unsigned int vertex_index = cell->vertex_index (vertex);
+               
+                 if (min_level[vertex_index] > level)
+                   min_level[vertex_index] = level;
+               
+                 if (max_level[vertex_index] < level)
+                   max_level[vertex_index] = level;
+               }
+             }
+           
+             for (unsigned int vertex = 0; vertex < n_vertices; ++vertex)
+               if (tria.vertex_used (vertex)) {
+                 Assert (min_level[vertex] < n_levels, ExcInternalError ());
+                 Assert (max_level[vertex] >= min_level[vertex], ExcInternalError ());
+                 dof_handler.mg_vertex_dofs[vertex].init (min_level[vertex], max_level[vertex], dof_handler.get_fe ().dofs_per_vertex);
+               }
+             
+               else {
+                 Assert (min_level[vertex] == n_levels, ExcInternalError ());
+                 Assert (max_level[vertex] == 0, ExcInternalError ());
+                 dof_handler.mg_vertex_dofs[vertex].init (1, 0, 0);
+               }
+           }
+         
+           template<int spacedim>
+           static
+           void reserve_space_mg (DoFHandler<2, spacedim>& dof_handler) {
+             Assert (dof_handler.get_tria ().n_levels () > 0, ExcMessage ("Invalid triangulation"));
+             dof_handler.clear_mg_space ();
+           
+             const dealii::FiniteElement<2, spacedim>& fe = dof_handler.get_fe ();
+             const dealii::Triangulation<2, spacedim>& tria = dof_handler.get_tria ();
+             const unsigned int& n_levels = tria.n_levels ();
+           
+             for (unsigned int i = 0; i < n_levels; ++i) {
+               dof_handler.mg_levels.push_back (new internal::DoFHandler::DoFLevel<2>);
+               dof_handler.mg_levels.back ()->quads.dofs = std::vector<unsigned int> (tria.n_raw_quads (i) * fe.dofs_per_quad, DoFHandler<2>::invalid_dof_index);
+             }
+           
+             dof_handler.mg_faces = new internal::DoFHandler::DoFFaces<2>;
+             dof_handler.mg_faces->lines.dofs = std::vector<unsigned int> (tria.n_raw_lines () * fe.dofs_per_line, DoFHandler<2>::invalid_dof_index);
+           
+             const unsigned int& n_vertices = tria.n_vertices ();
+           
+             dof_handler.mg_vertex_dofs.resize (n_vertices);
+           
+             std::vector<unsigned int> max_level (n_vertices, 0);
+             std::vector<unsigned int> min_level (n_vertices, n_levels);
+           
+             for (typename dealii::Triangulation<2, spacedim>::cell_iterator cell = tria.begin (); cell != tria.end (); ++cell) {
+               const unsigned int level = cell->level ();
+             
+               for (unsigned int vertex = 0; vertex < GeometryInfo<2>::vertices_per_cell; ++vertex) {
+                 const unsigned int vertex_index = cell->vertex_index (vertex);
+               
+                 if (min_level[vertex_index] > level)
+                   min_level[vertex_index] = level;
+               
+                 if (max_level[vertex_index] < level)
+                   max_level[vertex_index] = level;
+               }
+             }
+           
+             for (unsigned int vertex = 0; vertex < n_vertices; ++vertex)
+               if (tria.vertex_used (vertex)) {
+                 Assert (min_level[vertex] < n_levels, ExcInternalError ());
+                 Assert (max_level[vertex] >= min_level[vertex], ExcInternalError ());
+                 dof_handler.mg_vertex_dofs[vertex].init (min_level[vertex], max_level[vertex], fe.dofs_per_vertex);
+               }
+             
+               else {
+                 Assert (min_level[vertex] == n_levels, ExcInternalError ());
+                 Assert (max_level[vertex] == 0, ExcInternalError ());
+                 dof_handler.mg_vertex_dofs[vertex].init (1, 0, 0);
+               }
+           }
+         
+           template<int spacedim>
+           static
+           void reserve_space_mg (DoFHandler<3, spacedim>& dof_handler) {
+             Assert (dof_handler.get_tria ().n_levels () > 0, ExcMessage ("Invalid triangulation"));
+             dof_handler.clear_mg_space ();
+           
+             const dealii::FiniteElement<3, spacedim>& fe = dof_handler.get_fe ();
+             const dealii::Triangulation<3, spacedim>& tria = dof_handler.get_tria ();
+             const unsigned int& n_levels = tria.n_levels ();
+           
+             for (unsigned int i = 0; i < n_levels; ++i) {
+               dof_handler.mg_levels.push_back (new internal::DoFHandler::DoFLevel<3>);
+               dof_handler.mg_levels.back ()->hexes.dofs = std::vector<unsigned int> (tria.n_raw_hexs (i) * fe.dofs_per_hex, DoFHandler<3>::invalid_dof_index);
+             }
+           
+             dof_handler.mg_faces = new internal::DoFHandler::DoFFaces<3>;
+             dof_handler.mg_faces->lines.dofs = std::vector<unsigned int> (tria.n_raw_lines () * fe.dofs_per_line, DoFHandler<3>::invalid_dof_index);
+             dof_handler.mg_faces->quads.dofs = std::vector<unsigned int> (tria.n_raw_quads () * fe.dofs_per_quad, DoFHandler<3>::invalid_dof_index);
+           
+             const unsigned int& n_vertices = tria.n_vertices ();
+           
+             dof_handler.mg_vertex_dofs.resize (n_vertices);
+           
+             std::vector<unsigned int> max_level (n_vertices, 0);
+             std::vector<unsigned int> min_level (n_vertices, n_levels);
+           
+             for (typename dealii::Triangulation<3, spacedim>::cell_iterator cell = tria.begin (); cell != tria.end (); ++cell) {
+               const unsigned int level = cell->level ();
+             
+               for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_cell; ++vertex) {
+                 const unsigned int vertex_index = cell->vertex_index (vertex);
+               
+                 if (min_level[vertex_index] > level)
+                   min_level[vertex_index] = level;
+               
+                 if (max_level[vertex_index] < level)
+                   max_level[vertex_index] = level;
+               }
+             }
+           
+             for (unsigned int vertex = 0; vertex < n_vertices; ++vertex)
+               if (tria.vertex_used (vertex)) {
+                 Assert (min_level[vertex] < n_levels, ExcInternalError ());
+                 Assert (max_level[vertex] >= min_level[vertex], ExcInternalError ());
+                 dof_handler.mg_vertex_dofs[vertex].init (min_level[vertex], max_level[vertex], fe.dofs_per_vertex);
+               }
+             
+               else {
+                 Assert (min_level[vertex] == n_levels, ExcInternalError ());
+                 Assert (max_level[vertex] == 0, ExcInternalError ());
+                 dof_handler.mg_vertex_dofs[vertex].init (1, 0, 0);
+               }
+           }
+         
+           template<int spacedim>
+           static
+           unsigned int distribute_dofs_on_cell (typename DoFHandler<1, spacedim>::cell_iterator& cell, unsigned int next_free_dof) {
+                 const FiniteElement<1, spacedim>& fe = cell->get_fe ();
+               
+             if (fe.dofs_per_vertex > 0)
+               for (unsigned int vertex = 0; vertex < GeometryInfo<1>::vertices_per_cell; ++vertex) {
+                 typename DoFHandler<1, spacedim>::cell_iterator neighbor = cell->neighbor (vertex);
+               
+                 if (neighbor.state () == IteratorState::valid)
+                   if (neighbor->user_flag_set () && (neighbor->level () == cell->level ())) {
+                     if (vertex == 0)
+                       for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof)
+                         cell->set_mg_vertex_dof_index (cell->level (), 0, dof, neighbor->mg_vertex_dof_index (cell->level (), 1, dof));
+                   
+                     else
+                       for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof)
+                         cell->set_mg_vertex_dof_index (cell->level (), 1, dof, neighbor->mg_vertex_dof_index (cell->level (), 0, dof));
+                   
+                     continue;
+                   }
+               
+                 for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof)
+                   cell->set_mg_vertex_dof_index (cell->level (), vertex, dof, next_free_dof++);
+               }
+           
+             if (fe.dofs_per_line > 0)
+               for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof)
+                 cell->set_mg_dof_index (cell->level (), dof, next_free_dof++);
+           
+             cell->set_user_flag ();
+             return next_free_dof;
+           }
+         
+           template<int spacedim>
+           static
+           unsigned int distribute_dofs_on_cell (typename DoFHandler<2, spacedim>::cell_iterator& cell, unsigned int next_free_dof) {
+             const FiniteElement<2, spacedim>& fe = cell->get_fe ();
+           
+             if (fe.dofs_per_vertex > 0)
+               for (unsigned int vertex = 0; vertex < GeometryInfo<2>::vertices_per_cell; ++vertex)
+                 if (cell->mg_vertex_dof_index (cell->level (), vertex, 0) == DoFHandler<2>::invalid_dof_index)
+                   for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof)
+                     cell->set_mg_vertex_dof_index (cell->level (), vertex, dof, next_free_dof++);
+           
+             if (fe.dofs_per_line > 0)
+               for (unsigned int face = 0; face < GeometryInfo<2>::faces_per_cell; ++face) {
+                 typename DoFHandler<2, spacedim>::line_iterator line = cell->line (face);
+               
+                 if (line->mg_dof_index (cell->level (), 0) == DoFHandler<2>::invalid_dof_index)
+                   for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof)
+                     line->set_mg_dof_index (cell->level (), dof, next_free_dof++);
+               }
+           
+             if (fe.dofs_per_quad > 0)
+               for (unsigned int dof = 0; dof < fe.dofs_per_quad; ++dof)
+                 cell->set_mg_dof_index (cell->level (), dof, next_free_dof++);
+           
+             cell->set_user_flag ();
+             return next_free_dof;
+           }
+         
+           template<int spacedim>
+           static
+           unsigned int distribute_dofs_on_cell (typename DoFHandler<3, spacedim>::cell_iterator& cell, unsigned int next_free_dof) {
+             const FiniteElement<3, spacedim>& fe = cell->get_fe ();
+           
+             if (fe.dofs_per_vertex > 0)
+               for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_cell; ++vertex)
+                 if (cell->mg_vertex_dof_index (cell->level (), vertex, 0) == DoFHandler<3>::invalid_dof_index)
+                   for (unsigned int dof = 0; dof < fe.dofs_per_vertex; ++dof)
+                     cell->set_mg_vertex_dof_index (cell->level (), vertex, dof, next_free_dof++);
+           
+             if (fe.dofs_per_line > 0)
+               for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_cell; ++line) {
+                 typename DoFHandler<3, spacedim>::line_iterator line_it = cell->line (line);
+               
+                 if (line_it->mg_dof_index (cell->level (), 0) == DoFHandler<3>::invalid_dof_index)
+                   for (unsigned int dof = 0; dof < fe.dofs_per_line; ++dof)
+                     line_it->set_mg_dof_index (cell->level (), dof, next_free_dof++);
+               }
+           
+             if (fe.dofs_per_quad > 0)
+               for (unsigned int face = 0; face < GeometryInfo<3>::quads_per_cell; ++face) {
+                 typename DoFHandler<3, spacedim>::quad_iterator quad = cell->quad (face);
+               
+                 if (quad->mg_dof_index (cell->level (), 0) == DoFHandler<3>::invalid_dof_index)
+                   for (unsigned int dof = 0; dof < fe.dofs_per_quad; ++dof)
+                     quad->set_mg_dof_index (cell->level (), dof, next_free_dof++);
+               }
+           
+             if (fe.dofs_per_hex > 0)
+               for (unsigned int dof = 0; dof < fe.dofs_per_hex; ++dof)
+                 cell->set_mg_dof_index (cell->level (), dof, next_free_dof++);
+           
+             cell->set_user_flag ();
+             return next_free_dof;
+           }
+         
+           template<int spacedim>
+           static
+           unsigned int get_dof_index (const DoFHandler<1, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<1>& mg_level, internal::DoFHandler::DoFFaces<1>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<1>) {
+             return mg_level.lines.get_dof_index (dof_handler, obj_index, fe_index, local_index);
+           }
+         
+           template<int spacedim>
+           static
+           unsigned int get_dof_index (const DoFHandler<2, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<2>&, internal::DoFHandler::DoFFaces<2>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<1>) {
+             return mg_faces.lines.get_dof_index (dof_handler, obj_index, fe_index, local_index);
+           }
+         
+           template<int spacedim>
+           static
+           unsigned int get_dof_index (const DoFHandler<2, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<2>& mg_level, internal::DoFHandler::DoFFaces<2>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<2>) {
+             return mg_level.quads.get_dof_index (dof_handler, obj_index, fe_index, local_index);
+           }
+         
+           template<int spacedim>
+           static
+           unsigned int get_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>&, internal::DoFHandler::DoFFaces<3>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<1>) {
+             return mg_faces.lines.get_dof_index (dof_handler, obj_index, fe_index, local_index);
+           }
+         
+           template<int spacedim>
+           static
+           unsigned int get_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>&, internal::DoFHandler::DoFFaces<3>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<2>) {
+             return mg_faces.quads.get_dof_index (dof_handler, obj_index, fe_index, local_index);
+           }
+         
+           template<int spacedim>
+           static
+           unsigned int get_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>& mg_level, internal::DoFHandler::DoFFaces<3>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const int2type<3>) {
+             return mg_level.hexes.get_dof_index (dof_handler, obj_index, fe_index, local_index);
+           }
+         
+           template<int spacedim>
+           static
+           void set_dof_index (const DoFHandler<1, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<1>& mg_level, internal::DoFHandler::DoFFaces<1>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<1>) {
+             mg_level.lines.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index);
+           }
+         
+           template<int spacedim>
+           static
+           void set_dof_index (const DoFHandler<2, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<2>&, internal::DoFHandler::DoFFaces<2>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<1>) {
+             mg_faces.lines.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index);
+           }
+         
+           template<int spacedim>
+           static
+           void set_dof_index (const DoFHandler<2, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<2>& mg_level, internal::DoFHandler::DoFFaces<2>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<2>) {
+             mg_level.quads.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index);
+           }
+         
+           template<int spacedim>
+           static
+           void set_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>&, internal::DoFHandler::DoFFaces<3>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<1>) {
+             mg_faces.lines.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index);
+           }
+         
+           template<int spacedim>
+           static
+           void set_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>&, internal::DoFHandler::DoFFaces<3>& mg_faces, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<2>) {
+             mg_faces.quads.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index);
+           }
+         
+           template<int spacedim>
+           static
+           void set_dof_index (const DoFHandler<3, spacedim>& dof_handler, internal::DoFHandler::DoFLevel<3>& mg_level, internal::DoFHandler::DoFFaces<3>&, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index, const int2type<3>) {
+             mg_level.hexes.set_dof_index (dof_handler, obj_index, fe_index, local_index, global_index);
+           }
     };
   }
 }
@@ -358,10 +686,11 @@ namespace internal
 
 template<int dim, int spacedim>
 DoFHandler<dim,spacedim>::DoFHandler (const Triangulation<dim,spacedim> &tria)
-                :
-                tria(&tria, typeid(*this).name()),
-                selected_fe(0, typeid(*this).name()),
-                faces(NULL)
+                       :
+                       tria(&tria, typeid(*this).name()),
+                       selected_fe(0, typeid(*this).name()),
+                       faces(NULL),
+                       mg_faces (NULL)
 {
                                    // decide whether we need a
                                    // sequential or a parallel
@@ -377,10 +706,11 @@ DoFHandler<dim,spacedim>::DoFHandler (const Triangulation<dim,spacedim> &tria)
 
 template<int dim, int spacedim>
 DoFHandler<dim,spacedim>::DoFHandler ()
-                :
-                tria(0, typeid(*this).name()),
-                selected_fe(0, typeid(*this).name()),
-                faces(NULL)
+                       :
+                       tria(0, typeid(*this).name()),
+                       selected_fe(0, typeid(*this).name()),
+                       faces(NULL),
+                       mg_faces (NULL)
 {}
 
 
@@ -426,14 +756,14 @@ DoFHandler<dim,spacedim>::begin_raw (const unsigned int level) const
   switch (dim)
     {
       case 1:
-            return begin_raw_line (level);
+               return begin_raw_line (level);
       case 2:
-            return begin_raw_quad (level);
+               return begin_raw_quad (level);
       case 3:
-            return begin_raw_hex (level);
+               return begin_raw_hex (level);
       default:
-            Assert (false, ExcNotImplemented());
-            return raw_cell_iterator();
+               Assert (false, ExcNotImplemented());
+               return raw_cell_iterator();
     }
 }
 
@@ -446,14 +776,14 @@ DoFHandler<dim,spacedim>::begin (const unsigned int level) const
   switch (dim)
     {
       case 1:
-            return begin_line (level);
+               return begin_line (level);
       case 2:
-            return begin_quad (level);
+               return begin_quad (level);
       case 3:
-            return begin_hex (level);
+               return begin_hex (level);
       default:
-            Assert (false, ExcImpossibleInDim(dim));
-            return cell_iterator();
+               Assert (false, ExcImpossibleInDim(dim));
+               return cell_iterator();
     }
 }
 
@@ -466,14 +796,14 @@ DoFHandler<dim,spacedim>::begin_active (const unsigned int level) const
   switch (dim)
     {
       case 1:
-            return begin_active_line (level);
+               return begin_active_line (level);
       case 2:
-            return begin_active_quad (level);
+               return begin_active_quad (level);
       case 3:
-            return begin_active_hex (level);
+               return begin_active_hex (level);
       default:
-            Assert (false, ExcNotImplemented());
-            return active_cell_iterator();
+               Assert (false, ExcNotImplemented());
+               return active_cell_iterator();
     }
 }
 
@@ -486,14 +816,14 @@ DoFHandler<dim,spacedim>::last_raw () const
   switch (dim)
     {
       case 1:
-            return last_raw_line ();
+               return last_raw_line ();
       case 2:
-            return last_raw_quad ();
+               return last_raw_quad ();
       case 3:
-            return last_raw_hex ();
+               return last_raw_hex ();
       default:
-            Assert (false, ExcNotImplemented());
-            return raw_cell_iterator();
+               Assert (false, ExcNotImplemented());
+               return raw_cell_iterator();
     }
 }
 
@@ -506,14 +836,14 @@ DoFHandler<dim,spacedim>::last_raw (const unsigned int level) const
   switch (dim)
     {
       case 1:
-            return last_raw_line (level);
+               return last_raw_line (level);
       case 2:
-            return last_raw_quad (level);
+               return last_raw_quad (level);
       case 3:
-            return last_raw_hex (level);
+               return last_raw_hex (level);
       default:
-            Assert (false, ExcNotImplemented());
-            return raw_cell_iterator();
+               Assert (false, ExcNotImplemented());
+               return raw_cell_iterator();
     }
 }
 
@@ -526,14 +856,14 @@ DoFHandler<dim,spacedim>::last () const
   switch (dim)
     {
       case 1:
-            return last_line ();
+               return last_line ();
       case 2:
-            return last_quad ();
+               return last_quad ();
       case 3:
-            return last_hex ();
+               return last_hex ();
       default:
-            Assert (false, ExcNotImplemented());
-            return cell_iterator();
+               Assert (false, ExcNotImplemented());
+               return cell_iterator();
     }
 }
 
@@ -546,14 +876,14 @@ DoFHandler<dim,spacedim>::last (const unsigned int level) const
   switch (dim)
     {
       case 1:
-            return last_line (level);
+               return last_line (level);
       case 2:
-            return last_quad (level);
+               return last_quad (level);
       case 3:
-            return last_hex (level);
+               return last_hex (level);
       default:
-            Assert (false, ExcNotImplemented());
-            return cell_iterator();
+               Assert (false, ExcNotImplemented());
+               return cell_iterator();
     }
 }
 
@@ -566,14 +896,14 @@ DoFHandler<dim,spacedim>::last_active () const
   switch (dim)
     {
       case 1:
-            return last_active_line ();
+               return last_active_line ();
       case 2:
-            return last_active_quad ();
+               return last_active_quad ();
       case 3:
-            return last_active_hex ();
+               return last_active_hex ();
       default:
-            Assert (false, ExcNotImplemented());
-            return active_cell_iterator();
+               Assert (false, ExcNotImplemented());
+               return active_cell_iterator();
     }
 }
 
@@ -586,14 +916,14 @@ DoFHandler<dim,spacedim>::last_active (const unsigned int level) const
   switch (dim)
     {
       case 1:
-            return last_active_line (level);
+               return last_active_line (level);
       case 2:
-            return last_active_quad (level);
+               return last_active_quad (level);
       case 3:
-            return last_active_hex (level);
+               return last_active_hex (level);
       default:
-            Assert (false, ExcNotImplemented());
-            return active_cell_iterator();
+               Assert (false, ExcNotImplemented());
+               return active_cell_iterator();
     }
 }
 
@@ -605,14 +935,14 @@ DoFHandler<dim,spacedim>::end () const
   switch (dim)
     {
       case 1:
-            return end_line();
+               return end_line();
       case 2:
-            return end_quad();
+               return end_quad();
       case 3:
-            return end_hex();
+               return end_hex();
       default:
-            Assert (false, ExcImpossibleInDim(dim));
-            return raw_cell_iterator();
+               Assert (false, ExcImpossibleInDim(dim));
+               return raw_cell_iterator();
     }
 }
 
@@ -624,8 +954,8 @@ DoFHandler<dim, spacedim>::end_raw (const unsigned int level) const
 {
   Assert(tria != 0, ExcNotInitialized());
   return (level == tria->n_levels()-1 ?
-          end() :
-          begin_raw (level+1));
+             end() :
+             begin_raw (level+1));
 }
 
 
@@ -635,8 +965,8 @@ DoFHandler<dim, spacedim>::end (const unsigned int level) const
 {
   Assert(tria != 0, ExcNotInitialized());
   return (level == tria->n_levels()-1 ?
-          cell_iterator(end()) :
-          begin (level+1));
+             cell_iterator(end()) :
+             begin (level+1));
 }
 
 
@@ -646,8 +976,8 @@ DoFHandler<dim, spacedim>::end_active (const unsigned int level) const
 {
   Assert(tria != 0, ExcNotInitialized());
   return (level == tria->n_levels()-1 ?
-          active_cell_iterator(end()) :
-          begin_active (level+1));
+             active_cell_iterator(end()) :
+             begin_active (level+1));
 }
 
 
@@ -661,15 +991,15 @@ DoFHandler<dim,spacedim>::begin_raw_face () const
   switch (dim)
     {
       case 1:
-            Assert (false, ExcImpossibleInDim(1));
-            return raw_face_iterator();
+               Assert (false, ExcImpossibleInDim(1));
+               return raw_face_iterator();
       case 2:
-            return begin_raw_line ();
+               return begin_raw_line ();
       case 3:
-            return begin_raw_quad ();
+               return begin_raw_quad ();
       default:
-            Assert (false, ExcNotImplemented());
-            return raw_face_iterator ();
+               Assert (false, ExcNotImplemented());
+               return raw_face_iterator ();
     }
 }
 
@@ -682,15 +1012,15 @@ DoFHandler<dim,spacedim>::begin_face () const
   switch (dim)
     {
       case 1:
-            Assert (false, ExcImpossibleInDim(1));
-            return raw_face_iterator();
+               Assert (false, ExcImpossibleInDim(1));
+               return raw_face_iterator();
       case 2:
-            return begin_line ();
+               return begin_line ();
       case 3:
-            return begin_quad ();
+               return begin_quad ();
       default:
-            Assert (false, ExcNotImplemented());
-            return face_iterator ();
+               Assert (false, ExcNotImplemented());
+               return face_iterator ();
     }
 }
 
@@ -703,15 +1033,15 @@ DoFHandler<dim,spacedim>::begin_active_face () const
   switch (dim)
     {
       case 1:
-            Assert (false, ExcImpossibleInDim(1));
-            return raw_face_iterator();
+               Assert (false, ExcImpossibleInDim(1));
+               return raw_face_iterator();
       case 2:
-            return begin_active_line ();
+               return begin_active_line ();
       case 3:
-            return begin_active_quad ();
+               return begin_active_quad ();
       default:
-            Assert (false, ExcNotImplemented());
-            return active_face_iterator ();
+               Assert (false, ExcNotImplemented());
+               return active_face_iterator ();
     }
 }
 
@@ -733,15 +1063,15 @@ DoFHandler<dim,spacedim>::end_face () const
   switch (dim)
     {
       case 1:
-            Assert (false, ExcImpossibleInDim(1));
-            return raw_face_iterator();
+               Assert (false, ExcImpossibleInDim(1));
+               return raw_face_iterator();
       case 2:
-            return end_line ();
+               return end_line ();
       case 3:
-            return end_quad ();
+               return end_quad ();
       default:
-            Assert (false, ExcNotImplemented());
-            return raw_face_iterator ();
+               Assert (false, ExcNotImplemented());
+               return raw_face_iterator ();
     }
 }
 
@@ -765,15 +1095,15 @@ DoFHandler<dim,spacedim>::last_raw_face () const
   switch (dim)
     {
       case 1:
-            Assert (false, ExcImpossibleInDim(1));
-            return raw_face_iterator();
+               Assert (false, ExcImpossibleInDim(1));
+               return raw_face_iterator();
       case 2:
-            return last_raw_line ();
+               return last_raw_line ();
       case 3:
-            return last_raw_quad ();
+               return last_raw_quad ();
       default:
-            Assert (false, ExcNotImplemented());
-            return raw_face_iterator ();
+               Assert (false, ExcNotImplemented());
+               return raw_face_iterator ();
     }
 }
 
@@ -786,15 +1116,15 @@ DoFHandler<dim,spacedim>::last_face () const
   switch (dim)
     {
       case 1:
-            Assert (false, ExcImpossibleInDim(1));
-            return raw_face_iterator();
+               Assert (false, ExcImpossibleInDim(1));
+               return raw_face_iterator();
       case 2:
-            return last_line ();
+               return last_line ();
       case 3:
-            return last_quad ();
+               return last_quad ();
       default:
-            Assert (false, ExcNotImplemented());
-            return raw_face_iterator ();
+               Assert (false, ExcNotImplemented());
+               return raw_face_iterator ();
     }
 }
 
@@ -807,15 +1137,15 @@ DoFHandler<dim,spacedim>::last_active_face () const
   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 raw_face_iterator ();
     }
 }
 
@@ -832,22 +1162,22 @@ DoFHandler<dim, spacedim>::begin_raw_line (const unsigned int level) const
   switch (dim)
     {
       case 1:
-            Assert (level<tria->n_levels(), ExcInvalidLevel(level));
+               Assert (level<tria->n_levels(), ExcInvalidLevel(level));
 
-            if (tria->n_raw_lines(level) == 0)
-              return end_line ();
+               if (tria->n_raw_lines(level) == 0)
+                 return end_line ();
 
-            return raw_line_iterator (tria,
-                                      level,
-                                      0,
-                                      this);
+               return raw_line_iterator (tria,
+                                                     level,
+                                                     0,
+                                                     this);
 
       default:
-            Assert (level == 0, ExcFacesHaveNoLevel());
-            return raw_line_iterator (tria,
-                                      0,
-                                      0,
-                                      this);
+               Assert (level == 0, ExcFacesHaveNoLevel());
+               return raw_line_iterator (tria,
+                                                     0,
+                                                     0,
+                                                     this);
     }
 }
 
@@ -889,9 +1219,9 @@ typename DoFHandler<dim, spacedim>::raw_line_iterator
 DoFHandler<dim, spacedim>::end_line () const
 {
   return raw_line_iterator (tria,
-                            -1,
-                            -1,
-                            this);
+                                       -1,
+                                       -1,
+                                       this);
 }
 
 
@@ -904,21 +1234,21 @@ DoFHandler<dim, spacedim>::last_raw_line (const unsigned int level) const
   switch (dim)
     {
       case 1:
-            Assert (level<tria->n_levels(), ExcInvalidLevel(level));
-            Assert (tria->n_raw_lines(level) != 0,
-                    ExcEmptyLevel (level));
+               Assert (level<tria->n_levels(), ExcInvalidLevel(level));
+               Assert (tria->n_raw_lines(level) != 0,
+                           ExcEmptyLevel (level));
 
-            return raw_line_iterator (tria,
-                                      level,
-                                      tria->n_raw_lines(level)-1,
-                                      this);
+               return raw_line_iterator (tria,
+                                                     level,
+                                                     tria->n_raw_lines(level)-1,
+                                                     this);
 
       default:
-            Assert (level == 0, ExcFacesHaveNoLevel());
-            return raw_line_iterator (tria,
-                                      0,
-                                      tria->n_raw_lines()-1,
-                                      this);
+               Assert (level == 0, ExcFacesHaveNoLevel());
+               return raw_line_iterator (tria,
+                                                     0,
+                                                     tria->n_raw_lines()-1,
+                                                     this);
     }
 }
 
@@ -994,8 +1324,8 @@ DoFHandler<dim, spacedim>::end_raw_line (const unsigned int level) const
   Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel());
   if (dim == 1)
     return (level == tria->n_levels()-1 ?
-            end_line() :
-            begin_raw_line (level+1));
+               end_line() :
+               begin_raw_line (level+1));
   else
     return end_line();
 }
@@ -1008,8 +1338,8 @@ DoFHandler<dim, spacedim>::end_line (const unsigned int level) const
   Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel());
   if (dim == 1)
     return (level == tria->n_levels()-1 ?
-            line_iterator(end_line()) :
-            begin_line (level+1));
+               line_iterator(end_line()) :
+               begin_line (level+1));
   else
     return line_iterator(end_line());
 }
@@ -1022,8 +1352,8 @@ DoFHandler<dim, spacedim>::end_active_line (const unsigned int level) const
   Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel());
   if (dim == 1)
     return (level == tria->n_levels()-1 ?
-            active_line_iterator(end_line()) :
-            begin_active_line (level+1));
+               active_line_iterator(end_line()) :
+               begin_active_line (level+1));
   else
     return active_line_iterator(end_line());
 }
@@ -1040,35 +1370,35 @@ DoFHandler<dim,spacedim>::begin_raw_quad (const unsigned int level) const
   switch (dim)
     {
       case 1:
-            Assert (false, ExcImpossibleInDim(1));
-            return raw_hex_iterator();
+               Assert (false, ExcImpossibleInDim(1));
+               return raw_hex_iterator();
       case 2:
       {
-        Assert (level<tria->n_levels(), ExcInvalidLevel(level));
+           Assert (level<tria->n_levels(), ExcInvalidLevel(level));
 
-        if (tria->n_raw_quads(level) == 0)
-          return end_quad();
+           if (tria->n_raw_quads(level) == 0)
+             return end_quad();
 
-        return raw_quad_iterator (tria,
-                                  level,
-                                  0,
-                                  this);
+           return raw_quad_iterator (tria,
+                                                 level,
+                                                 0,
+                                                 this);
       }
 
       case 3:
       {
-        Assert (level == 0, ExcFacesHaveNoLevel());
+           Assert (level == 0, ExcFacesHaveNoLevel());
 
-        return raw_quad_iterator (tria,
-                                  0,
-                                  0,
-                                  this);
+           return raw_quad_iterator (tria,
+                                                 0,
+                                                 0,
+                                                 this);
       }
 
 
       default:
-            Assert (false, ExcNotImplemented());
-            return raw_hex_iterator();
+               Assert (false, ExcNotImplemented());
+               return raw_hex_iterator();
     }
 }
 
@@ -1113,8 +1443,8 @@ DoFHandler<dim, spacedim>::end_raw_quad (const unsigned int level) const
   Assert (dim == 2 || level == 0, ExcFacesHaveNoLevel());
   if (dim == 2)
     return (level == tria->n_levels()-1 ?
-            end_quad() :
-            begin_raw_quad (level+1));
+               end_quad() :
+               begin_raw_quad (level+1));
   else
     return end_quad();
 }
@@ -1128,8 +1458,8 @@ DoFHandler<dim, spacedim>::end_quad (const unsigned int level) const
   Assert (dim == 2 || level == 0, ExcFacesHaveNoLevel());
   if (dim == 2)
     return (level == tria->n_levels()-1 ?
-            quad_iterator(end_quad()) :
-            begin_quad (level+1));
+               quad_iterator(end_quad()) :
+               begin_quad (level+1));
   else
     return quad_iterator(end_quad());
 }
@@ -1142,8 +1472,8 @@ DoFHandler<dim, spacedim>::end_active_quad (const unsigned int level) const
   Assert(dim == 2 || level == 0, ExcFacesHaveNoLevel());
   if (dim == 2)
     return (level == tria->n_levels()-1 ?
-            active_quad_iterator(end_quad()) :
-            begin_active_quad (level+1));
+               active_quad_iterator(end_quad()) :
+               begin_active_quad (level+1));
   else
     return active_quad_iterator(end_quad());
 }
@@ -1155,9 +1485,9 @@ typename DoFHandler<dim,spacedim>::raw_quad_iterator
 DoFHandler<dim,spacedim>::end_quad () const
 {
   return raw_quad_iterator (tria,
-                            -1,
-                            -1,
-                            this);
+                                       -1,
+                                       -1,
+                                       this);
 }
 
 
@@ -1170,26 +1500,26 @@ DoFHandler<dim,spacedim>::last_raw_quad (const unsigned int level) const
   switch (dim)
     {
       case 1:
-            Assert (false, ExcImpossibleInDim(1));
-            return raw_quad_iterator();
+               Assert (false, ExcImpossibleInDim(1));
+               return raw_quad_iterator();
       case 2:
-            Assert (level<tria->n_levels(),
-                    ExcInvalidLevel(level));
-            Assert (tria->n_raw_quads(level) != 0,
-                    ExcEmptyLevel (level));
-            return raw_quad_iterator (tria,
-                                      level,
-                                      tria->n_raw_quads(level)-1,
-                                      this);
+               Assert (level<tria->n_levels(),
+                           ExcInvalidLevel(level));
+               Assert (tria->n_raw_quads(level) != 0,
+                           ExcEmptyLevel (level));
+               return raw_quad_iterator (tria,
+                                                     level,
+                                                     tria->n_raw_quads(level)-1,
+                                                     this);
       case 3:
-            Assert (level == 0, ExcFacesHaveNoLevel());
-            return raw_quad_iterator (tria,
-                                      0,
-                                      tria->n_raw_quads()-1,
-                                      this);
+               Assert (level == 0, ExcFacesHaveNoLevel());
+               return raw_quad_iterator (tria,
+                                                     0,
+                                                     tria->n_raw_quads()-1,
+                                                     this);
       default:
-            Assert (false, ExcNotImplemented());
-            return raw_quad_iterator();
+               Assert (false, ExcNotImplemented());
+               return raw_quad_iterator();
     }
 }
 
@@ -1273,24 +1603,24 @@ DoFHandler<dim,spacedim>::begin_raw_hex (const unsigned int level) const
     {
       case 1:
       case 2:
-            Assert (false, ExcImpossibleInDim(1));
-            return raw_hex_iterator();
+               Assert (false, ExcImpossibleInDim(1));
+               return raw_hex_iterator();
       case 3:
       {
-        Assert (level<tria->n_levels(), ExcInvalidLevel(level));
+           Assert (level<tria->n_levels(), ExcInvalidLevel(level));
 
-        if (tria->n_raw_hexs(level) == 0)
-          return end_hex();
+           if (tria->n_raw_hexs(level) == 0)
+             return end_hex();
 
-        return raw_hex_iterator (tria,
-                                 level,
-                                 0,
-                                 this);
+           return raw_hex_iterator (tria,
+                                                level,
+                                                0,
+                                                this);
       }
 
       default:
-            Assert (false, ExcNotImplemented());
-            return raw_hex_iterator();
+               Assert (false, ExcNotImplemented());
+               return raw_hex_iterator();
     }
 }
 
@@ -1333,8 +1663,8 @@ typename DoFHandler<dim, spacedim>::raw_hex_iterator
 DoFHandler<dim, spacedim>::end_raw_hex (const unsigned int level) const
 {
   return (level == tria->n_levels()-1 ?
-          end_hex() :
-          begin_raw_hex (level+1));
+             end_hex() :
+             begin_raw_hex (level+1));
 }
 
 
@@ -1343,8 +1673,8 @@ typename DoFHandler<dim, spacedim>::hex_iterator
 DoFHandler<dim, spacedim>::end_hex (const unsigned int level) const
 {
   return (level == tria->n_levels()-1 ?
-          hex_iterator(end_hex()) :
-          begin_hex (level+1));
+             hex_iterator(end_hex()) :
+             begin_hex (level+1));
 }
 
 
@@ -1353,8 +1683,8 @@ typename DoFHandler<dim, spacedim>::active_hex_iterator
 DoFHandler<dim, spacedim>::end_active_hex (const unsigned int level) const
 {
   return (level == tria->n_levels()-1 ?
-          active_hex_iterator(end_hex()) :
-          begin_active_hex (level+1));
+             active_hex_iterator(end_hex()) :
+             begin_active_hex (level+1));
 }
 
 
@@ -1364,9 +1694,9 @@ typename DoFHandler<dim, spacedim>::raw_hex_iterator
 DoFHandler<dim, spacedim>::end_hex () const
 {
   return raw_hex_iterator (tria,
-                           -1,
-                           -1,
-                           this);
+                                      -1,
+                                      -1,
+                                      this);
 }
 
 
@@ -1379,22 +1709,22 @@ DoFHandler<dim, spacedim>::last_raw_hex (const unsigned int level) const
     {
       case 1:
       case 2:
-            Assert (false, ExcImpossibleInDim(dim));
-            return raw_hex_iterator();
+               Assert (false, ExcImpossibleInDim(dim));
+               return raw_hex_iterator();
 
       case 3:
-            Assert (level<tria->n_levels(),
-                    ExcInvalidLevel(level));
-            Assert (tria->n_raw_hexs(level) != 0,
-                    ExcEmptyLevel (level));
-
-            return raw_hex_iterator (tria,
-                                     level,
-                                     tria->n_raw_hexs(level)-1,
-                                     this);
+               Assert (level<tria->n_levels(),
+                           ExcInvalidLevel(level));
+               Assert (tria->n_raw_hexs(level) != 0,
+                           ExcEmptyLevel (level));
+
+               return raw_hex_iterator (tria,
+                                                    level,
+                                                    tria->n_raw_hexs(level)-1,
+                                                    this);
       default:
-            Assert (false, ExcNotImplemented());
-            return raw_hex_iterator();
+               Assert (false, ExcNotImplemented());
+               return raw_hex_iterator();
     }
 }
 
@@ -1481,7 +1811,7 @@ unsigned int DoFHandler<1>::n_boundary_dofs (const FunctionMap &boundary_indicat
   for (FunctionMap::const_iterator i=boundary_indicators.begin();
        i!=boundary_indicators.end(); ++i)
     Assert ((i->first == 0) || (i->first == 1),
-            ExcInvalidBoundaryIndicator());
+               ExcInvalidBoundaryIndicator());
 
   return boundary_indicators.size()*get_fe().dofs_per_vertex;
 }
@@ -1497,7 +1827,7 @@ unsigned int DoFHandler<1>::n_boundary_dofs (const std::set<types::boundary_id_t
   for (std::set<types::boundary_id_t>::const_iterator i=boundary_indicators.begin();
        i!=boundary_indicators.end(); ++i)
     Assert ((*i == 0) || (*i == 1),
-            ExcInvalidBoundaryIndicator());
+               ExcInvalidBoundaryIndicator());
 
   return boundary_indicators.size()*get_fe().dofs_per_vertex;
 }
@@ -1520,7 +1850,7 @@ unsigned int DoFHandler<1,2>::n_boundary_dofs (const FunctionMap &boundary_indic
   for (FunctionMap::const_iterator i=boundary_indicators.begin();
        i!=boundary_indicators.end(); ++i)
     Assert ((i->first == 0) || (i->first == 1),
-            ExcInvalidBoundaryIndicator());
+               ExcInvalidBoundaryIndicator());
 
   return boundary_indicators.size()*get_fe().dofs_per_vertex;
 }
@@ -1536,7 +1866,7 @@ unsigned int DoFHandler<1,2>::n_boundary_dofs (const std::set<types::boundary_id
   for (std::set<types::boundary_id_t>::const_iterator i=boundary_indicators.begin();
        i!=boundary_indicators.end(); ++i)
     Assert ((*i == 0) || (*i == 1),
-            ExcInvalidBoundaryIndicator());
+               ExcInvalidBoundaryIndicator());
 
   return boundary_indicators.size()*get_fe().dofs_per_vertex;
 }
@@ -1562,13 +1892,13 @@ unsigned int DoFHandler<dim,spacedim>::n_boundary_dofs () const
                                    // and so every boundary line is
                                    // also part of a boundary face.
   active_face_iterator face = begin_active_face (),
-                       endf = end_face();
+                              endf = end_face();
   for (; face!=endf; ++face)
     if (face->at_boundary())
       {
-        face->get_dof_indices (dofs_on_face);
-        for (unsigned int i=0; i<dofs_per_face; ++i)
-          boundary_dofs.insert(dofs_on_face[i]);
+           face->get_dof_indices (dofs_on_face);
+           for (unsigned int i=0; i<dofs_per_face; ++i)
+             boundary_dofs.insert(dofs_on_face[i]);
       }
   return boundary_dofs.size();
 }
@@ -1580,21 +1910,21 @@ unsigned int
 DoFHandler<dim,spacedim>::n_boundary_dofs (const FunctionMap &boundary_indicators) const
 {
   Assert (boundary_indicators.find(types::internal_face_boundary_id) == boundary_indicators.end(),
-          ExcInvalidBoundaryIndicator());
+             ExcInvalidBoundaryIndicator());
 
   std::set<int> boundary_dofs;
 
   const unsigned int dofs_per_face = get_fe().dofs_per_face;
   std::vector<unsigned int> dofs_on_face(dofs_per_face);
   active_face_iterator face = begin_active_face (),
-                       endf = end_face();
+                              endf = end_face();
   for (; face!=endf; ++face)
     if (boundary_indicators.find(face->boundary_indicator()) !=
-        boundary_indicators.end())
+           boundary_indicators.end())
       {
-        face->get_dof_indices (dofs_on_face);
-        for (unsigned int i=0; i<dofs_per_face; ++i)
-          boundary_dofs.insert(dofs_on_face[i]);
+           face->get_dof_indices (dofs_on_face);
+           for (unsigned int i=0; i<dofs_per_face; ++i)
+             boundary_dofs.insert(dofs_on_face[i]);
       }
   return boundary_dofs.size();
 }
@@ -1606,23 +1936,23 @@ unsigned int
 DoFHandler<dim,spacedim>::n_boundary_dofs (const std::set<types::boundary_id_t> &boundary_indicators) const
 {
   Assert (boundary_indicators.find (types::internal_face_boundary_id) == boundary_indicators.end(),
-          ExcInvalidBoundaryIndicator());
+             ExcInvalidBoundaryIndicator());
 
   std::set<int> boundary_dofs;
 
   const unsigned int dofs_per_face = get_fe().dofs_per_face;
   std::vector<unsigned int> dofs_on_face(dofs_per_face);
   active_face_iterator face = begin_active_face (),
-                       endf = end_face();
+                              endf = end_face();
   for (; face!=endf; ++face)
     if (std::find (boundary_indicators.begin(),
-                   boundary_indicators.end(),
-                   face->boundary_indicator()) !=
-        boundary_indicators.end())
+                          boundary_indicators.end(),
+                          face->boundary_indicator()) !=
+           boundary_indicators.end())
       {
-        face->get_dof_indices (dofs_on_face);
-        for (unsigned int i=0; i<dofs_per_face; ++i)
-          boundary_dofs.insert(dofs_on_face[i]);
+           face->get_dof_indices (dofs_on_face);
+           for (unsigned int i=0; i<dofs_per_face; ++i)
+             boundary_dofs.insert(dofs_on_face[i]);
       }
   return boundary_dofs.size();
 }
@@ -1634,16 +1964,25 @@ std::size_t
 DoFHandler<dim,spacedim>::memory_consumption () const
 {
   std::size_t mem = (MemoryConsumption::memory_consumption (tria) +
-                     MemoryConsumption::memory_consumption (selected_fe) +
-                     MemoryConsumption::memory_consumption (block_info_object) +
-                     MemoryConsumption::memory_consumption (levels) +
-                     MemoryConsumption::memory_consumption (*faces) +
-                     MemoryConsumption::memory_consumption (faces) +
-                     sizeof (number_cache) +
-                     MemoryConsumption::memory_consumption (vertex_dofs));
+                            MemoryConsumption::memory_consumption (selected_fe) +
+                            MemoryConsumption::memory_consumption (block_info_object) +
+                            MemoryConsumption::memory_consumption (levels) +
+                            MemoryConsumption::memory_consumption (*faces) +
+                            MemoryConsumption::memory_consumption (faces) +
+                            sizeof (number_cache) +
+                            MemoryConsumption::memory_consumption (vertex_dofs));
   for (unsigned int i=0; i<levels.size(); ++i)
     mem += MemoryConsumption::memory_consumption (*levels[i]);
-
+  
+  for (unsigned int level = 0; level < mg_levels.size (); ++level)
+    mem += mg_levels[level]->memory_consumption ();
+  
+  mem += MemoryConsumption::memory_consumption (*mg_faces);
+  
+  for (unsigned int i = 0; i < mg_vertex_dofs.size (); ++i)
+    mem += sizeof (MGVertexDoFs) + (1 + mg_vertex_dofs[i].get_finest_level () - mg_vertex_dofs[i].get_coarsest_level ()) * sizeof (unsigned int);
+  
+  mem += MemoryConsumption::memory_consumption (mg_used_dofs);
   return mem;
 }
 
@@ -1652,7 +1991,7 @@ DoFHandler<dim,spacedim>::memory_consumption () const
 template<int dim, int spacedim>
 void DoFHandler<dim,spacedim>::
 distribute_dofs (const FiniteElement<dim,spacedim> &ff,
-                 const unsigned int                 offset)
+                        const unsigned int                 offset)
 {
   selected_fe = &ff;
 
@@ -1677,7 +2016,7 @@ distribute_dofs (const FiniteElement<dim,spacedim> &ff,
 
                                    // hand things off to the policy
   number_cache = policy->distribute_dofs (offset,
-                                          *this);
+                                                             *this);
 
                                    // initialize the block info object
                                    // only if this is a sequential
@@ -1688,6 +2027,53 @@ distribute_dofs (const FiniteElement<dim,spacedim> &ff,
 }
 
 
+template<int dim, int spacedim>
+void DoFHandler<dim, spacedim>::distribute_mg_dofs (const FiniteElement<dim, spacedim>& fe, const unsigned int offset) {
+  Assert ((dynamic_cast<const parallel::distributed::Triangulation<dim, spacedim>*> (&*tria) == 0), ExcMessage ("Invalid triangulation"));
+  distribute_dofs (fe);
+  reserve_space ();
+  
+  const unsigned int& n_levels = (*tria).n_levels ();
+  
+  mg_used_dofs.resize (n_levels, 0);
+  
+  std::vector<bool> user_flags;
+  
+  (*tria).save_user_flags (user_flags);
+  const_cast<Triangulation<dim, spacedim>&>(*tria).clear_user_flags ();
+  
+  for (unsigned int level = 0; level < n_levels; ++level) {
+    unsigned int next_free_dof = offset;
+    
+    for (cell_iterator cell = begin (level); cell != end (level); ++cell)
+      next_free_dof = internal::DoFHandler::Implementation::distribute_dofs_on_cell<spacedim> (cell, next_free_dof);
+    
+    mg_used_dofs[level] = next_free_dof;
+  }
+  
+  const_cast<Triangulation<dim, spacedim>&>(*tria).load_user_flags (user_flags);
+  block_info_object.initialize (*this, true, true);
+}
+
+template<int dim, int spacedim>
+void DoFHandler<dim, spacedim>::reserve_space () {
+  internal::DoFHandler::Implementation::reserve_space_mg (*this);
+}
+
+template<int dim, int spacedim>
+void DoFHandler<dim, spacedim>::clear_mg_space () {
+  for (unsigned int i = 0; i < mg_levels.size (); ++i)
+    delete mg_levels[i];
+  
+  mg_levels.clear ();
+  delete mg_faces;
+  mg_faces = NULL;
+  
+  std::vector<MGVertexDoFs> tmp;
+  
+  std::swap (mg_vertex_dofs, tmp);
+}
+
 
 template<int dim, int spacedim>
 void DoFHandler<dim,spacedim>::initialize_local_block_info ()
@@ -1705,6 +2091,7 @@ void DoFHandler<dim,spacedim>::clear ()
 
                                    // release memory
   clear_space ();
+  clear_mg_space ();
 }
 
 
@@ -1715,7 +2102,7 @@ DoFHandler<dim,spacedim>::
 renumber_dofs (const std::vector<unsigned int> &new_numbers)
 {
   Assert (new_numbers.size() == n_locally_owned_dofs(),
-          ExcRenumberingIncomplete());
+             ExcRenumberingIncomplete());
 
 #ifdef DEBUG
                                    // assert that the new indices are
@@ -1734,12 +2121,12 @@ renumber_dofs (const std::vector<unsigned int> &new_numbers)
       std::vector<unsigned int>::const_iterator p = tmp.begin();
       unsigned int                         i = 0;
       for (; p!=tmp.end(); ++p, ++i)
-        Assert (*p == i, ExcNewNumbersNotConsecutive(i));
+           Assert (*p == i, ExcNewNumbersNotConsecutive(i));
     }
   else
     for (unsigned int i=0; i<new_numbers.size(); ++i)
       Assert (new_numbers[i] < n_dofs(),
-              ExcMessage ("New DoF index is not less than the total number of dofs."));
+                 ExcMessage ("New DoF index is not less than the total number of dofs."));
 #endif
 
   number_cache = policy->renumber_dofs (new_numbers, *this);
@@ -1763,10 +2150,10 @@ DoFHandler<dim,spacedim>::max_couplings_between_boundary_dofs () const
   switch (dim)
     {
       case 1:
-            return get_fe().dofs_per_vertex;
+               return get_fe().dofs_per_vertex;
       case 2:
-            return (3*get_fe().dofs_per_vertex +
-                    2*get_fe().dofs_per_line);
+               return (3*get_fe().dofs_per_vertex +
+                           2*get_fe().dofs_per_line);
       case 3:
                                              // we need to take refinement of
                                              // one boundary face into
@@ -1780,16 +2167,16 @@ DoFHandler<dim,spacedim>::max_couplings_between_boundary_dofs () const
                                              // this assumption is not
                                              // justified and needs to be
                                              // fixed some time. fortunately,
-                                             // omitting it for now does no
+                                             // ommitting it for now does no
                                              // harm since the matrix will cry
                                              // foul if its requirements are
                                              // not satisfied
-            return (19*get_fe().dofs_per_vertex +
-                    28*get_fe().dofs_per_line +
-                    8*get_fe().dofs_per_quad);
+               return (19*get_fe().dofs_per_vertex +
+                           28*get_fe().dofs_per_line +
+                           8*get_fe().dofs_per_quad);
       default:
-            Assert (false, ExcNotImplemented());
-            return numbers::invalid_unsigned_int;
+               Assert (false, ExcNotImplemented());
+               return numbers::invalid_unsigned_int;
     }
 }
 
@@ -1809,6 +2196,72 @@ void DoFHandler<dim,spacedim>::clear_space ()
   std::swap (vertex_dofs, tmp);
 }
 
+template<int dim, int spacedim>
+template<int structdim>
+unsigned int DoFHandler<dim, spacedim>::get_dof_index (const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index) const {
+  return internal::DoFHandler::Implementation::get_dof_index (*this, *this->mg_levels[obj_level], *this->mg_faces, obj_index, fe_index, local_index, internal::int2type<structdim> ());
+}
+
+template<int dim, int spacedim>
+template<int structdim>
+void DoFHandler<dim, spacedim>::set_dof_index (const unsigned int obj_level, const unsigned int obj_index, const unsigned int fe_index, const unsigned int local_index, const unsigned int global_index) const {
+  internal::DoFHandler::Implementation::set_dof_index (*this, *this->mg_levels[obj_level], *this->mg_faces, obj_index, fe_index, local_index, global_index, internal::int2type<structdim> ());
+}
+
+template<int dim, int spacedim>
+DoFHandler<dim, spacedim>::MGVertexDoFs::MGVertexDoFs (): coarsest_level (numbers::invalid_unsigned_int), finest_level (0), indices (0), indices_offset (0) {
+}
+
+template<int dim, int spacedim>
+DoFHandler<dim, spacedim>::MGVertexDoFs::~MGVertexDoFs () {
+  delete[] indices;
+  delete[] indices_offset;
+}
+
+template<int dim, int spacedim>
+void DoFHandler<dim, spacedim>::MGVertexDoFs::init (const unsigned int cl, const unsigned int fl, const unsigned int dofs_per_vertex) {
+  if (indices != 0) {
+    delete[] indices;
+    indices = 0;
+  }
+  
+  if (indices_offset != 0) {
+    delete[] indices_offset;
+    indices_offset = 0;
+  }
+  
+  coarsest_level = cl;
+  finest_level = fl;
+  
+  if (cl > fl)
+    return;
+  
+  const unsigned int n_levels = finest_level - coarsest_level + 1;
+  const unsigned int n_indices = n_levels * dofs_per_vertex;
+  
+  indices = new unsigned int[n_indices];
+  Assert (indices != 0, ExcNoMemory ());
+  
+  for (unsigned int i = 0; i < n_indices; ++i)
+    indices[i] = DoFHandler<dim, spacedim>::invalid_dof_index;
+  
+  indices_offset = new unsigned int[n_levels];
+  Assert (indices != 0, ExcNoMemory ());
+  
+  for (unsigned int i = 0; i < n_levels; ++i)
+    indices_offset[i] = i * dofs_per_vertex;
+}
+
+template<int dim, int spacedim>
+unsigned int DoFHandler<dim, spacedim>::MGVertexDoFs::get_coarsest_level () const {
+  return coarsest_level;
+}
+
+template<int dim, int spacedim>
+unsigned int DoFHandler<dim, spacedim>::MGVertexDoFs::get_finest_level () const {
+  return finest_level;
+}
+
 
 /*-------------- Explicit Instantiations -------------------------------*/
 #include "dof_handler.inst"
index 68d86b942362590f93c2dce37d98f5b030a48377..d68a703e7a5072c9ddc9c3e2994fbc5b8edcad04 100644 (file)
@@ -31,7 +31,115 @@ for (deal_II_dimension : DIMENSIONS)
 
 #if deal_II_dimension == 3
     template class DoFHandler<1,deal_II_dimension>;
+    
+    template
+    unsigned int
+    DoFHandler<1,3>::
+    get_dof_index<1> (const unsigned int       obj_level,
+                             const unsigned int       obj_index,
+                             const unsigned int       fe_index,
+                             const unsigned int       local_index) const;
 #endif
 
+template
+unsigned int
+DoFHandler<deal_II_dimension,deal_II_dimension>::
+get_dof_index<1> (const unsigned int       obj_level,
+                 const unsigned int       obj_index,
+                 const unsigned int       fe_index,
+                 const unsigned int       local_index) const;
+
+#if deal_II_dimension < 3
+template
+unsigned int
+DoFHandler<deal_II_dimension,deal_II_dimension+1>::
+get_dof_index<1> (const unsigned int       obj_level,
+                 const unsigned int       obj_index,
+                 const unsigned int       fe_index,
+                 const unsigned int       local_index) const;
+#endif
+
+#if deal_II_dimension >= 2
+template
+unsigned int
+DoFHandler<deal_II_dimension,deal_II_dimension>::
+get_dof_index<2> (const unsigned int       obj_level,
+                 const unsigned int       obj_index,
+                 const unsigned int       fe_index,
+                 const unsigned int       local_index) const;
+
+#if deal_II_dimension < 3
+template
+unsigned int
+DoFHandler<deal_II_dimension,deal_II_dimension+1>::
+get_dof_index<2> (const unsigned int       obj_level,
+                 const unsigned int       obj_index,
+                 const unsigned int       fe_index,
+                 const unsigned int       local_index) const;
+#endif
+
+#if deal_II_dimension >= 3
+template
+unsigned int
+DoFHandler<deal_II_dimension,deal_II_dimension>::
+get_dof_index<3> (const unsigned int       obj_level,
+                 const unsigned int       obj_index,
+                 const unsigned int       fe_index,
+                 const unsigned int       local_index) const;
+#endif
+#endif
+
+template
+void
+DoFHandler<deal_II_dimension,deal_II_dimension>::
+set_dof_index<1> (const unsigned int       obj_level,
+                 const unsigned int       obj_index,
+                 const unsigned int       fe_index,
+                 const unsigned int       local_index,
+                 const unsigned int       global_index) const;
+
+#if deal_II_dimension < 3
+template
+void
+DoFHandler<deal_II_dimension,deal_II_dimension+1>::
+set_dof_index<1> (const unsigned int       obj_level,
+                 const unsigned int       obj_index,
+                 const unsigned int       fe_index,
+                 const unsigned int       local_index,
+                 const unsigned int       global_index) const;
+#endif
+
+#if deal_II_dimension >= 2
+template
+void
+DoFHandler<deal_II_dimension,deal_II_dimension>::
+set_dof_index<2> (const unsigned int       obj_level,
+                 const unsigned int       obj_index,
+                 const unsigned int       fe_index,
+                 const unsigned int       local_index,
+                 const unsigned int       global_index) const;
+
+#if deal_II_dimension < 3
+template
+void
+DoFHandler<deal_II_dimension,deal_II_dimension+1>::
+set_dof_index<2> (const unsigned int       obj_level,
+                 const unsigned int       obj_index,
+                 const unsigned int       fe_index,
+                 const unsigned int       local_index,
+                 const unsigned int       global_index) const;
+#endif
+
+#if deal_II_dimension >= 3
+template
+void
+DoFHandler<deal_II_dimension,deal_II_dimension>::
+set_dof_index<3> (const unsigned int       obj_level,
+                 const unsigned int       obj_index,
+                 const unsigned int       fe_index,
+                 const unsigned int       local_index,
+                 const unsigned int       global_index) const;
+#endif
+#endif
   }
 
index 891c69ef93753079a765d6ccc0424228a907b2a9..99636b0faacb376fdf5665c72724a358319d35a9 100644 (file)
@@ -57,17 +57,17 @@ namespace DoFTools
   template <class DH, class SparsityPattern>
   void
   make_sparsity_pattern (const DH               &dof,
-                         SparsityPattern        &sparsity,
-                         const ConstraintMatrix &constraints,
-                         const bool              keep_constrained_dofs,
-                         const types::subdomain_id_t subdomain_id)
+                                    SparsityPattern        &sparsity,
+                                    const ConstraintMatrix &constraints,
+                                    const bool              keep_constrained_dofs,
+                                    const types::subdomain_id_t subdomain_id)
   {
     const unsigned int n_dofs = dof.n_dofs();
 
     Assert (sparsity.n_rows() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
     Assert (sparsity.n_cols() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
 
                                      // If we have a distributed::Triangulation only
                                      // allow locally_owned subdomain. Not setting a
@@ -80,13 +80,13 @@ namespace DoFTools
       ||
       (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;
     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
@@ -95,23 +95,23 @@ namespace DoFTools
                                      // processor. Otherwise, just continue.
     for (; cell!=endc; ++cell)
       if (((subdomain_id == types::invalid_subdomain_id)
-           ||
-           (subdomain_id == cell->subdomain_id()))
-          &&
+              ||
+              (subdomain_id == cell->subdomain_id()))
+             &&
           cell->is_locally_owned())
-        {
-          const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
-          dofs_on_this_cell.resize (dofs_per_cell);
-          cell->get_dof_indices (dofs_on_this_cell);
+           {
+             const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
+             dofs_on_this_cell.resize (dofs_per_cell);
+             cell->get_dof_indices (dofs_on_this_cell);
 
                                            // make sparsity pattern for this
                                            // cell. if no constraints pattern was
                                            // given, then the following call acts
                                            // as if simply no constraints existed
-          constraints.add_entries_local_to_global (dofs_on_this_cell,
-                                                   sparsity,
-                                                   keep_constrained_dofs);
-        }
+             constraints.add_entries_local_to_global (dofs_on_this_cell,
+                                                                          sparsity,
+                                                                          keep_constrained_dofs);
+           }
   }
 
 
@@ -119,22 +119,22 @@ namespace DoFTools
   template <class DH, class SparsityPattern>
   void
   make_sparsity_pattern (const DH                &dof,
-                         const Table<2,Coupling> &couplings,
-                         SparsityPattern         &sparsity,
-                         const ConstraintMatrix  &constraints,
-                         const bool               keep_constrained_dofs,
-                         const types::subdomain_id_t subdomain_id)
+                                    const Table<2,Coupling> &couplings,
+                                    SparsityPattern         &sparsity,
+                                    const ConstraintMatrix  &constraints,
+                                    const bool               keep_constrained_dofs,
+                                    const types::subdomain_id_t subdomain_id)
   {
     const unsigned int n_dofs = dof.n_dofs();
 
     Assert (sparsity.n_rows() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
     Assert (sparsity.n_cols() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
     Assert (couplings.n_rows() == dof.get_fe().n_components(),
-            ExcDimensionMismatch(couplings.n_rows(), dof.get_fe().n_components()));
+               ExcDimensionMismatch(couplings.n_rows(), dof.get_fe().n_components()));
     Assert (couplings.n_cols() == dof.get_fe().n_components(),
-            ExcDimensionMismatch(couplings.n_cols(), dof.get_fe().n_components()));
+               ExcDimensionMismatch(couplings.n_cols(), dof.get_fe().n_components()));
 
                                      // If we have a distributed::Triangulation only
                                      // allow locally_owned subdomain. Not setting a
@@ -147,8 +147,8 @@ namespace DoFTools
       ||
       (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."));
 
     const hp::FECollection<DH::dimension,DH::space_dimension> fe_collection (dof.get_fe());
 
@@ -169,51 +169,51 @@ namespace DoFTools
     bool need_dof_mask = false;
     for (unsigned int i=0; i<couplings.n_rows(); ++i)
       for (unsigned int j=0; j<couplings.n_cols(); ++j)
-        if (couplings(i,j) == none)
-          need_dof_mask = true;
+           if (couplings(i,j) == none)
+             need_dof_mask = true;
 
     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
+                           = (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);
+                       }
+           }
 
 
     std::vector<unsigned int> 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
@@ -222,27 +222,27 @@ namespace DoFTools
                                      // processor. Otherwise, just continue.
     for (; cell!=endc; ++cell)
       if (((subdomain_id == types::invalid_subdomain_id)
-           ||
-           (subdomain_id == cell->subdomain_id()))
-          &&
+              ||
+              (subdomain_id == cell->subdomain_id()))
+             &&
           cell->is_locally_owned())
-        {
-          const unsigned int fe_index = cell->active_fe_index();
-          const unsigned int dofs_per_cell =fe_collection[fe_index].dofs_per_cell;
+           {
+             const unsigned int fe_index = cell->active_fe_index();
+             const unsigned int dofs_per_cell =fe_collection[fe_index].dofs_per_cell;
 
-          dofs_on_this_cell.resize (dofs_per_cell);
-          cell->get_dof_indices (dofs_on_this_cell);
+             dofs_on_this_cell.resize (dofs_per_cell);
+             cell->get_dof_indices (dofs_on_this_cell);
 
 
                                            // make sparsity pattern for this
                                            // cell. if no constraints pattern was
                                            // given, then the following call acts
                                            // as if simply no constraints existed
-          constraints.add_entries_local_to_global (dofs_on_this_cell,
-                                                   sparsity,
-                                                   keep_constrained_dofs,
-                                                   dof_mask[fe_index]);
-        }
+             constraints.add_entries_local_to_global (dofs_on_this_cell,
+                                                                          sparsity,
+                                                                          keep_constrained_dofs,
+                                                                          dof_mask[fe_index]);
+           }
   }
 
 
@@ -258,9 +258,9 @@ namespace DoFTools
     const unsigned int n_dofs_col = dof_col.n_dofs();
 
     Assert (sparsity.n_rows() == n_dofs_row,
-            ExcDimensionMismatch (sparsity.n_rows(), n_dofs_row));
+               ExcDimensionMismatch (sparsity.n_rows(), n_dofs_row));
     Assert (sparsity.n_cols() == n_dofs_col,
-            ExcDimensionMismatch (sparsity.n_cols(), n_dofs_col));
+               ExcDimensionMismatch (sparsity.n_cols(), n_dofs_col));
 
 
     const std::list<std::pair<typename DH::cell_iterator,
@@ -276,74 +276,74 @@ namespace DoFTools
 
     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;
+           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<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());
+                 }
+             }
       }
   }
 
@@ -362,14 +362,14 @@ namespace DoFTools
                                          // indicators in 1d, so it is no
                                          // performance problem to call the
                                          // other function
-        typename DH::FunctionMap boundary_indicators;
-        boundary_indicators[0] = 0;
-        boundary_indicators[1] = 0;
-        make_boundary_sparsity_pattern<DH, SparsityPattern> (dof,
-                                                             boundary_indicators,
-                                                             dof_to_boundary_mapping,
-                                                             sparsity);
-        return;
+           typename DH::FunctionMap boundary_indicators;
+           boundary_indicators[0] = 0;
+           boundary_indicators[1] = 0;
+           make_boundary_sparsity_pattern<DH, SparsityPattern> (dof,
+                                                                                        boundary_indicators,
+                                                                                        dof_to_boundary_mapping,
+                                                                                        sparsity);
+           return;
       }
 
     const unsigned int n_dofs = dof.n_dofs();
@@ -380,13 +380,13 @@ namespace DoFTools
 #ifdef DEBUG
     if (sparsity.n_rows() != 0)
       {
-        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);
+           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);
       };
 #endif
 
@@ -404,22 +404,22 @@ namespace DoFTools
                                      // and so every boundary line is
                                      // also part of a boundary face.
     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 (cell->at_boundary(f))
-          {
-            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 (cell->at_boundary(f))
+             {
+               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]]);
+             }
   }
 
 
@@ -435,82 +435,82 @@ namespace DoFTools
       {
                                          // first check left, then right
                                          // boundary point
-        for (unsigned int direction=0; direction<2; ++direction)
-          {
+           for (unsigned int direction=0; direction<2; ++direction)
+             {
                                              // if this boundary is not
                                              // requested, then go on with next one
-            if (boundary_indicators.find(direction) ==
-                boundary_indicators.end())
-              continue;
+               if (boundary_indicators.find(direction) ==
+                       boundary_indicators.end())
+                 continue;
 
                                              // 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<unsigned int> 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);
 
                                              // next get boundary mapped dof
                                              // indices of boundary dofs
-            for (unsigned int i=0; i<dofs_per_vertex; ++i)
-              boundary_dof_boundary_indices[i]
-                = dof_to_boundary_mapping[cell->vertex_dof_index(direction,i)];
-
-            for (unsigned int i=0; i<dofs_per_vertex; ++i)
-              sparsity.add_entries (boundary_dof_boundary_indices[i],
-                                    boundary_dof_boundary_indices.begin(),
-                                    boundary_dof_boundary_indices.end());
-          };
-        return;
+               for (unsigned int i=0; i<dofs_per_vertex; ++i)
+                 boundary_dof_boundary_indices[i]
+                       = dof_to_boundary_mapping[cell->vertex_dof_index(direction,i)];
+
+               for (unsigned int i=0; i<dofs_per_vertex; ++i)
+                 sparsity.add_entries (boundary_dof_boundary_indices[i],
+                                                   boundary_dof_boundary_indices.begin(),
+                                                   boundary_dof_boundary_indices.end());
+             };
+           return;
       }
 
     const unsigned int n_dofs = dof.n_dofs();
 
     AssertDimension (dof_to_boundary_mapping.size(), n_dofs);
     Assert (boundary_indicators.find(types::internal_face_boundary_id) == boundary_indicators.end(),
-            typename DH::ExcInvalidBoundaryIndicator());
+               typename DH::ExcInvalidBoundaryIndicator());
     Assert (sparsity.n_rows() == dof.n_boundary_dofs (boundary_indicators),
-            ExcDimensionMismatch (sparsity.n_rows(), dof.n_boundary_dofs (boundary_indicators)));
+               ExcDimensionMismatch (sparsity.n_rows(), dof.n_boundary_dofs (boundary_indicators)));
     Assert (sparsity.n_cols() == dof.n_boundary_dofs (boundary_indicators),
-            ExcDimensionMismatch (sparsity.n_cols(), dof.n_boundary_dofs (boundary_indicators)));
+               ExcDimensionMismatch (sparsity.n_cols(), dof.n_boundary_dofs (boundary_indicators)));
 #ifdef DEBUG
     if (sparsity.n_rows() != 0)
       {
-        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);
+           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);
       };
 #endif
 
     std::vector<unsigned int> 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]]);
+             }
   }
 
 
@@ -518,9 +518,9 @@ namespace DoFTools
   template <class DH, class SparsityPattern>
   void
   make_flux_sparsity_pattern (const DH        &dof,
-                              SparsityPattern &sparsity,
-                              const ConstraintMatrix &constraints,
-                              const bool              keep_constrained_dofs,
+                                         SparsityPattern &sparsity,
+                                         const ConstraintMatrix &constraints,
+                                         const bool              keep_constrained_dofs,
                               const types::subdomain_id_t subdomain_id)
   {
     const unsigned int n_dofs = dof.n_dofs();
@@ -539,15 +539,15 @@ namespace DoFTools
       ||
       (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;
     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(),
-                                      endc = dof.end();
+                                                     endc = dof.end();
 
                                      // TODO: in an old implementation, we used
                                      // user flags before to tag faces that were
@@ -563,57 +563,57 @@ namespace DoFTools
                                      // processor. Otherwise, just continue.
     for (; cell!=endc; ++cell)
       if (((subdomain_id == types::invalid_subdomain_id)
-           ||
-           (subdomain_id == cell->subdomain_id()))
+              ||
+              (subdomain_id == cell->subdomain_id()))
           &&
           cell->is_locally_owned())
-        {
-          const unsigned int n_dofs_on_this_cell = cell->get_fe().dofs_per_cell;
-          dofs_on_this_cell.resize (n_dofs_on_this_cell);
-          cell->get_dof_indices (dofs_on_this_cell);
+           {
+             const unsigned int n_dofs_on_this_cell = cell->get_fe().dofs_per_cell;
+             dofs_on_this_cell.resize (n_dofs_on_this_cell);
+             cell->get_dof_indices (dofs_on_this_cell);
 
                                            // make sparsity pattern for this
                                            // cell. if no constraints pattern was
                                            // given, then the following call acts
                                            // as if simply no constraints existed
-          constraints.add_entries_local_to_global (dofs_on_this_cell,
-                                                   sparsity,
-                                                   keep_constrained_dofs);
-
-          for (unsigned int face = 0;
-               face < GeometryInfo<DH::dimension>::faces_per_cell;
-               ++face)
-            {
-              typename DH::face_iterator cell_face = cell->face(face);
-              if (! cell->at_boundary(face) )
-                {
-                  typename DH::cell_iterator neighbor = cell->neighbor(face);
-
-                  if (cell_face->has_children())
-                    {
-                      for (unsigned int sub_nr = 0;
-                           sub_nr != cell_face->number_of_children();
-                           ++sub_nr)
-                        {
-                          const typename DH::cell_iterator
-                            sub_neighbor
-                            = cell->neighbor_child_on_subface (face, sub_nr);
-
-                          const unsigned int n_dofs_on_neighbor
-                            = sub_neighbor->get_fe().dofs_per_cell;
-                          dofs_on_other_cell.resize (n_dofs_on_neighbor);
-                          sub_neighbor->get_dof_indices (dofs_on_other_cell);
-
-                          constraints.add_entries_local_to_global
-                            (dofs_on_this_cell, dofs_on_other_cell,
-                             sparsity, keep_constrained_dofs);
-                          constraints.add_entries_local_to_global
-                            (dofs_on_other_cell, dofs_on_this_cell,
-                             sparsity, keep_constrained_dofs);
-                        }
-                    }
-                  else
-                    {
+             constraints.add_entries_local_to_global (dofs_on_this_cell,
+                                                                          sparsity,
+                                                                          keep_constrained_dofs);
+
+             for (unsigned int face = 0;
+                  face < GeometryInfo<DH::dimension>::faces_per_cell;
+                  ++face)
+               {
+                 typename DH::face_iterator cell_face = cell->face(face);
+                 if (! cell->at_boundary(face) )
+                       {
+                         typename DH::cell_iterator neighbor = cell->neighbor(face);
+
+                         if (cell_face->has_children())
+                           {
+                             for (unsigned int sub_nr = 0;
+                                      sub_nr != cell_face->number_of_children();
+                                      ++sub_nr)
+                                   {
+                                     const typename DH::cell_iterator
+                                       sub_neighbor
+                                       = cell->neighbor_child_on_subface (face, sub_nr);
+
+                                     const unsigned int n_dofs_on_neighbor
+                                       = sub_neighbor->get_fe().dofs_per_cell;
+                                     dofs_on_other_cell.resize (n_dofs_on_neighbor);
+                                     sub_neighbor->get_dof_indices (dofs_on_other_cell);
+
+                                     constraints.add_entries_local_to_global
+                                       (dofs_on_this_cell, dofs_on_other_cell,
+                                        sparsity, keep_constrained_dofs);
+                                     constraints.add_entries_local_to_global
+                                       (dofs_on_other_cell, dofs_on_this_cell,
+                                        sparsity, keep_constrained_dofs);
+                                   }
+                           }
+                         else
+                           {
                                                        // Refinement edges are taken care of
                                                        // by coarser cells
 
@@ -621,32 +621,32 @@ namespace DoFTools
                                                        // the constraints when the neighbor cell is
                                                        // coarser, but only the current cell is owned
                                                        // locally!
-                      if (cell->neighbor_is_coarser(face))
-                        continue;
+                             if (cell->neighbor_is_coarser(face))
+                                   continue;
 
-                      const unsigned int n_dofs_on_neighbor
-                        = neighbor->get_fe().dofs_per_cell;
-                      dofs_on_other_cell.resize (n_dofs_on_neighbor);
+                             const unsigned int n_dofs_on_neighbor
+                                   = neighbor->get_fe().dofs_per_cell;
+                             dofs_on_other_cell.resize (n_dofs_on_neighbor);
 
-                      neighbor->get_dof_indices (dofs_on_other_cell);
+                             neighbor->get_dof_indices (dofs_on_other_cell);
 
-                      constraints.add_entries_local_to_global
-                        (dofs_on_this_cell, dofs_on_other_cell,
-                         sparsity, keep_constrained_dofs);
+                             constraints.add_entries_local_to_global
+                                   (dofs_on_this_cell, dofs_on_other_cell,
+                                    sparsity, keep_constrained_dofs);
 
                                                        // only need to add these in case the neighbor
                                                        // cell is not locally owned - otherwise, we
                                                        // touch each face twice and hence put the
                                                        // indices the other way around
-                      if (cell->neighbor(face)->subdomain_id() !=
-                          cell->subdomain_id())
-                        constraints.add_entries_local_to_global
-                          (dofs_on_other_cell, dofs_on_this_cell,
-                           sparsity, keep_constrained_dofs);
-                    }
-                }
-            }
-        }
+                             if (cell->neighbor(face)->subdomain_id() !=
+                                     cell->subdomain_id())
+                                   constraints.add_entries_local_to_global
+                                     (dofs_on_other_cell, dofs_on_this_cell,
+                                      sparsity, keep_constrained_dofs);
+                           }
+                       }
+               }
+           }
   }
 
 
@@ -669,11 +669,11 @@ namespace DoFTools
    const Table<2,Coupling> &component_couplings)
   {
     Assert(component_couplings.n_rows() == fe.n_components(),
-           ExcDimensionMismatch(component_couplings.n_rows(),
-                                fe.n_components()));
+              ExcDimensionMismatch(component_couplings.n_rows(),
+                                               fe.n_components()));
     Assert(component_couplings.n_cols() == fe.n_components(),
-           ExcDimensionMismatch(component_couplings.n_cols(),
-                                fe.n_components()));
+              ExcDimensionMismatch(component_couplings.n_cols(),
+                                               fe.n_components()));
 
     const unsigned int n_dofs = fe.dofs_per_cell;
 
@@ -681,34 +681,34 @@ namespace DoFTools
 
     for (unsigned int i=0; i<n_dofs; ++i)
       {
-        const unsigned int ii
-          = (fe.is_primitive(i) ?
-             fe.system_to_component_index(i).first
-             :
-             (std::find (fe.get_nonzero_components(i).begin(),
-                         fe.get_nonzero_components(i).end(),
-                         true)
-              -
-              fe.get_nonzero_components(i).begin())
-          );
-        Assert (ii < fe.n_components(), ExcInternalError());
-
-        for (unsigned int j=0; j<n_dofs; ++j)
-          {
-            const unsigned int jj
-              = (fe.is_primitive(j) ?
-                 fe.system_to_component_index(j).first
-                 :
-                 (std::find (fe.get_nonzero_components(j).begin(),
-                             fe.get_nonzero_components(j).end(),
-                             true)
-                  -
-                  fe.get_nonzero_components(j).begin())
-              );
-            Assert (jj < fe.n_components(), ExcInternalError());
-
-            dof_couplings(i,j) = component_couplings(ii,jj);
-          }
+           const unsigned int ii
+             = (fe.is_primitive(i) ?
+                fe.system_to_component_index(i).first
+                :
+                (std::find (fe.get_nonzero_components(i).begin(),
+                                    fe.get_nonzero_components(i).end(),
+                                    true)
+                 -
+                 fe.get_nonzero_components(i).begin())
+               );
+           Assert (ii < fe.n_components(), ExcInternalError());
+
+           for (unsigned int j=0; j<n_dofs; ++j)
+             {
+               const unsigned int jj
+                 = (fe.is_primitive(j) ?
+                        fe.system_to_component_index(j).first
+                        :
+                        (std::find (fe.get_nonzero_components(j).begin(),
+                                        fe.get_nonzero_components(j).end(),
+                                        true)
+                         -
+                         fe.get_nonzero_components(j).begin())
+                   );
+               Assert (jj < fe.n_components(), ExcInternalError());
+
+               dof_couplings(i,j) = component_couplings(ii,jj);
+             }
       }
     return dof_couplings;
   }
@@ -723,7 +723,7 @@ namespace DoFTools
     std::vector<Table<2,Coupling> > return_value (fe.size());
     for (unsigned int i=0; i<fe.size(); ++i)
       return_value[i]
-        = dof_couplings_from_component_couplings(fe[i], component_couplings);
+           = dof_couplings_from_component_couplings(fe[i], component_couplings);
 
     return return_value;
   }
@@ -742,230 +742,230 @@ namespace DoFTools
       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<unsigned int> dofs_on_this_cell(fe.dofs_per_cell);
-        std::vector<unsigned int> 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);
 
-        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 ();
+                                   }
+                           }
+                       }
             }
       }
 
@@ -976,9 +976,9 @@ namespace DoFTools
       template <int dim, int spacedim, class SparsityPattern>
       void
       make_flux_sparsity_pattern (const dealii::hp::DoFHandler<dim,spacedim> &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)
       {
                                          // while the implementation above is
                                          // quite optimized and caches a lot of
@@ -992,174 +992,174 @@ namespace DoFTools
                                          // 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<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<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));
 
-        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 ();
+                             }
+                         }
+                 }
+             }
       }
     }
 
@@ -1171,9 +1171,9 @@ namespace DoFTools
   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)
   {
                                      // do the error checking and frame code
                                      // here, and then pass on to more
@@ -1183,17 +1183,17 @@ namespace DoFTools
     const unsigned int n_comp = dof.get_fe().n_components();
 
     Assert (sparsity.n_rows() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
     Assert (sparsity.n_cols() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
     Assert (int_mask.n_rows() == n_comp,
-            ExcDimensionMismatch (int_mask.n_rows(), n_comp));
+               ExcDimensionMismatch (int_mask.n_rows(), n_comp));
     Assert (int_mask.n_cols() == n_comp,
-            ExcDimensionMismatch (int_mask.n_cols(), n_comp));
+               ExcDimensionMismatch (int_mask.n_cols(), n_comp));
     Assert (flux_mask.n_rows() == n_comp,
-            ExcDimensionMismatch (flux_mask.n_rows(), n_comp));
+               ExcDimensionMismatch (flux_mask.n_rows(), n_comp));
     Assert (flux_mask.n_cols() == n_comp,
-            ExcDimensionMismatch (flux_mask.n_cols(), n_comp));
+               ExcDimensionMismatch (flux_mask.n_cols(), n_comp));
 
 
                                      // Clear user flags because we will
@@ -1209,7 +1209,7 @@ namespace DoFTools
     const_cast<Triangulation<DH::dimension,DH::space_dimension> &>(dof.get_tria()).clear_user_flags ();
 
     internal::make_flux_sparsity_pattern (dof, sparsity,
-                                          int_mask, flux_mask);
+                                                             int_mask, flux_mask);
 
                                      // finally restore the user flags
     const_cast<Triangulation<DH::dimension,DH::space_dimension> &>(dof.get_tria()).load_user_flags(user_flags);
@@ -1228,14 +1228,14 @@ namespace DoFTools
       inline
       bool
       check_master_dof_list (const FullMatrix<double> &face_interpolation_matrix,
-                             const std::vector<unsigned int> &master_dof_list)
+                                        const std::vector<unsigned int> &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
@@ -1260,34 +1260,34 @@ namespace DoFTools
                                          // enough, or whether we have to
                                          // fear that the matrix is not
                                          // regular
-        double diagonal_sum = 0;
-        for (unsigned int i=0; i<N; ++i)
-          diagonal_sum += std::fabs(tmp(i,i));
-        const double typical_diagonal_element = diagonal_sum/N;
+           double diagonal_sum = 0;
+           for (unsigned int i=0; i<N; ++i)
+             diagonal_sum += std::fabs(tmp(i,i));
+           const double typical_diagonal_element = diagonal_sum/N;
 
                                          // initialize the array that holds
                                          // the permutations that we find
                                          // during pivot search
-        std::vector<unsigned int> p(N);
-        for (unsigned int i=0; i<N; ++i)
-          p[i] = i;
+           std::vector<unsigned int> p(N);
+           for (unsigned int i=0; i<N; ++i)
+             p[i] = i;
 
-        for (unsigned int j=0; j<N; ++j)
-          {
+           for (unsigned int j=0; j<N; ++j)
+             {
                                              // pivot search: search that
                                              // part of the line on and
                                              // right of the diagonal for
                                              // the largest element
-            double       max = std::fabs(tmp(j,j));
-            unsigned int r   = j;
-            for (unsigned int i=j+1; i<N; ++i)
-              {
-                if (std::fabs(tmp(i,j)) > max)
-                  {
-                    max = std::fabs(tmp(i,j));
-                    r = i;
-                  }
-              }
+               double       max = std::fabs(tmp(j,j));
+               unsigned int r   = j;
+               for (unsigned int i=j+1; i<N; ++i)
+                 {
+                       if (std::fabs(tmp(i,j)) > max)
+                         {
+                           max = std::fabs(tmp(i,j));
+                           r = i;
+                         }
+                 }
                                              // check whether the
                                              // pivot is too small. if
                                              // that is the case, then
@@ -1295,44 +1295,44 @@ namespace DoFTools
                                              // and we shouldn't use
                                              // this set of master
                                              // dofs
-            if (max < 1.e-12*typical_diagonal_element)
-              return false;
+               if (max < 1.e-12*typical_diagonal_element)
+                 return false;
 
                                              // row interchange
-            if (r>j)
-              {
-                for (unsigned int k=0; k<N; ++k)
-                  std::swap (tmp(j,k), tmp(r,k));
+               if (r>j)
+                 {
+                       for (unsigned int k=0; k<N; ++k)
+                         std::swap (tmp(j,k), tmp(r,k));
 
-                std::swap (p[j], p[r]);
-              }
+                       std::swap (p[j], p[r]);
+                 }
 
                                              // transformation
-            const double hr = 1./tmp(j,j);
-            tmp(j,j) = hr;
-            for (unsigned int k=0; k<N; ++k)
-              {
-                if (k==j) continue;
-                for (unsigned int i=0; i<N; ++i)
-                  {
-                    if (i==j) continue;
-                    tmp(i,k) -= tmp(i,j)*tmp(j,k)*hr;
-                  }
-              }
-            for (unsigned int i=0; i<N; ++i)
-              {
-                tmp(i,j) *= hr;
-                tmp(j,i) *= -hr;
-              }
-            tmp(j,j) = hr;
-          }
+               const double hr = 1./tmp(j,j);
+               tmp(j,j) = hr;
+               for (unsigned int k=0; k<N; ++k)
+                 {
+                       if (k==j) continue;
+                       for (unsigned int i=0; i<N; ++i)
+                         {
+                           if (i==j) continue;
+                           tmp(i,k) -= tmp(i,j)*tmp(j,k)*hr;
+                         }
+                 }
+               for (unsigned int i=0; i<N; ++i)
+                 {
+                       tmp(i,j) *= hr;
+                       tmp(j,i) *= -hr;
+                 }
+               tmp(j,j) = hr;
+             }
 
                                          // everything went fine, so
                                          // we can accept this set of
                                          // master dofs (at least as
                                          // far as they have already
                                          // been collected)
-        return true;
+           return true;
       }
 
 
@@ -1378,22 +1378,22 @@ namespace DoFTools
       template <int dim, int spacedim>
       void
       select_master_dofs_for_face_restriction (const FiniteElement<dim,spacedim> &fe1,
-                                               const FiniteElement<dim,spacedim> &fe2,
-                                               const FullMatrix<double> &face_interpolation_matrix,
-                                               std::vector<bool>        &master_dof_mask)
+                                                                  const FiniteElement<dim,spacedim> &fe2,
+                                                                  const FullMatrix<double> &face_interpolation_matrix,
+                                                                  std::vector<bool>        &master_dof_mask)
       {
-        Assert (fe1.dofs_per_face >= fe2.dofs_per_face,
-                ExcInternalError());
-        AssertDimension (master_dof_mask.size(), fe1.dofs_per_face);
-
-        Assert (fe2.dofs_per_vertex <= fe1.dofs_per_vertex,
-                ExcInternalError());
-        Assert (fe2.dofs_per_line <= fe1.dofs_per_line,
-                ExcInternalError());
-        Assert ((dim < 3)
-                ||
-                (fe2.dofs_per_quad <= fe1.dofs_per_quad),
-                ExcInternalError());
+           Assert (fe1.dofs_per_face >= fe2.dofs_per_face,
+                       ExcInternalError());
+           AssertDimension (master_dof_mask.size(), fe1.dofs_per_face);
+
+           Assert (fe2.dofs_per_vertex <= fe1.dofs_per_vertex,
+                       ExcInternalError());
+           Assert (fe2.dofs_per_line <= fe1.dofs_per_line,
+                       ExcInternalError());
+           Assert ((dim < 3)
+                       ||
+                       (fe2.dofs_per_quad <= fe1.dofs_per_quad),
+                       ExcInternalError());
 
                                          // the idea here is to designate as
                                          // many DoFs in fe1 per object
@@ -1431,16 +1431,16 @@ namespace DoFTools
                                          // the other one. this latter case
                                          // shows up when running
                                          // hp/hp_constraints_q_system_06
-        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<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)
+                 {
                                                  // make sure that we
                                                  // were able to find
                                                  // a set of master
@@ -1448,20 +1448,20 @@ namespace DoFTools
                                                  // code down below
                                                  // didn't just reject
                                                  // all our efforts
-                Assert (i < fe1.dofs_per_vertex,
-                        ExcInternalError());
+                       Assert (i < fe1.dofs_per_vertex,
+                                   ExcInternalError());
                                                  // tentatively push
                                                  // this vertex dof
-                master_dof_list.push_back (index+i);
+                       master_dof_list.push_back (index+i);
 
                                                  // then see what
                                                  // happens. if it
                                                  // succeeds, fine
-                if (check_master_dof_list (face_interpolation_matrix,
-                                           master_dof_list)
-                    == true)
-                  ++dofs_added;
-                else
+                       if (check_master_dof_list (face_interpolation_matrix,
+                                                              master_dof_list)
+                           == true)
+                         ++dofs_added;
+                       else
                                                    // well, it
                                                    // didn't. simply
                                                    // pop that dof
@@ -1469,74 +1469,74 @@ namespace DoFTools
                                                    // again and try
                                                    // with the next
                                                    // dof
-                  master_dof_list.pop_back ();
+                         master_dof_list.pop_back ();
 
                                                  // forward counter by
                                                  // one
-                ++i;
-              }
-            index += fe1.dofs_per_vertex;
-          }
+                       ++i;
+                 }
+               index += fe1.dofs_per_vertex;
+             }
 
-        for (int l=0;
-             l<static_cast<signed int>(GeometryInfo<dim>::lines_per_face);
-             ++l)
-          {
+           for (int l=0;
+                l<static_cast<signed int>(GeometryInfo<dim>::lines_per_face);
+                ++l)
+             {
                                              // same algorithm as above
-            unsigned int dofs_added = 0;
-            unsigned int i          = 0;
-            while (dofs_added < fe2.dofs_per_line)
-              {
-                Assert (i < fe1.dofs_per_line,
-                        ExcInternalError());
-
-                master_dof_list.push_back (index+i);
-                if (check_master_dof_list (face_interpolation_matrix,
-                                           master_dof_list)
-                    == true)
-                  ++dofs_added;
-                else
-                  master_dof_list.pop_back ();
-
-                ++i;
-              }
-            index += fe1.dofs_per_line;
-          }
+               unsigned int dofs_added = 0;
+               unsigned int i          = 0;
+               while (dofs_added < fe2.dofs_per_line)
+                 {
+                       Assert (i < fe1.dofs_per_line,
+                                   ExcInternalError());
+
+                       master_dof_list.push_back (index+i);
+                       if (check_master_dof_list (face_interpolation_matrix,
+                                                              master_dof_list)
+                           == true)
+                         ++dofs_added;
+                       else
+                         master_dof_list.pop_back ();
+
+                       ++i;
+                 }
+               index += fe1.dofs_per_line;
+             }
 
-        for (int q=0;
-             q<static_cast<signed int>(GeometryInfo<dim>::quads_per_face);
-             ++q)
-          {
+           for (int q=0;
+                q<static_cast<signed int>(GeometryInfo<dim>::quads_per_face);
+                ++q)
+             {
                                              // same algorithm as above
-            unsigned int dofs_added = 0;
-            unsigned int i          = 0;
-            while (dofs_added < fe2.dofs_per_quad)
-              {
-                Assert (i < fe1.dofs_per_quad,
-                        ExcInternalError());
-
-                master_dof_list.push_back (index+i);
-                if (check_master_dof_list (face_interpolation_matrix,
-                                           master_dof_list)
-                    == true)
-                  ++dofs_added;
-                else
-                  master_dof_list.pop_back ();
-
-                ++i;
-              }
-            index += fe1.dofs_per_quad;
-          }
+               unsigned int dofs_added = 0;
+               unsigned int i          = 0;
+               while (dofs_added < fe2.dofs_per_quad)
+                 {
+                       Assert (i < fe1.dofs_per_quad,
+                                   ExcInternalError());
+
+                       master_dof_list.push_back (index+i);
+                       if (check_master_dof_list (face_interpolation_matrix,
+                                                              master_dof_list)
+                           == true)
+                         ++dofs_added;
+                       else
+                         master_dof_list.pop_back ();
+
+                       ++i;
+                 }
+               index += fe1.dofs_per_quad;
+             }
 
-        AssertDimension (index, fe1.dofs_per_face);
-        AssertDimension (master_dof_list.size(), fe2.dofs_per_face);
+           AssertDimension (index, fe1.dofs_per_face);
+           AssertDimension (master_dof_list.size(), fe2.dofs_per_face);
 
                                          // finally copy the list into the
                                          // mask
-        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<unsigned int>::const_iterator i=master_dof_list.begin();
+                i!=master_dof_list.end(); ++i)
+             master_dof_mask[*i] = true;
       }
 
 
@@ -1550,19 +1550,19 @@ namespace DoFTools
       template <int dim, int spacedim>
       void
       ensure_existence_of_master_dof_mask (const FiniteElement<dim,spacedim> &fe1,
-                                           const FiniteElement<dim,spacedim> &fe2,
-                                           const FullMatrix<double> &face_interpolation_matrix,
-                                           std_cxx1x::shared_ptr<std::vector<bool> > &master_dof_mask)
+                                                              const FiniteElement<dim,spacedim> &fe2,
+                                                              const FullMatrix<double> &face_interpolation_matrix,
+                                                              std_cxx1x::shared_ptr<std::vector<bool> > &master_dof_mask)
       {
-        if (master_dof_mask == std_cxx1x::shared_ptr<std::vector<bool> >())
-          {
-            master_dof_mask = std_cxx1x::shared_ptr<std::vector<bool> >
-                              (new std::vector<bool> (fe1.dofs_per_face));
-            select_master_dofs_for_face_restriction (fe1,
-                                                     fe2,
-                                                     face_interpolation_matrix,
-                                                     *master_dof_mask);
-          }
+           if (master_dof_mask == std_cxx1x::shared_ptr<std::vector<bool> >())
+             {
+               master_dof_mask = std_cxx1x::shared_ptr<std::vector<bool> >
+                                         (new std::vector<bool> (fe1.dofs_per_face));
+               select_master_dofs_for_face_restriction (fe1,
+                                                                            fe2,
+                                                                            face_interpolation_matrix,
+                                                                            *master_dof_mask);
+             }
       }
 
 
@@ -1578,17 +1578,17 @@ namespace DoFTools
       template <int dim, int spacedim>
       void
       ensure_existence_of_face_matrix (const FiniteElement<dim,spacedim> &fe1,
-                                       const FiniteElement<dim,spacedim> &fe2,
-                                       std_cxx1x::shared_ptr<FullMatrix<double> > &matrix)
+                                                      const FiniteElement<dim,spacedim> &fe2,
+                                                      std_cxx1x::shared_ptr<FullMatrix<double> > &matrix)
       {
-        if (matrix == std_cxx1x::shared_ptr<FullMatrix<double> >())
-          {
-            matrix = std_cxx1x::shared_ptr<FullMatrix<double> >
-                     (new FullMatrix<double> (fe2.dofs_per_face,
-                                              fe1.dofs_per_face));
-            fe1.get_face_interpolation_matrix (fe2,
-                                               *matrix);
-          }
+           if (matrix == std_cxx1x::shared_ptr<FullMatrix<double> >())
+             {
+               matrix = std_cxx1x::shared_ptr<FullMatrix<double> >
+                            (new FullMatrix<double> (fe2.dofs_per_face,
+                                                                 fe1.dofs_per_face));
+               fe1.get_face_interpolation_matrix (fe2,
+                                                                  *matrix);
+             }
       }
 
 
@@ -1600,19 +1600,19 @@ namespace DoFTools
       template <int dim, int spacedim>
       void
       ensure_existence_of_subface_matrix (const FiniteElement<dim,spacedim> &fe1,
-                                          const FiniteElement<dim,spacedim> &fe2,
-                                          const unsigned int        subface,
-                                          std_cxx1x::shared_ptr<FullMatrix<double> > &matrix)
+                                                             const FiniteElement<dim,spacedim> &fe2,
+                                                             const unsigned int        subface,
+                                                             std_cxx1x::shared_ptr<FullMatrix<double> > &matrix)
       {
-        if (matrix == std_cxx1x::shared_ptr<FullMatrix<double> >())
-          {
-            matrix = std_cxx1x::shared_ptr<FullMatrix<double> >
-                     (new FullMatrix<double> (fe2.dofs_per_face,
-                                              fe1.dofs_per_face));
-            fe1.get_subface_interpolation_matrix (fe2,
-                                                  subface,
-                                                  *matrix);
-          }
+           if (matrix == std_cxx1x::shared_ptr<FullMatrix<double> >())
+             {
+               matrix = std_cxx1x::shared_ptr<FullMatrix<double> >
+                            (new FullMatrix<double> (fe2.dofs_per_face,
+                                                                 fe1.dofs_per_face));
+               fe1.get_subface_interpolation_matrix (fe2,
+                                                                         subface,
+                                                                         *matrix);
+             }
       }
 
 
@@ -1626,57 +1626,57 @@ namespace DoFTools
                                         */
       void
       ensure_existence_of_split_face_matrix (const FullMatrix<double> &face_interpolation_matrix,
-                                             const std::vector<bool> &master_dof_mask,
-                                             std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > > &split_matrix)
+                                                                const std::vector<bool> &master_dof_mask,
+                                                                std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > > &split_matrix)
       {
-        AssertDimension (master_dof_mask.size(), face_interpolation_matrix.m());
-        Assert (std::count (master_dof_mask.begin(), master_dof_mask.end(), true) ==
-                static_cast<signed int>(face_interpolation_matrix.n()),
-                ExcInternalError());
+           AssertDimension (master_dof_mask.size(), face_interpolation_matrix.m());
+           Assert (std::count (master_dof_mask.begin(), master_dof_mask.end(), true) ==
+                       static_cast<signed int>(face_interpolation_matrix.n()),
+                       ExcInternalError());
 
-        if (split_matrix ==
-            std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > >())
-          {
-            split_matrix
-              = std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > >
-              (new std::pair<FullMatrix<double>,FullMatrix<double> >());
+           if (split_matrix ==
+               std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > >())
+             {
+               split_matrix
+                 = std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > >
+                 (new std::pair<FullMatrix<double>,FullMatrix<double> >());
 
-            const unsigned int n_master_dofs = face_interpolation_matrix.n();
-            const unsigned int n_dofs        = face_interpolation_matrix.m();
+               const unsigned int n_master_dofs = face_interpolation_matrix.n();
+               const unsigned int n_dofs        = face_interpolation_matrix.m();
 
-            Assert (n_master_dofs <= n_dofs, ExcInternalError());
+               Assert (n_master_dofs <= n_dofs, ExcInternalError());
 
                                              // copy and invert the master
                                              // component, copy the slave
                                              // component
-            split_matrix->first.reinit (n_master_dofs, n_master_dofs);
-            split_matrix->second.reinit (n_dofs-n_master_dofs, n_master_dofs);
-
-            unsigned int nth_master_dof = 0,
-                         nth_slave_dof  = 0;
-
-            for (unsigned int i=0; i<n_dofs; ++i)
-              if (master_dof_mask[i] == true)
-                {
-                  for (unsigned int j=0; j<n_master_dofs; ++j)
-                    split_matrix->first(nth_master_dof,j)
-                      = face_interpolation_matrix(i,j);
-                  ++nth_master_dof;
-                }
-              else
-                {
-                  for (unsigned int j=0; j<n_master_dofs; ++j)
-                    split_matrix->second(nth_slave_dof,j)
-                      = face_interpolation_matrix(i,j);
-                  ++nth_slave_dof;
-                }
-
-            AssertDimension (nth_master_dof, n_master_dofs);
-            AssertDimension (nth_slave_dof, n_dofs-n_master_dofs);
+               split_matrix->first.reinit (n_master_dofs, n_master_dofs);
+               split_matrix->second.reinit (n_dofs-n_master_dofs, n_master_dofs);
+
+               unsigned int nth_master_dof = 0,
+                                    nth_slave_dof  = 0;
+
+               for (unsigned int i=0; i<n_dofs; ++i)
+                 if (master_dof_mask[i] == true)
+                       {
+                         for (unsigned int j=0; j<n_master_dofs; ++j)
+                           split_matrix->first(nth_master_dof,j)
+                             = face_interpolation_matrix(i,j);
+                         ++nth_master_dof;
+                       }
+                 else
+                       {
+                         for (unsigned int j=0; j<n_master_dofs; ++j)
+                           split_matrix->second(nth_slave_dof,j)
+                             = face_interpolation_matrix(i,j);
+                         ++nth_slave_dof;
+                       }
+
+               AssertDimension (nth_master_dof, n_master_dofs);
+               AssertDimension (nth_slave_dof, n_dofs-n_master_dofs);
 
 //TODO[WB]: We should make sure very small entries are removed after inversion
-            split_matrix->first.gauss_jordan ();
-          }
+               split_matrix->first.gauss_jordan ();
+             }
       }
 
 
@@ -1688,21 +1688,21 @@ namespace DoFTools
       template <typename>
       struct DoFHandlerSupportsDifferentFEs
       {
-          static const bool value = true;
+             static const bool value = true;
       };
 
 
       template <int dim, int spacedim>
       struct DoFHandlerSupportsDifferentFEs< dealii::DoFHandler<dim,spacedim> >
       {
-          static const bool value = false;
+             static const bool value = false;
       };
 
 
       template <int dim, int spacedim>
       struct DoFHandlerSupportsDifferentFEs< dealii::MGDoFHandler<dim,spacedim> >
       {
-          static const bool value = false;
+             static const bool value = false;
       };
 
 
@@ -1719,7 +1719,7 @@ namespace DoFTools
       unsigned int
       n_finite_elements (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler)
       {
-        return dof_handler.get_fe().size();
+           return dof_handler.get_fe().size();
       }
 
 
@@ -1727,7 +1727,7 @@ namespace DoFTools
       unsigned int
       n_finite_elements (const DH &)
       {
-        return 1;
+           return 1;
       }
 
 
@@ -1744,44 +1744,44 @@ namespace DoFTools
       unsigned int
       get_most_dominating_subface_fe_index (const face_iterator &face)
       {
-        const unsigned int dim
-          = face_iterator::AccessorType::dimension;
-        const unsigned int spacedim
-          = face_iterator::AccessorType::space_dimension;
-
-        unsigned int dominating_subface_no = 0;
-        for (; dominating_subface_no<face->n_children();
-             ++dominating_subface_no)
-          {
+           const unsigned int dim
+             = face_iterator::AccessorType::dimension;
+           const unsigned int spacedim
+             = face_iterator::AccessorType::space_dimension;
+
+           unsigned int dominating_subface_no = 0;
+           for (; dominating_subface_no<face->n_children();
+                ++dominating_subface_no)
+             {
                                              // each of the subfaces
                                              // can have only a single
                                              // fe_index associated
                                              // with them, since there
                                              // is no cell on the
                                              // other side
-            Assert (face->child(dominating_subface_no)
-                    ->n_active_fe_indices()
-                    == 1,
-                    ExcInternalError());
-
-            const FiniteElement<dim,spacedim> &
-              this_subface_fe = (face->child(dominating_subface_no)
-                                 ->get_fe (face->child(dominating_subface_no)
-                                           ->nth_active_fe_index(0)));
-
-            FiniteElementDomination::Domination
-              domination = FiniteElementDomination::either_element_can_dominate;
-            for (unsigned int sf=0; sf<face->n_children(); ++sf)
-              if (sf != dominating_subface_no)
-                {
-                  const FiniteElement<dim,spacedim> &
-                    that_subface_fe = (face->child(sf)
-                                       ->get_fe (face->child(sf)
-                                                 ->nth_active_fe_index(0)));
-
-                  domination = domination &
-                               this_subface_fe.compare_for_face_domination(that_subface_fe);
-                }
+               Assert (face->child(dominating_subface_no)
+                           ->n_active_fe_indices()
+                           == 1,
+                           ExcInternalError());
+
+               const FiniteElement<dim,spacedim> &
+                 this_subface_fe = (face->child(dominating_subface_no)
+                                                ->get_fe (face->child(dominating_subface_no)
+                                                              ->nth_active_fe_index(0)));
+
+               FiniteElementDomination::Domination
+                 domination = FiniteElementDomination::either_element_can_dominate;
+               for (unsigned int sf=0; sf<face->n_children(); ++sf)
+                 if (sf != dominating_subface_no)
+                       {
+                         const FiniteElement<dim,spacedim> &
+                           that_subface_fe = (face->child(sf)
+                                                      ->get_fe (face->child(sf)
+                                                                        ->nth_active_fe_index(0)));
+
+                         domination = domination &
+                                          this_subface_fe.compare_for_face_domination(that_subface_fe);
+                       }
 
                                              // see if the element
                                              // on this subface is
@@ -1789,22 +1789,22 @@ namespace DoFTools
                                              // the ones on all
                                              // other subfaces,
                                              // and if so take it
-            if ((domination == FiniteElementDomination::this_element_dominates)
-                ||
-                (domination == FiniteElementDomination::either_element_can_dominate))
-              break;
-          }
+               if ((domination == FiniteElementDomination::this_element_dominates)
+                       ||
+                       (domination == FiniteElementDomination::either_element_can_dominate))
+                 break;
+             }
 
                                          // check that we have
                                          // found one such subface
-        Assert (dominating_subface_no < face->n_children(),
-                ExcNotImplemented());
+           Assert (dominating_subface_no < face->n_children(),
+                       ExcNotImplemented());
 
                                          // return the finite element
                                          // index used on it. note
                                          // that only a single fe can
                                          // be active on such subfaces
-        return face->child (dominating_subface_no)->nth_active_fe_index(0);
+           return face->child (dominating_subface_no)->nth_active_fe_index(0);
       }
 
 
@@ -1827,60 +1827,60 @@ namespace DoFTools
                                         */
       void
       filter_constraints (const std::vector<unsigned int> &master_dofs,
-                          const std::vector<unsigned int> &slave_dofs,
-                          const FullMatrix<double> &face_constraints,
-                          ConstraintMatrix &constraints)
+                                     const std::vector<unsigned int> &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
                                          // in parallel distributed
                                          // mode
-        for (unsigned int row=0; row!=n_slave_dofs; ++row)
-          Assert (slave_dofs[row] != numbers::invalid_unsigned_int,
-                  ExcInternalError());
-        for (unsigned int col=0; col!=n_master_dofs; ++col)
-          Assert (master_dofs[col] != numbers::invalid_unsigned_int,
-                  ExcInternalError());
+           for (unsigned int row=0; row!=n_slave_dofs; ++row)
+             Assert (slave_dofs[row] != numbers::invalid_unsigned_int,
+                         ExcInternalError());
+           for (unsigned int col=0; col!=n_master_dofs; ++col)
+             Assert (master_dofs[col] != numbers::invalid_unsigned_int,
+                         ExcInternalError());
 
 
-        for (unsigned int row=0; row!=n_slave_dofs; ++row)
-          if (constraints.is_constrained (slave_dofs[row]) == false)
-            {
-              bool constraint_already_satisfied = false;
+           for (unsigned int row=0; row!=n_slave_dofs; ++row)
+             if (constraints.is_constrained (slave_dofs[row]) == false)
+               {
+                 bool constraint_already_satisfied = false;
 
                                                // Check if we have an identity
                                                // constraint, which is already
                                                // satisfied by unification of
                                                // the corresponding global dof
                                                // indices
-              for (unsigned int i=0; i<n_master_dofs; ++i)
-                if (face_constraints (row,i) == 1.0)
-                  if (master_dofs[i] == slave_dofs[row])
-                    {
-                      constraint_already_satisfied = true;
-                      break;
-                    }
-
-              if (constraint_already_satisfied == false)
-                {
+                 for (unsigned int i=0; i<n_master_dofs; ++i)
+                       if (face_constraints (row,i) == 1.0)
+                         if (master_dofs[i] == slave_dofs[row])
+                           {
+                             constraint_already_satisfied = true;
+                             break;
+                           }
+
+                 if (constraint_already_satisfied == false)
+                       {
                                                    // add up the absolute
                                                    // values of all
                                                    // constraints in this line
                                                    // to get a measure of
                                                    // their absolute size
-                  double abs_sum = 0;
-                  for (unsigned int i=0; i<n_master_dofs; ++i)
-                    abs_sum += std::abs (face_constraints(row,i));
+                         double abs_sum = 0;
+                         for (unsigned int i=0; i<n_master_dofs; ++i)
+                           abs_sum += std::abs (face_constraints(row,i));
 
                                                    // then enter those
                                                    // constraints that are
@@ -1897,17 +1897,17 @@ namespace DoFTools
                                                    // than necessary without
                                                    // producing any
                                                    // significant effect
-                  constraints.add_line (slave_dofs[row]);
-                  for (unsigned int i=0; i<n_master_dofs; ++i)
-                    if ((face_constraints(row,i) != 0)
-                        &&
-                        (std::fabs(face_constraints(row,i)) >= 1e-14*abs_sum))
-                      constraints.add_entry (slave_dofs[row],
-                                             master_dofs[i],
-                                             face_constraints (row,i));
-                  constraints.set_inhomogeneity (slave_dofs[row], 0.);
-                }
-            }
+                         constraints.add_line (slave_dofs[row]);
+                         for (unsigned int i=0; i<n_master_dofs; ++i)
+                           if ((face_constraints(row,i) != 0)
+                                   &&
+                                   (std::fabs(face_constraints(row,i)) >= 1e-14*abs_sum))
+                             constraints.add_entry (slave_dofs[row],
+                                                                master_dofs[i],
+                                                                face_constraints (row,i));
+                         constraints.set_inhomogeneity (slave_dofs[row], 0.);
+                       }
+               }
       }
 
     }
@@ -1916,7 +1916,7 @@ namespace DoFTools
 
     void
     make_hp_hanging_node_constraints (const dealii::DoFHandler<1> &,
-                                      ConstraintMatrix    &)
+                                                     ConstraintMatrix    &)
     {
                                        // nothing to do for regular
                                        // dof handlers in 1d
@@ -1926,8 +1926,8 @@ namespace DoFTools
 
     void
     make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1> &,
-                                            ConstraintMatrix    &,
-                                            dealii::internal::int2type<1>)
+                                                               ConstraintMatrix    &,
+                                                               dealii::internal::int2type<1>)
     {
                                        // nothing to do for regular
                                        // dof handlers in 1d
@@ -1936,7 +1936,7 @@ namespace DoFTools
 
     void
     make_hp_hanging_node_constraints (const dealii::MGDoFHandler<1> &,
-                                      ConstraintMatrix    &)
+                                                     ConstraintMatrix    &)
     {
                                        // nothing to do for regular
                                        // dof handlers in 1d
@@ -1946,8 +1946,8 @@ namespace DoFTools
 
     void
     make_oldstyle_hanging_node_constraints (const dealii::MGDoFHandler<1> &,
-                                            ConstraintMatrix    &,
-                                            dealii::internal::int2type<1>)
+                                                               ConstraintMatrix    &,
+                                                               dealii::internal::int2type<1>)
     {
                                        // nothing to do for regular
                                        // dof handlers in 1d
@@ -1956,7 +1956,7 @@ namespace DoFTools
 
     void
     make_hp_hanging_node_constraints (const dealii::hp::DoFHandler<1> &/*dof_handler*/,
-                                      ConstraintMatrix        &/*constraints*/)
+                                                     ConstraintMatrix        &/*constraints*/)
     {
                                        // we may have to compute
                                        // constraints for
@@ -1969,8 +1969,8 @@ namespace DoFTools
 
     void
     make_oldstyle_hanging_node_constraints (const dealii::hp::DoFHandler<1> &/*dof_handler*/,
-                                            ConstraintMatrix        &/*constraints*/,
-                                            dealii::internal::int2type<1>)
+                                                               ConstraintMatrix        &/*constraints*/,
+                                                               dealii::internal::int2type<1>)
     {
                                        // we may have to compute
                                        // constraints for
@@ -1982,7 +1982,7 @@ namespace DoFTools
 
     void
     make_hp_hanging_node_constraints (const dealii::DoFHandler<1,2> &,
-                                      ConstraintMatrix    &)
+                                                     ConstraintMatrix    &)
     {
                                        // nothing to do for regular
                                        // dof handlers in 1d
@@ -1992,8 +1992,8 @@ namespace DoFTools
 
     void
     make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1,2> &,
-                                            ConstraintMatrix    &,
-                                            dealii::internal::int2type<1>)
+                                                               ConstraintMatrix    &,
+                                                               dealii::internal::int2type<1>)
     {
                                        // nothing to do for regular
                                        // dof handlers in 1d
@@ -2058,8 +2058,8 @@ namespace DoFTools
     template <class DH>
     void
     make_oldstyle_hanging_node_constraints (const DH         &dof_handler,
-                                            ConstraintMatrix &constraints,
-                                            dealii::internal::int2type<2>)
+                                                               ConstraintMatrix &constraints,
+                                                               dealii::internal::int2type<2>)
     {
       const unsigned int dim = 2;
 
@@ -2085,16 +2085,16 @@ namespace DoFTools
                                        // refined, we can only visit each
                                        // face with hanging nodes once
       typename DH::active_cell_iterator cell = dof_handler.begin_active(),
-                                        endc = dof_handler.end();
+                                                           endc = dof_handler.end();
       for (; cell!=endc; ++cell)
                                          // artificial cells can at
                                          // best neighbor ghost cells,
                                          // but we're not interested
                                          // in these interfaces
-        if (!cell->is_artificial ())
-          for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
-            if (cell->face(face)->has_children())
-              {
+           if (!cell->is_artificial ())
+             for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+               if (cell->face(face)->has_children())
+                 {
                                                  // in any case, faces
                                                  // can have at most two
                                                  // active fe indices,
@@ -2107,84 +2107,84 @@ namespace DoFTools
                                                  // children can have
                                                  // only one as
                                                  // well. check this
-                Assert (cell->face(face)->n_active_fe_indices() == 1,
-                        ExcInternalError());
-                Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
-                        == true,
-                        ExcInternalError());
-                for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
-                  if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
-                    Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1,
-                            ExcInternalError());
+                       Assert (cell->face(face)->n_active_fe_indices() == 1,
+                                   ExcInternalError());
+                       Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
+                                   == true,
+                                   ExcInternalError());
+                       for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+                         if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
+                           Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1,
+                                       ExcInternalError());
 
                                                  // right now, all that
                                                  // is implemented is
                                                  // the case that both
                                                  // sides use the same
                                                  // fe
-                for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
-                  if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
-                    Assert (cell->face(face)->child(c)
-                            ->fe_index_is_active(cell->active_fe_index()) == true,
-                            ExcNotImplemented());
+                       for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+                         if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
+                           Assert (cell->face(face)->child(c)
+                                       ->fe_index_is_active(cell->active_fe_index()) == true,
+                                       ExcNotImplemented());
 
                                                  // ok, start up the work
-                const FiniteElement<dim,spacedim> &fe       = cell->get_fe();
-                const unsigned int        fe_index = cell->active_fe_index();
+                       const FiniteElement<dim,spacedim> &fe       = cell->get_fe();
+                       const unsigned int        fe_index = cell->active_fe_index();
 
-                const unsigned int
-                  n_dofs_on_mother   = 2*fe.dofs_per_vertex + fe.dofs_per_line,
-                  n_dofs_on_children = fe.dofs_per_vertex + 2*fe.dofs_per_line;
+                       const unsigned int
+                         n_dofs_on_mother   = 2*fe.dofs_per_vertex + fe.dofs_per_line,
+                         n_dofs_on_children = fe.dofs_per_vertex + 2*fe.dofs_per_line;
 
-                dofs_on_mother.resize (n_dofs_on_mother);
-                dofs_on_children.resize (n_dofs_on_children);
+                       dofs_on_mother.resize (n_dofs_on_mother);
+                       dofs_on_children.resize (n_dofs_on_children);
 
-                Assert(n_dofs_on_mother == fe.constraints().n(),
-                       ExcDimensionMismatch(n_dofs_on_mother,
-                                            fe.constraints().n()));
-                Assert(n_dofs_on_children == fe.constraints().m(),
-                       ExcDimensionMismatch(n_dofs_on_children,
-                                            fe.constraints().m()));
+                       Assert(n_dofs_on_mother == fe.constraints().n(),
+                              ExcDimensionMismatch(n_dofs_on_mother,
+                                                               fe.constraints().n()));
+                       Assert(n_dofs_on_children == fe.constraints().m(),
+                              ExcDimensionMismatch(n_dofs_on_children,
+                                                               fe.constraints().m()));
 
-                const typename DH::line_iterator this_face = cell->face(face);
+                       const typename DH::line_iterator this_face = cell->face(face);
 
                                                  // fill the dofs indices. Use same
                                                  // enumeration scheme as in
                                                  // @p{FiniteElement::constraints()}
-                unsigned int next_index = 0;
-                for (unsigned int vertex=0; vertex<2; ++vertex)
-                  for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
-                    dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof,
-                                                                               fe_index);
-                for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
-                  dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index);
-                AssertDimension (next_index, dofs_on_mother.size());
-
-                next_index = 0;
-                for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
-                  dofs_on_children[next_index++]
-                    = this_face->child(0)->vertex_dof_index(1,dof,fe_index);
-                for (unsigned int child=0; child<2; ++child)
-                  for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
-                    dofs_on_children[next_index++]
-                      = this_face->child(child)->dof_index(dof, fe_index);
-                AssertDimension (next_index, dofs_on_children.size());
+                       unsigned int next_index = 0;
+                       for (unsigned int vertex=0; vertex<2; ++vertex)
+                         for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+                           dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof,
+                                                                                                                  fe_index);
+                       for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+                         dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index);
+                       AssertDimension (next_index, dofs_on_mother.size());
+
+                       next_index = 0;
+                       for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+                         dofs_on_children[next_index++]
+                           = this_face->child(0)->vertex_dof_index(1,dof,fe_index);
+                       for (unsigned int child=0; child<2; ++child)
+                         for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+                           dofs_on_children[next_index++]
+                             = this_face->child(child)->dof_index(dof, fe_index);
+                       AssertDimension (next_index, dofs_on_children.size());
 
                                                  // for each row in the constraint
                                                  // matrix for this line:
-                for (unsigned int row=0; row!=dofs_on_children.size(); ++row)
-                  {
-                    constraints.add_line (dofs_on_children[row]);
-                    for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
-                      constraints.add_entry (dofs_on_children[row],
-                                             dofs_on_mother[i],
-                                             fe.constraints()(row,i));
-
-                    constraints.set_inhomogeneity (dofs_on_children[row], 0.);
-                  }
-              }
-            else
-              {
+                       for (unsigned int row=0; row!=dofs_on_children.size(); ++row)
+                         {
+                           constraints.add_line (dofs_on_children[row]);
+                           for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
+                             constraints.add_entry (dofs_on_children[row],
+                                                                dofs_on_mother[i],
+                                                                fe.constraints()(row,i));
+
+                           constraints.set_inhomogeneity (dofs_on_children[row], 0.);
+                         }
+                 }
+               else
+                 {
                                                  // this face has no
                                                  // children, but it
                                                  // could still be
@@ -2197,16 +2197,16 @@ namespace DoFTools
                                                  // case that the
                                                  // neighbor is an
                                                  // artificial cell
-                if (!cell->at_boundary(face) &&
-                    !cell->neighbor(face)->is_artificial())
-                  {
-                    Assert (cell->face(face)->n_active_fe_indices() == 1,
-                            ExcNotImplemented());
-                    Assert (cell->face(face)
-                            ->fe_index_is_active(cell->active_fe_index()) == true,
-                            ExcInternalError());
-                  }
-              }
+                       if (!cell->at_boundary(face) &&
+                           !cell->neighbor(face)->is_artificial())
+                         {
+                           Assert (cell->face(face)->n_active_fe_indices() == 1,
+                                       ExcNotImplemented());
+                           Assert (cell->face(face)
+                                       ->fe_index_is_active(cell->active_fe_index()) == true,
+                                       ExcInternalError());
+                         }
+                 }
     }
 
 
@@ -2214,8 +2214,8 @@ namespace DoFTools
     template <class DH>
     void
     make_oldstyle_hanging_node_constraints (const DH         &dof_handler,
-                                            ConstraintMatrix &constraints,
-                                            dealii::internal::int2type<3>)
+                                                               ConstraintMatrix &constraints,
+                                                               dealii::internal::int2type<3>)
     {
       const unsigned int dim = 3;
 
@@ -2239,26 +2239,26 @@ namespace DoFTools
                                        // refined, we can only visit each
                                        // face with hanging nodes once
       typename DH::active_cell_iterator cell = dof_handler.begin_active(),
-                                        endc = dof_handler.end();
+                                                           endc = dof_handler.end();
       for (; cell!=endc; ++cell)
                                          // artificial cells can at
                                          // best neighbor ghost cells,
                                          // but we're not interested
                                          // in these interfaces
-        if (!cell->is_artificial ())
-          for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
-            if (cell->face(face)->has_children())
-              {
+           if (!cell->is_artificial ())
+             for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+               if (cell->face(face)->has_children())
+                 {
                                                  // first of all, make sure that
                                                  // we treat a case which is
                                                  // possible, i.e. either no dofs
                                                  // on the face at all or no
                                                  // anisotropic refinement
-                if (cell->get_fe().dofs_per_face == 0)
-                  continue;
+                       if (cell->get_fe().dofs_per_face == 0)
+                         continue;
 
-                Assert(cell->face(face)->refinement_case()==RefinementCase<dim-1>::isotropic_refinement,
-                       ExcNotImplemented());
+                       Assert(cell->face(face)->refinement_case()==RefinementCase<dim-1>::isotropic_refinement,
+                              ExcNotImplemented());
 
                                                  // in any case, faces
                                                  // can have at most two
@@ -2272,12 +2272,12 @@ namespace DoFTools
                                                  // children can have
                                                  // only one as
                                                  // well. check this
-                AssertDimension (cell->face(face)->n_active_fe_indices(), 1);
-                Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
-                        == true,
-                        ExcInternalError());
-                for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
-                  AssertDimension (cell->face(face)->child(c)->n_active_fe_indices(), 1);
+                       AssertDimension (cell->face(face)->n_active_fe_indices(), 1);
+                       Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
+                                   == true,
+                                   ExcInternalError());
+                       for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+                         AssertDimension (cell->face(face)->child(c)->n_active_fe_indices(), 1);
 
                                                  // right now, all that
                                                  // is implemented is
@@ -2289,141 +2289,141 @@ namespace DoFTools
                                                  // this face and the
                                                  // children have the
                                                  // same fe
-                for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
-                  if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
-                    {
-                      Assert (cell->face(face)->child(c)
-                              ->fe_index_is_active(cell->active_fe_index()) == true,
-                              ExcNotImplemented());
-                      for (unsigned int e=0; e<4; ++e)
-                        {
-                          Assert (cell->face(face)->child(c)->line(e)
-                                  ->n_active_fe_indices() == 1,
-                                  ExcNotImplemented());
-                          Assert (cell->face(face)->child(c)->line(e)
-                                  ->fe_index_is_active(cell->active_fe_index()) == true,
-                                  ExcNotImplemented());
-                        }
-                    }
-                for (unsigned int e=0; e<4; ++e)
-                  {
-                    Assert (cell->face(face)->line(e)
-                            ->n_active_fe_indices() == 1,
-                            ExcNotImplemented());
-                    Assert (cell->face(face)->line(e)
-                            ->fe_index_is_active(cell->active_fe_index()) == true,
-                            ExcNotImplemented());
-                  }
+                       for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+                         if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
+                           {
+                             Assert (cell->face(face)->child(c)
+                                         ->fe_index_is_active(cell->active_fe_index()) == true,
+                                         ExcNotImplemented());
+                             for (unsigned int e=0; e<4; ++e)
+                                   {
+                                     Assert (cell->face(face)->child(c)->line(e)
+                                                 ->n_active_fe_indices() == 1,
+                                                 ExcNotImplemented());
+                                     Assert (cell->face(face)->child(c)->line(e)
+                                                 ->fe_index_is_active(cell->active_fe_index()) == true,
+                                                 ExcNotImplemented());
+                                   }
+                           }
+                       for (unsigned int e=0; e<4; ++e)
+                         {
+                           Assert (cell->face(face)->line(e)
+                                       ->n_active_fe_indices() == 1,
+                                       ExcNotImplemented());
+                           Assert (cell->face(face)->line(e)
+                                       ->fe_index_is_active(cell->active_fe_index()) == true,
+                                       ExcNotImplemented());
+                         }
 
                                                  // ok, start up the work
-                const FiniteElement<dim> &fe       = cell->get_fe();
-                const unsigned int        fe_index = cell->active_fe_index();
+                       const FiniteElement<dim> &fe       = cell->get_fe();
+                       const unsigned int        fe_index = cell->active_fe_index();
 
-                const unsigned int n_dofs_on_mother = fe.dofs_per_face;
-                const unsigned int n_dofs_on_children = (5*fe.dofs_per_vertex+
-                                                         12*fe.dofs_per_line+
-                                                         4*fe.dofs_per_quad);
+                       const unsigned int n_dofs_on_mother = fe.dofs_per_face;
+                       const unsigned int n_dofs_on_children = (5*fe.dofs_per_vertex+
+                                                                                    12*fe.dofs_per_line+
+                                                                                    4*fe.dofs_per_quad);
 //TODO[TL]: think about this and the following in case of anisotropic refinement
 
-                dofs_on_mother.resize (n_dofs_on_mother);
-                dofs_on_children.resize (n_dofs_on_children);
+                       dofs_on_mother.resize (n_dofs_on_mother);
+                       dofs_on_children.resize (n_dofs_on_children);
 
-                Assert(n_dofs_on_mother == fe.constraints().n(),
-                       ExcDimensionMismatch(n_dofs_on_mother,
-                                            fe.constraints().n()));
-                Assert(n_dofs_on_children == fe.constraints().m(),
-                       ExcDimensionMismatch(n_dofs_on_children,
-                                            fe.constraints().m()));
+                       Assert(n_dofs_on_mother == fe.constraints().n(),
+                              ExcDimensionMismatch(n_dofs_on_mother,
+                                                               fe.constraints().n()));
+                       Assert(n_dofs_on_children == fe.constraints().m(),
+                              ExcDimensionMismatch(n_dofs_on_children,
+                                                               fe.constraints().m()));
 
-                const typename DH::face_iterator this_face = cell->face(face);
+                       const typename DH::face_iterator this_face = cell->face(face);
 
                                                  // fill the dofs indices. Use same
                                                  // enumeration scheme as in
                                                  // @p{FiniteElement::constraints()}
-                unsigned int next_index = 0;
-                for (unsigned int vertex=0; vertex<4; ++vertex)
-                  for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
-                    dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof,
-                                                                               fe_index);
-                for (unsigned int line=0; line<4; ++line)
-                  for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
-                    dofs_on_mother[next_index++]
-                      = this_face->line(line)->dof_index(dof, fe_index);
-                for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
-                  dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index);
-                AssertDimension (next_index, dofs_on_mother.size());
-
-                next_index = 0;
+                       unsigned int next_index = 0;
+                       for (unsigned int vertex=0; vertex<4; ++vertex)
+                         for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+                           dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof,
+                                                                                                                  fe_index);
+                       for (unsigned int line=0; line<4; ++line)
+                         for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+                           dofs_on_mother[next_index++]
+                             = this_face->line(line)->dof_index(dof, fe_index);
+                       for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
+                         dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index);
+                       AssertDimension (next_index, dofs_on_mother.size());
+
+                       next_index = 0;
 
                                                  // assert some consistency
                                                  // assumptions
                                                  //TODO[TL]: think about this in case of anisotropic refinement
-                Assert (dof_handler.get_tria().get_anisotropic_refinement_flag() ||
-                        ((this_face->child(0)->vertex_index(3) ==
-                          this_face->child(1)->vertex_index(2)) &&
-                         (this_face->child(0)->vertex_index(3) ==
-                          this_face->child(2)->vertex_index(1)) &&
-                         (this_face->child(0)->vertex_index(3) ==
-                          this_face->child(3)->vertex_index(0))),
-                        ExcInternalError());
-                for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
-                  dofs_on_children[next_index++]
-                    = this_face->child(0)->vertex_dof_index(3,dof);
+                       Assert (dof_handler.get_tria().get_anisotropic_refinement_flag() ||
+                                   ((this_face->child(0)->vertex_index(3) ==
+                                     this_face->child(1)->vertex_index(2)) &&
+                                    (this_face->child(0)->vertex_index(3) ==
+                                     this_face->child(2)->vertex_index(1)) &&
+                                    (this_face->child(0)->vertex_index(3) ==
+                                     this_face->child(3)->vertex_index(0))),
+                                   ExcInternalError());
+                       for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+                         dofs_on_children[next_index++]
+                           = this_face->child(0)->vertex_dof_index(3,dof);
 
                                                  // dof numbers on the centers of
                                                  // the lines bounding this face
-                for (unsigned int line=0; line<4; ++line)
-                  for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
-                    dofs_on_children[next_index++]
-                      = this_face->line(line)->child(0)->vertex_dof_index(1,dof, fe_index);
+                       for (unsigned int line=0; line<4; ++line)
+                         for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+                           dofs_on_children[next_index++]
+                             = this_face->line(line)->child(0)->vertex_dof_index(1,dof, fe_index);
 
                                                  // next the dofs on the lines interior
                                                  // to the face; the order of these
                                                  // lines is laid down in the
                                                  // FiniteElement class documentation
-                for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
-                  dofs_on_children[next_index++]
-                    = this_face->child(0)->line(1)->dof_index(dof, fe_index);
-                for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
-                  dofs_on_children[next_index++]
-                    = this_face->child(2)->line(1)->dof_index(dof, fe_index);
-                for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
-                  dofs_on_children[next_index++]
-                    = this_face->child(0)->line(3)->dof_index(dof, fe_index);
-                for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
-                  dofs_on_children[next_index++]
-                    = this_face->child(1)->line(3)->dof_index(dof, fe_index);
+                       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+                         dofs_on_children[next_index++]
+                           = this_face->child(0)->line(1)->dof_index(dof, fe_index);
+                       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+                         dofs_on_children[next_index++]
+                           = this_face->child(2)->line(1)->dof_index(dof, fe_index);
+                       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+                         dofs_on_children[next_index++]
+                           = this_face->child(0)->line(3)->dof_index(dof, fe_index);
+                       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+                         dofs_on_children[next_index++]
+                           = this_face->child(1)->line(3)->dof_index(dof, fe_index);
 
                                                  // dofs on the bordering lines
-                for (unsigned int line=0; line<4; ++line)
-                  for (unsigned int child=0; child<2; ++child)
-                    for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
-                      dofs_on_children[next_index++]
-                        = this_face->line(line)->child(child)->dof_index(dof, fe_index);
+                       for (unsigned int line=0; line<4; ++line)
+                         for (unsigned int child=0; child<2; ++child)
+                           for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+                             dofs_on_children[next_index++]
+                                   = this_face->line(line)->child(child)->dof_index(dof, fe_index);
 
                                                  // finally, for the dofs interior
                                                  // to the four child faces
-                for (unsigned int child=0; child<4; ++child)
-                  for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
-                    dofs_on_children[next_index++]
-                      = this_face->child(child)->dof_index(dof, fe_index);
-                AssertDimension (next_index, dofs_on_children.size());
+                       for (unsigned int child=0; child<4; ++child)
+                         for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
+                           dofs_on_children[next_index++]
+                             = this_face->child(child)->dof_index(dof, fe_index);
+                       AssertDimension (next_index, dofs_on_children.size());
 
                                                  // for each row in the constraint
                                                  // matrix for this line:
-                for (unsigned int row=0; row!=dofs_on_children.size(); ++row)
-                  {
-                    constraints.add_line (dofs_on_children[row]);
-                    for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
-                      constraints.add_entry (dofs_on_children[row],
-                                             dofs_on_mother[i],
-                                             fe.constraints()(row,i));
-
-                    constraints.set_inhomogeneity(dofs_on_children[row], 0.);
-                  }
-              }
-            else
-              {
+                       for (unsigned int row=0; row!=dofs_on_children.size(); ++row)
+                         {
+                           constraints.add_line (dofs_on_children[row]);
+                           for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
+                             constraints.add_entry (dofs_on_children[row],
+                                                                dofs_on_mother[i],
+                                                                fe.constraints()(row,i));
+
+                           constraints.set_inhomogeneity(dofs_on_children[row], 0.);
+                         }
+                 }
+               else
+                 {
                                                  // this face has no
                                                  // children, but it
                                                  // could still be
@@ -2436,23 +2436,23 @@ namespace DoFTools
                                                  // case that the
                                                  // neighbor is an
                                                  // artificial cell
-                if (!cell->at_boundary(face) &&
-                    !cell->neighbor(face)->is_artificial())
-                  {
-                    Assert (cell->face(face)->n_active_fe_indices() == 1,
-                            ExcNotImplemented());
-                    Assert (cell->face(face)
-                            ->fe_index_is_active(cell->active_fe_index()) == true,
-                            ExcInternalError());
-                  }
-              }
+                       if (!cell->at_boundary(face) &&
+                           !cell->neighbor(face)->is_artificial())
+                         {
+                           Assert (cell->face(face)->n_active_fe_indices() == 1,
+                                       ExcNotImplemented());
+                           Assert (cell->face(face)
+                                       ->fe_index_is_active(cell->active_fe_index()) == true,
+                                       ExcInternalError());
+                         }
+                 }
     }
 
 
     template <class DH>
     void
     make_hp_hanging_node_constraints (const DH         &dof_handler,
-                                      ConstraintMatrix &constraints)
+                                                     ConstraintMatrix &constraints)
     {
                                        // note: this function is going
                                        // to be hard to understand if
@@ -2492,12 +2492,12 @@ namespace DoFTools
                                        // time they are needed, and
                                        // then just reuse them
       Table<2,std_cxx1x::shared_ptr<FullMatrix<double> > >
-        face_interpolation_matrices (n_finite_elements (dof_handler),
-                                     n_finite_elements (dof_handler));
+           face_interpolation_matrices (n_finite_elements (dof_handler),
+                                                    n_finite_elements (dof_handler));
       Table<3,std_cxx1x::shared_ptr<FullMatrix<double> > >
-        subface_interpolation_matrices (n_finite_elements (dof_handler),
-                                        n_finite_elements (dof_handler),
-                                        GeometryInfo<dim>::max_children_per_face);
+           subface_interpolation_matrices (n_finite_elements (dof_handler),
+                                                           n_finite_elements (dof_handler),
+                                                           GeometryInfo<dim>::max_children_per_face);
 
                                        // similarly have a cache for
                                        // the matrices that are split
@@ -2509,8 +2509,8 @@ namespace DoFTools
                                        // interpolation matrix as
                                        // described in the @ref hp_paper "hp paper"
       Table<2,std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > > >
-        split_face_interpolation_matrices (n_finite_elements (dof_handler),
-                                           n_finite_elements (dof_handler));
+           split_face_interpolation_matrices (n_finite_elements (dof_handler),
+                                                              n_finite_elements (dof_handler));
 
                                        // finally, for each pair of finite
                                        // elements, have a mask that states
@@ -2518,8 +2518,8 @@ namespace DoFTools
                                        // the coarse side of a refined face
                                        // will act as master dofs.
       Table<2,std_cxx1x::shared_ptr<std::vector<bool> > >
-        master_dof_masks (n_finite_elements (dof_handler),
-                          n_finite_elements (dof_handler));
+           master_dof_masks (n_finite_elements (dof_handler),
+                                     n_finite_elements (dof_handler));
 
                                        // loop over all faces
                                        //
@@ -2529,26 +2529,26 @@ namespace DoFTools
                                        // refined, we can only visit each
                                        // face with hanging nodes once
       typename DH::active_cell_iterator cell = dof_handler.begin_active(),
-                                        endc = dof_handler.end();
+                                                           endc = dof_handler.end();
       for (; cell!=endc; ++cell)
                                          // artificial cells can at
                                          // best neighbor ghost cells,
                                          // but we're not interested
                                          // in these interfaces
-        if (!cell->is_artificial ())
-          for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
-            if (cell->face(face)->has_children())
-              {
+           if (!cell->is_artificial ())
+             for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+               if (cell->face(face)->has_children())
+                 {
                                                  // first of all, make sure that
                                                  // we treat a case which is
                                                  // possible, i.e. either no dofs
                                                  // on the face at all or no
                                                  // anisotropic refinement
-                if (cell->get_fe().dofs_per_face == 0)
-                  continue;
+                       if (cell->get_fe().dofs_per_face == 0)
+                         continue;
 
-                Assert(cell->face(face)->refinement_case()==RefinementCase<dim-1>::isotropic_refinement,
-                       ExcNotImplemented());
+                       Assert(cell->face(face)->refinement_case()==RefinementCase<dim-1>::isotropic_refinement,
+                              ExcNotImplemented());
 
                                                  // so now we've found a
                                                  // face of an active
@@ -2569,14 +2569,14 @@ namespace DoFTools
                                                  // each of the children
                                                  // can have only one as
                                                  // well. check this
-                Assert (cell->face(face)->n_active_fe_indices() == 1,
-                        ExcInternalError());
-                Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
-                        == true,
-                        ExcInternalError());
-                for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
-                  Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1,
-                          ExcInternalError());
+                       Assert (cell->face(face)->n_active_fe_indices() == 1,
+                                   ExcInternalError());
+                       Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
+                                   == true,
+                                   ExcInternalError());
+                       for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+                         Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1,
+                                     ExcInternalError());
 
                                                  // first find out
                                                  // whether we can
@@ -2595,21 +2595,21 @@ namespace DoFTools
                                                  // ignore all
                                                  // interfaces with
                                                  // artificial cells
-                FiniteElementDomination::Domination
-                  mother_face_dominates = FiniteElementDomination::either_element_can_dominate;
-
-                if (DoFHandlerSupportsDifferentFEs<DH>::value == true)
-                  for (unsigned int c=0; c<cell->face(face)->number_of_children(); ++c)
-                    if (!cell->neighbor_child_on_subface (face, c)->is_artificial())
-                      mother_face_dominates = mother_face_dominates &
-                                              (cell->get_fe().compare_for_face_domination
-                                               (cell->neighbor_child_on_subface (face, c)->get_fe()));
-
-                switch (mother_face_dominates)
-                  {
-                    case FiniteElementDomination::this_element_dominates:
-                    case FiniteElementDomination::either_element_can_dominate:
-                    {
+                       FiniteElementDomination::Domination
+                         mother_face_dominates = FiniteElementDomination::either_element_can_dominate;
+
+                       if (DoFHandlerSupportsDifferentFEs<DH>::value == true)
+                         for (unsigned int c=0; c<cell->face(face)->number_of_children(); ++c)
+                           if (!cell->neighbor_child_on_subface (face, c)->is_artificial())
+                             mother_face_dominates = mother_face_dominates &
+                                                                 (cell->get_fe().compare_for_face_domination
+                                                                  (cell->neighbor_child_on_subface (face, c)->get_fe()));
+
+                       switch (mother_face_dominates)
+                         {
+                           case FiniteElementDomination::this_element_dominates:
+                           case FiniteElementDomination::either_element_can_dominate:
+                           {
                                                        // Case 1 (the
                                                        // simple case
                                                        // and the only
@@ -2634,10 +2634,10 @@ namespace DoFTools
                                                        // against the
                                                        // DoFs on the
                                                        // face itself
-                      master_dofs.resize (cell->get_fe().dofs_per_face);
+                             master_dofs.resize (cell->get_fe().dofs_per_face);
 
-                      cell->face(face)->get_dof_indices (master_dofs,
-                                                         cell->active_fe_index ());
+                             cell->face(face)->get_dof_indices (master_dofs,
+                                                                                    cell->active_fe_index ());
 
                                                        // Now create
                                                        // constraint matrix
@@ -2675,21 +2675,21 @@ namespace DoFTools
                                                        // node is only
                                                        // detected if we also
                                                        // look between ghosts
-                      for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
-                        {
-                          if (cell->neighbor_child_on_subface (face, c)->is_artificial()
-                              ||
-                              (dim == 2 && cell->neighbor_child_on_subface (face, c)->is_ghost()))
-                            continue;
+                             for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+                                   {
+                                     if (cell->neighbor_child_on_subface (face, c)->is_artificial()
+                                         ||
+                                         (dim == 2 && cell->neighbor_child_on_subface (face, c)->is_ghost()))
+                                       continue;
 
-                          const typename DH::active_face_iterator
-                            subface = cell->face(face)->child(c);
+                                     const typename DH::active_face_iterator
+                                       subface = cell->face(face)->child(c);
 
-                          Assert (subface->n_active_fe_indices() == 1,
-                                  ExcInternalError());
+                                     Assert (subface->n_active_fe_indices() == 1,
+                                                 ExcInternalError());
 
-                          const unsigned int
-                            subface_fe_index = subface->nth_active_fe_index(0);
+                                     const unsigned int
+                                       subface_fe_index = subface->nth_active_fe_index(0);
 
                                                            // we sometime run
                                                            // into the
@@ -2719,22 +2719,22 @@ namespace DoFTools
                                                            // care of. in that
                                                            // case, just
                                                            // continue
-                          if (cell->get_fe().compare_for_face_domination
-                              (subface->get_fe(subface_fe_index))
-                              ==
-                              FiniteElementDomination::no_requirements)
-                            continue;
+                                     if (cell->get_fe().compare_for_face_domination
+                                         (subface->get_fe(subface_fe_index))
+                                         ==
+                                         FiniteElementDomination::no_requirements)
+                                       continue;
 
                                                            // Same procedure as for the
                                                            // mother cell. Extract the face
                                                            // DoFs from the cell DoFs.
-                          slave_dofs.resize (subface->get_fe(subface_fe_index)
-                                             .dofs_per_face);
-                          subface->get_dof_indices (slave_dofs, subface_fe_index);
+                                     slave_dofs.resize (subface->get_fe(subface_fe_index)
+                                                                .dofs_per_face);
+                                     subface->get_dof_indices (slave_dofs, subface_fe_index);
 
-                          for (unsigned int i=0; i<slave_dofs.size(); ++i)
-                            Assert (slave_dofs[i] != numbers::invalid_unsigned_int,
-                                    ExcInternalError());
+                                     for (unsigned int i=0; i<slave_dofs.size(); ++i)
+                                       Assert (slave_dofs[i] != numbers::invalid_unsigned_int,
+                                                   ExcInternalError());
 
                                                            // Now create the
                                                            // element constraint
@@ -2790,28 +2790,28 @@ namespace DoFTools
                                                            // properties of a
                                                            // finite element onto
                                                            // that mesh
-                          ensure_existence_of_subface_matrix
-                            (cell->get_fe(),
-                             subface->get_fe(subface_fe_index),
-                             c,
-                             subface_interpolation_matrices
-                             [cell->active_fe_index()][subface_fe_index][c]);
+                                     ensure_existence_of_subface_matrix
+                                       (cell->get_fe(),
+                                        subface->get_fe(subface_fe_index),
+                                        c,
+                                        subface_interpolation_matrices
+                                        [cell->active_fe_index()][subface_fe_index][c]);
 
                                                            // Add constraints to global constraint
                                                            // matrix.
-                          filter_constraints (master_dofs,
-                                              slave_dofs,
-                                              *(subface_interpolation_matrices
-                                                [cell->active_fe_index()][subface_fe_index][c]),
-                                              constraints);
-                        }
-
-                      break;
-                    }
-
-                    case FiniteElementDomination::other_element_dominates:
-                    case FiniteElementDomination::neither_element_dominates:
-                    {
+                                     filter_constraints (master_dofs,
+                                                                 slave_dofs,
+                                                                 *(subface_interpolation_matrices
+                                                                       [cell->active_fe_index()][subface_fe_index][c]),
+                                                                 constraints);
+                                   }
+
+                             break;
+                           }
+
+                           case FiniteElementDomination::other_element_dominates:
+                           case FiniteElementDomination::neither_element_dominates:
+                           {
                                                        // Case 2 (the "complex"
                                                        // case): at least one
                                                        // (the neither_... case)
@@ -2830,8 +2830,8 @@ namespace DoFTools
                                                        // dof handlers,
                                                        // add a check
                                                        // here...
-                      Assert (DoFHandlerSupportsDifferentFEs<DH>::value == true,
-                              ExcInternalError());
+                             Assert (DoFHandlerSupportsDifferentFEs<DH>::value == true,
+                                         ExcInternalError());
 
                                                        // we first have
                                                        // to find the
@@ -2842,11 +2842,11 @@ namespace DoFTools
                                                        // the other ones
                                                        // can be
                                                        // constrained to
-                      const unsigned int dominating_fe_index
-                        = get_most_dominating_subface_fe_index (cell->face(face));
+                             const unsigned int dominating_fe_index
+                                   = get_most_dominating_subface_fe_index (cell->face(face));
 
-                      const FiniteElement<dim,spacedim> &dominating_fe
-                        = dof_handler.get_fe()[dominating_fe_index];
+                             const FiniteElement<dim,spacedim> &dominating_fe
+                                   = dof_handler.get_fe()[dominating_fe_index];
 
                                                        // check also
                                                        // that it is
@@ -2860,59 +2860,59 @@ namespace DoFTools
                                                        // into the
                                                        // branch for the
                                                        // 'complex' case
-                      Assert ((dominating_fe.compare_for_face_domination
-                               (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0)))
-                               == FiniteElementDomination::this_element_dominates)
-                              ||
-                              (dominating_fe.compare_for_face_domination
-                               (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0)))
-                               == FiniteElementDomination::either_element_can_dominate),
-                              ExcInternalError());
+                             Assert ((dominating_fe.compare_for_face_domination
+                                          (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0)))
+                                          == FiniteElementDomination::this_element_dominates)
+                                         ||
+                                         (dominating_fe.compare_for_face_domination
+                                          (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0)))
+                                          == FiniteElementDomination::either_element_can_dominate),
+                                         ExcInternalError());
 
 
                                                        // first get the
                                                        // interpolation matrix
                                                        // from the mother to the
                                                        // virtual dofs
-                      Assert (dominating_fe.dofs_per_face <=
-                              cell->get_fe().dofs_per_face,
-                              ExcInternalError());
+                             Assert (dominating_fe.dofs_per_face <=
+                                         cell->get_fe().dofs_per_face,
+                                         ExcInternalError());
 
-                      ensure_existence_of_face_matrix
-                        (dominating_fe,
-                         cell->get_fe(),
-                         face_interpolation_matrices
-                         [dominating_fe_index][cell->active_fe_index()]);
+                             ensure_existence_of_face_matrix
+                                   (dominating_fe,
+                                    cell->get_fe(),
+                                    face_interpolation_matrices
+                                    [dominating_fe_index][cell->active_fe_index()]);
 
                                                        // split this matrix into
                                                        // master and slave
                                                        // components. invert the
                                                        // master component
-                      ensure_existence_of_master_dof_mask
-                        (cell->get_fe(),
-                         dominating_fe,
-                         (*face_interpolation_matrices
-                          [dominating_fe_index]
-                          [cell->active_fe_index()]),
-                         master_dof_masks
-                         [dominating_fe_index]
-                         [cell->active_fe_index()]);
-
-                      ensure_existence_of_split_face_matrix
-                        (*face_interpolation_matrices
-                         [dominating_fe_index][cell->active_fe_index()],
-                         (*master_dof_masks
-                          [dominating_fe_index][cell->active_fe_index()]),
-                         split_face_interpolation_matrices
-                         [dominating_fe_index][cell->active_fe_index()]);
-
-                      const FullMatrix<double> &restrict_mother_to_virtual_master_inv
-                        = (split_face_interpolation_matrices
-                           [dominating_fe_index][cell->active_fe_index()]->first);
-
-                      const FullMatrix<double> &restrict_mother_to_virtual_slave
-                        = (split_face_interpolation_matrices
-                           [dominating_fe_index][cell->active_fe_index()]->second);
+                             ensure_existence_of_master_dof_mask
+                                   (cell->get_fe(),
+                                    dominating_fe,
+                                    (*face_interpolation_matrices
+                                     [dominating_fe_index]
+                                     [cell->active_fe_index()]),
+                                    master_dof_masks
+                                    [dominating_fe_index]
+                                    [cell->active_fe_index()]);
+
+                             ensure_existence_of_split_face_matrix
+                                   (*face_interpolation_matrices
+                                    [dominating_fe_index][cell->active_fe_index()],
+                                    (*master_dof_masks
+                                     [dominating_fe_index][cell->active_fe_index()]),
+                                    split_face_interpolation_matrices
+                                    [dominating_fe_index][cell->active_fe_index()]);
+
+                             const FullMatrix<double> &restrict_mother_to_virtual_master_inv
+                                   = (split_face_interpolation_matrices
+                                      [dominating_fe_index][cell->active_fe_index()]->first);
+
+                             const FullMatrix<double> &restrict_mother_to_virtual_slave
+                                   = (split_face_interpolation_matrices
+                                      [dominating_fe_index][cell->active_fe_index()]->second);
 
                                                        // now compute
                                                        // the constraint
@@ -2922,12 +2922,12 @@ namespace DoFTools
                                                        // inverse matrix
                                                        // and the slave
                                                        // part
-                      constraint_matrix.reinit (cell->get_fe().dofs_per_face -
-                                                dominating_fe.dofs_per_face,
-                                                dominating_fe.dofs_per_face);
-                      restrict_mother_to_virtual_slave
-                        .mmult (constraint_matrix,
-                                restrict_mother_to_virtual_master_inv);
+                             constraint_matrix.reinit (cell->get_fe().dofs_per_face -
+                                                                       dominating_fe.dofs_per_face,
+                                                                       dominating_fe.dofs_per_face);
+                             restrict_mother_to_virtual_slave
+                                   .mmult (constraint_matrix,
+                                               restrict_mother_to_virtual_master_inv);
 
                                                        // then figure
                                                        // out the global
@@ -2936,29 +2936,29 @@ namespace DoFTools
                                                        // slave dofs and
                                                        // apply
                                                        // constraints
-                      scratch_dofs.resize (cell->get_fe().dofs_per_face);
-                      cell->face(face)->get_dof_indices (scratch_dofs,
-                                                         cell->active_fe_index ());
+                             scratch_dofs.resize (cell->get_fe().dofs_per_face);
+                             cell->face(face)->get_dof_indices (scratch_dofs,
+                                                                                    cell->active_fe_index ());
 
                                                        // split dofs into master
                                                        // and slave components
-                      master_dofs.clear ();
-                      slave_dofs.clear ();
-                      for (unsigned int i=0; i<cell->get_fe().dofs_per_face; ++i)
-                        if ((*master_dof_masks
-                             [dominating_fe_index][cell->active_fe_index()])[i] == true)
-                          master_dofs.push_back (scratch_dofs[i]);
-                        else
-                          slave_dofs.push_back (scratch_dofs[i]);
+                             master_dofs.clear ();
+                             slave_dofs.clear ();
+                             for (unsigned int i=0; i<cell->get_fe().dofs_per_face; ++i)
+                                   if ((*master_dof_masks
+                                        [dominating_fe_index][cell->active_fe_index()])[i] == true)
+                                     master_dofs.push_back (scratch_dofs[i]);
+                                   else
+                                     slave_dofs.push_back (scratch_dofs[i]);
 
-                      AssertDimension (master_dofs.size(), dominating_fe.dofs_per_face);
-                      AssertDimension (slave_dofs.size(),
-                                       cell->get_fe().dofs_per_face - dominating_fe.dofs_per_face);
+                             AssertDimension (master_dofs.size(), dominating_fe.dofs_per_face);
+                             AssertDimension (slave_dofs.size(),
+                                                      cell->get_fe().dofs_per_face - dominating_fe.dofs_per_face);
 
-                      filter_constraints (master_dofs,
-                                          slave_dofs,
-                                          constraint_matrix,
-                                          constraints);
+                             filter_constraints (master_dofs,
+                                                             slave_dofs,
+                                                             constraint_matrix,
+                                                             constraints);
 
 
 
@@ -2969,9 +2969,9 @@ namespace DoFTools
                                                        // as discussed
                                                        // in the hp
                                                        // paper
-                      for (unsigned int sf=0;
-                           sf<cell->face(face)->n_children(); ++sf)
-                        {
+                             for (unsigned int sf=0;
+                                      sf<cell->face(face)->n_children(); ++sf)
+                                   {
                                                            // ignore
                                                            // interfaces
                                                            // with
@@ -2982,62 +2982,62 @@ namespace DoFTools
                                                            // between
                                                            // ghost
                                                            // cells in 2d
-                          if (cell->neighbor_child_on_subface (face, sf)->is_artificial()
-                              ||
-                              (dim==2 && cell->is_ghost()
-                               &&
-                               cell->neighbor_child_on_subface (face, sf)->is_ghost()))
-                            continue;
-
-                          Assert (cell->face(face)->child(sf)
-                                  ->n_active_fe_indices() == 1,
-                                  ExcInternalError());
-
-                          const unsigned int subface_fe_index
-                            = cell->face(face)->child(sf)->nth_active_fe_index(0);
-                          const FiniteElement<dim,spacedim> &subface_fe
-                            = dof_handler.get_fe()[subface_fe_index];
+                                     if (cell->neighbor_child_on_subface (face, sf)->is_artificial()
+                                         ||
+                                         (dim==2 && cell->is_ghost()
+                                          &&
+                                          cell->neighbor_child_on_subface (face, sf)->is_ghost()))
+                                       continue;
+
+                                     Assert (cell->face(face)->child(sf)
+                                                 ->n_active_fe_indices() == 1,
+                                                 ExcInternalError());
+
+                                     const unsigned int subface_fe_index
+                                       = cell->face(face)->child(sf)->nth_active_fe_index(0);
+                                     const FiniteElement<dim,spacedim> &subface_fe
+                                       = dof_handler.get_fe()[subface_fe_index];
 
                                                            // first get the
                                                            // interpolation
                                                            // matrix from the
                                                            // subface to the
                                                            // virtual dofs
-                          Assert (dominating_fe.dofs_per_face <=
-                                  subface_fe.dofs_per_face,
-                                  ExcInternalError());
-                          ensure_existence_of_subface_matrix
-                            (dominating_fe,
-                             subface_fe,
-                             sf,
-                             subface_interpolation_matrices
-                             [dominating_fe_index][subface_fe_index][sf]);
-
-                          const FullMatrix<double> &restrict_subface_to_virtual
-                            = *(subface_interpolation_matrices
-                                [dominating_fe_index][subface_fe_index][sf]);
-
-                          constraint_matrix.reinit (subface_fe.dofs_per_face,
-                                                    dominating_fe.dofs_per_face);
-
-                          restrict_subface_to_virtual
-                            .mmult (constraint_matrix,
-                                    restrict_mother_to_virtual_master_inv);
-
-                          slave_dofs.resize (subface_fe.dofs_per_face);
-                          cell->face(face)->child(sf)->get_dof_indices (slave_dofs,
-                                                                        subface_fe_index);
-
-                          filter_constraints (master_dofs,
-                                              slave_dofs,
-                                              constraint_matrix,
-                                              constraints);
-                        }
-
-                      break;
-                    }
-
-                    case FiniteElementDomination::no_requirements:
+                                     Assert (dominating_fe.dofs_per_face <=
+                                                 subface_fe.dofs_per_face,
+                                                 ExcInternalError());
+                                     ensure_existence_of_subface_matrix
+                                       (dominating_fe,
+                                        subface_fe,
+                                        sf,
+                                        subface_interpolation_matrices
+                                        [dominating_fe_index][subface_fe_index][sf]);
+
+                                     const FullMatrix<double> &restrict_subface_to_virtual
+                                       = *(subface_interpolation_matrices
+                                               [dominating_fe_index][subface_fe_index][sf]);
+
+                                     constraint_matrix.reinit (subface_fe.dofs_per_face,
+                                                                           dominating_fe.dofs_per_face);
+
+                                     restrict_subface_to_virtual
+                                       .mmult (constraint_matrix,
+                                                   restrict_mother_to_virtual_master_inv);
+
+                                     slave_dofs.resize (subface_fe.dofs_per_face);
+                                     cell->face(face)->child(sf)->get_dof_indices (slave_dofs,
+                                                                                                           subface_fe_index);
+
+                                     filter_constraints (master_dofs,
+                                                                 slave_dofs,
+                                                                 constraint_matrix,
+                                                                 constraints);
+                                   }
+
+                             break;
+                           }
+
+                           case FiniteElementDomination::no_requirements:
                                                            // there
                                                            // are no
                                                            // continuity
@@ -3047,24 +3047,24 @@ namespace DoFTools
                                                            // elements. record
                                                            // no
                                                            // constraints
-                          break;
+                                     break;
 
-                    default:
+                           default:
                                                            // we shouldn't get here
-                          Assert (false, ExcInternalError());
-                  }
-              }
-            else
-              {
+                                     Assert (false, ExcInternalError());
+                         }
+                 }
+               else
+                 {
                                                  // this face has no
                                                  // children, but it
                                                  // could still be that
                                                  // it is shared by two
                                                  // cells that use a
                                                  // different fe index
-                Assert (cell->face(face)
-                        ->fe_index_is_active(cell->active_fe_index()) == true,
-                        ExcInternalError());
+                       Assert (cell->face(face)
+                                   ->fe_index_is_active(cell->active_fe_index()) == true,
+                                   ExcInternalError());
 
                                                  // see if there is a
                                                  // neighbor that is
@@ -3078,10 +3078,10 @@ namespace DoFTools
                                                  // cells may not have
                                                  // an active_fe_index
                                                  // set, etc
-                if (!cell->at_boundary(face)
-                    &&
-                    cell->neighbor(face)->is_artificial())
-                  continue;
+                       if (!cell->at_boundary(face)
+                           &&
+                           cell->neighbor(face)->is_artificial())
+                         continue;
 
                                                  // Only if there is
                                                  // a neighbor with
@@ -3090,42 +3090,42 @@ namespace DoFTools
                                                  // and the same h-level,
                                                  // some action has
                                                  // to be taken.
-                if ((DoFHandlerSupportsDifferentFEs<DH>::value == true)
-                    &&
-                    !cell->face(face)->at_boundary ()
-                    &&
-                    (cell->neighbor(face)->active_fe_index () !=
-                     cell->active_fe_index ())
-                    &&
-                    (!cell->face(face)->has_children() &&
-                     !cell->neighbor_is_coarser(face) ))
-                  {
-                    const typename DH::cell_iterator neighbor = cell->neighbor (face);
+                       if ((DoFHandlerSupportsDifferentFEs<DH>::value == true)
+                           &&
+                           !cell->face(face)->at_boundary ()
+                           &&
+                           (cell->neighbor(face)->active_fe_index () !=
+                            cell->active_fe_index ())
+                           &&
+                           (!cell->face(face)->has_children() &&
+                            !cell->neighbor_is_coarser(face) ))
+                         {
+                           const typename DH::cell_iterator neighbor = cell->neighbor (face);
 
                                                      // see which side of the
                                                      // face we have to
                                                      // constrain
-                    switch (cell->get_fe().compare_for_face_domination (neighbor->get_fe ()))
-                      {
-                        case FiniteElementDomination::this_element_dominates:
-                        {
+                           switch (cell->get_fe().compare_for_face_domination (neighbor->get_fe ()))
+                             {
+                                   case FiniteElementDomination::this_element_dominates:
+                                   {
                                                            // Get DoFs on
                                                            // dominating and
                                                            // dominated side of
                                                            // the face
-                          master_dofs.resize (cell->get_fe().dofs_per_face);
-                          cell->face(face)->get_dof_indices (master_dofs,
-                                                             cell->active_fe_index ());
+                                     master_dofs.resize (cell->get_fe().dofs_per_face);
+                                     cell->face(face)->get_dof_indices (master_dofs,
+                                                                                        cell->active_fe_index ());
 
-                          slave_dofs.resize (neighbor->get_fe().dofs_per_face);
-                          cell->face(face)->get_dof_indices (slave_dofs,
-                                                             neighbor->active_fe_index ());
+                                     slave_dofs.resize (neighbor->get_fe().dofs_per_face);
+                                     cell->face(face)->get_dof_indices (slave_dofs,
+                                                                                        neighbor->active_fe_index ());
 
                                                            // break if the n_master_dofs == 0,
                                                            // because we are attempting to
                                                            // constrain to an element that has
                                                            // has no face dofs
-                          if(master_dofs.size() == 0) break;
+                                     if(master_dofs.size() == 0) break;
 
                                                            // make sure
                                                            // the element
@@ -3133,26 +3133,26 @@ namespace DoFTools
                                                            // for this
                                                            // face are
                                                            // available
-                          ensure_existence_of_face_matrix
-                            (cell->get_fe(),
-                             neighbor->get_fe(),
-                             face_interpolation_matrices
-                             [cell->active_fe_index()][neighbor->active_fe_index()]);
+                                     ensure_existence_of_face_matrix
+                                       (cell->get_fe(),
+                                        neighbor->get_fe(),
+                                        face_interpolation_matrices
+                                        [cell->active_fe_index()][neighbor->active_fe_index()]);
 
                                                            // Add constraints to global constraint
                                                            // matrix.
-                          filter_constraints (master_dofs,
-                                              slave_dofs,
-                                              *(face_interpolation_matrices
-                                                [cell->active_fe_index()]
-                                                [neighbor->active_fe_index()]),
-                                              constraints);
-
-                          break;
-                        }
-
-                        case FiniteElementDomination::other_element_dominates:
-                        {
+                                     filter_constraints (master_dofs,
+                                                                 slave_dofs,
+                                                                 *(face_interpolation_matrices
+                                                                       [cell->active_fe_index()]
+                                                                       [neighbor->active_fe_index()]),
+                                                                 constraints);
+
+                                     break;
+                                   }
+
+                                   case FiniteElementDomination::other_element_dominates:
+                                   {
                                                            // we don't do anything
                                                            // here since we will
                                                            // come back to this
@@ -3161,11 +3161,11 @@ namespace DoFTools
                                                            // we will fall into
                                                            // the first case
                                                            // clause above
-                          break;
-                        }
+                                     break;
+                                   }
 
-                        case FiniteElementDomination::either_element_can_dominate:
-                        {
+                                   case FiniteElementDomination::either_element_can_dominate:
+                                   {
                                                            // it appears as if
                                                            // neither element has
                                                            // any constraints on
@@ -3208,38 +3208,38 @@ namespace DoFTools
                                                            // finite elements
                                                            // actually do have
                                                            // dofs on the face
-                          if ((cell->get_fe().dofs_per_face != 0)
-                              ||
-                              (cell->neighbor(face)->get_fe().dofs_per_face != 0))
-                            {
-                              Assert (cell->get_fe().dofs_per_face
-                                      ==
-                                      cell->neighbor(face)->get_fe().dofs_per_face,
-                                      ExcNotImplemented());
+                                     if ((cell->get_fe().dofs_per_face != 0)
+                                         ||
+                                         (cell->neighbor(face)->get_fe().dofs_per_face != 0))
+                                       {
+                                         Assert (cell->get_fe().dofs_per_face
+                                                     ==
+                                                     cell->neighbor(face)->get_fe().dofs_per_face,
+                                                     ExcNotImplemented());
 
                                                                // (ab)use the master
                                                                // and slave dofs
                                                                // arrays for a
                                                                // moment here
-                              master_dofs.resize (cell->get_fe().dofs_per_face);
-                              cell->face(face)
-                                ->get_dof_indices (master_dofs,
-                                                   cell->active_fe_index ());
+                                         master_dofs.resize (cell->get_fe().dofs_per_face);
+                                         cell->face(face)
+                                               ->get_dof_indices (master_dofs,
+                                                                          cell->active_fe_index ());
 
-                              slave_dofs.resize (cell->neighbor(face)->get_fe().dofs_per_face);
-                              cell->face(face)
-                                ->get_dof_indices (slave_dofs,
-                                                   cell->neighbor(face)->active_fe_index ());
+                                         slave_dofs.resize (cell->neighbor(face)->get_fe().dofs_per_face);
+                                         cell->face(face)
+                                               ->get_dof_indices (slave_dofs,
+                                                                          cell->neighbor(face)->active_fe_index ());
 
-                              for (unsigned int i=0; i<cell->get_fe().dofs_per_face; ++i)
-                                AssertDimension (master_dofs[i], slave_dofs[i]);
-                            }
+                                         for (unsigned int i=0; i<cell->get_fe().dofs_per_face; ++i)
+                                               AssertDimension (master_dofs[i], slave_dofs[i]);
+                                       }
 
-                          break;
-                        }
+                                     break;
+                                   }
 
-                        case FiniteElementDomination::neither_element_dominates:
-                        {
+                                   case FiniteElementDomination::neither_element_dominates:
+                                   {
                                                            // we don't presently
                                                            // know what exactly to
                                                            // do here. it isn't quite
@@ -3250,23 +3250,23 @@ namespace DoFTools
                                                            // following statement
                                                            // and see what exactly
                                                            // is going on
-                          Assert (false, ExcNotImplemented());
-                          break;
-                        }
+                                     Assert (false, ExcNotImplemented());
+                                     break;
+                                   }
 
-                        case FiniteElementDomination::no_requirements:
-                        {
+                                   case FiniteElementDomination::no_requirements:
+                                   {
                                                            // nothing to do here
-                          break;
-                        }
+                                     break;
+                                   }
 
-                        default:
+                                   default:
                                                                // we shouldn't get
                                                                // here
-                              Assert (false, ExcInternalError());
-                      }
-                  }
-              }
+                                         Assert (false, ExcInternalError());
+                             }
+                         }
+                 }
     }
   }
 
@@ -3276,7 +3276,7 @@ namespace DoFTools
   template <class DH>
   void
   make_hanging_node_constraints (const DH &dof_handler,
-                                 ConstraintMatrix &constraints)
+                                                ConstraintMatrix &constraints)
   {
                                      // Decide whether to use the
                                      // new or old make_hanging_node_constraints
@@ -3288,13 +3288,13 @@ namespace DoFTools
                                      // for the moment.
     if (dof_handler.get_fe().hp_constraints_are_implemented ())
       internal::
-        make_hp_hanging_node_constraints (dof_handler,
-                                          constraints);
+           make_hp_hanging_node_constraints (dof_handler,
+                                                             constraints);
     else
       internal::
-        make_oldstyle_hanging_node_constraints (dof_handler,
-                                                constraints,
-                                                dealii::internal::int2type<DH::dimension>());
+           make_oldstyle_hanging_node_constraints (dof_handler,
+                                                                       constraints,
+                                                                       dealii::internal::int2type<DH::dimension>());
   }
 
 
@@ -3463,40 +3463,40 @@ namespace DoFTools
     inline
     void
     extract_dofs_by_component (const DH                   &dof,
-                               const std::vector<bool>    &component_select,
-                               const bool                  sort_by_blocks,
-                               std::vector<unsigned char> &dofs_by_component)
+                                          const std::vector<bool>    &component_select,
+                                          const bool                  sort_by_blocks,
+                                          std::vector<unsigned char> &dofs_by_component)
     {
       const dealii::hp::FECollection<DH::dimension,DH::space_dimension>
-        fe_collection (dof.get_fe());
+           fe_collection (dof.get_fe());
       Assert (fe_collection.n_components() < 256, ExcNotImplemented());
       Assert (dofs_by_component.size() == dof.n_locally_owned_dofs(),
-              ExcDimensionMismatch(dofs_by_component.size(),
-                                   dof.n_locally_owned_dofs()));
+                 ExcDimensionMismatch(dofs_by_component.size(),
+                                                  dof.n_locally_owned_dofs()));
 
                                        // next set up a table for the
                                        // degrees of freedom on each of
                                        // the cells whether it is
                                        // something interesting or not
       std::vector<std::vector<unsigned char> > local_component_association
-        (fe_collection.size());
+           (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_component_association[f].resize(fe.dofs_per_cell);
-          if (sort_by_blocks == true)
-            {
-              for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
-                local_component_association[f][i]
-                  = fe.system_to_block_index(i).first;
-            }
-          else
-            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
+           {
+             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)
+               {
+                 for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+                       local_component_association[f][i]
+                         = fe.system_to_block_index(i).first;
+               }
+             else
+               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
@@ -3508,52 +3508,52 @@ namespace DoFTools
                                                  // 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());
+                       {
+                         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;
-                        }
-                }
-        }
+                         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
       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];
-          }
+              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];
+             }
     }
   }
 
@@ -3574,7 +3574,7 @@ namespace DoFTools
     AssertDimension (dof_data.size(), dof_handler.n_dofs());
     AssertIndexRange (component, n_components(dof_handler));
     Assert (fe_is_primitive(dof_handler) == true,
-            typename FiniteElement<dim>::ExcFENotPrimitive());
+               typename FiniteElement<dim>::ExcFENotPrimitive());
 
                                      // store a flag whether we should care
                                      // about different components. this is
@@ -3589,16 +3589,16 @@ namespace DoFTools
       dof_data = 0;
     else
       {
-        std::vector<unsigned char> component_dofs (dof_handler.n_locally_owned_dofs());
-        std::vector<bool> component_mask (dof_handler.get_fe().n_components(),
-                                          false);
-        component_mask[component] = true;
-        internal::extract_dofs_by_component (dof_handler, component_mask,
-                                             false, component_dofs);
-
-        for (unsigned int i=0; i<dof_data.size(); ++i)
-          if (component_dofs[i] == static_cast<unsigned char>(component))
-            dof_data(i) = 0;
+           std::vector<unsigned char> component_dofs (dof_handler.n_locally_owned_dofs());
+           std::vector<bool> component_mask (dof_handler.get_fe().n_components(),
+                                                             false);
+           component_mask[component] = true;
+           internal::extract_dofs_by_component (dof_handler, component_mask,
+                                                                false, component_dofs);
+
+           for (unsigned int i=0; i<dof_data.size(); ++i)
+             if (component_dofs[i] == static_cast<unsigned char>(component))
+               dof_data(i) = 0;
       }
 
                                      // count how often we have added a value
@@ -3606,31 +3606,31 @@ namespace DoFTools
     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;
     dof_indices.reserve (max_dofs_per_cell(dof_handler));
 
     for (unsigned int present_cell = 0; cell!=endc; ++cell, ++present_cell)
       {
-        const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
-        dof_indices.resize (dofs_per_cell);
-        cell->get_dof_indices (dof_indices);
+           const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
+           dof_indices.resize (dofs_per_cell);
+           cell->get_dof_indices (dof_indices);
 
-        for (unsigned int i=0; i<dofs_per_cell; ++i)
+           for (unsigned int i=0; i<dofs_per_cell; ++i)
                                            // consider this dof only if it
                                            // is the right component. if there
                                            // is only one component, short cut
                                            // the test
-          if (!consider_components ||
-              (cell->get_fe().system_to_component_index(i).first == component))
-            {
+             if (!consider_components ||
+                 (cell->get_fe().system_to_component_index(i).first == component))
+               {
                                                // sum up contribution of the
                                                // present_cell to this dof
-              dof_data(dof_indices[i]) += cell_data(present_cell);
+                 dof_data(dof_indices[i]) += cell_data(present_cell);
                                                // note that we added another
                                                // summand
-              ++touch_count[dof_indices[i]];
-            }
+                 ++touch_count[dof_indices[i]];
+               }
       }
 
                                      // compute the mean value on all the
@@ -3642,10 +3642,10 @@ namespace DoFTools
                                          // at least once. this needs not be
                                          // the case if the vector has more than
                                          // one component
-        Assert (consider_components || (touch_count[i]!=0),
-                ExcInternalError());
-        if (touch_count[i] != 0)
-          dof_data(i) /=  touch_count[i];
+           Assert (consider_components || (touch_count[i]!=0),
+                       ExcInternalError());
+           if (touch_count[i] != 0)
+             dof_data(i) /=  touch_count[i];
       }
   }
 
@@ -3663,33 +3663,33 @@ namespace DoFTools
 
     if (count_by_blocks == true)
       {
-        Assert(component_select.size() == fe.n_blocks(),
-               ExcDimensionMismatch(component_select.size(), fe.n_blocks()));
+           Assert(component_select.size() == fe.n_blocks(),
+                  ExcDimensionMismatch(component_select.size(), fe.n_blocks()));
       }
     else
       {
-        Assert(component_select.size() == n_components(dof),
-               ExcDimensionMismatch(component_select.size(), n_components(dof)));
+           Assert(component_select.size() == n_components(dof),
+                  ExcDimensionMismatch(component_select.size(), n_components(dof)));
       }
 
     Assert(selected_dofs.size() == dof.n_locally_owned_dofs(),
-           ExcDimensionMismatch(selected_dofs.size(), dof.n_locally_owned_dofs()));
+              ExcDimensionMismatch(selected_dofs.size(), dof.n_locally_owned_dofs()));
 
                                      // two special cases: no component
                                      // is selected, and all components
                                      // are selected; both rather
                                      // stupid, but easy to catch
     if (std::count (component_select.begin(), component_select.end(), true)
-        == 0)
+           == 0)
       {
-        std::fill_n (selected_dofs.begin(), dof.n_locally_owned_dofs(), false);
-        return;
+           std::fill_n (selected_dofs.begin(), dof.n_locally_owned_dofs(), false);
+           return;
       }
     else if (std::count (component_select.begin(), component_select.end(), true)
-             == static_cast<signed int>(component_select.size()))
+                == static_cast<signed int>(component_select.size()))
       {
-        std::fill_n (selected_dofs.begin(), dof.n_locally_owned_dofs(), true);
-        return;
+           std::fill_n (selected_dofs.begin(), dof.n_locally_owned_dofs(), true);
+           return;
       }
 
 
@@ -3705,11 +3705,11 @@ namespace DoFTools
                                      // job.
     std::vector<unsigned char> dofs_by_component (dof.n_locally_owned_dofs());
     internal::extract_dofs_by_component (dof, component_select, count_by_blocks,
-                                         dofs_by_component);
+                                                            dofs_by_component);
 
     for (unsigned int i=0; i<dof.n_locally_owned_dofs(); ++i)
       if (component_select[dofs_by_component[i]] == true)
-        selected_dofs[i] = true;
+           selected_dofs[i] = true;
   }
 
 
@@ -3726,33 +3726,33 @@ namespace DoFTools
 
     if (count_by_blocks == true)
       {
-        Assert(component_select.size() == fe.n_blocks(),
-               ExcDimensionMismatch(component_select.size(), fe.n_blocks()));
+           Assert(component_select.size() == fe.n_blocks(),
+                  ExcDimensionMismatch(component_select.size(), fe.n_blocks()));
       }
     else
       {
-        Assert(component_select.size() == n_components(dof),
-               ExcDimensionMismatch(component_select.size(), n_components(dof)));
+           Assert(component_select.size() == n_components(dof),
+                  ExcDimensionMismatch(component_select.size(), n_components(dof)));
       }
 
     Assert(selected_dofs.size() == dof.n_dofs(),
-           ExcDimensionMismatch(selected_dofs.size(), dof.n_dofs()));
+              ExcDimensionMismatch(selected_dofs.size(), dof.n_dofs()));
 
                                      // two special cases: no component
                                      // is selected, and all components
                                      // are selected; both rather
                                      // stupid, but easy to catch
     if (std::count (component_select.begin(), component_select.end(), true)
-        == 0)
+           == 0)
       {
-        std::fill_n (selected_dofs.begin(), dof.n_dofs(), false);
-        return;
+           std::fill_n (selected_dofs.begin(), dof.n_dofs(), false);
+           return;
       };
     if (std::count (component_select.begin(), component_select.end(), true)
-        == static_cast<signed int>(component_select.size()))
+           == static_cast<signed int>(component_select.size()))
       {
-        std::fill_n (selected_dofs.begin(), dof.n_dofs(), true);
-        return;
+           std::fill_n (selected_dofs.begin(), dof.n_dofs(), true);
+           return;
       };
 
 
@@ -3768,55 +3768,55 @@ namespace DoFTools
                                      // job.
     std::vector<unsigned char> dofs_by_component (dof.n_dofs());
     internal::extract_dofs_by_component (dof, component_select, count_by_blocks,
-                                         dofs_by_component);
+                                                            dofs_by_component);
 
     for (unsigned int i=0; i<dof.n_dofs(); ++i)
       if (component_select[dofs_by_component[i]] == true)
-        selected_dofs[i] = true;
+           selected_dofs[i] = true;
   }
 
 
 
-  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 std::vector<bool> &component_select,
     std::vector<bool>       &selected_dofs,
     const bool               count_by_blocks)
   {
-    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()));
+           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_select.size() == fe.n_components(),
+                  ExcDimensionMismatch(component_select.size(), fe.n_components()));
       }
 
     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
                                      // are selected, both rather
                                      // stupid, but easy to catch
     if (std::count (component_select.begin(), component_select.end(), true)
-        == 0)
+           == 0)
       {
-        std::fill_n (selected_dofs.begin(), dof.n_dofs(level), false);
-        return;
+           std::fill_n (selected_dofs.begin(), dof.n_dofs(level), false);
+           return;
       };
     if (std::count (component_select.begin(), component_select.end(), true)
-        == static_cast<signed int>(component_select.size()))
+           == static_cast<signed int>(component_select.size()))
       {
-        std::fill_n (selected_dofs.begin(), dof.n_dofs(level), true);
-        return;
+           std::fill_n (selected_dofs.begin(), dof.n_dofs(level), true);
+           return;
       };
 
                                      // preset all values by false
@@ -3829,13 +3829,13 @@ namespace DoFTools
     std::vector<bool> local_selected_dofs (fe.dofs_per_cell, false);
     for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
       if (count_by_blocks == true)
-        local_selected_dofs[i]
-          = component_select[fe.system_to_block_index(i).first];
+           local_selected_dofs[i]
+             = component_select[fe.system_to_block_index(i).first];
       else
-        if (fe.is_primitive(i))
-          local_selected_dofs[i]
-            = component_select[fe.system_to_component_index(i).first];
-        else
+           if (fe.is_primitive(i))
+             local_selected_dofs[i]
+               = component_select[fe.system_to_component_index(i).first];
+           else
                                            // if this shape function is
                                            // not primitive, then we have
                                            // to work harder. we have to
@@ -3849,43 +3849,43 @@ namespace DoFTools
                                            // the base element to which
                                            // the local dof with index i
                                            // belongs
-          {
-            unsigned int first_comp = 0;
-            const unsigned int this_base = fe.system_to_base_index(i).first.first;
-            const unsigned int this_multiplicity
-              = fe.system_to_base_index(i).first.second;
-
-            for (unsigned int b=0; b<this_base; ++b)
-              first_comp += fe.base_element(b).n_components() *
-                            fe.element_multiplicity(b);
-            for (unsigned int m=0; m<this_multiplicity; ++m)
-              first_comp += fe.base_element(this_base).n_components();
-            const unsigned int end_comp = first_comp +
-                                          fe.base_element(this_base).n_components();
-
-            Assert (first_comp < fe.n_components(), ExcInternalError());
-            Assert (end_comp <= fe.n_components(),  ExcInternalError());
+             {
+               unsigned int first_comp = 0;
+               const unsigned int this_base = fe.system_to_base_index(i).first.first;
+               const unsigned int this_multiplicity
+                 = fe.system_to_base_index(i).first.second;
+
+               for (unsigned int b=0; b<this_base; ++b)
+                 first_comp += fe.base_element(b).n_components() *
+                                       fe.element_multiplicity(b);
+               for (unsigned int m=0; m<this_multiplicity; ++m)
+                 first_comp += fe.base_element(this_base).n_components();
+               const unsigned int end_comp = first_comp +
+                                                             fe.base_element(this_base).n_components();
+
+               Assert (first_comp < fe.n_components(), ExcInternalError());
+               Assert (end_comp <= fe.n_components(),  ExcInternalError());
 
                                              // now check whether any of
                                              // the components in between
                                              // is set
-            for (unsigned int c=first_comp; c<end_comp; ++c)
-              if (component_select[c] == true)
-                {
-                  local_selected_dofs[i] = true;
-                  break;
-                }
-          }
+               for (unsigned int c=first_comp; c<end_comp; ++c)
+                 if (component_select[c] == true)
+                       {
+                         local_selected_dofs[i] = true;
+                         break;
+                       }
+             }
 
                                      // then loop over all cells and do
                                      // work
     std::vector<unsigned int> indices(fe.dofs_per_cell);
-    typename MGDoFHandler<dim,spacedim>::cell_iterator c;
+    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];
       }
   }
 
@@ -4049,13 +4049,13 @@ namespace DoFTools
   template <class DH>
   void
   extract_dofs_with_support_on_boundary (const DH                      &dof_handler,
-                                         const std::vector<bool>       &component_select,
-                                         std::vector<bool>             &selected_dofs,
-                                         const std::set<types::boundary_id_t> &boundary_indicators)
+                                                            const std::vector<bool>       &component_select,
+                                                            std::vector<bool>             &selected_dofs,
+                                                            const std::set<types::boundary_id_t> &boundary_indicators)
   {
     AssertDimension (component_select.size(), n_components(dof_handler));
     Assert (boundary_indicators.find (types::internal_face_boundary_id) == boundary_indicators.end(),
-            ExcInvalidBoundaryIndicator());
+               ExcInvalidBoundaryIndicator());
 
                                      // let's see whether we have to
                                      // check for certain boundary
@@ -4068,7 +4068,7 @@ namespace DoFTools
                                      // component is selected, or all
     const bool check_vector_component
       = (component_select != std::vector<bool>(component_select.size(),
-                                               true));
+                                                                  true));
 
                                      // clear and reset array by default
                                      // values
@@ -4091,26 +4091,26 @@ namespace DoFTools
                                      // face which we will be visiting
                                      // sooner or later
     for (typename DH::active_cell_iterator cell=dof_handler.begin_active();
-         cell!=dof_handler.end(); ++cell)
+            cell!=dof_handler.end(); ++cell)
       for (unsigned int face=0;
-           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()))
-            {
-              const FiniteElement<DH::dimension, DH::space_dimension> &fe = cell->get_fe();
-
-              const unsigned int dofs_per_cell = fe.dofs_per_cell;
-              cell_dof_indices.resize (dofs_per_cell);
-              cell->get_dof_indices (cell_dof_indices);
-
-              for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
-                if (fe.has_support_on_face(i,face))
-                  {
-                    if (!check_vector_component)
-                      selected_dofs[cell_dof_indices[i]] = true;
-                    else
+              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()))
+               {
+                 const FiniteElement<DH::dimension, DH::space_dimension> &fe = cell->get_fe();
+
+                 const unsigned int dofs_per_cell = fe.dofs_per_cell;
+                 cell_dof_indices.resize (dofs_per_cell);
+                 cell->get_dof_indices (cell_dof_indices);
+
+                 for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+                       if (fe.has_support_on_face(i,face))
+                         {
+                           if (!check_vector_component)
+                             selected_dofs[cell_dof_indices[i]] = true;
+                           else
                                                        // check for
                                                        // component is
                                                        // required. somewhat
@@ -4121,29 +4121,29 @@ namespace DoFTools
                                                        // but use usual
                                                        // convention (see
                                                        // docs)
-                      {
-                        if (fe.is_primitive (i))
-                          selected_dofs[cell_dof_indices[i]]
-                            = (component_select[fe.system_to_component_index(i).first]
-                               == true);
-                        else // not primitive
-                          {
-                            const unsigned int first_nonzero_comp
-                              = (std::find (fe.get_nonzero_components(i).begin(),
-                                            fe.get_nonzero_components(i).end(),
-                                            true)
-                                 -
-                                 fe.get_nonzero_components(i).begin());
-                            Assert (first_nonzero_comp < fe.n_components(),
-                                    ExcInternalError());
-
-                            selected_dofs[cell_dof_indices[i]]
-                              = (component_select[first_nonzero_comp]
-                                 == true);
-                          }
-                      }
-                  }
-            }
+                             {
+                                   if (fe.is_primitive (i))
+                                     selected_dofs[cell_dof_indices[i]]
+                                       = (component_select[fe.system_to_component_index(i).first]
+                                          == true);
+                                   else // not primitive
+                                     {
+                                       const unsigned int first_nonzero_comp
+                                         = (std::find (fe.get_nonzero_components(i).begin(),
+                                                               fe.get_nonzero_components(i).end(),
+                                                               true)
+                                                -
+                                                fe.get_nonzero_components(i).begin());
+                                       Assert (first_nonzero_comp < fe.n_components(),
+                                                   ExcInternalError());
+
+                                       selected_dofs[cell_dof_indices[i]]
+                                         = (component_select[first_nonzero_comp]
+                                                == true);
+                                     }
+                             }
+                         }
+               }
   }
 
 
@@ -4155,12 +4155,12 @@ namespace DoFTools
     {
       template <int spacedim>
       void extract_hanging_node_dofs (const dealii::DoFHandler<1,spacedim> &dof_handler,
-                                      std::vector<bool>           &selected_dofs)
+                                                     std::vector<bool>           &selected_dofs)
       {
-        Assert(selected_dofs.size() == dof_handler.n_dofs(),
-               ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs()));
+           Assert(selected_dofs.size() == dof_handler.n_dofs(),
+                  ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs()));
                                          // preset all values by false
-        std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false);
+           std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false);
 
                                          // there are no hanging nodes in 1d
       }
@@ -4168,101 +4168,101 @@ namespace DoFTools
 
       template <int spacedim>
       void extract_hanging_node_dofs (const dealii::DoFHandler<2,spacedim> &dof_handler,
-                                      std::vector<bool>           &selected_dofs)
+                                                     std::vector<bool>           &selected_dofs)
       {
-        const unsigned int dim = 2;
+           const unsigned int dim = 2;
 
-        Assert(selected_dofs.size() == dof_handler.n_dofs(),
-               ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs()));
+           Assert(selected_dofs.size() == dof_handler.n_dofs(),
+                  ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs()));
                                          // preset all values by false
-        std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false);
+           std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false);
 
-        const FiniteElement<dim,spacedim> &fe = dof_handler.get_fe();
+           const FiniteElement<dim,spacedim> &fe = dof_handler.get_fe();
 
                                          // this function is similar to the
                                          // make_sparsity_pattern function,
                                          // see there for more information
-        typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
-          cell = dof_handler.begin_active(),
-          endc = dof_handler.end();
-        for (; cell!=endc; ++cell)
-          for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
-            if (cell->face(face)->has_children())
-              {
-                const typename dealii::DoFHandler<dim,spacedim>::line_iterator
-                  line = cell->face(face);
-
-                for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
-                  selected_dofs[line->child(0)->vertex_dof_index(1,dof)] = true;
-
-                for (unsigned int child=0; child<2; ++child)
-                  for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
-                    selected_dofs[line->child(child)->dof_index(dof)] = true;
-              }
+           typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
+             cell = dof_handler.begin_active(),
+             endc = dof_handler.end();
+           for (; cell!=endc; ++cell)
+             for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+               if (cell->face(face)->has_children())
+                 {
+                       const typename dealii::DoFHandler<dim,spacedim>::line_iterator
+                         line = cell->face(face);
+
+                       for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+                         selected_dofs[line->child(0)->vertex_dof_index(1,dof)] = true;
+
+                       for (unsigned int child=0; child<2; ++child)
+                         for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+                           selected_dofs[line->child(child)->dof_index(dof)] = true;
+                 }
       }
 
 
       template <int spacedim>
       void extract_hanging_node_dofs (const dealii::DoFHandler<3,spacedim> &dof_handler,
-                                      std::vector<bool>           &selected_dofs)
+                                                     std::vector<bool>           &selected_dofs)
       {
-        const unsigned int dim = 3;
+           const unsigned int dim = 3;
 
-        Assert(selected_dofs.size() == dof_handler.n_dofs(),
-               ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs()));
+           Assert(selected_dofs.size() == dof_handler.n_dofs(),
+                  ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs()));
                                          // preset all values by false
-        std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false);
+           std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false);
 
-        const FiniteElement<dim,spacedim> &fe = dof_handler.get_fe();
+           const FiniteElement<dim,spacedim> &fe = dof_handler.get_fe();
 
                                          // this function is similar to the
                                          // make_sparsity_pattern function,
                                          // see there for more information
 
-        typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
-          cell = dof_handler.begin_active(),
-          endc = dof_handler.end();
-        for (; cell!=endc; ++cell)
-          for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
-            if (cell->face(f)->has_children())
-              {
-                const typename dealii::DoFHandler<dim,spacedim>::face_iterator
-                  face = cell->face(f);
+           typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
+             cell = dof_handler.begin_active(),
+             endc = dof_handler.end();
+           for (; cell!=endc; ++cell)
+             for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+               if (cell->face(f)->has_children())
+                 {
+                       const typename dealii::DoFHandler<dim,spacedim>::face_iterator
+                         face = cell->face(f);
 
-                for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
-                  selected_dofs[face->child(0)->vertex_dof_index(2,dof)] = true;
+                       for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+                         selected_dofs[face->child(0)->vertex_dof_index(2,dof)] = true;
 
                                                  // dof numbers on the centers of
                                                  // the lines bounding this face
-                for (unsigned int line=0; line<4; ++line)
-                  for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
-                    selected_dofs[face->line(line)->child(0)->vertex_dof_index(1,dof)] = true;
+                       for (unsigned int line=0; line<4; ++line)
+                         for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+                           selected_dofs[face->line(line)->child(0)->vertex_dof_index(1,dof)] = true;
 
                                                  // next the dofs on the lines interior
                                                  // to the face; the order of these
                                                  // lines is laid down in the
                                                  // FiniteElement class documentation
-                for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
-                  selected_dofs[face->child(0)->line(1)->dof_index(dof)] = true;
-                for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
-                  selected_dofs[face->child(1)->line(2)->dof_index(dof)] = true;
-                for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
-                  selected_dofs[face->child(2)->line(3)->dof_index(dof)] = true;
-                for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
-                  selected_dofs[face->child(3)->line(0)->dof_index(dof)] = true;
+                       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+                         selected_dofs[face->child(0)->line(1)->dof_index(dof)] = true;
+                       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+                         selected_dofs[face->child(1)->line(2)->dof_index(dof)] = true;
+                       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+                         selected_dofs[face->child(2)->line(3)->dof_index(dof)] = true;
+                       for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+                         selected_dofs[face->child(3)->line(0)->dof_index(dof)] = true;
 
                                                  // dofs on the bordering lines
-                for (unsigned int line=0; line<4; ++line)
-                  for (unsigned int child=0; child<2; ++child)
-                    for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
-                      selected_dofs[face->line(line)->child(child)->dof_index(dof)] = true;
+                       for (unsigned int line=0; line<4; ++line)
+                         for (unsigned int child=0; child<2; ++child)
+                           for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+                             selected_dofs[face->line(line)->child(child)->dof_index(dof)] = true;
 
                                                  // finally, for the dofs interior
                                                  // to the four child faces
-                for (unsigned int child=0; child<4; ++child)
-                  for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
-                    selected_dofs[face->child(child)->dof_index(dof)] = true;
-              }
+                       for (unsigned int child=0; child<4; ++child)
+                         for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
+                           selected_dofs[face->child(child)->dof_index(dof)] = true;
+                 }
       }
     }
   }
@@ -4273,10 +4273,10 @@ namespace DoFTools
   void
 
   extract_hanging_node_dofs (const DoFHandler<dim,spacedim> &dof_handler,
-                             std::vector<bool>              &selected_dofs)
+                                        std::vector<bool>              &selected_dofs)
   {
     internal::extract_hanging_node_dofs (dof_handler,
-                                         selected_dofs);
+                                                            selected_dofs);
   }
 
 
@@ -4284,11 +4284,11 @@ namespace DoFTools
   template <class DH>
   void
   extract_subdomain_dofs (const DH                   &dof_handler,
-                          const types::subdomain_id_t subdomain_id,
-                          std::vector<bool>          &selected_dofs)
+                                     const types::subdomain_id_t subdomain_id,
+                                     std::vector<bool>          &selected_dofs)
   {
     Assert(selected_dofs.size() == dof_handler.n_dofs(),
-           ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs()));
+              ExcDimensionMismatch(selected_dofs.size(), dof_handler.n_dofs()));
 
                                      // preset all values by false
     std::fill_n (selected_dofs.begin(), dof_handler.n_dofs(), false);
@@ -4304,13 +4304,13 @@ namespace DoFTools
       endc = dof_handler.end();
     for (; cell!=endc; ++cell)
       if (cell->subdomain_id() == subdomain_id)
-        {
-          const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
-          local_dof_indices.resize (dofs_per_cell);
-          cell->get_dof_indices (local_dof_indices);
-          for (unsigned int i=0; i<dofs_per_cell; ++i)
-            selected_dofs[local_dof_indices[i]] = true;
-        };
+           {
+             const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
+             local_dof_indices.resize (dofs_per_cell);
+             cell->get_dof_indices (local_dof_indices);
+             for (unsigned int i=0; i<dofs_per_cell; ++i)
+               selected_dofs[local_dof_indices[i]] = true;
+           };
   }
 
 
@@ -4318,7 +4318,7 @@ namespace DoFTools
   template <class DH>
   void
   extract_locally_owned_dofs (const DH & dof_handler,
-                              IndexSet & dof_set)
+                                         IndexSet & dof_set)
   {
                                      // collect all the locally owned dofs
     dof_set = dof_handler.locally_owned_dofs();
@@ -4330,7 +4330,7 @@ namespace DoFTools
   template <class DH>
   void
   extract_locally_active_dofs (const DH & dof_handler,
-                               IndexSet & dof_set)
+                                          IndexSet & dof_set)
   {
                                      // collect all the locally owned dofs
     dof_set = dof_handler.locally_owned_dofs();
@@ -4345,19 +4345,19 @@ namespace DoFTools
     std::set<unsigned int> 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);
-
-          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);
-        }
+           {
+             dof_indices.resize(cell->get_fe().dofs_per_cell);
+             cell->get_dof_indices(dof_indices);
+
+             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);
+           }
 
     dof_set.add_indices(global_dof_indices.begin(), global_dof_indices.end());
 
@@ -4369,7 +4369,7 @@ namespace DoFTools
   template <class DH>
   void
   extract_locally_relevant_dofs (const DH & dof_handler,
-                                 IndexSet & dof_set)
+                                                IndexSet & dof_set)
   {
                                      // collect all the locally owned dofs
     dof_set = dof_handler.locally_owned_dofs();
@@ -4384,19 +4384,19 @@ namespace DoFTools
     std::set<unsigned int> 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);
-
-          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);
-        }
+           {
+             dof_indices.resize(cell->get_fe().dofs_per_cell);
+             cell->get_dof_indices(dof_indices);
+
+             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);
+           }
 
     dof_set.add_indices(global_dof_indices.begin(), global_dof_indices.end());
 
@@ -4408,33 +4408,33 @@ namespace DoFTools
   template <class DH>
   void
   extract_constant_modes (const DH                        &dof_handler,
-                          const std::vector<bool>         &component_select,
-                          std::vector<std::vector<bool> > &constant_modes)
+                                     const std::vector<bool>         &component_select,
+                                     std::vector<std::vector<bool> > &constant_modes)
   {
     const unsigned int n_components = dof_handler.get_fe().n_components();
     Assert (n_components == component_select.size(),
-            ExcDimensionMismatch(n_components,
-                                 component_select.size()));
+               ExcDimensionMismatch(n_components,
+                                                component_select.size()));
     std::vector<unsigned int> localized_component (n_components,
-                                                   numbers::invalid_unsigned_int);
+                                                                          numbers::invalid_unsigned_int);
     unsigned int n_components_selected = 0;
     for (unsigned int i=0; i<n_components; ++i)
       if (component_select[i] == true)
-        localized_component[i] = n_components_selected++;
+           localized_component[i] = n_components_selected++;
 
     std::vector<unsigned char> dofs_by_component (dof_handler.n_locally_owned_dofs());
     internal::extract_dofs_by_component (dof_handler, component_select, false,
-                                         dofs_by_component);
+                                                            dofs_by_component);
     unsigned int n_selected_dofs = 0;
     for (unsigned int i=0; i<n_components; ++i)
       if (component_select[i] == true)
-        n_selected_dofs += std::count (dofs_by_component.begin(),
-                                       dofs_by_component.end(), i);
+           n_selected_dofs += std::count (dofs_by_component.begin(),
+                                                      dofs_by_component.end(), i);
 
                                      // First count the number of dofs
                                      // in the current component.
     constant_modes.resize (n_components_selected, std::vector<bool>(n_selected_dofs,
-                                                                    false));
+                                                                                                   false));
     std::vector<unsigned int> component_list (n_components, 0);
     for (unsigned int d=0; d<n_components; ++d)
       component_list[d] = component_select[d];
@@ -4442,10 +4442,10 @@ namespace DoFTools
     unsigned int counter = 0;
     for (unsigned int i=0; i<dof_handler.n_locally_owned_dofs(); ++i)
       if (component_select[dofs_by_component[i]])
-        {
-          constant_modes[localized_component[dofs_by_component[i]]][counter] = true;
-          ++counter;
-        }
+           {
+             constant_modes[localized_component[dofs_by_component[i]]][counter] = true;
+             ++counter;
+           }
   }
 
 
@@ -4453,7 +4453,7 @@ namespace DoFTools
   template <class DH>
   void
   get_active_fe_indices (const DH                  &dof_handler,
-                         std::vector<unsigned int> &active_fe_indices)
+                                    std::vector<unsigned int> &active_fe_indices)
   {
     AssertDimension (active_fe_indices.size(), dof_handler.get_tria().n_active_cells());
 
@@ -4469,25 +4469,25 @@ namespace DoFTools
   template <class DH>
   void
   get_subdomain_association (const DH                  &dof_handler,
-                             std::vector<types::subdomain_id_t> &subdomain_association)
+                                        std::vector<types::subdomain_id_t> &subdomain_association)
   {
                                      // if the Triangulation is distributed, the
                                      // only thing we can usefully ask is for
                                      // its locally owned subdomain
     Assert ((dynamic_cast<const parallel::distributed::
-             Triangulation<DH::dimension,DH::space_dimension>*>
-             (&dof_handler.get_tria()) == 0),
-            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."));
+                Triangulation<DH::dimension,DH::space_dimension>*>
+                (&dof_handler.get_tria()) == 0),
+               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."));
 
     Assert(subdomain_association.size() == dof_handler.n_dofs(),
-           ExcDimensionMismatch(subdomain_association.size(),
-                                dof_handler.n_dofs()));
+              ExcDimensionMismatch(subdomain_association.size(),
+                                               dof_handler.n_dofs()));
 
                                      // 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;
     local_dof_indices.reserve (max_dofs_per_cell(dof_handler));
@@ -4507,14 +4507,14 @@ namespace DoFTools
       endc = dof_handler.end();
     for (; cell!=endc; ++cell)
       {
-        Assert (cell->is_artificial() == false,
-                ExcMessage ("You can't call this function for meshes that "
-                            "have artificial cells."));
+           Assert (cell->is_artificial() == false,
+                       ExcMessage ("You can't call this function for meshes that "
+                                       "have artificial cells."));
 
-        const types::subdomain_id_t subdomain_id = cell->subdomain_id();
-        const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
-        local_dof_indices.resize (dofs_per_cell);
-        cell->get_dof_indices (local_dof_indices);
+           const types::subdomain_id_t subdomain_id = cell->subdomain_id();
+           const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
+           local_dof_indices.resize (dofs_per_cell);
+           cell->get_dof_indices (local_dof_indices);
 
                                          // set subdomain ids. if dofs
                                          // already have their values
@@ -4526,23 +4526,23 @@ namespace DoFTools
                                          // one, where we take "random"
                                          // to be "once this way once
                                          // that way"
-        for (unsigned int i=0; i<dofs_per_cell; ++i)
-          if (subdomain_association[local_dof_indices[i]] ==
-              numbers::invalid_unsigned_int)
-            subdomain_association[local_dof_indices[i]] = subdomain_id;
-          else
-            {
-              if (coin_flip == true)
-                subdomain_association[local_dof_indices[i]] = subdomain_id;
-              coin_flip = !coin_flip;
-            }
+           for (unsigned int i=0; i<dofs_per_cell; ++i)
+             if (subdomain_association[local_dof_indices[i]] ==
+                 numbers::invalid_unsigned_int)
+               subdomain_association[local_dof_indices[i]] = subdomain_id;
+             else
+               {
+                 if (coin_flip == true)
+                       subdomain_association[local_dof_indices[i]] = subdomain_id;
+                 coin_flip = !coin_flip;
+               }
       }
 
     Assert (std::find (subdomain_association.begin(),
-                       subdomain_association.end(),
-                       types::invalid_subdomain_id)
-            == subdomain_association.end(),
-            ExcInternalError());
+                              subdomain_association.end(),
+                              types::invalid_subdomain_id)
+               == subdomain_association.end(),
+               ExcInternalError());
   }
 
 
@@ -4550,14 +4550,14 @@ namespace DoFTools
   template <class DH>
   unsigned int
   count_dofs_with_subdomain_association (const DH           &dof_handler,
-                                         const types::subdomain_id_t subdomain)
+                                                            const types::subdomain_id_t subdomain)
   {
     std::vector<types::subdomain_id_t> subdomain_association (dof_handler.n_dofs());
     get_subdomain_association (dof_handler, subdomain_association);
 
     return std::count (subdomain_association.begin(),
-                       subdomain_association.end(),
-                       subdomain);
+                              subdomain_association.end(),
+                              subdomain);
   }
 
 
@@ -4565,7 +4565,7 @@ namespace DoFTools
   template <class DH>
   IndexSet
   dof_indices_with_subdomain_association (const DH           &dof_handler,
-                                          const types::subdomain_id_t subdomain)
+                                                             const types::subdomain_id_t subdomain)
   {
 
                                      // If we have a distributed::Triangulation only
@@ -4575,8 +4575,8 @@ namespace DoFTools
       ||
       (subdomain == dof_handler.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."));
 
     IndexSet index_set (dof_handler.n_dofs());
 
@@ -4626,12 +4626,12 @@ namespace DoFTools
   template <class DH>
   void
   count_dofs_with_subdomain_association (const DH           &dof_handler,
-                                         const types::subdomain_id_t subdomain,
-                                         std::vector<unsigned int> &n_dofs_on_subdomain)
+                                                            const types::subdomain_id_t subdomain,
+                                                            std::vector<unsigned int> &n_dofs_on_subdomain)
   {
     Assert (n_dofs_on_subdomain.size() == dof_handler.get_fe().n_components(),
-            ExcDimensionMismatch (n_dofs_on_subdomain.size(),
-                                  dof_handler.get_fe().n_components()));
+               ExcDimensionMismatch (n_dofs_on_subdomain.size(),
+                                                 dof_handler.get_fe().n_components()));
     std::fill (n_dofs_on_subdomain.begin(), n_dofs_on_subdomain.end(), 0);
 
                                      // in debug mode, make sure that there are
@@ -4641,15 +4641,15 @@ namespace DoFTools
     {
       bool found = false;
       for (typename Triangulation<DH::dimension,DH::space_dimension>::active_cell_iterator
-             cell=dof_handler.get_tria().begin_active();
-           cell!=dof_handler.get_tria().end(); ++cell)
-        if (cell->subdomain_id() == subdomain)
-          {
-            found = true;
-            break;
-          }
+                cell=dof_handler.get_tria().begin_active();
+              cell!=dof_handler.get_tria().end(); ++cell)
+           if (cell->subdomain_id() == subdomain)
+             {
+               found = true;
+               break;
+             }
       Assert (found == true,
-              ExcMessage ("There are no cells for the given subdomain!"));
+                 ExcMessage ("There are no cells for the given subdomain!"));
     }
 #endif
 
@@ -4658,14 +4658,14 @@ namespace DoFTools
 
     std::vector<unsigned char> component_association (dof_handler.n_dofs());
     internal::extract_dofs_by_component (dof_handler, std::vector<bool>(), false,
-                                         component_association);
+                                                            component_association);
 
     for (unsigned int c=0; c<dof_handler.get_fe().n_components(); ++c)
       {
-        for (unsigned int i=0; i<dof_handler.n_dofs(); ++i)
-          if ((subdomain_association[i] == subdomain) &&
-              (component_association[i] == static_cast<unsigned char>(c)))
-            ++n_dofs_on_subdomain[c];
+           for (unsigned int i=0; i<dof_handler.n_dofs(); ++i)
+             if ((subdomain_association[i] == subdomain) &&
+                 (component_association[i] == static_cast<unsigned char>(c)))
+               ++n_dofs_on_subdomain[c];
       }
   }
 
@@ -4680,41 +4680,41 @@ namespace DoFTools
     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<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<unsigned int>        &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
                                                    // to copy the result to those components
-                  if (!base.is_primitive() && !only_once)
-                    for (unsigned int dd=1;dd<d;++dd)
-                      dofs_per_component[target_component[component-d+dd]] =
-                        dofs_per_component[target_component[component-d]];
-                }
-            }
-        }
+                         if (!base.is_primitive() && !only_once)
+                           for (unsigned int dd=1;dd<d;++dd)
+                             dofs_per_component[target_component[component-d+dd]] =
+                                   dofs_per_component[target_component[component-d]];
+                       }
+               }
+           }
     }
 
     template <int dim, int spacedim>
@@ -4796,19 +4796,19 @@ namespace DoFTools
                                      // vector as identity.
     if (target_component.size()==0)
       {
-        target_component.resize(n_components);
-        for (unsigned int i=0; i<n_components; ++i)
-          target_component[i] = i;
+           target_component.resize(n_components);
+           for (unsigned int i=0; i<n_components; ++i)
+             target_component[i] = i;
       }
     else
       Assert (target_component.size()==n_components,
-              ExcDimensionMismatch(target_component.size(),
-                                   n_components));
+                 ExcDimensionMismatch(target_component.size(),
+                                                  n_components));
 
 
     const unsigned int max_component
       = *std::max_element (target_component.begin(),
-                           target_component.end());
+                                      target_component.end());
     const unsigned int n_target_components = max_component + 1;
 
     AssertDimension (dofs_per_component.size(), n_target_components);
@@ -4819,8 +4819,8 @@ namespace DoFTools
                                      // computations
     if (n_components == 1)
       {
-        dofs_per_component[0] = dof_handler.n_locally_owned_dofs();
-        return;
+           dofs_per_component[0] = dof_handler.n_locally_owned_dofs();
+           return;
       }
 
 
@@ -4829,13 +4829,13 @@ namespace DoFTools
                                      // separately. do so in parallel
     std::vector<unsigned char> dofs_by_component (dof_handler.n_locally_owned_dofs());
     internal::extract_dofs_by_component (dof_handler, std::vector<bool>(), false,
-                                         dofs_by_component);
+                                                            dofs_by_component);
 
                                      // next count what we got
     unsigned int component = 0;
     internal::resolve_components(dof_handler.get_fe(),
                                  dofs_by_component, target_component,
-                                 only_once, dofs_per_component, component);
+                                                only_once, dofs_per_component, component);
     Assert (n_components == component, ExcInternalError());
 
                                      // finally sanity check. this is
@@ -4843,25 +4843,25 @@ namespace DoFTools
                                      // is actually primitive, so
                                      // exclude other elements from this
     Assert ((internal::all_elements_are_primitive(dof_handler.get_fe()) == false)
-            ||
-            (std::accumulate (dofs_per_component.begin(),
-                              dofs_per_component.end(), 0U)
-             == dof_handler.n_locally_owned_dofs()),
-            ExcInternalError());
+               ||
+               (std::accumulate (dofs_per_component.begin(),
+                                         dofs_per_component.end(), 0U)
+                == dof_handler.n_locally_owned_dofs()),
+               ExcInternalError());
 
                                      // reduce information from all CPUs
 #if defined(DEAL_II_USE_P4EST) && defined(DEAL_II_COMPILER_SUPPORTS_MPI)
     const unsigned int dim = DH::dimension;
     const unsigned int spacedim = DH::space_dimension;
-
+    
     if (const parallel::distributed::Triangulation<dim,spacedim> * tria
-        = (dynamic_cast<const parallel::distributed::Triangulation<dim,spacedim>*>
-           (&dof_handler.get_tria())))
+           = (dynamic_cast<const parallel::distributed::Triangulation<dim,spacedim>*>
+              (&dof_handler.get_tria())))
       {
-        std::vector<unsigned int> local_dof_count = dofs_per_component;
+           std::vector<unsigned int> local_dof_count = dofs_per_component;
 
-        MPI_Allreduce ( &local_dof_count[0], &dofs_per_component[0], n_target_components,
-                        MPI_UNSIGNED, MPI_SUM, tria->get_communicator());
+           MPI_Allreduce ( &local_dof_count[0], &dofs_per_component[0], n_target_components,
+                                   MPI_UNSIGNED, MPI_SUM, tria->get_communicator());
       }
 #endif
   }
@@ -4953,11 +4953,11 @@ namespace DoFTools
   template <int dim, int spacedim>
   void
   count_dofs_per_component (const DoFHandler<dim,spacedim> &dof_handler,
-                            std::vector<unsigned int>      &dofs_per_component,
-                            std::vector<unsigned int>       target_component)
+                                       std::vector<unsigned int>      &dofs_per_component,
+                                       std::vector<unsigned int>       target_component)
   {
     count_dofs_per_component (dof_handler, dofs_per_component,
-                              false, target_component);
+                                         false, target_component);
   }
 
 
@@ -4980,18 +4980,18 @@ namespace DoFTools
       template <int dim, int spacedim>
       void
       compute_intergrid_weights_3 (
-        const dealii::DoFHandler<dim,spacedim>              &coarse_grid,
-        const unsigned int                  coarse_component,
-        const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
-        const std::vector<dealii::Vector<double> > &parameter_dofs,
-        const std::vector<int>             &weight_mapping,
-        std::vector<std::map<unsigned int, float> > &weights,
-        const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &begin,
-        const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &end)
+           const dealii::DoFHandler<dim,spacedim>              &coarse_grid,
+           const unsigned int                  coarse_component,
+           const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
+           const std::vector<dealii::Vector<double> > &parameter_dofs,
+           const std::vector<int>             &weight_mapping,
+           std::vector<std::map<unsigned int, float> > &weights,
+           const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &begin,
+           const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &end)
       {
                                          // aliases to the finite elements
                                          // used by the dof handlers:
-        const FiniteElement<dim,spacedim> &coarse_fe = coarse_grid.get_fe();
+           const FiniteElement<dim,spacedim> &coarse_fe = coarse_grid.get_fe();
 
                                          // for each cell on the parameter grid:
                                          // find out which degrees of freedom on the
@@ -5062,44 +5062,44 @@ namespace DoFTools
                                          // 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<unsigned int> 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);
 
-        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
-            cell->get_dof_indices (parameter_dof_indices);
+               cell->get_dof_indices (parameter_dof_indices);
 
                                              // loop over all dofs on this
                                              // cell and check whether they
                                              // are interesting for us
-            for (unsigned int local_dof=0;
-                 local_dof<coarse_fe.dofs_per_cell;
-                 ++local_dof)
-              if (coarse_fe.system_to_component_index(local_dof).first
-                  ==
-                  coarse_component)
-                {
+               for (unsigned int local_dof=0;
+                        local_dof<coarse_fe.dofs_per_cell;
+                        ++local_dof)
+                 if (coarse_fe.system_to_component_index(local_dof).first
+                         ==
+                         coarse_component)
+                       {
                                                    // the how-many-th
                                                    // parameter is this on
                                                    // this cell?
-                  const unsigned int local_parameter_dof
-                    = coarse_fe.system_to_component_index(local_dof).second;
+                         const unsigned int local_parameter_dof
+                           = coarse_fe.system_to_component_index(local_dof).second;
 
-                  global_parameter_representation = 0;
+                         global_parameter_representation = 0;
 
                                                    // distribute the representation of
                                                    // @p{local_parameter_dof} on the
                                                    // parameter grid cell @p{cell} to
                                                    // the global data space
-                  coarse_to_fine_grid_map[cell]->
-                    set_dof_values_by_interpolation (parameter_dofs[local_parameter_dof],
-                                                     global_parameter_representation);
+                         coarse_to_fine_grid_map[cell]->
+                           set_dof_values_by_interpolation (parameter_dofs[local_parameter_dof],
+                                                                            global_parameter_representation);
                                                    // now that we've got the global
                                                    // representation of each parameter
                                                    // dof, we've only got to clobber the
@@ -5136,28 +5136,28 @@ namespace DoFTools
                                                    // different intergrid
                                                    // weights, have only one
                                                    // mutex for all of them
-                  static Threads::ThreadMutex mutex;
-                  Threads::ThreadMutex::ScopedLock lock (mutex);
-                  for (unsigned int i=0; i<global_parameter_representation.size(); ++i)
+                         static Threads::ThreadMutex mutex;
+                         Threads::ThreadMutex::ScopedLock lock (mutex);
+                         for (unsigned int i=0; i<global_parameter_representation.size(); ++i)
                                                      // set this weight if it belongs
                                                      // to a parameter dof.
-                    if (weight_mapping[i] != -1)
-                      {
+                           if (weight_mapping[i] != -1)
+                             {
                                                          // only overwrite old
                                                          // value if not by
                                                          // zero
-                        if (global_parameter_representation(i) != 0)
-                          {
-                            const unsigned int wi = parameter_dof_indices[local_dof],
-                                               wj = weight_mapping[i];
-                            weights[wi][wj] = global_parameter_representation(i);
-                          };
-                      }
-                    else
-                      Assert (global_parameter_representation(i) == 0,
-                              ExcInternalError());
-                }
-          }
+                                   if (global_parameter_representation(i) != 0)
+                                     {
+                                       const unsigned int wi = parameter_dof_indices[local_dof],
+                                                                  wj = weight_mapping[i];
+                                       weights[wi][wj] = global_parameter_representation(i);
+                                     };
+                             }
+                           else
+                             Assert (global_parameter_representation(i) == 0,
+                                         ExcInternalError());
+                       }
+             }
       }
 
 
@@ -5171,42 +5171,42 @@ namespace DoFTools
       template <int dim, int spacedim>
       void
       compute_intergrid_weights_2 (
-        const dealii::DoFHandler<dim,spacedim>              &coarse_grid,
-        const unsigned int                  coarse_component,
-        const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
-        const std::vector<dealii::Vector<double> > &parameter_dofs,
-        const std::vector<int>             &weight_mapping,
-        std::vector<std::map<unsigned int,float> > &weights)
+           const dealii::DoFHandler<dim,spacedim>              &coarse_grid,
+           const unsigned int                  coarse_component,
+           const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
+           const std::vector<dealii::Vector<double> > &parameter_dofs,
+           const std::vector<int>             &weight_mapping,
+           std::vector<std::map<unsigned int,float> > &weights)
       {
                                          // simply distribute the range of
                                          // cells to different threads
-        typedef typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator active_cell_iterator;
-        std::vector<std::pair<active_cell_iterator,active_cell_iterator> >
-          cell_intervals = Threads::split_range<active_cell_iterator> (coarse_grid.begin_active(),
-                                                                       coarse_grid.end(),
-                                                                       multithread_info.n_default_threads);
+           typedef typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator active_cell_iterator;
+           std::vector<std::pair<active_cell_iterator,active_cell_iterator> >
+             cell_intervals = Threads::split_range<active_cell_iterator> (coarse_grid.begin_active(),
+                                                                                                      coarse_grid.end(),
+                                                                                                      multithread_info.n_default_threads);
 
 //TODO: use WorkStream here
-        Threads::TaskGroup<> tasks;
-        void (*fun_ptr) (const dealii::DoFHandler<dim,spacedim>              &,
-                         const unsigned int                  ,
-                         const InterGridMap<dealii::DoFHandler<dim,spacedim> > &,
-                         const std::vector<dealii::Vector<double> > &,
-                         const std::vector<int>             &,
-                         std::vector<std::map<unsigned int, float> > &,
-                         const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &,
-                         const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &)
-          = &compute_intergrid_weights_3<dim>;
-        for (unsigned int i=0; i<multithread_info.n_default_threads; ++i)
-          tasks += Threads::new_task (fun_ptr,
-                                      coarse_grid, coarse_component,
-                                      coarse_to_fine_grid_map, parameter_dofs,
-                                      weight_mapping, weights,
-                                      cell_intervals[i].first,
-                                      cell_intervals[i].second);
+           Threads::TaskGroup<> tasks;
+           void (*fun_ptr) (const dealii::DoFHandler<dim,spacedim>              &,
+                                    const unsigned int                  ,
+                                    const InterGridMap<dealii::DoFHandler<dim,spacedim> > &,
+                                    const std::vector<dealii::Vector<double> > &,
+                                    const std::vector<int>             &,
+                                    std::vector<std::map<unsigned int, float> > &,
+                                    const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &,
+                                    const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &)
+             = &compute_intergrid_weights_3<dim>;
+           for (unsigned int i=0; i<multithread_info.n_default_threads; ++i)
+             tasks += Threads::new_task (fun_ptr,
+                                                     coarse_grid, coarse_component,
+                                                     coarse_to_fine_grid_map, parameter_dofs,
+                                                     weight_mapping, weights,
+                                                     cell_intervals[i].first,
+                                                     cell_intervals[i].second);
 
                                          // wait for the tasks to finish
-        tasks.join_all ();
+           tasks.join_all ();
       }
 
 
@@ -5221,48 +5221,48 @@ namespace DoFTools
       template <int dim, int spacedim>
       unsigned int
       compute_intergrid_weights_1 (
-        const dealii::DoFHandler<dim,spacedim>              &coarse_grid,
-        const unsigned int                  coarse_component,
-        const dealii::DoFHandler<dim,spacedim>              &fine_grid,
-        const unsigned int                  fine_component,
-        const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
-        std::vector<std::map<unsigned int, float> > &weights,
-        std::vector<int>                   &weight_mapping)
+           const dealii::DoFHandler<dim,spacedim>              &coarse_grid,
+           const unsigned int                  coarse_component,
+           const dealii::DoFHandler<dim,spacedim>              &fine_grid,
+           const unsigned int                  fine_component,
+           const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
+           std::vector<std::map<unsigned int, float> > &weights,
+           std::vector<int>                   &weight_mapping)
       {
                                          // aliases to the finite elements
                                          // used by the dof handlers:
-        const FiniteElement<dim,spacedim> &coarse_fe = coarse_grid.get_fe(),
-                                          &fine_fe   = fine_grid.get_fe();
+           const FiniteElement<dim,spacedim> &coarse_fe = coarse_grid.get_fe(),
+                                                             &fine_fe   = fine_grid.get_fe();
 
                                          // global numbers of dofs
-        const unsigned int n_coarse_dofs = coarse_grid.n_dofs(),
-                           n_fine_dofs   = fine_grid.n_dofs();
+           const unsigned int n_coarse_dofs = coarse_grid.n_dofs(),
+                                      n_fine_dofs   = fine_grid.n_dofs();
 
                                          // local numbers of dofs
-        const unsigned int fine_dofs_per_cell   = fine_fe.dofs_per_cell;
+           const unsigned int fine_dofs_per_cell   = fine_fe.dofs_per_cell;
 
                                          // alias the number of dofs per
                                          // cell belonging to the
                                          // coarse_component which is to be
                                          // the restriction of the fine
                                          // grid:
-        const unsigned int coarse_dofs_per_cell_component
-          = coarse_fe.base_element(coarse_fe.component_to_base_index(coarse_component).first).dofs_per_cell;
+           const unsigned int coarse_dofs_per_cell_component
+             = coarse_fe.base_element(coarse_fe.component_to_base_index(coarse_component).first).dofs_per_cell;
 
 
                                          // Try to find out whether the
                                          // grids stem from the same coarse
                                          // grid. This is a rather crude
                                          // test, but better than nothing
-        Assert (coarse_grid.get_tria().n_cells(0) == fine_grid.get_tria().n_cells(0),
-                ExcGridsDontMatch());
+           Assert (coarse_grid.get_tria().n_cells(0) == fine_grid.get_tria().n_cells(0),
+                       ExcGridsDontMatch());
 
                                          // check whether the map correlates
                                          // the right objects
-        Assert (&coarse_to_fine_grid_map.get_source_grid() == &coarse_grid,
-                ExcGridsDontMatch ());
-        Assert (&coarse_to_fine_grid_map.get_destination_grid() == &fine_grid,
-                ExcGridsDontMatch ());
+           Assert (&coarse_to_fine_grid_map.get_source_grid() == &coarse_grid,
+                       ExcGridsDontMatch ());
+           Assert (&coarse_to_fine_grid_map.get_destination_grid() == &fine_grid,
+                       ExcGridsDontMatch ());
 
 
                                          // check whether component numbers
@@ -5271,21 +5271,21 @@ namespace DoFTools
         AssertIndexRange (fine_component, fine_fe.n_components());
                                          // check whether respective finite
                                          // elements are equal
-        Assert (coarse_fe.base_element (coarse_fe.component_to_base_index(coarse_component).first)
-                ==
-                fine_fe.base_element (fine_fe.component_to_base_index(fine_component).first),
-                ExcFiniteElementsDontMatch());
+           Assert (coarse_fe.base_element (coarse_fe.component_to_base_index(coarse_component).first)
+                       ==
+                       fine_fe.base_element (fine_fe.component_to_base_index(fine_component).first),
+                       ExcFiniteElementsDontMatch());
 
 #ifdef DEBUG
                                          // if in debug mode, check whether
                                          // the coarse grid is indeed
                                          // coarser everywhere than the fine
                                          // grid
-        for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
-               cell=coarse_grid.begin_active();
-             cell != coarse_grid.end(); ++cell)
-          Assert (cell->level() <= coarse_to_fine_grid_map[cell]->level(),
-                  ExcGridNotCoarser());
+           for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
+                  cell=coarse_grid.begin_active();
+                cell != coarse_grid.end(); ++cell)
+             Assert (cell->level() <= coarse_to_fine_grid_map[cell]->level(),
+                         ExcGridNotCoarser());
 #endif
 
 
@@ -5314,89 +5314,89 @@ namespace DoFTools
                                          // degree of freedom of the
                                          // coarse-grid variable in the
                                          // fine-grid element
-        std::vector<dealii::Vector<double> >
-          parameter_dofs (coarse_dofs_per_cell_component,
-                          dealii::Vector<double>(fine_dofs_per_cell));
+           std::vector<dealii::Vector<double> >
+             parameter_dofs (coarse_dofs_per_cell_component,
+                                     dealii::Vector<double>(fine_dofs_per_cell));
                                          // for each coarse dof: find its
                                          // position within the fine element
                                          // and set this value to one in the
                                          // respective vector (all other values
                                          // are zero by construction)
-        for (unsigned int local_coarse_dof=0;
-             local_coarse_dof<coarse_dofs_per_cell_component;
-             ++local_coarse_dof)
-          for (unsigned int fine_dof=0; fine_dof<fine_fe.dofs_per_cell; ++fine_dof)
-            if (fine_fe.system_to_component_index(fine_dof)
-                ==
-                std::make_pair (fine_component, local_coarse_dof))
-              {
-                parameter_dofs[local_coarse_dof](fine_dof) = 1.;
-                break;
-              };
+           for (unsigned int local_coarse_dof=0;
+                local_coarse_dof<coarse_dofs_per_cell_component;
+                ++local_coarse_dof)
+             for (unsigned int fine_dof=0; fine_dof<fine_fe.dofs_per_cell; ++fine_dof)
+               if (fine_fe.system_to_component_index(fine_dof)
+                       ==
+                       std::make_pair (fine_component, local_coarse_dof))
+                 {
+                       parameter_dofs[local_coarse_dof](fine_dof) = 1.;
+                       break;
+                 };
 
 
                                          // find out how many DoFs there are
                                          // on the grids belonging to the
                                          // components we want to match
-        unsigned int n_parameters_on_fine_grid=0;
-        if (true)
-          {
+           unsigned int n_parameters_on_fine_grid=0;
+           if (true)
+             {
                                              // have a flag for each dof on
                                              // the fine grid and set it
                                              // 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<unsigned int>  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);
 
-            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)
-          {
-            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<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 this DoF is a
                                                    // parameter dof and has
                                                    // not yet been numbered,
                                                    // then do so
-                  if ((fine_fe.system_to_component_index(i).first == fine_component) &&
-                      (weight_mapping[local_dof_indices[i]] == -1))
-                    {
-                      weight_mapping[local_dof_indices[i]] = next_free_index;
-                      ++next_free_index;
-                    };
-              };
+                         if ((fine_fe.system_to_component_index(i).first == fine_component) &&
+                             (weight_mapping[local_dof_indices[i]] == -1))
+                           {
+                             weight_mapping[local_dof_indices[i]] = next_free_index;
+                             ++next_free_index;
+                           };
+                 };
 
-            Assert (next_free_index == n_parameters_on_fine_grid,
-                    ExcInternalError());
-          };
+               Assert (next_free_index == n_parameters_on_fine_grid,
+                           ExcInternalError());
+             };
 
 
                                          // for each cell on the parameter grid:
@@ -5411,9 +5411,9 @@ namespace DoFTools
                                          // you want to read more
                                          // information on the algorithm
                                          // used.
-        compute_intergrid_weights_2 (coarse_grid, coarse_component,
-                                     coarse_to_fine_grid_map, parameter_dofs,
-                                     weight_mapping, weights);
+           compute_intergrid_weights_2 (coarse_grid, coarse_component,
+                                                    coarse_to_fine_grid_map, parameter_dofs,
+                                                    weight_mapping, weights);
 
 
                                          // ok, now we have all weights for each
@@ -5438,22 +5438,22 @@ namespace DoFTools
                                          // a dof belongs to, but this at
                                          // least tests some errors
 #ifdef DEBUG
-        for (unsigned int col=0; col<n_parameters_on_fine_grid; ++col)
-          {
-            double sum=0;
-            for (unsigned int row=0; row<n_coarse_dofs; ++row)
-              if (weights[row].find(col) != weights[row].end())
-                sum += weights[row][col];
-            Assert ((std::fabs(sum-1) < 1.e-12) ||
-                    ((coarse_fe.n_components()>1) && (sum==0)), ExcInternalError());
-          };
+           for (unsigned int col=0; col<n_parameters_on_fine_grid; ++col)
+             {
+               double sum=0;
+               for (unsigned int row=0; row<n_coarse_dofs; ++row)
+                 if (weights[row].find(col) != weights[row].end())
+                       sum += weights[row][col];
+               Assert ((std::fabs(sum-1) < 1.e-12) ||
+                           ((coarse_fe.n_components()>1) && (sum==0)), ExcInternalError());
+             };
 #endif
 
 
-        return n_parameters_on_fine_grid;
+           return n_parameters_on_fine_grid;
       }
-
-
+      
+      
     }
   }
 
@@ -5519,13 +5519,13 @@ namespace DoFTools
 
     const unsigned int n_parameters_on_fine_grid
       = internal::compute_intergrid_weights_1 (coarse_grid, coarse_component,
-                                               fine_grid, fine_component,
-                                               coarse_to_fine_grid_map,
-                                               weights, weight_mapping);
+                                                                  fine_grid, fine_component,
+                                                                  coarse_to_fine_grid_map,
+                                                                  weights, weight_mapping);
 
                                      // global numbers of dofs
     const unsigned int n_coarse_dofs = coarse_grid.n_dofs(),
-                       n_fine_dofs   = fine_grid.n_dofs();
+                              n_fine_dofs   = fine_grid.n_dofs();
 
 
                                      // get an array in which we store
@@ -5534,10 +5534,10 @@ namespace DoFTools
     std::vector<bool> coarse_dof_is_parameter (coarse_grid.n_dofs());
     if (true)
       {
-        std::vector<bool> mask (coarse_grid.get_fe().n_components(),
-                                false);
-        mask[coarse_component] = true;
-        extract_dofs (coarse_grid, mask, coarse_dof_is_parameter);
+           std::vector<bool> mask (coarse_grid.get_fe().n_components(),
+                                               false);
+           mask[coarse_component] = true;
+           extract_dofs (coarse_grid, mask, coarse_dof_is_parameter);
       };
 
                                      // now we know that the weights in
@@ -5561,50 +5561,50 @@ namespace DoFTools
                                      // possibly others)
     std::vector<int> representants(n_coarse_dofs, -1);
     for (unsigned int parameter_dof=0; parameter_dof<n_coarse_dofs;
-         ++parameter_dof)
+            ++parameter_dof)
       if (coarse_dof_is_parameter[parameter_dof] == true)
-        {
+           {
                                            // if this is the line of a
                                            // parameter dof on the
                                            // coarse grid, then it
                                            // should have at least one
                                            // dependent node on the fine
                                            // grid
-          Assert (weights[parameter_dof].size() > 0, ExcInternalError());
+             Assert (weights[parameter_dof].size() > 0, ExcInternalError());
 
                                            // find the column where the
                                            // representant is mentioned
-          std::map<unsigned int,float>::const_iterator i = weights[parameter_dof].begin();
-          for (; i!=weights[parameter_dof].end(); ++i)
-            if (i->second == 1)
-              break;
-          Assert (i!=weights[parameter_dof].end(), ExcInternalError());
-          const unsigned int column = i->first;
+             std::map<unsigned int,float>::const_iterator i = weights[parameter_dof].begin();
+             for (; i!=weights[parameter_dof].end(); ++i)
+               if (i->second == 1)
+                 break;
+             Assert (i!=weights[parameter_dof].end(), ExcInternalError());
+             const unsigned int column = i->first;
 
                                            // now we know in which column of
                                            // weights the representant is, but
                                            // we don't know its global index. get
                                            // it using the inverse operation of
                                            // the weight_mapping
-          unsigned int global_dof=0;
-          for (; global_dof<weight_mapping.size(); ++global_dof)
-            if (weight_mapping[global_dof] == static_cast<int>(column))
-              break;
-          Assert (global_dof < weight_mapping.size(), ExcInternalError());
+             unsigned int global_dof=0;
+             for (; global_dof<weight_mapping.size(); ++global_dof)
+               if (weight_mapping[global_dof] == static_cast<int>(column))
+                 break;
+             Assert (global_dof < weight_mapping.size(), ExcInternalError());
 
                                            // now enter the representants global
                                            // index into our list
-          representants[parameter_dof] = global_dof;
-        }
+             representants[parameter_dof] = global_dof;
+           }
       else
-        {
+           {
                                            // consistency check: if this
                                            // is no parameter dof on the
                                            // coarse grid, then the
                                            // respective row must be
                                            // empty!
-          Assert (weights[parameter_dof].size() == 0, ExcInternalError());
-        };
+             Assert (weights[parameter_dof].size() == 0, ExcInternalError());
+           };
 
 
 
@@ -5634,52 +5634,52 @@ namespace DoFTools
                                          // dof, then we consider this dof
                                          // to be unconstrained. otherwise,
                                          // all other dofs are constrained
-        {
-          const unsigned int col = weight_mapping[global_dof];
-          Assert (col < n_parameters_on_fine_grid, ExcInternalError());
-
-          unsigned int first_used_row=0;
+           {
+             const unsigned int col = weight_mapping[global_dof];
+             Assert (col < n_parameters_on_fine_grid, ExcInternalError());
 
-          {
-            Assert (weights.size() > 0, ExcInternalError());
-            std::map<unsigned int,float>::const_iterator
-              col_entry = weights[0].end();
-            for (; first_used_row<n_coarse_dofs; ++first_used_row)
-              {
-                col_entry = weights[first_used_row].find(col);
-                if (col_entry != weights[first_used_row].end())
-                  break;
-              }
+             unsigned int first_used_row=0;
 
-            Assert (col_entry != weights[first_used_row].end(), ExcInternalError());
-
-            if ((col_entry->second == 1) &&
-                (representants[first_used_row] == static_cast<int>(global_dof)))
+             {
+               Assert (weights.size() > 0, ExcInternalError());
+               std::map<unsigned int,float>::const_iterator
+                 col_entry = weights[0].end();
+               for (; first_used_row<n_coarse_dofs; ++first_used_row)
+                 {
+                       col_entry = weights[first_used_row].find(col);
+                       if (col_entry != weights[first_used_row].end())
+                         break;
+                 }
+
+               Assert (col_entry != weights[first_used_row].end(), ExcInternalError());
+
+               if ((col_entry->second == 1) &&
+                       (representants[first_used_row] == static_cast<int>(global_dof)))
                                                // dof unconstrained or
                                                // constrained to itself
                                                // (in case this cell is
                                                // mapped to itself, rather
                                                // than to children of
                                                // itself)
-              continue;
-          }
+                 continue;
+             }
 
 
                                            // 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::make_pair(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::make_pair(representants[row],
+                                                                                     j->second));
+               };
+
+             constraints.add_entries (global_dof, constraint_line);
+           };
   }
 
 
@@ -5743,33 +5743,33 @@ namespace DoFTools
     std::vector<int> weight_mapping;
 
     internal::compute_intergrid_weights_1 (coarse_grid, coarse_component,
-                                           fine_grid, fine_component,
-                                           coarse_to_fine_grid_map,
-                                           weights, weight_mapping);
+                                                              fine_grid, fine_component,
+                                                              coarse_to_fine_grid_map,
+                                                              weights, weight_mapping);
 
                                      // now compute the requested
                                      // representation
     const unsigned int n_global_parm_dofs
       = std::count_if (weight_mapping.begin(), weight_mapping.end(),
-                       std::bind2nd (std::not_equal_to<int> (), -1));
+                              std::bind2nd (std::not_equal_to<int> (), -1));
 
                                      // first construct the inverse
                                      // mapping of weight_mapping
     std::vector<unsigned int> inverse_weight_mapping (n_global_parm_dofs,
-                                                      DoFHandler<dim,spacedim>::invalid_dof_index);
+                                                                             DoFHandler<dim,spacedim>::invalid_dof_index);
     for (unsigned int i=0; i<weight_mapping.size(); ++i)
       {
-        const unsigned int parameter_dof = weight_mapping[i];
+           const unsigned int parameter_dof = weight_mapping[i];
                                          // if this global dof is a
                                          // parameter
-        if (parameter_dof != numbers::invalid_unsigned_int)
-          {
-            Assert (parameter_dof < n_global_parm_dofs, ExcInternalError());
-            Assert ((inverse_weight_mapping[parameter_dof] == DoFHandler<dim,spacedim>::invalid_dof_index),
-                    ExcInternalError());
+           if (parameter_dof != numbers::invalid_unsigned_int)
+             {
+               Assert (parameter_dof < n_global_parm_dofs, ExcInternalError());
+               Assert ((inverse_weight_mapping[parameter_dof] == DoFHandler<dim,spacedim>::invalid_dof_index),
+                           ExcInternalError());
 
-            inverse_weight_mapping[parameter_dof] = i;
-          };
+               inverse_weight_mapping[parameter_dof] = i;
+             };
       };
 
                                      // next copy over weights array
@@ -5783,14 +5783,14 @@ namespace DoFTools
     const unsigned int n_coarse_dofs = coarse_grid.n_dofs();
     for (unsigned int i=0; i<n_coarse_dofs; ++i)
       {
-        std::map<unsigned int, float>::const_iterator j = weights[i].begin();
-        for (; j!=weights[i].end(); ++j)
-          {
-            const unsigned int p = inverse_weight_mapping[j->first];
-            Assert (p<n_rows, ExcInternalError());
+           std::map<unsigned int, float>::const_iterator j = weights[i].begin();
+           for (; j!=weights[i].end(); ++j)
+             {
+               const unsigned int p = inverse_weight_mapping[j->first];
+               Assert (p<n_rows, ExcInternalError());
 
-            transfer_representation[p][i] = j->second;
-          };
+               transfer_representation[p][i] = j->second;
+             };
       };
   }
 
@@ -5799,13 +5799,13 @@ namespace DoFTools
   template <class DH>
   void
   map_dof_to_boundary_indices (const DH                  &dof_handler,
-                               std::vector<unsigned int> &mapping)
+                                          std::vector<unsigned int> &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;
     dofs_on_face.reserve (max_dofs_per_face(dof_handler));
@@ -5825,19 +5825,19 @@ namespace DoFTools
                                      // face which we will be visiting
                                      // sooner or later
     typename DH::active_cell_iterator cell = dof_handler.begin_active(),
-                                      endc = dof_handler.end();
+                                                     endc = dof_handler.end();
     for (; cell!=endc; ++cell)
       for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
-        if (cell->at_boundary(f))
-          {
-            const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
-            dofs_on_face.resize (dofs_per_face);
-            cell->face(f)->get_dof_indices (dofs_on_face,
-                                            cell->active_fe_index());
-            for (unsigned int i=0; i<dofs_per_face; ++i)
-              if (mapping[dofs_on_face[i]] == DH::invalid_dof_index)
-                mapping[dofs_on_face[i]] = next_boundary_index++;
-          }
+           if (cell->at_boundary(f))
+             {
+               const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
+               dofs_on_face.resize (dofs_per_face);
+               cell->face(f)->get_dof_indices (dofs_on_face,
+                                                               cell->active_fe_index());
+               for (unsigned int i=0; i<dofs_per_face; ++i)
+                 if (mapping[dofs_on_face[i]] == DH::invalid_dof_index)
+                       mapping[dofs_on_face[i]] = next_boundary_index++;
+             }
 
     AssertDimension (next_boundary_index, dof_handler.n_boundary_dofs());
   }
@@ -5852,11 +5852,11 @@ namespace DoFTools
   {
     Assert (&dof_handler.get_fe() != 0, ExcNoFESelected());
     Assert (boundary_indicators.find (types::internal_face_boundary_id) == boundary_indicators.end(),
-            ExcInvalidBoundaryIndicator());
+               ExcInvalidBoundaryIndicator());
 
     mapping.clear ();
     mapping.insert (mapping.end(), dof_handler.n_dofs(),
-                    DH::invalid_dof_index);
+                           DH::invalid_dof_index);
 
                                      // return if there is nothing to do
     if (boundary_indicators.size() == 0)
@@ -5867,29 +5867,29 @@ namespace DoFTools
     unsigned int next_boundary_index = 0;
 
     typename DH::active_cell_iterator cell = dof_handler.begin_active(),
-                                      endc = dof_handler.end();
+                                                     endc = dof_handler.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_face.resize (dofs_per_face);
-            cell->face(f)->get_dof_indices (dofs_on_face, cell->active_fe_index());
-            for (unsigned int i=0; i<dofs_per_face; ++i)
-              if (mapping[dofs_on_face[i]] == DH::invalid_dof_index)
-                mapping[dofs_on_face[i]] = next_boundary_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_face.resize (dofs_per_face);
+               cell->face(f)->get_dof_indices (dofs_on_face, cell->active_fe_index());
+               for (unsigned int i=0; i<dofs_per_face; ++i)
+                 if (mapping[dofs_on_face[i]] == DH::invalid_dof_index)
+                       mapping[dofs_on_face[i]] = next_boundary_index++;
+             }
 
     AssertDimension (next_boundary_index,
-                     dof_handler.n_boundary_dofs (boundary_indicators));
+                            dof_handler.n_boundary_dofs (boundary_indicators));
   }
 
   namespace internal
   {
     namespace
     {
-      template <class DH>
+      template<class DH>
       void
       map_dofs_to_support_points(const hp::MappingCollection<DH::dimension, DH::space_dimension> & mapping,
                                  const DH  &dof_handler,
@@ -5939,9 +5939,9 @@ namespace DoFTools
 
                 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();
+                  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];
@@ -6067,12 +6067,12 @@ namespace DoFTools
 
     for (unsigned int i=0;i<fe.n_components();++i)
       {
-        const unsigned int ib = fe.component_to_block_index(i);
-        for (unsigned int j=0;j<fe.n_components();++j)
-          {
-            const unsigned int jb = fe.component_to_block_index(j);
-            tables_by_block[0](ib,jb) |= table(i,j);
-          }
+           const unsigned int ib = fe.component_to_block_index(i);
+           for (unsigned int j=0;j<fe.n_components();++j)
+             {
+               const unsigned int jb = fe.component_to_block_index(j);
+               tables_by_block[0](ib,jb) |= table(i,j);
+             }
       }
   }
 
@@ -6089,20 +6089,20 @@ namespace DoFTools
 
     for (unsigned int f=0;f<fe_collection.size();++f)
       {
-        const FiniteElement<dim,spacedim>& fe = fe_collection[f];
+           const FiniteElement<dim,spacedim>& fe = fe_collection[f];
 
-        const unsigned int nb = fe.n_blocks();
-        tables_by_block[f].reinit(nb, nb);
-        tables_by_block[f].fill(none);
-        for (unsigned int i=0;i<fe.n_components();++i)
-          {
-            const unsigned int ib = fe.component_to_block_index(i);
-            for (unsigned int j=0;j<fe.n_components();++j)
-              {
-                const unsigned int jb = fe.component_to_block_index(j);
-                tables_by_block[f](ib,jb) |= table(i,j);
-              }
-          }
+           const unsigned int nb = fe.n_blocks();
+           tables_by_block[f].reinit(nb, nb);
+           tables_by_block[f].fill(none);
+           for (unsigned int i=0;i<fe.n_components();++i)
+             {
+               const unsigned int ib = fe.component_to_block_index(i);
+               for (unsigned int j=0;j<fe.n_components();++j)
+                 {
+                       const unsigned int jb = fe.component_to_block_index(j);
+                       tables_by_block[f](ib,jb) |= table(i,j);
+                 }
+             }
       }
   }
 
@@ -6111,14 +6111,14 @@ namespace DoFTools
   template <int dim, int spacedim, template <int,int> class DH>
   void
   make_zero_boundary_constraints (const DH<dim, spacedim> &dof,
-                                  ConstraintMatrix        &zero_boundary_constraints,
-                                  const std::vector<bool> &component_mask_)
+                                                 ConstraintMatrix        &zero_boundary_constraints,
+                                                 const std::vector<bool> &component_mask_)
   {
     Assert ((component_mask_.size() == 0) ||
-            (component_mask_.size() == dof.get_fe().n_components()),
-            ExcMessage ("The number of components in the mask has to be either "
-                        "zero or equal to the number of components in the finite "
-                        "element."));
+               (component_mask_.size() == dof.get_fe().n_components()),
+               ExcMessage ("The number of components in the mask has to be either "
+                                   "zero or equal to the number of components in the finite "
+                                   "element."));
 
     const unsigned int n_components = DoFTools::n_components (dof);
 
@@ -6126,10 +6126,10 @@ namespace DoFTools
                                      // 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_);
+                                                               std::vector<bool> (n_components, true) :
+                                                               component_mask_);
     Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0,
-            VectorTools::ExcNoComponentSelected());
+               VectorTools::ExcNoComponentSelected());
 
                                      // a field to store the indices
     std::vector<unsigned int> face_dofs;
@@ -6139,47 +6139,46 @@ namespace DoFTools
       cell = dof.begin_active(),
       endc = dof.end();
     for (; cell!=endc; ++cell)
-      if (!cell->is_artificial())
-       for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
-            ++face_no)
-         {
-           const FiniteElement<dim,spacedim> &fe = cell->get_fe();
+      for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
+              ++face_no)
+           {
+             const FiniteElement<dim,spacedim> &fe = cell->get_fe();
 
-           typename DH<dim,spacedim>::face_iterator face = cell->face(face_no);
+             typename DH<dim,spacedim>::face_iterator face = cell->face(face_no);
 
                                              // if face is on the boundary
-           if (face->at_boundary ())
-             {
-                                                // get indices and physical
-                                                // location on this face
-               face_dofs.resize (fe.dofs_per_face);
-               face->get_dof_indices (face_dofs, cell->active_fe_index());
-
-                                                // enter those dofs into the list
-                                                // that match the component
-                                                // signature.
-               for (unsigned int i=0; i<face_dofs.size(); ++i)
-                 {
-                                                    // Find out if a dof
-                                                    // has a contribution
-                                                    // in this component,
-                                                    // and if so, add it
-                                                    // to the list
-                   const std::vector<bool> &nonzero_component_array
-                     = cell->get_fe().get_nonzero_components (i);
-                   bool nonzero = false;
-                   for (unsigned int c=0; c<n_components; ++c)
-                     if (nonzero_component_array[c] && component_mask[c])
-                       {
-                         nonzero = true;
-                         break;
-                       }
-
-                   if (nonzero)
-                     zero_boundary_constraints.add_line (face_dofs[i]);
-                 }
-             }
-         }
+             if (face->at_boundary ())
+               {
+                                               // get indices and physical
+                                               // location on this face
+                 face_dofs.resize (fe.dofs_per_face);
+                 face->get_dof_indices (face_dofs, cell->active_fe_index());
+
+                                               // enter those dofs into the list
+                                               // that match the component
+                                               // signature.
+                 for (unsigned int i=0; i<face_dofs.size(); ++i)
+                       {
+                                                   // Find out if a dof
+                                                   // has a contribution
+                                                   // in this component,
+                                                   // and if so, add it
+                                                   // to the list
+                         const std::vector<bool> &nonzero_component_array
+                           = cell->get_fe().get_nonzero_components (i);
+                         bool nonzero = false;
+                         for (unsigned int c=0; c<n_components; ++c)
+                           if (nonzero_component_array[c] && component_mask[c])
+                             {
+                                   nonzero = true;
+                                   break;
+                             }
+
+                         if (nonzero)
+                           zero_boundary_constraints.add_line (face_dofs[i]);
+                       }
+               }
+           }
   }
 
   template <class DH, class Sparsity>
index 5d7124b652a1c58b5a5afa681b15054a196ff562..816dfc283c89d9a0d4e6769c924f52d48f07d14e 100644 (file)
@@ -364,7 +364,7 @@ for (deal_II_dimension : DIMENSIONS)
   template
   void DoFTools::make_single_patch (SparsityPattern&, const MGDoFHandler<deal_II_dimension>&,
   unsigned int, bool);
-
+  
   template
   void DoFTools::make_child_patches(SparsityPattern&, const MGDoFHandler<deal_II_dimension>&,
   unsigned int, bool, bool);
@@ -427,8 +427,12 @@ template void DoFTools::extract_dofs<deal_II_dimension>
 (const hp::DoFHandler<deal_II_dimension>&,
  const std::vector<bool>&, std::vector<bool>&, bool);
 
-template void DoFTools::extract_level_dofs<deal_II_dimension>
-(const unsigned int level, const MGDoFHandler<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);
+
+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);
 
 template
@@ -601,13 +605,13 @@ unsigned int
 DoFTools::count_dofs_with_subdomain_association<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> >
 (const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &,
  const types::subdomain_id_t);
-
 template
 IndexSet
 DoFTools::dof_indices_with_subdomain_association<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> >
 (const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &,
  const types::subdomain_id_t);
-
 template
 void
 DoFTools::get_subdomain_association<DoFHandler<deal_II_dimension,deal_II_dimension+1> >
@@ -727,11 +731,17 @@ void
 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>
-(const unsigned int level, const MGDoFHandler<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 
+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);
 
 #endif
@@ -752,8 +762,14 @@ DoFTools::count_dofs_per_component<hp::DoFHandler<1,3> > (
 
 template
 void
-DoFTools::extract_level_dofs<1,3>
-(const unsigned int level, const MGDoFHandler<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 
+DoFTools::extract_level_dofs<MGDoFHandler<1, 3> >
+(const unsigned int, const MGDoFHandler<1, 3>&,
  const std::vector<bool>&, std::vector<bool>&, bool);
 
 #endif
@@ -1002,7 +1018,7 @@ DoFTools::extract_hanging_node_dofs
  DoFTools::map_dof_to_boundary_indices<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> >
  (const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &,
   std::vector<unsigned int> &);
-
+  
 #endif
 
 #if deal_II_dimension == 3
@@ -1042,5 +1058,4 @@ DoFTools::extract_hanging_node_dofs
 
 #endif
 
-
 }
index 2548bb351646ea55261ba4d86ce0b5d8048fe588..6d1c147187aa4a1212b413b85190d32ebf87c2fb 100644 (file)
@@ -66,55 +66,55 @@ namespace internal
     template <int structdim, int dim, int spacedim>
     void
     ensure_existence_of_dof_identities (const FiniteElement<dim,spacedim> &fe1,
-                                        const FiniteElement<dim,spacedim> &fe2,
-                                        std_cxx1x::shared_ptr<DoFIdentities> &identities)
+                                                           const FiniteElement<dim,spacedim> &fe2,
+                                                           std_cxx1x::shared_ptr<DoFIdentities> &identities)
     {
                                        // see if we need to fill this
                                        // entry, or whether it already
                                        // exists
       if (identities.get() == 0)
-        {
-          switch (structdim)
-            {
-              case 0:
-              {
-                identities =
-                  std_cxx1x::shared_ptr<DoFIdentities>
-                  (new DoFIdentities(fe1.hp_vertex_dof_identities(fe2)));
-                break;
-              }
-
-              case 1:
-              {
-                identities =
-                  std_cxx1x::shared_ptr<DoFIdentities>
-                  (new DoFIdentities(fe1.hp_line_dof_identities(fe2)));
-                break;
-              }
-
-              case 2:
-              {
-                identities =
-                  std_cxx1x::shared_ptr<DoFIdentities>
-                  (new DoFIdentities(fe1.hp_quad_dof_identities(fe2)));
-                break;
-              }
-
-              default:
-                    Assert (false, ExcNotImplemented());
-            }
+           {
+             switch (structdim)
+               {
+                 case 0:
+                 {
+                       identities =
+                         std_cxx1x::shared_ptr<DoFIdentities>
+                         (new DoFIdentities(fe1.hp_vertex_dof_identities(fe2)));
+                       break;
+                 }
+
+                 case 1:
+                 {
+                       identities =
+                         std_cxx1x::shared_ptr<DoFIdentities>
+                         (new DoFIdentities(fe1.hp_line_dof_identities(fe2)));
+                       break;
+                 }
+
+                 case 2:
+                 {
+                       identities =
+                         std_cxx1x::shared_ptr<DoFIdentities>
+                         (new DoFIdentities(fe1.hp_quad_dof_identities(fe2)));
+                       break;
+                 }
+
+                 default:
+                           Assert (false, ExcNotImplemented());
+               }
 
                                            // double check whether the
                                            // newly created entries
                                            // make any sense at all
-          for (unsigned int i=0; i<identities->size(); ++i)
-            {
-              Assert ((*identities)[i].first < fe1.template n_dofs_per_object<structdim>(),
-                      ExcInternalError());
-              Assert ((*identities)[i].second < fe2.template n_dofs_per_object<structdim>(),
-                      ExcInternalError());
-            }
-        }
+             for (unsigned int i=0; i<identities->size(); ++i)
+               {
+                 Assert ((*identities)[i].first < fe1.template n_dofs_per_object<structdim>(),
+                             ExcInternalError());
+                 Assert ((*identities)[i].second < fe2.template n_dofs_per_object<structdim>(),
+                             ExcInternalError());
+               }
+           }
     }
 
 
@@ -145,7 +145,7 @@ namespace internal
             if (other_fe_index != dominating_fe_index)
               {
                 const FiniteElement<dim, spacedim>
-                  &that_fe
+                         &that_fe
                   = object->get_fe (object->nth_active_fe_index(other_fe_index));
 
                 domination = domination &
@@ -204,11 +204,11 @@ namespace internal
                                             * same in all space
                                             * dimensions.
                                             */
-          template<int dim, int spacedim>
-          static
-          void
-          reserve_space_vertices (DoFHandler<dim,spacedim> &dof_handler)
-            {
+             template<int dim, int spacedim>
+             static
+             void
+             reserve_space_vertices (DoFHandler<dim,spacedim> &dof_handler)
+               {
                                                // The final step is allocating
                                                // memory is to set up vertex dof
                                                // information. since vertices
@@ -221,15 +221,15 @@ namespace internal
                                                // step, we then actually
                                                // allocate memory for the
                                                // required dofs
-              std::vector<std::vector<bool> >
-                vertex_fe_association (dof_handler.finite_elements->size(),
-                                       std::vector<bool> (dof_handler.tria->n_vertices(), false));
+                 std::vector<std::vector<bool> >
+                       vertex_fe_association (dof_handler.finite_elements->size(),
+                                                      std::vector<bool> (dof_handler.tria->n_vertices(), false));
 
-              for (typename DoFHandler<dim,spacedim>::active_cell_iterator
-                     cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell)
-                for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
-                  vertex_fe_association[cell->active_fe_index()][cell->vertex_index(v)]
-                    = true;
+                 for (typename DoFHandler<dim,spacedim>::active_cell_iterator
+                            cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell)
+                       for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
+                         vertex_fe_association[cell->active_fe_index()][cell->vertex_index(v)]
+                           = true;
 
                                                // in debug mode, make sure
                                                // that each vertex is
@@ -239,15 +239,15 @@ namespace internal
                                                // vertices are actually
                                                // active)
 #ifdef DEBUG
-              for (unsigned int v=0; v<dof_handler.tria->n_vertices(); ++v)
-                if (dof_handler.tria->vertex_used(v) == true)
-                  {
-                    unsigned int fe=0;
-                    for (; fe<dof_handler.finite_elements->size(); ++fe)
-                      if (vertex_fe_association[fe][v] == true)
-                        break;
-                    Assert (fe != dof_handler.finite_elements->size(), ExcInternalError());
-                  }
+                 for (unsigned int v=0; v<dof_handler.tria->n_vertices(); ++v)
+                       if (dof_handler.tria->vertex_used(v) == true)
+                         {
+                           unsigned int fe=0;
+                           for (; fe<dof_handler.finite_elements->size(); ++fe)
+                             if (vertex_fe_association[fe][v] == true)
+                                   break;
+                           Assert (fe != dof_handler.finite_elements->size(), ExcInternalError());
+                         }
 #endif
 
                                                // next count how much memory
@@ -261,48 +261,48 @@ namespace internal
                                                // fe_indices. at the same time
                                                // already fill the
                                                // vertex_dofs_offsets field
-              dof_handler.vertex_dofs_offsets.resize (dof_handler.tria->n_vertices(),
-                                                      numbers::invalid_unsigned_int);
+                 dof_handler.vertex_dofs_offsets.resize (dof_handler.tria->n_vertices(),
+                                                                             numbers::invalid_unsigned_int);
 
-              unsigned int vertex_slots_needed = 0;
-              for (unsigned int v=0; v<dof_handler.tria->n_vertices(); ++v)
-                if (dof_handler.tria->vertex_used(v) == true)
-                  {
-                    dof_handler.vertex_dofs_offsets[v] = vertex_slots_needed;
+                 unsigned int vertex_slots_needed = 0;
+                 for (unsigned int v=0; v<dof_handler.tria->n_vertices(); ++v)
+                       if (dof_handler.tria->vertex_used(v) == true)
+                         {
+                           dof_handler.vertex_dofs_offsets[v] = vertex_slots_needed;
 
-                    for (unsigned int fe=0; fe<dof_handler.finite_elements->size(); ++fe)
-                      if (vertex_fe_association[fe][v] == true)
-                        vertex_slots_needed += (*dof_handler.finite_elements)[fe].dofs_per_vertex + 1;
-                    ++vertex_slots_needed;
-                  }
+                           for (unsigned int fe=0; fe<dof_handler.finite_elements->size(); ++fe)
+                             if (vertex_fe_association[fe][v] == true)
+                                   vertex_slots_needed += (*dof_handler.finite_elements)[fe].dofs_per_vertex + 1;
+                           ++vertex_slots_needed;
+                         }
 
                                                // now allocate the space we
                                                // have determined we need, and
                                                // set up the linked lists for
                                                // each of the vertices
-              dof_handler.vertex_dofs.resize (vertex_slots_needed,
-                                              DoFHandler<dim,spacedim>::invalid_dof_index);
-              for (unsigned int v=0; v<dof_handler.tria->n_vertices(); ++v)
-                if (dof_handler.tria->vertex_used(v) == true)
-                  {
-                    unsigned int pointer = dof_handler.vertex_dofs_offsets[v];
-                    for (unsigned int fe=0; fe<dof_handler.finite_elements->size(); ++fe)
-                      if (vertex_fe_association[fe][v] == true)
-                        {
+                 dof_handler.vertex_dofs.resize (vertex_slots_needed,
+                                                                 DoFHandler<dim,spacedim>::invalid_dof_index);
+                 for (unsigned int v=0; v<dof_handler.tria->n_vertices(); ++v)
+                       if (dof_handler.tria->vertex_used(v) == true)
+                         {
+                           unsigned int pointer = dof_handler.vertex_dofs_offsets[v];
+                           for (unsigned int fe=0; fe<dof_handler.finite_elements->size(); ++fe)
+                             if (vertex_fe_association[fe][v] == true)
+                                   {
                                                            // if this vertex
                                                            // uses this fe,
                                                            // then set the
                                                            // fe_index and
                                                            // move the pointer
                                                            // ahead
-                          dof_handler.vertex_dofs[pointer] = fe;
-                          pointer += (*dof_handler.finite_elements)[fe].dofs_per_vertex + 1;
-                        }
+                                     dof_handler.vertex_dofs[pointer] = fe;
+                                     pointer += (*dof_handler.finite_elements)[fe].dofs_per_vertex + 1;
+                                   }
                                                      // finally place the end
                                                      // marker
-                    dof_handler.vertex_dofs[pointer] = numbers::invalid_unsigned_int;
-                  }
-            }
+                           dof_handler.vertex_dofs[pointer] = numbers::invalid_unsigned_int;
+                         }
+               }
 
 
 
@@ -320,16 +320,16 @@ namespace internal
                                             * it can not be implemented dimension
                                             * independent.
                                             */
-          template <int spacedim>
-          static
-          unsigned int
-          distribute_dofs_on_cell (const typename dealii::hp::DoFHandler<1,spacedim>::active_cell_iterator &cell,
-                                   unsigned int          next_free_dof)
-            {
-              const unsigned int dim = 1;
+             template <int spacedim>
+             static
+             unsigned int
+             distribute_dofs_on_cell (const typename dealii::hp::DoFHandler<1,spacedim>::active_cell_iterator &cell,
+                                                  unsigned int          next_free_dof)
+               {
+                 const unsigned int dim = 1;
 
-              const FiniteElement<dim,spacedim> &fe       = cell->get_fe();
-              const unsigned int                 fe_index = cell->active_fe_index ();
+                 const FiniteElement<dim,spacedim> &fe       = cell->get_fe();
+                 const unsigned int                 fe_index = cell->active_fe_index ();
 
                                                // number dofs on vertices. to do
                                                // so, check whether dofs for
@@ -339,42 +339,42 @@ namespace internal
                                                // first dof), and if this isn't
                                                // the case distribute new ones
                                                // there
-              if (fe.dofs_per_vertex > 0)
-                for (unsigned int vertex=0; vertex<GeometryInfo<1>::vertices_per_cell; ++vertex)
-                  if (cell->vertex_dof_index(vertex, 0, fe_index) ==
-                      DoFHandler<dim,spacedim>::invalid_dof_index)
-                    for (unsigned int d=0; d<fe.dofs_per_vertex; ++d, ++next_free_dof)
-                      cell->set_vertex_dof_index (vertex, d, next_free_dof, fe_index);
+                 if (fe.dofs_per_vertex > 0)
+                       for (unsigned int vertex=0; vertex<GeometryInfo<1>::vertices_per_cell; ++vertex)
+                         if (cell->vertex_dof_index(vertex, 0, fe_index) ==
+                             DoFHandler<dim,spacedim>::invalid_dof_index)
+                           for (unsigned int d=0; d<fe.dofs_per_vertex; ++d, ++next_free_dof)
+                             cell->set_vertex_dof_index (vertex, d, next_free_dof, fe_index);
 
                                                // finally for the line. this one
                                                // shouldn't be numbered yet
-              if (fe.dofs_per_line > 0)
-                {
-                  Assert ((cell->dof_index(0, fe_index) ==
-                           DoFHandler<dim,spacedim>::invalid_dof_index),
-                          ExcInternalError());
+                 if (fe.dofs_per_line > 0)
+                       {
+                         Assert ((cell->dof_index(0, fe_index) ==
+                                      DoFHandler<dim,spacedim>::invalid_dof_index),
+                                     ExcInternalError());
 
-                  for (unsigned int d=0; d<fe.dofs_per_line; ++d, ++next_free_dof)
-                    cell->set_dof_index (d, next_free_dof, fe_index);
-                }
+                         for (unsigned int d=0; d<fe.dofs_per_line; ++d, ++next_free_dof)
+                           cell->set_dof_index (d, next_free_dof, fe_index);
+                       }
 
                                                // note that this cell has been processed
-              cell->set_user_flag ();
+                 cell->set_user_flag ();
 
-              return next_free_dof;
-            }
+                 return next_free_dof;
+               }
 
 
-          template <int spacedim>
-          static
-          unsigned int
-          distribute_dofs_on_cell (const typename dealii::hp::DoFHandler<2,spacedim>::active_cell_iterator &cell,
-                                   unsigned int          next_free_dof)
-            {
-              const unsigned int dim = 2;
+             template <int spacedim>
+             static
+             unsigned int
+             distribute_dofs_on_cell (const typename dealii::hp::DoFHandler<2,spacedim>::active_cell_iterator &cell,
+                                                  unsigned int          next_free_dof)
+               {
+                 const unsigned int dim = 2;
 
-              const FiniteElement<dim,spacedim> &fe       = cell->get_fe();
-              const unsigned int                 fe_index = cell->active_fe_index ();
+                 const FiniteElement<dim,spacedim> &fe       = cell->get_fe();
+                 const unsigned int                 fe_index = cell->active_fe_index ();
 
                                                // number dofs on vertices. to do
                                                // so, check whether dofs for
@@ -384,60 +384,60 @@ namespace internal
                                                // first dof), and if this isn't
                                                // the case distribute new ones
                                                // there
-              if (fe.dofs_per_vertex > 0)
-                for (unsigned int vertex=0; vertex<GeometryInfo<2>::vertices_per_cell; ++vertex)
-                  if (cell->vertex_dof_index(vertex, 0, fe_index) ==
-                      DoFHandler<dim,spacedim>::invalid_dof_index)
-                    for (unsigned int d=0; d<fe.dofs_per_vertex; ++d, ++next_free_dof)
-                      cell->set_vertex_dof_index (vertex, d, next_free_dof, fe_index);
+                 if (fe.dofs_per_vertex > 0)
+                       for (unsigned int vertex=0; vertex<GeometryInfo<2>::vertices_per_cell; ++vertex)
+                         if (cell->vertex_dof_index(vertex, 0, fe_index) ==
+                             DoFHandler<dim,spacedim>::invalid_dof_index)
+                           for (unsigned int d=0; d<fe.dofs_per_vertex; ++d, ++next_free_dof)
+                             cell->set_vertex_dof_index (vertex, d, next_free_dof, fe_index);
 
                                                // next the sides. do the
                                                // same as above: check whether
                                                // the line is already numbered
                                                // for the present fe_index, and
                                                // if not do it
-              if (fe.dofs_per_line > 0)
-                for (unsigned int l=0; l<GeometryInfo<2>::lines_per_cell; ++l)
-                  {
-                    typename DoFHandler<dim,spacedim>::line_iterator
-                      line = cell->line(l);
+                 if (fe.dofs_per_line > 0)
+                       for (unsigned int l=0; l<GeometryInfo<2>::lines_per_cell; ++l)
+                         {
+                           typename DoFHandler<dim,spacedim>::line_iterator
+                             line = cell->line(l);
 
-                    if (line->dof_index(0,fe_index) ==
-                        DoFHandler<dim,spacedim>::invalid_dof_index)
-                      for (unsigned int d=0; d<fe.dofs_per_line; ++d, ++next_free_dof)
-                        line->set_dof_index (d, next_free_dof, fe_index);
-                  }
+                           if (line->dof_index(0,fe_index) ==
+                                   DoFHandler<dim,spacedim>::invalid_dof_index)
+                             for (unsigned int d=0; d<fe.dofs_per_line; ++d, ++next_free_dof)
+                                   line->set_dof_index (d, next_free_dof, fe_index);
+                         }
 
 
                                                // finally for the quad. this one
                                                // shouldn't be numbered yet
-              if (fe.dofs_per_quad > 0)
-                {
-                  Assert ((cell->dof_index(0, fe_index) ==
-                           DoFHandler<dim,spacedim>::invalid_dof_index),
-                          ExcInternalError());
+                 if (fe.dofs_per_quad > 0)
+                       {
+                         Assert ((cell->dof_index(0, fe_index) ==
+                                      DoFHandler<dim,spacedim>::invalid_dof_index),
+                                     ExcInternalError());
 
-                  for (unsigned int d=0; d<fe.dofs_per_quad; ++d, ++next_free_dof)
-                    cell->set_dof_index (d, next_free_dof, fe_index);
-                }
+                         for (unsigned int d=0; d<fe.dofs_per_quad; ++d, ++next_free_dof)
+                           cell->set_dof_index (d, next_free_dof, fe_index);
+                       }
 
                                                // note that this cell has been processed
-              cell->set_user_flag ();
+                 cell->set_user_flag ();
 
-              return next_free_dof;
-            }
+                 return next_free_dof;
+               }
 
 
-          template <int spacedim>
-          static
-          unsigned int
-          distribute_dofs_on_cell (const typename dealii::hp::DoFHandler<3,spacedim>::active_cell_iterator &cell,
-                                   unsigned int          next_free_dof)
-            {
-              const unsigned int dim = 3;
+             template <int spacedim>
+             static
+             unsigned int
+             distribute_dofs_on_cell (const typename dealii::hp::DoFHandler<3,spacedim>::active_cell_iterator &cell,
+                                                  unsigned int          next_free_dof)
+               {
+                 const unsigned int dim = 3;
 
-              const FiniteElement<dim,spacedim> &fe       = cell->get_fe();
-              const unsigned int                 fe_index = cell->active_fe_index ();
+                 const FiniteElement<dim,spacedim> &fe       = cell->get_fe();
+                 const unsigned int                 fe_index = cell->active_fe_index ();
 
                                                // number dofs on vertices. to do
                                                // so, check whether dofs for
@@ -447,61 +447,61 @@ namespace internal
                                                // first dof), and if this isn't
                                                // the case distribute new ones
                                                // there
-              if (fe.dofs_per_vertex > 0)
-                for (unsigned int vertex=0; vertex<GeometryInfo<3>::vertices_per_cell; ++vertex)
-                  if (cell->vertex_dof_index(vertex, 0, fe_index) ==
-                      DoFHandler<dim,spacedim>::invalid_dof_index)
-                    for (unsigned int d=0; d<fe.dofs_per_vertex; ++d, ++next_free_dof)
-                      cell->set_vertex_dof_index (vertex, d, next_free_dof, fe_index);
+                 if (fe.dofs_per_vertex > 0)
+                       for (unsigned int vertex=0; vertex<GeometryInfo<3>::vertices_per_cell; ++vertex)
+                         if (cell->vertex_dof_index(vertex, 0, fe_index) ==
+                             DoFHandler<dim,spacedim>::invalid_dof_index)
+                           for (unsigned int d=0; d<fe.dofs_per_vertex; ++d, ++next_free_dof)
+                             cell->set_vertex_dof_index (vertex, d, next_free_dof, fe_index);
 
                                                // next the four lines. do the
                                                // same as above: check whether
                                                // the line is already numbered
                                                // for the present fe_index, and
                                                // if not do it
-              if (fe.dofs_per_line > 0)
-                for (unsigned int l=0; l<GeometryInfo<3>::lines_per_cell; ++l)
-                  {
-                    typename DoFHandler<dim,spacedim>::line_iterator
-                      line = cell->line(l);
-
-                    if (line->dof_index(0,fe_index) ==
-                        DoFHandler<dim,spacedim>::invalid_dof_index)
-                      for (unsigned int d=0; d<fe.dofs_per_line; ++d, ++next_free_dof)
-                        line->set_dof_index (d, next_free_dof, fe_index);
-                  }
+                 if (fe.dofs_per_line > 0)
+                       for (unsigned int l=0; l<GeometryInfo<3>::lines_per_cell; ++l)
+                         {
+                           typename DoFHandler<dim,spacedim>::line_iterator
+                             line = cell->line(l);
+
+                           if (line->dof_index(0,fe_index) ==
+                                   DoFHandler<dim,spacedim>::invalid_dof_index)
+                             for (unsigned int d=0; d<fe.dofs_per_line; ++d, ++next_free_dof)
+                                   line->set_dof_index (d, next_free_dof, fe_index);
+                         }
 
                                                // same for quads
-              if (fe.dofs_per_quad > 0)
-                for (unsigned int q=0; q<GeometryInfo<3>::quads_per_cell; ++q)
-                  {
-                    typename DoFHandler<dim,spacedim>::quad_iterator
-                      quad = cell->quad(q);
+                 if (fe.dofs_per_quad > 0)
+                       for (unsigned int q=0; q<GeometryInfo<3>::quads_per_cell; ++q)
+                         {
+                           typename DoFHandler<dim,spacedim>::quad_iterator
+                             quad = cell->quad(q);
 
-                    if (quad->dof_index(0,fe_index) ==
-                        DoFHandler<dim,spacedim>::invalid_dof_index)
-                      for (unsigned int d=0; d<fe.dofs_per_quad; ++d, ++next_free_dof)
-                        quad->set_dof_index (d, next_free_dof, fe_index);
-                  }
+                           if (quad->dof_index(0,fe_index) ==
+                                   DoFHandler<dim,spacedim>::invalid_dof_index)
+                             for (unsigned int d=0; d<fe.dofs_per_quad; ++d, ++next_free_dof)
+                                   quad->set_dof_index (d, next_free_dof, fe_index);
+                         }
 
 
                                                // finally for the hex. this one
                                                // shouldn't be numbered yet
-              if (fe.dofs_per_hex > 0)
-                {
-                  Assert ((cell->dof_index(0, fe_index) ==
-                           DoFHandler<dim,spacedim>::invalid_dof_index),
-                          ExcInternalError());
+                 if (fe.dofs_per_hex > 0)
+                       {
+                         Assert ((cell->dof_index(0, fe_index) ==
+                                      DoFHandler<dim,spacedim>::invalid_dof_index),
+                                     ExcInternalError());
 
-                  for (unsigned int d=0; d<fe.dofs_per_hex; ++d, ++next_free_dof)
-                    cell->set_dof_index (d, next_free_dof, fe_index);
-                }
+                         for (unsigned int d=0; d<fe.dofs_per_hex; ++d, ++next_free_dof)
+                           cell->set_dof_index (d, next_free_dof, fe_index);
+                       }
 
                                                // note that this cell has been processed
-              cell->set_user_flag ();
+                 cell->set_user_flag ();
 
-              return next_free_dof;
-            }
+                 return next_free_dof;
+               }
 
 
                                            /**
@@ -513,47 +513,47 @@ namespace internal
                                             * was selected when calling
                                             * @p distribute_dofs the last time.
                                             */
-          template <int spacedim>
-          static
-          void
-          reserve_space (DoFHandler<1,spacedim> &dof_handler)
-            {
-              const unsigned int dim = 1;
-
-              typedef DoFHandler<dim,spacedim> BaseClass;
-
-              Assert (dof_handler.finite_elements != 0,
-                      typename BaseClass::ExcNoFESelected());
-              Assert (dof_handler.finite_elements->size() > 0,
-                      typename BaseClass::ExcNoFESelected());
-              Assert (dof_handler.tria->n_levels() > 0,
-                      typename
-                      BaseClass::ExcInvalidTriangulation());
-              Assert (dof_handler.tria->n_levels() == dof_handler.levels.size (),
-                      ExcInternalError ());
+             template <int spacedim>
+             static
+             void
+             reserve_space (DoFHandler<1,spacedim> &dof_handler)
+               {
+                 const unsigned int dim = 1;
+
+                 typedef DoFHandler<dim,spacedim> BaseClass;
+
+                 Assert (dof_handler.finite_elements != 0,
+                             typename BaseClass::ExcNoFESelected());
+                 Assert (dof_handler.finite_elements->size() > 0,
+                             typename BaseClass::ExcNoFESelected());
+                 Assert (dof_handler.tria->n_levels() > 0,
+                             typename
+                             BaseClass::ExcInvalidTriangulation());
+                 Assert (dof_handler.tria->n_levels() == dof_handler.levels.size (),
+                             ExcInternalError ());
 
                                                // Release all space except the
                                                // active_fe_indices field which
                                                // we have to backup before
-              {
-                std::vector<std::vector<unsigned int> >
-                  active_fe_backup(dof_handler.levels.size ());
-                for (unsigned int level = 0; level<dof_handler.levels.size (); ++level)
-                  std::swap (dof_handler.levels[level]->active_fe_indices, active_fe_backup[level]);
+                 {
+                       std::vector<std::vector<unsigned int> >
+                         active_fe_backup(dof_handler.levels.size ());
+                       for (unsigned int level = 0; level<dof_handler.levels.size (); ++level)
+                         std::swap (dof_handler.levels[level]->active_fe_indices, active_fe_backup[level]);
 
                                                  // delete all levels and set them up
                                                  // newly, since vectors are
                                                  // troublesome if you want to change
                                                  // their size
-                dof_handler.clear_space ();
+                       dof_handler.clear_space ();
 
-                for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
-                  {
-                    dof_handler.levels.push_back (new internal::hp::DoFLevel<dim>);
-                    std::swap (active_fe_backup[level],
-                               dof_handler.levels[level]->active_fe_indices);
-                  }
-              }
+                       for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
+                         {
+                           dof_handler.levels.push_back (new internal::hp::DoFLevel<dim>);
+                           std::swap (active_fe_backup[level],
+                                          dof_handler.levels[level]->active_fe_indices);
+                         }
+                 }
 
                                                // LINE (CELL) DOFs
 
@@ -571,26 +571,26 @@ namespace internal
                                                // other (lower dimensional)
                                                // objects since exactly one
                                                // finite element is used for it
-              for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
-                {
-                  dof_handler.levels[level]->lines.dof_offsets
-                    = std::vector<unsigned int> (dof_handler.tria->n_raw_lines(level),
-                                                 DoFHandler<dim,spacedim>::invalid_dof_index);
-
-                  unsigned int next_free_dof = 0;
-                  for (typename DoFHandler<dim,spacedim>::active_cell_iterator
-                         cell=dof_handler.begin_active(level);
-                       cell!=dof_handler.end_active(level); ++cell)
-                    if (!cell->has_children())
-                      {
-                        dof_handler.levels[level]->lines.dof_offsets[cell->index()] = next_free_dof;
-                        next_free_dof += cell->get_fe().dofs_per_line;
-                      }
-
-                  dof_handler.levels[level]->lines.dofs
-                    = std::vector<unsigned int> (next_free_dof,
-                                                 DoFHandler<dim,spacedim>::invalid_dof_index);
-                }
+                 for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
+                       {
+                         dof_handler.levels[level]->lines.dof_offsets
+                           = std::vector<unsigned int> (dof_handler.tria->n_raw_lines(level),
+                                                                        DoFHandler<dim,spacedim>::invalid_dof_index);
+
+                         unsigned int next_free_dof = 0;
+                         for (typename DoFHandler<dim,spacedim>::active_cell_iterator
+                                    cell=dof_handler.begin_active(level);
+                              cell!=dof_handler.end_active(level); ++cell)
+                           if (!cell->has_children())
+                             {
+                                   dof_handler.levels[level]->lines.dof_offsets[cell->index()] = next_free_dof;
+                                   next_free_dof += cell->get_fe().dofs_per_line;
+                             }
+
+                         dof_handler.levels[level]->lines.dofs
+                           = std::vector<unsigned int> (next_free_dof,
+                                                                        DoFHandler<dim,spacedim>::invalid_dof_index);
+                       }
 
                                                // safety check: make sure that
                                                // the number of DoFs we
@@ -600,75 +600,75 @@ namespace internal
                                                // we couldn't use this simpler
                                                // algorithm)
 #ifdef DEBUG
-              for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
-                {
-                  unsigned int counter = 0;
-                  for (typename DoFHandler<dim,spacedim>::cell_iterator
-                         cell=dof_handler.begin_active(level);
-                       cell!=dof_handler.end_active(level); ++cell)
-                    if (!cell->has_children())
-                      counter += cell->get_fe().dofs_per_line;
-
-                  Assert (dof_handler.levels[level]->lines.dofs.size() == counter,
-                          ExcInternalError());
-                  Assert (static_cast<unsigned int>
-                          (std::count (dof_handler.levels[level]->lines.dof_offsets.begin(),
-                                       dof_handler.levels[level]->lines.dof_offsets.end(),
-                                       DoFHandler<dim,spacedim>::invalid_dof_index))
-                          ==
-                          dof_handler.tria->n_raw_lines(level) - dof_handler.tria->n_active_lines(level),
-                          ExcInternalError());
-                }
+                 for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
+                       {
+                         unsigned int counter = 0;
+                         for (typename DoFHandler<dim,spacedim>::cell_iterator
+                                    cell=dof_handler.begin_active(level);
+                              cell!=dof_handler.end_active(level); ++cell)
+                           if (!cell->has_children())
+                             counter += cell->get_fe().dofs_per_line;
+
+                         Assert (dof_handler.levels[level]->lines.dofs.size() == counter,
+                                     ExcInternalError());
+                         Assert (static_cast<unsigned int>
+                                     (std::count (dof_handler.levels[level]->lines.dof_offsets.begin(),
+                                                      dof_handler.levels[level]->lines.dof_offsets.end(),
+                                                      DoFHandler<dim,spacedim>::invalid_dof_index))
+                                     ==
+                                     dof_handler.tria->n_raw_lines(level) - dof_handler.tria->n_active_lines(level),
+                                     ExcInternalError());
+                       }
 #endif
 
 
                                                // VERTEX DOFS
-              reserve_space_vertices (dof_handler);
-            }
+                 reserve_space_vertices (dof_handler);
+               }
 
 
-          template <int spacedim>
-          static
-          void
-          reserve_space (DoFHandler<2,spacedim> &dof_handler)
-            {
-              const unsigned int dim = 2;
+             template <int spacedim>
+             static
+             void
+             reserve_space (DoFHandler<2,spacedim> &dof_handler)
+               {
+                 const unsigned int dim = 2;
 
-              typedef DoFHandler<dim,spacedim> BaseClass;
+                 typedef DoFHandler<dim,spacedim> BaseClass;
 
-              Assert (dof_handler.finite_elements != 0,
-                      typename BaseClass::ExcNoFESelected());
-              Assert (dof_handler.finite_elements->size() > 0,
-                      typename BaseClass::ExcNoFESelected());
-              Assert (dof_handler.tria->n_levels() > 0,
-                      typename BaseClass::ExcInvalidTriangulation());
-              Assert (dof_handler.tria->n_levels() == dof_handler.levels.size (),
-                      ExcInternalError ());
+                 Assert (dof_handler.finite_elements != 0,
+                             typename BaseClass::ExcNoFESelected());
+                 Assert (dof_handler.finite_elements->size() > 0,
+                             typename BaseClass::ExcNoFESelected());
+                 Assert (dof_handler.tria->n_levels() > 0,
+                             typename BaseClass::ExcInvalidTriangulation());
+                 Assert (dof_handler.tria->n_levels() == dof_handler.levels.size (),
+                             ExcInternalError ());
 
                                                // Release all space except the
                                                // active_fe_indices field which
                                                // we have to backup before
-              {
-                std::vector<std::vector<unsigned int> >
-                  active_fe_backup(dof_handler.levels.size ());
-                for (unsigned int level = 0; level<dof_handler.levels.size (); ++level)
-                  std::swap (dof_handler.levels[level]->active_fe_indices,
-                             active_fe_backup[level]);
+                 {
+                       std::vector<std::vector<unsigned int> >
+                         active_fe_backup(dof_handler.levels.size ());
+                       for (unsigned int level = 0; level<dof_handler.levels.size (); ++level)
+                         std::swap (dof_handler.levels[level]->active_fe_indices,
+                                        active_fe_backup[level]);
 
                                                  // delete all levels and set them up
                                                  // newly, since vectors are
                                                  // troublesome if you want to change
                                                  // their size
-                dof_handler.clear_space ();
+                       dof_handler.clear_space ();
 
-                for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
-                  {
-                    dof_handler.levels.push_back (new internal::hp::DoFLevel<dim>);
-                    std::swap (active_fe_backup[level],
-                               dof_handler.levels[level]->active_fe_indices);
-                  }
-                dof_handler.faces = new internal::hp::DoFFaces<2>;
-              }
+                       for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
+                         {
+                           dof_handler.levels.push_back (new internal::hp::DoFLevel<dim>);
+                           std::swap (active_fe_backup[level],
+                                          dof_handler.levels[level]->active_fe_indices);
+                         }
+                       dof_handler.faces = new internal::hp::DoFFaces<2>;
+                 }
 
 
                                                // QUAD (CELL) DOFs
@@ -687,26 +687,26 @@ namespace internal
                                                // other (lower dimensional)
                                                // objects since exactly one
                                                // finite element is used for it
-              for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
-                {
-                  dof_handler.levels[level]->quads.dof_offsets
-                    = std::vector<unsigned int> (dof_handler.tria->n_raw_quads(level),
-                                                 DoFHandler<dim,spacedim>::invalid_dof_index);
-
-                  unsigned int next_free_dof = 0;
-                  for (typename DoFHandler<dim,spacedim>::active_cell_iterator
-                         cell=dof_handler.begin_active(level);
-                       cell!=dof_handler.end_active(level); ++cell)
-                    if (!cell->has_children())
-                      {
-                        dof_handler.levels[level]->quads.dof_offsets[cell->index()] = next_free_dof;
-                        next_free_dof += cell->get_fe().dofs_per_quad;
-                      }
-
-                  dof_handler.levels[level]->quads.dofs
-                    = std::vector<unsigned int> (next_free_dof,
-                                                 DoFHandler<dim,spacedim>::invalid_dof_index);
-                }
+                 for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
+                       {
+                         dof_handler.levels[level]->quads.dof_offsets
+                           = std::vector<unsigned int> (dof_handler.tria->n_raw_quads(level),
+                                                                        DoFHandler<dim,spacedim>::invalid_dof_index);
+
+                         unsigned int next_free_dof = 0;
+                         for (typename DoFHandler<dim,spacedim>::active_cell_iterator
+                                    cell=dof_handler.begin_active(level);
+                              cell!=dof_handler.end_active(level); ++cell)
+                           if (!cell->has_children())
+                             {
+                                   dof_handler.levels[level]->quads.dof_offsets[cell->index()] = next_free_dof;
+                                   next_free_dof += cell->get_fe().dofs_per_quad;
+                             }
+
+                         dof_handler.levels[level]->quads.dofs
+                           = std::vector<unsigned int> (next_free_dof,
+                                                                        DoFHandler<dim,spacedim>::invalid_dof_index);
+                       }
 
                                                // safety check: make sure that
                                                // the number of DoFs we
@@ -716,25 +716,25 @@ namespace internal
                                                // we couldn't use this simpler
                                                // algorithm)
 #ifdef DEBUG
-              for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
-                {
-                  unsigned int counter = 0;
-                  for (typename DoFHandler<dim,spacedim>::cell_iterator
-                         cell=dof_handler.begin_active(level);
-                       cell!=dof_handler.end_active(level); ++cell)
-                    if (!cell->has_children())
-                      counter += cell->get_fe().dofs_per_quad;
-
-                  Assert (dof_handler.levels[level]->quads.dofs.size() == counter,
-                          ExcInternalError());
-                  Assert (static_cast<unsigned int>
-                          (std::count (dof_handler.levels[level]->quads.dof_offsets.begin(),
-                                       dof_handler.levels[level]->quads.dof_offsets.end(),
-                                       DoFHandler<dim,spacedim>::invalid_dof_index))
-                          ==
-                          dof_handler.tria->n_raw_quads(level) - dof_handler.tria->n_active_quads(level),
-                          ExcInternalError());
-                }
+                 for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
+                       {
+                         unsigned int counter = 0;
+                         for (typename DoFHandler<dim,spacedim>::cell_iterator
+                                    cell=dof_handler.begin_active(level);
+                              cell!=dof_handler.end_active(level); ++cell)
+                           if (!cell->has_children())
+                             counter += cell->get_fe().dofs_per_quad;
+
+                         Assert (dof_handler.levels[level]->quads.dofs.size() == counter,
+                                     ExcInternalError());
+                         Assert (static_cast<unsigned int>
+                                     (std::count (dof_handler.levels[level]->quads.dof_offsets.begin(),
+                                                      dof_handler.levels[level]->quads.dof_offsets.end(),
+                                                      DoFHandler<dim,spacedim>::invalid_dof_index))
+                                     ==
+                                     dof_handler.tria->n_raw_quads(level) - dof_handler.tria->n_active_quads(level),
+                                     ExcInternalError());
+                       }
 #endif
 
 
@@ -764,24 +764,24 @@ namespace internal
                                                // if so skip it (consequently,
                                                // we have to save and later
                                                // restore the line flags)
-              {
-                std::vector<bool> saved_line_user_flags;
-                const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
-                  .save_user_flags_line (saved_line_user_flags);
-                const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
-                  .clear_user_flags_line ();
+                 {
+                       std::vector<bool> saved_line_user_flags;
+                       const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
+                         .save_user_flags_line (saved_line_user_flags);
+                       const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
+                         .clear_user_flags_line ();
 
                                                  // an array to hold how many
                                                  // slots (see the hp::DoFLevel
                                                  // class) we will have to store
                                                  // on each level
-                unsigned int n_line_slots = 0;
+                       unsigned int n_line_slots = 0;
 
-                for (typename DoFHandler<dim,spacedim>::active_cell_iterator
-                       cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell)
-                  for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
-                    if (! cell->face(face)->user_flag_set())
-                      {
+                       for (typename DoFHandler<dim,spacedim>::active_cell_iterator
+                              cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell)
+                         for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+                           if (! cell->face(face)->user_flag_set())
+                             {
                                                          // ok, face has not been
                                                          // visited. so we need to
                                                          // allocate space for it. let's
@@ -794,23 +794,23 @@ namespace internal
                                                          // coarser nor finer, but has
                                                          // happens to have the same
                                                          // active_fe_index:
-                        if (cell->at_boundary(face)
-                            ||
-                            cell->face(face)->has_children()
-                            ||
-                            cell->neighbor_is_coarser(face)
-                            ||
-                            (!cell->at_boundary(face)
-                             &&
-                             (cell->active_fe_index() == cell->neighbor(face)->active_fe_index())))
+                                   if (cell->at_boundary(face)
+                                       ||
+                                       cell->face(face)->has_children()
+                                       ||
+                                       cell->neighbor_is_coarser(face)
+                                       ||
+                                       (!cell->at_boundary(face)
+                                        &&
+                                        (cell->active_fe_index() == cell->neighbor(face)->active_fe_index())))
                                                            // ok, one set of
                                                            // dofs. that makes
                                                            // one index, 1 times
                                                            // dofs_per_line
                                                            // dofs, and one stop
                                                            // index
-                          n_line_slots
-                            += (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_line + 2;
+                                     n_line_slots
+                                       += (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_line + 2;
 
                                                          // otherwise we do
                                                          // indeed need two
@@ -818,19 +818,19 @@ namespace internal
                                                          // indices, two sets of
                                                          // dofs, and one stop
                                                          // index:
-                        else
-                          n_line_slots
-                            += ((*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_line
-                                +
-                                (*dof_handler.finite_elements)[cell->neighbor(face)->active_fe_index()]
-                                .dofs_per_line
-                                +
-                                3);
+                                   else
+                                     n_line_slots
+                                       += ((*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_line
+                                               +
+                                               (*dof_handler.finite_elements)[cell->neighbor(face)->active_fe_index()]
+                                               .dofs_per_line
+                                               +
+                                               3);
 
                                                          // mark this face as
                                                          // visited
-                        cell->face(face)->set_user_flag ();
-                      }
+                                   cell->face(face)->set_user_flag ();
+                             }
 
                                                  // now that we know how many
                                                  // line dofs we will have to
@@ -840,51 +840,51 @@ namespace internal
                                                  // lines, though only the
                                                  // active ones will have a
                                                  // non-invalid value later on
-                dof_handler.faces->lines.dof_offsets
-                  = std::vector<unsigned int> (dof_handler.tria->n_raw_lines(),
-                                               DoFHandler<dim,spacedim>::invalid_dof_index);
-                dof_handler.faces->lines.dofs
-                  = std::vector<unsigned int> (n_line_slots,
-                                               DoFHandler<dim,spacedim>::invalid_dof_index);
+                       dof_handler.faces->lines.dof_offsets
+                         = std::vector<unsigned int> (dof_handler.tria->n_raw_lines(),
+                                                                  DoFHandler<dim,spacedim>::invalid_dof_index);
+                       dof_handler.faces->lines.dofs
+                         = std::vector<unsigned int> (n_line_slots,
+                                                                  DoFHandler<dim,spacedim>::invalid_dof_index);
 
                                                  // with the memory now
                                                  // allocated, loop over the
                                                  // dof_handler.cells again and prime the
                                                  // _offset values as well as
                                                  // the fe_index fields
-                const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
-                  .clear_user_flags_line ();
+                       const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
+                         .clear_user_flags_line ();
 
-                unsigned int next_free_line_slot = 0;
+                       unsigned int next_free_line_slot = 0;
 
-                for (typename DoFHandler<dim,spacedim>::active_cell_iterator
-                       cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell)
-                  for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
-                    if (! cell->face(face)->user_flag_set())
-                      {
+                       for (typename DoFHandler<dim,spacedim>::active_cell_iterator
+                              cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell)
+                         for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+                           if (! cell->face(face)->user_flag_set())
+                             {
                                                          // same decision tree
                                                          // as before
-                        if (cell->at_boundary(face)
-                            ||
-                            cell->face(face)->has_children()
-                            ||
-                            cell->neighbor_is_coarser(face)
-                            ||
-                            (!cell->at_boundary(face)
-                             &&
-                             (cell->active_fe_index() == cell->neighbor(face)->active_fe_index())))
-                          {
-                            dof_handler.faces
-                              ->lines.dof_offsets[cell->face(face)->index()]
-                              = next_free_line_slot;
+                                   if (cell->at_boundary(face)
+                                       ||
+                                       cell->face(face)->has_children()
+                                       ||
+                                       cell->neighbor_is_coarser(face)
+                                       ||
+                                       (!cell->at_boundary(face)
+                                        &&
+                                        (cell->active_fe_index() == cell->neighbor(face)->active_fe_index())))
+                                     {
+                                       dof_handler.faces
+                                         ->lines.dof_offsets[cell->face(face)->index()]
+                                         = next_free_line_slot;
 
                                                              // set first slot
                                                              // for this line to
                                                              // active_fe_index
                                                              // of this face
-                            dof_handler.faces
-                              ->lines.dofs[next_free_line_slot]
-                              = cell->active_fe_index();
+                                       dof_handler.faces
+                                         ->lines.dofs[next_free_line_slot]
+                                         = cell->active_fe_index();
 
                                                              // the next
                                                              // dofs_per_line
@@ -905,22 +905,22 @@ namespace internal
                                                              // finally, mark
                                                              // those slots as
                                                              // used
-                            next_free_line_slot
-                              += (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_line + 2;
-                          }
-                        else
-                          {
-                            dof_handler.faces
-                              ->lines.dof_offsets[cell->face(face)->index()]
-                              = next_free_line_slot;
+                                       next_free_line_slot
+                                         += (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_line + 2;
+                                     }
+                                   else
+                                     {
+                                       dof_handler.faces
+                                         ->lines.dof_offsets[cell->face(face)->index()]
+                                         = next_free_line_slot;
 
                                                              // set first slot
                                                              // for this line to
                                                              // active_fe_index
                                                              // of this face
-                            dof_handler.faces
-                              ->lines.dofs[next_free_line_slot]
-                              = cell->active_fe_index();
+                                       dof_handler.faces
+                                         ->lines.dofs[next_free_line_slot]
+                                         = cell->active_fe_index();
 
                                                              // the next
                                                              // dofs_per_line
@@ -933,13 +933,13 @@ namespace internal
                                                              // fe_index for the
                                                              // neighboring
                                                              // cell:
-                            dof_handler.faces
-                              ->lines.dofs[next_free_line_slot
-                                           +
-                                           (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_line
-                                           +
-                                           1]
-                              = cell->neighbor(face)->active_fe_index();
+                                       dof_handler.faces
+                                         ->lines.dofs[next_free_line_slot
+                                                              +
+                                                              (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_line
+                                                              +
+                                                              1]
+                                         = cell->neighbor(face)->active_fe_index();
                                                              // then again a set
                                                              // of dofs that we
                                                              // need not set
@@ -958,81 +958,81 @@ namespace internal
                                                              // finally, mark
                                                              // those slots as
                                                              // used
-                            next_free_line_slot
-                              += ((*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_line
-                                  +
-                                  (*dof_handler.finite_elements)[cell->neighbor(face)->active_fe_index()]
-                                  .dofs_per_line
-                                  +
-                                  3);
-                          }
+                                       next_free_line_slot
+                                         += ((*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_line
+                                                 +
+                                                 (*dof_handler.finite_elements)[cell->neighbor(face)->active_fe_index()]
+                                                 .dofs_per_line
+                                                 +
+                                                 3);
+                                     }
 
                                                          // mark this face as
                                                          // visited
-                        cell->face(face)->set_user_flag ();
-                      }
+                                   cell->face(face)->set_user_flag ();
+                             }
 
                                                  // we should have moved the
                                                  // cursor for each level to the
                                                  // total number of dofs on that
                                                  // level. check that
-                Assert (next_free_line_slot == n_line_slots,
-                        ExcInternalError());
+                       Assert (next_free_line_slot == n_line_slots,
+                                   ExcInternalError());
 
                                                  // at the end, restore the user
                                                  // flags for the lines
-                const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
-                  .load_user_flags_line (saved_line_user_flags);
-              }
+                       const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
+                         .load_user_flags_line (saved_line_user_flags);
+                 }
 
 
                                                // VERTEX DOFS
-              reserve_space_vertices (dof_handler);
-            }
+                 reserve_space_vertices (dof_handler);
+               }
 
 
-          template <int spacedim>
-          static
-          void
-          reserve_space (DoFHandler<3,spacedim> &dof_handler)
-            {
-              const unsigned int dim = 3;
+             template <int spacedim>
+             static
+             void
+             reserve_space (DoFHandler<3,spacedim> &dof_handler)
+               {
+                 const unsigned int dim = 3;
 
-              typedef DoFHandler<dim,spacedim> BaseClass;
+                 typedef DoFHandler<dim,spacedim> BaseClass;
 
-              Assert (dof_handler.finite_elements != 0,
-                      typename BaseClass::ExcNoFESelected());
-              Assert (dof_handler.finite_elements->size() > 0,
-                      typename BaseClass::ExcNoFESelected());
-              Assert (dof_handler.tria->n_levels() > 0,
-                      typename BaseClass::ExcInvalidTriangulation());
-              Assert (dof_handler.tria->n_levels() == dof_handler.levels.size (),
-                      ExcInternalError ());
+                 Assert (dof_handler.finite_elements != 0,
+                             typename BaseClass::ExcNoFESelected());
+                 Assert (dof_handler.finite_elements->size() > 0,
+                             typename BaseClass::ExcNoFESelected());
+                 Assert (dof_handler.tria->n_levels() > 0,
+                             typename BaseClass::ExcInvalidTriangulation());
+                 Assert (dof_handler.tria->n_levels() == dof_handler.levels.size (),
+                             ExcInternalError ());
 
                                                // Release all space except the
                                                // active_fe_indices field which
                                                // we have to backup before
-              {
-                std::vector<std::vector<unsigned int> >
-                  active_fe_backup(dof_handler.levels.size ());
-                for (unsigned int level = 0; level<dof_handler.levels.size (); ++level)
-                  std::swap (dof_handler.levels[level]->active_fe_indices,
-                             active_fe_backup[level]);
+                 {
+                       std::vector<std::vector<unsigned int> >
+                         active_fe_backup(dof_handler.levels.size ());
+                       for (unsigned int level = 0; level<dof_handler.levels.size (); ++level)
+                         std::swap (dof_handler.levels[level]->active_fe_indices,
+                                        active_fe_backup[level]);
 
                                                  // delete all levels and set them up
                                                  // newly, since vectors are
                                                  // troublesome if you want to change
                                                  // their size
-                dof_handler.clear_space ();
+                       dof_handler.clear_space ();
 
-                for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
-                  {
-                    dof_handler.levels.push_back (new internal::hp::DoFLevel<dim>);
-                    std::swap (active_fe_backup[level],
-                               dof_handler.levels[level]->active_fe_indices);
-                  }
-                dof_handler.faces = new internal::hp::DoFFaces<3>;
-              }
+                       for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
+                         {
+                           dof_handler.levels.push_back (new internal::hp::DoFLevel<dim>);
+                           std::swap (active_fe_backup[level],
+                                          dof_handler.levels[level]->active_fe_indices);
+                         }
+                       dof_handler.faces = new internal::hp::DoFFaces<3>;
+                 }
 
 
                                                // HEX (CELL) DOFs
@@ -1051,26 +1051,26 @@ namespace internal
                                                // other (lower dimensional)
                                                // objects since exactly one
                                                // finite element is used for it
-              for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
-                {
-                  dof_handler.levels[level]->hexes.dof_offsets
-                    = std::vector<unsigned int> (dof_handler.tria->n_raw_hexs(level),
-                                                 DoFHandler<dim,spacedim>::invalid_dof_index);
-
-                  unsigned int next_free_dof = 0;
-                  for (typename DoFHandler<dim,spacedim>::active_cell_iterator
-                         cell=dof_handler.begin_active(level);
-                       cell!=dof_handler.end_active(level); ++cell)
-                    if (!cell->has_children())
-                      {
-                        dof_handler.levels[level]->hexes.dof_offsets[cell->index()] = next_free_dof;
-                        next_free_dof += cell->get_fe().dofs_per_hex;
-                      }
-
-                  dof_handler.levels[level]->hexes.dofs
-                    = std::vector<unsigned int> (next_free_dof,
-                                                 DoFHandler<dim,spacedim>::invalid_dof_index);
-                }
+                 for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
+                       {
+                         dof_handler.levels[level]->hexes.dof_offsets
+                           = std::vector<unsigned int> (dof_handler.tria->n_raw_hexs(level),
+                                                                        DoFHandler<dim,spacedim>::invalid_dof_index);
+
+                         unsigned int next_free_dof = 0;
+                         for (typename DoFHandler<dim,spacedim>::active_cell_iterator
+                                    cell=dof_handler.begin_active(level);
+                              cell!=dof_handler.end_active(level); ++cell)
+                           if (!cell->has_children())
+                             {
+                                   dof_handler.levels[level]->hexes.dof_offsets[cell->index()] = next_free_dof;
+                                   next_free_dof += cell->get_fe().dofs_per_hex;
+                             }
+
+                         dof_handler.levels[level]->hexes.dofs
+                           = std::vector<unsigned int> (next_free_dof,
+                                                                        DoFHandler<dim,spacedim>::invalid_dof_index);
+                       }
 
                                                // safety check: make sure that
                                                // the number of DoFs we
@@ -1080,25 +1080,25 @@ namespace internal
                                                // we couldn't use this simpler
                                                // algorithm)
 #ifdef DEBUG
-              for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
-                {
-                  unsigned int counter = 0;
-                  for (typename DoFHandler<dim,spacedim>::cell_iterator
-                         cell=dof_handler.begin_active(level);
-                       cell!=dof_handler.end_active(level); ++cell)
-                    if (!cell->has_children())
-                      counter += cell->get_fe().dofs_per_hex;
-
-                  Assert (dof_handler.levels[level]->hexes.dofs.size() == counter,
-                          ExcInternalError());
-                  Assert (static_cast<unsigned int>
-                          (std::count (dof_handler.levels[level]->hexes.dof_offsets.begin(),
-                                       dof_handler.levels[level]->hexes.dof_offsets.end(),
-                                       DoFHandler<dim,spacedim>::invalid_dof_index))
-                          ==
-                          dof_handler.tria->n_raw_hexs(level) - dof_handler.tria->n_active_hexs(level),
-                          ExcInternalError());
-                }
+                 for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
+                       {
+                         unsigned int counter = 0;
+                         for (typename DoFHandler<dim,spacedim>::cell_iterator
+                                    cell=dof_handler.begin_active(level);
+                              cell!=dof_handler.end_active(level); ++cell)
+                           if (!cell->has_children())
+                             counter += cell->get_fe().dofs_per_hex;
+
+                         Assert (dof_handler.levels[level]->hexes.dofs.size() == counter,
+                                     ExcInternalError());
+                         Assert (static_cast<unsigned int>
+                                     (std::count (dof_handler.levels[level]->hexes.dof_offsets.begin(),
+                                                      dof_handler.levels[level]->hexes.dof_offsets.end(),
+                                                      DoFHandler<dim,spacedim>::invalid_dof_index))
+                                     ==
+                                     dof_handler.tria->n_raw_hexs(level) - dof_handler.tria->n_active_hexs(level),
+                                     ExcInternalError());
+                       }
 #endif
 
 
@@ -1128,23 +1128,23 @@ namespace internal
                                                // if so skip it (consequently,
                                                // we have to save and later
                                                // restore the line flags)
-              {
-                std::vector<bool> saved_quad_user_flags;
-                const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
-                  .save_user_flags_quad (saved_quad_user_flags);
-                const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
-                  .clear_user_flags_quad ();
+                 {
+                       std::vector<bool> saved_quad_user_flags;
+                       const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
+                         .save_user_flags_quad (saved_quad_user_flags);
+                       const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
+                         .clear_user_flags_quad ();
 
                                                  // examine, how how many
                                                  // slots (see the hp::DoFLevel
                                                  // class) we will have to store
-                unsigned int n_quad_slots = 0;
+                       unsigned int n_quad_slots = 0;
 
-                for (typename DoFHandler<dim,spacedim>::active_cell_iterator
-                       cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell)
-                  for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
-                    if (! cell->face(face)->user_flag_set())
-                      {
+                       for (typename DoFHandler<dim,spacedim>::active_cell_iterator
+                              cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell)
+                         for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+                           if (! cell->face(face)->user_flag_set())
+                             {
                                                          // ok, face has not been
                                                          // visited. so we need to
                                                          // allocate space for
@@ -1160,23 +1160,23 @@ namespace internal
                                                          // same level, but
                                                          // happens to have the
                                                          // same active_fe_index:
-                        if (cell->at_boundary(face)
-                            ||
-                            cell->face(face)->has_children()
-                            ||
-                            cell->neighbor_is_coarser(face)
-                            ||
-                            (!cell->at_boundary(face)
-                             &&
-                             (cell->active_fe_index() == cell->neighbor(face)->active_fe_index())))
+                                   if (cell->at_boundary(face)
+                                       ||
+                                       cell->face(face)->has_children()
+                                       ||
+                                       cell->neighbor_is_coarser(face)
+                                       ||
+                                       (!cell->at_boundary(face)
+                                        &&
+                                        (cell->active_fe_index() == cell->neighbor(face)->active_fe_index())))
                                                            // ok, one set of
                                                            // dofs. that makes
                                                            // one index, 1 times
                                                            // dofs_per_quad
                                                            // dofs, and one stop
                                                            // index
-                          n_quad_slots
-                            += (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_quad + 2;
+                                     n_quad_slots
+                                       += (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_quad + 2;
 
                                                          // otherwise we do
                                                          // indeed need two
@@ -1184,19 +1184,19 @@ namespace internal
                                                          // indices, two sets of
                                                          // dofs, and one stop
                                                          // index:
-                        else
-                          n_quad_slots
-                            += ((*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_quad
-                                +
-                                (*dof_handler.finite_elements)[cell->neighbor(face)->active_fe_index()]
-                                .dofs_per_quad
-                                +
-                                3);
+                                   else
+                                     n_quad_slots
+                                       += ((*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_quad
+                                               +
+                                               (*dof_handler.finite_elements)[cell->neighbor(face)->active_fe_index()]
+                                               .dofs_per_quad
+                                               +
+                                           3);
 
                                                          // mark this face as
                                                          // visited
-                        cell->face(face)->set_user_flag ();
-                      }
+                                   cell->face(face)->set_user_flag ();
+                             }
 
                                                  // now that we know how many
                                                  // quad dofs we will have to
@@ -1206,54 +1206,54 @@ namespace internal
                                                  // quads, though only the
                                                  // active ones will have a
                                                  // non-invalid value later on
-                if (true)
-                  {
-                    dof_handler.faces->quads.dof_offsets
-                      = std::vector<unsigned int> (dof_handler.tria->n_raw_quads(),
-                                                   DoFHandler<dim,spacedim>::invalid_dof_index);
-                    dof_handler.faces->quads.dofs
-                      = std::vector<unsigned int> (n_quad_slots,
-                                                   DoFHandler<dim,spacedim>::invalid_dof_index);
-                  }
+                       if (true)
+                         {
+                           dof_handler.faces->quads.dof_offsets
+                             = std::vector<unsigned int> (dof_handler.tria->n_raw_quads(),
+                                                                          DoFHandler<dim,spacedim>::invalid_dof_index);
+                           dof_handler.faces->quads.dofs
+                             = std::vector<unsigned int> (n_quad_slots,
+                                                                          DoFHandler<dim,spacedim>::invalid_dof_index);
+                         }
 
                                                  // with the memory now
                                                  // allocated, loop over the
                                                  // dof_handler.cells again and prime the
                                                  // _offset values as well as
                                                  // the fe_index fields
-                const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
-                  .clear_user_flags_quad ();
+                       const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
+                         .clear_user_flags_quad ();
 
-                unsigned int next_free_quad_slot = 0;
+                       unsigned int next_free_quad_slot = 0;
 
-                for (typename DoFHandler<dim,spacedim>::active_cell_iterator
-                       cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell)
-                  for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
-                    if (! cell->face(face)->user_flag_set())
-                      {
+                       for (typename DoFHandler<dim,spacedim>::active_cell_iterator
+                              cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell)
+                         for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+                           if (! cell->face(face)->user_flag_set())
+                             {
                                                          // same decision tree
                                                          // as before
-                        if (cell->at_boundary(face)
-                            ||
-                            cell->face(face)->has_children()
-                            ||
-                            cell->neighbor_is_coarser(face)
-                            ||
-                            (!cell->at_boundary(face)
-                             &&
-                             (cell->active_fe_index() == cell->neighbor(face)->active_fe_index())))
-                          {
-                            dof_handler.faces
-                              ->quads.dof_offsets[cell->face(face)->index()]
-                              = next_free_quad_slot;
+                                   if (cell->at_boundary(face)
+                                       ||
+                                       cell->face(face)->has_children()
+                                       ||
+                                       cell->neighbor_is_coarser(face)
+                                       ||
+                                       (!cell->at_boundary(face)
+                                        &&
+                                        (cell->active_fe_index() == cell->neighbor(face)->active_fe_index())))
+                                     {
+                                       dof_handler.faces
+                                         ->quads.dof_offsets[cell->face(face)->index()]
+                                         = next_free_quad_slot;
 
                                                              // set first slot
                                                              // for this quad to
                                                              // active_fe_index
                                                              // of this face
-                            dof_handler.faces
-                              ->quads.dofs[next_free_quad_slot]
-                              = cell->active_fe_index();
+                                       dof_handler.faces
+                                         ->quads.dofs[next_free_quad_slot]
+                                         = cell->active_fe_index();
 
                                                              // the next
                                                              // dofs_per_quad
@@ -1274,22 +1274,22 @@ namespace internal
                                                              // finally, mark
                                                              // those slots as
                                                              // used
-                            next_free_quad_slot
-                              += (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_quad + 2;
-                          }
-                        else
-                          {
-                            dof_handler.faces
-                              ->quads.dof_offsets[cell->face(face)->index()]
-                              = next_free_quad_slot;
+                                       next_free_quad_slot
+                                         += (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_quad + 2;
+                                     }
+                                   else
+                                     {
+                                       dof_handler.faces
+                                         ->quads.dof_offsets[cell->face(face)->index()]
+                                         = next_free_quad_slot;
 
                                                              // set first slot
                                                              // for this quad to
                                                              // active_fe_index
                                                              // of this face
-                            dof_handler.faces
-                              ->quads.dofs[next_free_quad_slot]
-                              = cell->active_fe_index();
+                                       dof_handler.faces
+                                         ->quads.dofs[next_free_quad_slot]
+                                         = cell->active_fe_index();
 
                                                              // the next
                                                              // dofs_per_quad
@@ -1302,13 +1302,13 @@ namespace internal
                                                              // fe_index for the
                                                              // neighboring
                                                              // cell:
-                            dof_handler.faces
-                              ->quads.dofs[next_free_quad_slot
-                                           +
-                                           (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_quad
-                                           +
-                                           1]
-                              = cell->neighbor(face)->active_fe_index();
+                                       dof_handler.faces
+                                         ->quads.dofs[next_free_quad_slot
+                                                              +
+                                                              (*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_quad
+                                                              +
+                                                              1]
+                                         = cell->neighbor(face)->active_fe_index();
                                                              // then again a set
                                                              // of dofs that we
                                                              // need not set
@@ -1327,31 +1327,31 @@ namespace internal
                                                              // finally, mark
                                                              // those slots as
                                                              // used
-                            next_free_quad_slot
-                              += ((*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_quad
-                                  +
-                                  (*dof_handler.finite_elements)[cell->neighbor(face)->active_fe_index()]
-                                  .dofs_per_quad
-                                  +
-                                  3);
-                          }
+                                       next_free_quad_slot
+                                         += ((*dof_handler.finite_elements)[cell->active_fe_index()].dofs_per_quad
+                                                 +
+                                                 (*dof_handler.finite_elements)[cell->neighbor(face)->active_fe_index()]
+                                                 .dofs_per_quad
+                                                 +
+                                                 3);
+                                     }
 
                                                          // mark this face as
                                                          // visited
-                        cell->face(face)->set_user_flag ();
-                      }
+                                   cell->face(face)->set_user_flag ();
+                             }
 
                                                  // we should have moved the
                                                  // cursor to the total number
                                                  // of dofs. check that
-                Assert (next_free_quad_slot == n_quad_slots,
-                        ExcInternalError());
+                       Assert (next_free_quad_slot == n_quad_slots,
+                                   ExcInternalError());
 
                                                  // at the end, restore the user
                                                  // flags for the quads
-                const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
-                  .load_user_flags_quad (saved_quad_user_flags);
-              }
+                       const_cast<dealii::Triangulation<dim,spacedim>&>(*dof_handler.tria)
+                         .load_user_flags_quad (saved_quad_user_flags);
+                 }
 
 
                                                // LINE DOFS
@@ -1365,8 +1365,8 @@ namespace internal
                                                // the algorithm we use is
                                                // somewhat similar to what we do
                                                // in reserve_space_vertices()
-              if (true)
-                {
+                 if (true)
+                       {
                                                    // what we do first is to set up
                                                    // an array in which we record
                                                    // whether a line is associated
@@ -1375,17 +1375,17 @@ namespace internal
                                                    // step, we then actually
                                                    // allocate memory for the
                                                    // required dofs
-                  std::vector<std::vector<bool> >
-                    line_fe_association (dof_handler.finite_elements->size(),
-                                         std::vector<bool> (dof_handler.tria->n_raw_lines(),
-                                                            false));
-
-                  for (typename DoFHandler<dim,spacedim>::active_cell_iterator
-                         cell=dof_handler.begin_active();
-                       cell!=dof_handler.end(); ++cell)
-                    for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++l)
-                      line_fe_association[cell->active_fe_index()][cell->line_index(l)]
-                        = true;
+                         std::vector<std::vector<bool> >
+                           line_fe_association (dof_handler.finite_elements->size(),
+                                                            std::vector<bool> (dof_handler.tria->n_raw_lines(),
+                                                                                       false));
+
+                         for (typename DoFHandler<dim,spacedim>::active_cell_iterator
+                                    cell=dof_handler.begin_active();
+                              cell!=dof_handler.end(); ++cell)
+                           for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++l)
+                             line_fe_association[cell->active_fe_index()][cell->line_index(l)]
+                                   = true;
 
                                                    // first check which of the
                                                    // lines is used at all,
@@ -1396,14 +1396,14 @@ namespace internal
                                                    // case we do not have to
                                                    // allocate any memory at
                                                    // all
-                  std::vector<bool> line_is_used (dof_handler.tria->n_raw_lines(), false);
-                  for (unsigned int line=0; line<dof_handler.tria->n_raw_lines(); ++line)
-                    for (unsigned int fe=0; fe<dof_handler.finite_elements->size(); ++fe)
-                      if (line_fe_association[fe][line] == true)
-                        {
-                          line_is_used[line] = true;
-                          break;
-                        }
+                         std::vector<bool> line_is_used (dof_handler.tria->n_raw_lines(), false);
+                         for (unsigned int line=0; line<dof_handler.tria->n_raw_lines(); ++line)
+                           for (unsigned int fe=0; fe<dof_handler.finite_elements->size(); ++fe)
+                             if (line_fe_association[fe][line] == true)
+                                   {
+                                     line_is_used[line] = true;
+                                     break;
+                                   }
 
                                                    // next count how much memory
                                                    // we actually need. for each
@@ -1416,77 +1416,77 @@ namespace internal
                                                    // fe_indices. at the same
                                                    // time already fill the
                                                    // line_dofs_offsets field
-                  dof_handler.faces->lines.dof_offsets
-                    .resize (dof_handler.tria->n_raw_lines(),
-                             numbers::invalid_unsigned_int);
-
-                  unsigned int line_slots_needed = 0;
-                  for (unsigned int line=0; line<dof_handler.tria->n_raw_lines(); ++line)
-                    if (line_is_used[line] == true)
-                      {
-                        dof_handler.faces->lines.dof_offsets[line] = line_slots_needed;
-
-                        for (unsigned int fe=0; fe<dof_handler.finite_elements->size(); ++fe)
-                          if (line_fe_association[fe][line] == true)
-                            line_slots_needed += (*dof_handler.finite_elements)[fe].dofs_per_line + 1;
-                        ++line_slots_needed;
-                      }
+                         dof_handler.faces->lines.dof_offsets
+                           .resize (dof_handler.tria->n_raw_lines(),
+                                        numbers::invalid_unsigned_int);
+
+                         unsigned int line_slots_needed = 0;
+                         for (unsigned int line=0; line<dof_handler.tria->n_raw_lines(); ++line)
+                           if (line_is_used[line] == true)
+                             {
+                                   dof_handler.faces->lines.dof_offsets[line] = line_slots_needed;
+
+                                   for (unsigned int fe=0; fe<dof_handler.finite_elements->size(); ++fe)
+                                     if (line_fe_association[fe][line] == true)
+                                       line_slots_needed += (*dof_handler.finite_elements)[fe].dofs_per_line + 1;
+                                   ++line_slots_needed;
+                             }
 
                                                    // now allocate the space we
                                                    // have determined we need, and
                                                    // set up the linked lists for
                                                    // each of the lines
-                  dof_handler.faces->lines.dofs.resize (line_slots_needed,
-                                                        DoFHandler<dim,spacedim>::invalid_dof_index);
-                  for (unsigned int line=0; line<dof_handler.tria->n_raw_lines(); ++line)
-                    if (line_is_used[line] == true)
-                      {
-                        unsigned int pointer = dof_handler.faces->lines.dof_offsets[line];
-                        for (unsigned int fe=0; fe<dof_handler.finite_elements->size(); ++fe)
-                          if (line_fe_association[fe][line] == true)
-                            {
+                         dof_handler.faces->lines.dofs.resize (line_slots_needed,
+                                                                                   DoFHandler<dim,spacedim>::invalid_dof_index);
+                         for (unsigned int line=0; line<dof_handler.tria->n_raw_lines(); ++line)
+                           if (line_is_used[line] == true)
+                             {
+                                   unsigned int pointer = dof_handler.faces->lines.dof_offsets[line];
+                                   for (unsigned int fe=0; fe<dof_handler.finite_elements->size(); ++fe)
+                                     if (line_fe_association[fe][line] == true)
+                                       {
                                                                // if this line
                                                                // uses this fe,
                                                                // then set the
                                                                // fe_index and
                                                                // move the
                                                                // pointer ahead
-                              dof_handler.faces->lines.dofs[pointer] = fe;
-                              pointer += (*dof_handler.finite_elements)[fe].dofs_per_line + 1;
-                            }
+                                         dof_handler.faces->lines.dofs[pointer] = fe;
+                                         pointer += (*dof_handler.finite_elements)[fe].dofs_per_line + 1;
+                                       }
                                                          // finally place the end
                                                          // marker
-                        dof_handler.faces->lines.dofs[pointer] = numbers::invalid_unsigned_int;
-                      }
-                }
+                                   dof_handler.faces->lines.dofs[pointer] = numbers::invalid_unsigned_int;
+                             }
+                       }
 
 
 
                                                // VERTEX DOFS
-              reserve_space_vertices (dof_handler);
-            }
+                 reserve_space_vertices (dof_handler);
+               }
 
 
                                            /**
                                             * Implement the function of same name
                                             * in the mother class.
                                             */
-          template <int spacedim>
-          static
-          unsigned int
-          max_couplings_between_dofs (const DoFHandler<1,spacedim> &dof_handler)
-            {
-              return std::min(3*dof_handler.finite_elements->max_dofs_per_vertex() +
-                              2*dof_handler.finite_elements->max_dofs_per_line(), dof_handler.n_dofs());
-            }
-
-
-
-          template <int spacedim>
-          static
-          unsigned int
-          max_couplings_between_dofs (const DoFHandler<2,spacedim> &dof_handler)
-            {
+             template <int spacedim>
+             static
+             unsigned int
+             max_couplings_between_dofs (const DoFHandler<1,spacedim> &dof_handler)
+               {
+                 return std::min(3*dof_handler.finite_elements->max_dofs_per_vertex() +
+                                         2*dof_handler.finite_elements->max_dofs_per_line(), dof_handler.n_dofs());
+               }
+
+
+
+             template <int spacedim>
+             static
+             unsigned int
+             max_couplings_between_dofs (const DoFHandler<2,spacedim> &dof_handler)
+               {
                                                // get these numbers by drawing pictures
                                                // and counting...
                                                // example:
@@ -1508,47 +1508,47 @@ namespace internal
                                                // nodes)
                                                // count lines -> 28 (don't forget to count
                                                // mother and children separately!)
-              unsigned int max_couplings;
-              switch (dof_handler.tria->max_adjacent_cells())
-                {
-                  case 4:
-                        max_couplings=19*dof_handler.finite_elements->max_dofs_per_vertex() +
-                                      28*dof_handler.finite_elements->max_dofs_per_line() +
-                                      8*dof_handler.finite_elements->max_dofs_per_quad();
-                        break;
-                  case 5:
-                        max_couplings=21*dof_handler.finite_elements->max_dofs_per_vertex() +
-                                      31*dof_handler.finite_elements->max_dofs_per_line() +
-                                      9*dof_handler.finite_elements->max_dofs_per_quad();
-                        break;
-                  case 6:
-                        max_couplings=28*dof_handler.finite_elements->max_dofs_per_vertex() +
-                                      42*dof_handler.finite_elements->max_dofs_per_line() +
-                                      12*dof_handler.finite_elements->max_dofs_per_quad();
-                        break;
-                  case 7:
-                        max_couplings=30*dof_handler.finite_elements->max_dofs_per_vertex() +
-                                      45*dof_handler.finite_elements->max_dofs_per_line() +
-                                      13*dof_handler.finite_elements->max_dofs_per_quad();
-                        break;
-                  case 8:
-                        max_couplings=37*dof_handler.finite_elements->max_dofs_per_vertex() +
-                                      56*dof_handler.finite_elements->max_dofs_per_line() +
-                                      16*dof_handler.finite_elements->max_dofs_per_quad();
-                        break;
-                  default:
-                        Assert (false, ExcNotImplemented());
-                        max_couplings=0;
-                };
-              return std::min(max_couplings,dof_handler.n_dofs());
-            }
-
-
-          template <int spacedim>
-          static
-          unsigned int
-          max_couplings_between_dofs (const DoFHandler<3,spacedim> &dof_handler)
-            {
+                 unsigned int max_couplings;
+                 switch (dof_handler.tria->max_adjacent_cells())
+                       {
+                         case 4:
+                                   max_couplings=19*dof_handler.finite_elements->max_dofs_per_vertex() +
+                                                     28*dof_handler.finite_elements->max_dofs_per_line() +
+                                                     8*dof_handler.finite_elements->max_dofs_per_quad();
+                                   break;
+                         case 5:
+                                   max_couplings=21*dof_handler.finite_elements->max_dofs_per_vertex() +
+                                                     31*dof_handler.finite_elements->max_dofs_per_line() +
+                                                     9*dof_handler.finite_elements->max_dofs_per_quad();
+                                   break;
+                         case 6:
+                                   max_couplings=28*dof_handler.finite_elements->max_dofs_per_vertex() +
+                                                     42*dof_handler.finite_elements->max_dofs_per_line() +
+                                                     12*dof_handler.finite_elements->max_dofs_per_quad();
+                                   break;
+                         case 7:
+                                   max_couplings=30*dof_handler.finite_elements->max_dofs_per_vertex() +
+                                                     45*dof_handler.finite_elements->max_dofs_per_line() +
+                                                     13*dof_handler.finite_elements->max_dofs_per_quad();
+                                   break;
+                         case 8:
+                                   max_couplings=37*dof_handler.finite_elements->max_dofs_per_vertex() +
+                                                     56*dof_handler.finite_elements->max_dofs_per_line() +
+                                                     16*dof_handler.finite_elements->max_dofs_per_quad();
+                                   break;
+                         default:
+                                   Assert (false, ExcNotImplemented());
+                                   max_couplings=0;
+                       };
+                 return std::min(max_couplings,dof_handler.n_dofs());
+               }
+
+
+             template <int spacedim>
+             static
+             unsigned int
+             max_couplings_between_dofs (const DoFHandler<3,spacedim> &dof_handler)
+               {
 //TODO:[?] Invent significantly better estimates than the ones in this function
                                                // doing the same thing here is a rather
                                                // complicated thing, compared to the 2d
@@ -1559,22 +1559,22 @@ namespace internal
                                                // at each vertex
                                                //
                                                // can anyone give better estimate here?
-              const unsigned int max_adjacent_cells = dof_handler.tria->max_adjacent_cells();
-
-              unsigned int max_couplings;
-              if (max_adjacent_cells <= 8)
-                max_couplings=7*7*7*dof_handler.finite_elements->max_dofs_per_vertex() +
-                              7*6*7*3*dof_handler.finite_elements->max_dofs_per_line() +
-                              9*4*7*3*dof_handler.finite_elements->max_dofs_per_quad() +
-                              27*dof_handler.finite_elements->max_dofs_per_hex();
-              else
-                {
-                  Assert (false, ExcNotImplemented());
-                  max_couplings=0;
-                }
-
-              return std::min(max_couplings,dof_handler.n_dofs());
-            }
+                 const unsigned int max_adjacent_cells = dof_handler.tria->max_adjacent_cells();
+
+                 unsigned int max_couplings;
+                 if (max_adjacent_cells <= 8)
+                       max_couplings=7*7*7*dof_handler.finite_elements->max_dofs_per_vertex() +
+                                         7*6*7*3*dof_handler.finite_elements->max_dofs_per_line() +
+                                         9*4*7*3*dof_handler.finite_elements->max_dofs_per_quad() +
+                                         27*dof_handler.finite_elements->max_dofs_per_hex();
+                 else
+                       {
+                         Assert (false, ExcNotImplemented());
+                         max_couplings=0;
+                       }
+
+                 return std::min(max_couplings,dof_handler.n_dofs());
+               }
       };
     }
   }
@@ -1598,13 +1598,13 @@ namespace hp
   DoFHandler<dim,spacedim>::DoFHandler (const Triangulation<dim,spacedim> &tria)
                   :
                   tria(&tria, typeid(*this).name()),
-                  faces (NULL)
+                         faces (NULL)
   {
     Assert ((dynamic_cast<const parallel::distributed::Triangulation< dim, spacedim >*>
-             (&tria)
-             == 0),
-            ExcMessage ("The given triangulation is parallel distributed but "
-                        "this class does not currently support this."));
+                (&tria)
+                == 0),
+               ExcMessage ("The given triangulation is parallel distributed but "
+                                   "this class does not currently support this."));
 
     create_active_fe_table ();
 
@@ -1647,15 +1647,15 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              return begin_raw_line (level);
-        case 2:
-              return begin_raw_quad (level);
-        case 3:
-              return begin_raw_hex (level);
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_cell_iterator();
+           case 1:
+                 return begin_raw_line (level);
+           case 2:
+                 return begin_raw_quad (level);
+           case 3:
+                 return begin_raw_hex (level);
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_cell_iterator();
       }
   }
 
@@ -1667,15 +1667,15 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              return begin_line (level);
-        case 2:
-              return begin_quad (level);
-        case 3:
-              return begin_hex (level);
-        default:
-              Assert (false, ExcImpossibleInDim(dim));
-              return cell_iterator();
+           case 1:
+                 return begin_line (level);
+           case 2:
+                 return begin_quad (level);
+           case 3:
+                 return begin_hex (level);
+           default:
+                 Assert (false, ExcImpossibleInDim(dim));
+                 return cell_iterator();
       }
   }
 
@@ -1687,15 +1687,15 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              return begin_active_line (level);
-        case 2:
-              return begin_active_quad (level);
-        case 3:
-              return begin_active_hex (level);
-        default:
-              Assert (false, ExcNotImplemented());
-              return active_cell_iterator();
+           case 1:
+                 return begin_active_line (level);
+           case 2:
+                 return begin_active_quad (level);
+           case 3:
+                 return begin_active_hex (level);
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return active_cell_iterator();
       }
   }
 
@@ -1707,15 +1707,15 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              return last_raw_line ();
-        case 2:
-              return last_raw_quad ();
-        case 3:
-              return last_raw_hex ();
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_cell_iterator();
+           case 1:
+                 return last_raw_line ();
+           case 2:
+                 return last_raw_quad ();
+           case 3:
+                 return last_raw_hex ();
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_cell_iterator();
       }
   }
 
@@ -1727,15 +1727,15 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              return last_raw_line (level);
-        case 2:
-              return last_raw_quad (level);
-        case 3:
-              return last_raw_hex (level);
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_cell_iterator();
+           case 1:
+                 return last_raw_line (level);
+           case 2:
+                 return last_raw_quad (level);
+           case 3:
+                 return last_raw_hex (level);
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_cell_iterator();
       }
   }
 
@@ -1747,15 +1747,15 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              return last_line ();
-        case 2:
-              return last_quad ();
-        case 3:
-              return last_hex ();
-        default:
-              Assert (false, ExcNotImplemented());
-              return cell_iterator();
+           case 1:
+                 return last_line ();
+           case 2:
+                 return last_quad ();
+           case 3:
+                 return last_hex ();
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return cell_iterator();
       }
   }
 
@@ -1767,15 +1767,15 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              return last_line (level);
-        case 2:
-              return last_quad (level);
-        case 3:
-              return last_hex (level);
-        default:
-              Assert (false, ExcNotImplemented());
-              return cell_iterator();
+           case 1:
+                 return last_line (level);
+           case 2:
+                 return last_quad (level);
+           case 3:
+                 return last_hex (level);
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return cell_iterator();
       }
   }
 
@@ -1787,15 +1787,15 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              return last_active_line ();
-        case 2:
-              return last_active_quad ();
-        case 3:
-              return last_active_hex ();
-        default:
-              Assert (false, ExcNotImplemented());
-              return active_cell_iterator();
+           case 1:
+                 return last_active_line ();
+           case 2:
+                 return last_active_quad ();
+           case 3:
+                 return last_active_hex ();
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return active_cell_iterator();
       }
   }
 
@@ -1807,15 +1807,15 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              return last_active_line (level);
-        case 2:
-              return last_active_quad (level);
-        case 3:
-              return last_active_hex (level);
-        default:
-              Assert (false, ExcNotImplemented());
-              return active_cell_iterator();
+           case 1:
+                 return last_active_line (level);
+           case 2:
+                 return last_active_quad (level);
+           case 3:
+                 return last_active_hex (level);
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return active_cell_iterator();
       }
   }
 
@@ -1826,15 +1826,15 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              return end_line();
-        case 2:
-              return end_quad();
-        case 3:
-              return end_hex();
-        default:
-              Assert (false, ExcImpossibleInDim(dim));
-              return raw_cell_iterator();
+           case 1:
+                 return end_line();
+           case 2:
+                 return end_quad();
+           case 3:
+                 return end_hex();
+           default:
+                 Assert (false, ExcImpossibleInDim(dim));
+                 return raw_cell_iterator();
       }
   }
 
@@ -1845,8 +1845,8 @@ namespace hp
   DoFHandler<dim, spacedim>::end_raw (const unsigned int level) const
   {
     return (level == tria->n_levels()-1 ?
-            end() :
-            begin_raw (level+1));
+               end() :
+               begin_raw (level+1));
   }
 
 
@@ -1855,8 +1855,8 @@ namespace hp
   DoFHandler<dim, spacedim>::end (const unsigned int level) const
   {
     return (level == tria->n_levels()-1 ?
-            cell_iterator(end()) :
-            begin (level+1));
+               cell_iterator(end()) :
+               begin (level+1));
   }
 
 
@@ -1865,8 +1865,8 @@ namespace hp
   DoFHandler<dim, spacedim>::end_active (const unsigned int level) const
   {
     return (level == tria->n_levels()-1 ?
-            active_cell_iterator(end()) :
-            begin_active (level+1));
+               active_cell_iterator(end()) :
+               begin_active (level+1));
   }
 
 
@@ -1879,16 +1879,16 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              Assert (false, ExcImpossibleInDim(1));
-              return raw_face_iterator();
-        case 2:
-              return begin_raw_line ();
-        case 3:
-              return begin_raw_quad ();
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_face_iterator ();
+           case 1:
+                 Assert (false, ExcImpossibleInDim(1));
+                 return raw_face_iterator();
+           case 2:
+                 return begin_raw_line ();
+           case 3:
+                 return begin_raw_quad ();
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_face_iterator ();
       }
   }
 
@@ -1900,16 +1900,16 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              Assert (false, ExcImpossibleInDim(1));
-              return raw_face_iterator();
-        case 2:
-              return begin_line ();
-        case 3:
-              return begin_quad ();
-        default:
-              Assert (false, ExcNotImplemented());
-              return face_iterator ();
+           case 1:
+                 Assert (false, ExcImpossibleInDim(1));
+                 return raw_face_iterator();
+           case 2:
+                 return begin_line ();
+           case 3:
+                 return begin_quad ();
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return face_iterator ();
       }
   }
 
@@ -1921,16 +1921,16 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              Assert (false, ExcImpossibleInDim(1));
-              return raw_face_iterator();
-        case 2:
-              return begin_active_line ();
-        case 3:
-              return begin_active_quad ();
-        default:
-              Assert (false, ExcNotImplemented());
-              return active_face_iterator ();
+           case 1:
+                 Assert (false, ExcImpossibleInDim(1));
+                 return raw_face_iterator();
+           case 2:
+                 return begin_active_line ();
+           case 3:
+                 return begin_active_quad ();
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return active_face_iterator ();
       }
   }
 
@@ -1951,16 +1951,16 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              Assert (false, ExcImpossibleInDim(1));
-              return raw_face_iterator();
-        case 2:
-              return end_line ();
-        case 3:
-              return end_quad ();
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_face_iterator ();
+           case 1:
+                 Assert (false, ExcImpossibleInDim(1));
+                 return raw_face_iterator();
+           case 2:
+                 return end_line ();
+           case 3:
+                 return end_quad ();
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_face_iterator ();
       }
   }
 
@@ -1983,16 +1983,16 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              Assert (false, ExcImpossibleInDim(1));
-              return raw_face_iterator();
-        case 2:
-              return last_raw_line ();
-        case 3:
-              return last_raw_quad ();
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_face_iterator ();
+           case 1:
+                 Assert (false, ExcImpossibleInDim(1));
+                 return raw_face_iterator();
+           case 2:
+                 return last_raw_line ();
+           case 3:
+                 return last_raw_quad ();
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_face_iterator ();
       }
   }
 
@@ -2004,16 +2004,16 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              Assert (false, ExcImpossibleInDim(1));
-              return raw_face_iterator();
-        case 2:
-              return last_line ();
-        case 3:
-              return last_quad ();
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_face_iterator ();
+           case 1:
+                 Assert (false, ExcImpossibleInDim(1));
+                 return raw_face_iterator();
+           case 2:
+                 return last_line ();
+           case 3:
+                 return last_quad ();
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_face_iterator ();
       }
   }
 
@@ -2025,16 +2025,16 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              Assert (false, ExcImpossibleInDim(1));
-              return raw_face_iterator();
-        case 2:
-              return last_active_line ();
-        case 3:
-              return last_active_quad ();
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_face_iterator ();
+           case 1:
+                 Assert (false, ExcImpossibleInDim(1));
+                 return raw_face_iterator();
+           case 2:
+                 return last_active_line ();
+           case 3:
+                 return last_active_quad ();
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_face_iterator ();
       }
   }
 
@@ -2049,23 +2049,23 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              Assert (level<tria->n_levels(), ExcInvalidLevel(level));
-
-              if (tria->n_raw_lines(level) == 0)
-                return end_line ();
-
-              return raw_line_iterator (tria,
-                                        level,
-                                        0,
-                                        this);
-
-        default:
-              Assert (level == 0, ExcFacesHaveNoLevel());
-              return raw_line_iterator (tria,
-                                        0,
-                                        0,
-                                        this);
+           case 1:
+                 Assert (level<tria->n_levels(), ExcInvalidLevel(level));
+
+                 if (tria->n_raw_lines(level) == 0)
+                       return end_line ();
+
+                 return raw_line_iterator (tria,
+                                                           level,
+                                                           0,
+                                                           this);
+
+           default:
+                 Assert (level == 0, ExcFacesHaveNoLevel());
+                 return raw_line_iterator (tria,
+                                                           0,
+                                                           0,
+                                                           this);
       }
   }
 
@@ -2080,7 +2080,7 @@ namespace hp
       return ri;
     while (ri->used() == false)
       if ((++ri).state() != IteratorState::valid)
-        return ri;
+           return ri;
     return ri;
   }
 
@@ -2096,7 +2096,7 @@ namespace hp
       return i;
     while (i->has_children())
       if ((++i).state() != IteratorState::valid)
-        return i;
+           return i;
     return i;
   }
 
@@ -2107,9 +2107,9 @@ namespace hp
   DoFHandler<dim, spacedim>::end_line () const
   {
     return raw_line_iterator (tria,
-                              -1,
-                              -1,
-                              this);
+                                         -1,
+                                         -1,
+                                         this);
   }
 
 
@@ -2120,22 +2120,22 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              Assert (level<tria->n_levels(), ExcInvalidLevel(level));
-              Assert (tria->n_raw_lines(level) != 0,
-                      ExcEmptyLevel (level));
-
-              return raw_line_iterator (tria,
-                                        level,
-                                        tria->n_raw_lines(level)-1,
-                                        this);
-
-        default:
-              Assert (level == 0, ExcFacesHaveNoLevel());
-              return raw_line_iterator (tria,
-                                        0,
-                                        tria->n_raw_lines()-1,
-                                        this);
+           case 1:
+                 Assert (level<tria->n_levels(), ExcInvalidLevel(level));
+                 Assert (tria->n_raw_lines(level) != 0,
+                             ExcEmptyLevel (level));
+
+                 return raw_line_iterator (tria,
+                                                           level,
+                                                           tria->n_raw_lines(level)-1,
+                                                           this);
+
+           default:
+                 Assert (level == 0, ExcFacesHaveNoLevel());
+                 return raw_line_iterator (tria,
+                                                           0,
+                                                           tria->n_raw_lines()-1,
+                                                           this);
       }
   }
 
@@ -2162,7 +2162,7 @@ namespace hp
       return ri;
     while ((--ri).state() == IteratorState::valid)
       if (ri->used()==true)
-        return ri;
+           return ri;
     return ri;
   }
 
@@ -2188,7 +2188,7 @@ namespace hp
       return i;
     while ((--i).state() == IteratorState::valid)
       if (i->has_children()==false)
-        return i;
+           return i;
     return i;
   }
 
@@ -2211,8 +2211,8 @@ namespace hp
     Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel());
     if (dim == 1)
       return (level == tria->n_levels()-1 ?
-              end_line() :
-              begin_raw_line (level+1));
+                 end_line() :
+                 begin_raw_line (level+1));
     else
       return end_line();
   }
@@ -2225,8 +2225,8 @@ namespace hp
     Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel());
     if (dim == 1)
       return (level == tria->n_levels()-1 ?
-              line_iterator(end_line()) :
-              begin_line (level+1));
+                 line_iterator(end_line()) :
+                 begin_line (level+1));
     else
       return line_iterator(end_line());
   }
@@ -2239,8 +2239,8 @@ namespace hp
     Assert (dim == 1 || level == 0, ExcFacesHaveNoLevel());
     if (dim == 1)
       return (level == tria->n_levels()-1 ?
-              active_line_iterator(end_line()) :
-              begin_active_line (level+1));
+                 active_line_iterator(end_line()) :
+                 begin_active_line (level+1));
     else
       return active_line_iterator(end_line());
   }
@@ -2256,36 +2256,36 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              Assert (false, ExcImpossibleInDim(1));
-              return raw_hex_iterator();
-        case 2:
-        {
-          Assert (level<tria->n_levels(), ExcInvalidLevel(level));
-
-          if (tria->n_raw_quads(level) == 0)
-            return end_quad();
-
-          return raw_quad_iterator (tria,
-                                    level,
-                                    0,
-                                    this);
-        }
-
-        case 3:
-        {
-          Assert (level == 0, ExcFacesHaveNoLevel());
-
-          return raw_quad_iterator (tria,
-                                    0,
-                                    0,
-                                    this);
-        }
-
-
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_hex_iterator();
+           case 1:
+                 Assert (false, ExcImpossibleInDim(1));
+                 return raw_hex_iterator();
+           case 2:
+           {
+             Assert (level<tria->n_levels(), ExcInvalidLevel(level));
+
+             if (tria->n_raw_quads(level) == 0)
+               return end_quad();
+
+             return raw_quad_iterator (tria,
+                                                   level,
+                                                   0,
+                                                   this);
+           }
+
+           case 3:
+           {
+             Assert (level == 0, ExcFacesHaveNoLevel());
+
+             return raw_quad_iterator (tria,
+                                                   0,
+                                                   0,
+                                                   this);
+           }
+
+
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_hex_iterator();
       }
   }
 
@@ -2301,7 +2301,7 @@ namespace hp
       return ri;
     while (ri->used() == false)
       if ((++ri).state() != IteratorState::valid)
-        return ri;
+           return ri;
     return ri;
   }
 
@@ -2317,7 +2317,7 @@ namespace hp
       return i;
     while (i->has_children())
       if ((++i).state() != IteratorState::valid)
-        return i;
+           return i;
     return i;
   }
 
@@ -2330,8 +2330,8 @@ namespace hp
     Assert (dim == 2 || level == 0, ExcFacesHaveNoLevel());
     if (dim == 2)
       return (level == tria->n_levels()-1 ?
-              end_quad() :
-              begin_raw_quad (level+1));
+                 end_quad() :
+                 begin_raw_quad (level+1));
     else
       return end_quad();
   }
@@ -2345,8 +2345,8 @@ namespace hp
     Assert (dim == 2 || level == 0, ExcFacesHaveNoLevel());
     if (dim == 2)
       return (level == tria->n_levels()-1 ?
-              quad_iterator(end_quad()) :
-              begin_quad (level+1));
+                 quad_iterator(end_quad()) :
+                 begin_quad (level+1));
     else
       return quad_iterator(end_quad());
   }
@@ -2359,8 +2359,8 @@ namespace hp
     Assert(dim == 2 || level == 0, ExcFacesHaveNoLevel());
     if (dim == 2)
       return (level == tria->n_levels()-1 ?
-              active_quad_iterator(end_quad()) :
-              begin_active_quad (level+1));
+                 active_quad_iterator(end_quad()) :
+                 begin_active_quad (level+1));
     else
       return active_quad_iterator(end_quad());
   }
@@ -2372,9 +2372,9 @@ namespace hp
   DoFHandler<dim,spacedim>::end_quad () const
   {
     return raw_quad_iterator (tria,
-                              -1,
-                              -1,
-                              this);
+                                         -1,
+                                         -1,
+                                         this);
   }
 
 
@@ -2385,27 +2385,27 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-              Assert (false, ExcImpossibleInDim(1));
-              return raw_quad_iterator();
-        case 2:
-              Assert (level<tria->n_levels(),
-                      ExcInvalidLevel(level));
-              Assert (tria->n_raw_quads(level) != 0,
-                      ExcEmptyLevel (level));
-              return raw_quad_iterator (tria,
-                                        level,
-                                        tria->n_raw_quads(level)-1,
-                                        this);
-        case 3:
-              Assert (level == 0, ExcFacesHaveNoLevel());
-              return raw_quad_iterator (tria,
-                                        0,
-                                        tria->n_raw_quads()-1,
-                                        this);
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_quad_iterator();
+           case 1:
+                 Assert (false, ExcImpossibleInDim(1));
+                 return raw_quad_iterator();
+           case 2:
+                 Assert (level<tria->n_levels(),
+                             ExcInvalidLevel(level));
+                 Assert (tria->n_raw_quads(level) != 0,
+                             ExcEmptyLevel (level));
+                 return raw_quad_iterator (tria,
+                                                           level,
+                                                           tria->n_raw_quads(level)-1,
+                                                           this);
+           case 3:
+                 Assert (level == 0, ExcFacesHaveNoLevel());
+                 return raw_quad_iterator (tria,
+                                                           0,
+                                                           tria->n_raw_quads()-1,
+                                                           this);
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_quad_iterator();
       }
   }
 
@@ -2433,7 +2433,7 @@ namespace hp
       return ri;
     while ((--ri).state() == IteratorState::valid)
       if (ri->used()==true)
-        return ri;
+           return ri;
     return ri;
   }
 
@@ -2461,7 +2461,7 @@ namespace hp
       return i;
     while ((--i).state() == IteratorState::valid)
       if (i->has_children()==false)
-        return i;
+           return i;
     return i;
   }
 
@@ -2487,26 +2487,26 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-        case 2:
-              Assert (false, ExcImpossibleInDim(1));
-              return raw_hex_iterator();
-        case 3:
-        {
-          Assert (level<tria->n_levels(), ExcInvalidLevel(level));
-
-          if (tria->n_raw_hexs(level) == 0)
-            return end_hex();
-
-          return raw_hex_iterator (tria,
-                                   level,
-                                   0,
-                                   this);
-        }
-
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_hex_iterator();
+           case 1:
+           case 2:
+                 Assert (false, ExcImpossibleInDim(1));
+                 return raw_hex_iterator();
+           case 3:
+           {
+             Assert (level<tria->n_levels(), ExcInvalidLevel(level));
+
+             if (tria->n_raw_hexs(level) == 0)
+               return end_hex();
+
+             return raw_hex_iterator (tria,
+                                                  level,
+                                                  0,
+                                                  this);
+           }
+
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_hex_iterator();
       }
   }
 
@@ -2522,7 +2522,7 @@ namespace hp
       return ri;
     while (ri->used() == false)
       if ((++ri).state() != IteratorState::valid)
-        return ri;
+           return ri;
     return ri;
   }
 
@@ -2538,7 +2538,7 @@ namespace hp
       return i;
     while (i->has_children())
       if ((++i).state() != IteratorState::valid)
-        return i;
+           return i;
     return i;
   }
 
@@ -2549,8 +2549,8 @@ namespace hp
   DoFHandler<dim, spacedim>::end_raw_hex (const unsigned int level) const
   {
     return (level == tria->n_levels()-1 ?
-            end_hex() :
-            begin_raw_hex (level+1));
+               end_hex() :
+               begin_raw_hex (level+1));
   }
 
 
@@ -2559,8 +2559,8 @@ namespace hp
   DoFHandler<dim, spacedim>::end_hex (const unsigned int level) const
   {
     return (level == tria->n_levels()-1 ?
-            hex_iterator(end_hex()) :
-            begin_hex (level+1));
+               hex_iterator(end_hex()) :
+               begin_hex (level+1));
   }
 
 
@@ -2569,8 +2569,8 @@ namespace hp
   DoFHandler<dim, spacedim>::end_active_hex (const unsigned int level) const
   {
     return (level == tria->n_levels()-1 ?
-            active_hex_iterator(end_hex()) :
-            begin_active_hex (level+1));
+               active_hex_iterator(end_hex()) :
+               begin_active_hex (level+1));
   }
 
 
@@ -2580,9 +2580,9 @@ namespace hp
   DoFHandler<dim, spacedim>::end_hex () const
   {
     return raw_hex_iterator (tria,
-                             -1,
-                             -1,
-                             this);
+                                        -1,
+                                        -1,
+                                        this);
   }
 
 
@@ -2593,24 +2593,24 @@ namespace hp
   {
     switch (dim)
       {
-        case 1:
-        case 2:
-              Assert (false, ExcImpossibleInDim(dim));
-              return raw_hex_iterator();
-
-        case 3:
-              Assert (level<tria->n_levels(),
-                      ExcInvalidLevel(level));
-              Assert (tria->n_raw_hexs(level) != 0,
-                      ExcEmptyLevel (level));
-
-              return raw_hex_iterator (tria,
-                                       level,
-                                       tria->n_raw_hexs(level)-1,
-                                       this);
-        default:
-              Assert (false, ExcNotImplemented());
-              return raw_hex_iterator();
+           case 1:
+           case 2:
+                 Assert (false, ExcImpossibleInDim(dim));
+                 return raw_hex_iterator();
+
+           case 3:
+                 Assert (level<tria->n_levels(),
+                             ExcInvalidLevel(level));
+                 Assert (tria->n_raw_hexs(level) != 0,
+                             ExcEmptyLevel (level));
+
+                 return raw_hex_iterator (tria,
+                                                      level,
+                                                      tria->n_raw_hexs(level)-1,
+                                                      this);
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return raw_hex_iterator();
       }
   }
 
@@ -2635,7 +2635,7 @@ namespace hp
       return ri;
     while ((--ri).state() == IteratorState::valid)
       if (ri->used()==true)
-        return ri;
+           return ri;
     return ri;
   }
 
@@ -2660,7 +2660,7 @@ namespace hp
       return i;
     while ((--i).state() == IteratorState::valid)
       if (i->has_children()==false)
-        return i;
+           return i;
     return i;
   }
 
@@ -2804,6 +2804,7 @@ namespace hp
   }
 
 
+
 template <>
   unsigned int DoFHandler<1,3>::n_boundary_dofs () const
   {
@@ -2855,7 +2856,7 @@ template <>
             dofs_on_face.resize (dofs_per_face);
 
             cell->face(f)->get_dof_indices (dofs_on_face,
-                                            cell->active_fe_index());
+                                                               cell->active_fe_index());
             for (unsigned int i=0; i<dofs_per_face; ++i)
               boundary_dofs.insert(dofs_on_face[i]);
           };
@@ -2891,7 +2892,7 @@ template <>
             dofs_on_face.resize (dofs_per_face);
 
             cell->face(f)->get_dof_indices (dofs_on_face,
-                                            cell->active_fe_index());
+                                                               cell->active_fe_index());
             for (unsigned int i=0; i<dofs_per_face; ++i)
               boundary_dofs.insert(dofs_on_face[i]);
           }
@@ -2967,14 +2968,14 @@ template <>
   DoFHandler<dim,spacedim>::memory_consumption () const
   {
     std::size_t mem = (MemoryConsumption::memory_consumption (tria) +
-                       MemoryConsumption::memory_consumption (finite_elements) +
-                       MemoryConsumption::memory_consumption (tria) +
-                       MemoryConsumption::memory_consumption (levels) +
-                       MemoryConsumption::memory_consumption (*faces) +
-                       MemoryConsumption::memory_consumption (number_cache) +
-                       MemoryConsumption::memory_consumption (vertex_dofs) +
-                       MemoryConsumption::memory_consumption (vertex_dofs_offsets) +
-                       MemoryConsumption::memory_consumption (has_children));
+                              MemoryConsumption::memory_consumption (finite_elements) +
+                              MemoryConsumption::memory_consumption (tria) +
+                              MemoryConsumption::memory_consumption (levels) +
+                              MemoryConsumption::memory_consumption (*faces) +
+                              MemoryConsumption::memory_consumption (number_cache) +
+                              MemoryConsumption::memory_consumption (vertex_dofs) +
+                              MemoryConsumption::memory_consumption (vertex_dofs_offsets) +
+                              MemoryConsumption::memory_consumption (has_children));
     for (unsigned int i=0; i<levels.size(); ++i)
       mem += MemoryConsumption::memory_consumption (*levels[i]);
     mem += MemoryConsumption::memory_consumption (*faces);
@@ -3002,44 +3003,44 @@ template <>
                                      // make that necessary...
     Table<2,std_cxx1x::shared_ptr<internal::hp::DoFIdentities> >
       vertex_dof_identities (get_fe().size(),
-                             get_fe().size());
+                                        get_fe().size());
 
                                      // loop over all vertices and
                                      // see which one we need to
                                      // work on
     for (unsigned int vertex_index=0; vertex_index<get_tria().n_vertices();
-         ++vertex_index)
+            ++vertex_index)
       {
-        const unsigned int n_active_fe_indices
-          = internal::DoFAccessor::Implementation::
-          n_active_vertex_fe_indices (*this, vertex_index);
-        if (n_active_fe_indices > 1)
-          {
-            const unsigned int
-              first_fe_index
-              = internal::DoFAccessor::Implementation::
-              nth_active_vertex_fe_index (*this, vertex_index, 0);
+           const unsigned int n_active_fe_indices
+             = internal::DoFAccessor::Implementation::
+             n_active_vertex_fe_indices (*this, vertex_index);
+           if (n_active_fe_indices > 1)
+             {
+               const unsigned int
+                 first_fe_index
+                 = internal::DoFAccessor::Implementation::
+                 nth_active_vertex_fe_index (*this, vertex_index, 0);
 
                                              // loop over all the
                                              // other FEs with which
                                              // we want to identify
                                              // the DoF indices of
                                              // the first FE of
-            for (unsigned int f=1; f<n_active_fe_indices; ++f)
-              {
-                const unsigned int
-                  other_fe_index
-                  = internal::DoFAccessor::Implementation::
-                  nth_active_vertex_fe_index (*this, vertex_index, f);
+               for (unsigned int f=1; f<n_active_fe_indices; ++f)
+                 {
+                       const unsigned int
+                         other_fe_index
+                         = internal::DoFAccessor::Implementation::
+                         nth_active_vertex_fe_index (*this, vertex_index, f);
 
                                                  // make sure the
                                                  // entry in the
                                                  // equivalence
                                                  // table exists
-                internal::hp::ensure_existence_of_dof_identities<0>
-                  (get_fe()[first_fe_index],
-                   get_fe()[other_fe_index],
-                   vertex_dof_identities[first_fe_index][other_fe_index]);
+                       internal::hp::ensure_existence_of_dof_identities<0>
+                         (get_fe()[first_fe_index],
+                          get_fe()[other_fe_index],
+                          vertex_dof_identities[first_fe_index][other_fe_index]);
 
                                                  // then loop
                                                  // through the
@@ -3065,34 +3066,34 @@ template <>
                                                  // lower, to avoid
                                                  // circular
                                                  // reasoning.
-                internal::hp::DoFIdentities &identities
-                  = *vertex_dof_identities[first_fe_index][other_fe_index];
-                for (unsigned int i=0; i<identities.size(); ++i)
-                  {
-                    const unsigned int lower_dof_index
-                      = internal::DoFAccessor::Implementation::
-                      get_vertex_dof_index (*this,
-                                            vertex_index,
-                                            first_fe_index,
-                                            identities[i].first);
-                    const unsigned int higher_dof_index
-                      = internal::DoFAccessor::Implementation::
-                      get_vertex_dof_index (*this,
-                                            vertex_index,
-                                            other_fe_index,
-                                            identities[i].second);
-
-                    Assert ((new_dof_indices[higher_dof_index] ==
-                             numbers::invalid_unsigned_int)
-                            ||
-                            (new_dof_indices[higher_dof_index] ==
-                             lower_dof_index),
-                            ExcInternalError());
-
-                    new_dof_indices[higher_dof_index] = lower_dof_index;
-                  }
-              }
-          }
+                       internal::hp::DoFIdentities &identities
+                         = *vertex_dof_identities[first_fe_index][other_fe_index];
+                       for (unsigned int i=0; i<identities.size(); ++i)
+                         {
+                           const unsigned int lower_dof_index
+                             = internal::DoFAccessor::Implementation::
+                             get_vertex_dof_index (*this,
+                                                               vertex_index,
+                                                               first_fe_index,
+                                                               identities[i].first);
+                           const unsigned int higher_dof_index
+                             = internal::DoFAccessor::Implementation::
+                             get_vertex_dof_index (*this,
+                                                               vertex_index,
+                                                               other_fe_index,
+                                                               identities[i].second);
+
+                           Assert ((new_dof_indices[higher_dof_index] ==
+                                        numbers::invalid_unsigned_int)
+                                       ||
+                                       (new_dof_indices[higher_dof_index] ==
+                                        lower_dof_index),
+                                       ExcInternalError());
+
+                           new_dof_indices[higher_dof_index] = lower_dof_index;
+                         }
+                 }
+             }
       }
   }
 
@@ -3160,51 +3161,51 @@ template <>
                                      // at most 2
     Table<2,std_cxx1x::shared_ptr<internal::hp::DoFIdentities> >
       line_dof_identities (finite_elements->size(),
-                           finite_elements->size());
+                                      finite_elements->size());
 
     for (line_iterator line=begin_line(); line!=end_line(); ++line)
       {
-        unsigned int unique_sets_of_dofs
-          = line->n_active_fe_indices();
+           unsigned int unique_sets_of_dofs
+             = line->n_active_fe_indices();
 
                                          // do a first loop over all sets of
                                          // dofs and do identity
                                          // uniquification
-        for (unsigned int f=0; f<line->n_active_fe_indices(); ++f)
-          for (unsigned int g=f+1; g<line->n_active_fe_indices(); ++g)
-            {
-              const unsigned int fe_index_1 = line->nth_active_fe_index (f),
-                                 fe_index_2 = line->nth_active_fe_index (g);
-
-              if (((*finite_elements)[fe_index_1].dofs_per_line
-                   ==
-                   (*finite_elements)[fe_index_2].dofs_per_line)
-                  &&
-                  ((*finite_elements)[fe_index_1].dofs_per_line > 0))
-                {
-                  internal::hp::ensure_existence_of_dof_identities<1>
-                    ((*finite_elements)[fe_index_1],
-                     (*finite_elements)[fe_index_2],
-                     line_dof_identities[fe_index_1][fe_index_2]);
+           for (unsigned int f=0; f<line->n_active_fe_indices(); ++f)
+             for (unsigned int g=f+1; g<line->n_active_fe_indices(); ++g)
+               {
+                 const unsigned int fe_index_1 = line->nth_active_fe_index (f),
+                                                fe_index_2 = line->nth_active_fe_index (g);
+
+                 if (((*finite_elements)[fe_index_1].dofs_per_line
+                          ==
+                          (*finite_elements)[fe_index_2].dofs_per_line)
+                         &&
+                         ((*finite_elements)[fe_index_1].dofs_per_line > 0))
+                       {
+                         internal::hp::ensure_existence_of_dof_identities<1>
+                           ((*finite_elements)[fe_index_1],
+                            (*finite_elements)[fe_index_2],
+                            line_dof_identities[fe_index_1][fe_index_2]);
                                                    // see if these sets of dofs
                                                    // are identical. the first
                                                    // condition for this is that
                                                    // indeed there are n
                                                    // identities
-                  if (line_dof_identities[fe_index_1][fe_index_2]->size()
-                      ==
-                      (*finite_elements)[fe_index_1].dofs_per_line)
-                    {
-                      unsigned int i=0;
-                      for (; i<(*finite_elements)[fe_index_1].dofs_per_line; ++i)
-                        if (((*(line_dof_identities[fe_index_1][fe_index_2]))[i].first != i)
-                            &&
-                            ((*(line_dof_identities[fe_index_1][fe_index_2]))[i].second != i))
+                         if (line_dof_identities[fe_index_1][fe_index_2]->size()
+                             ==
+                             (*finite_elements)[fe_index_1].dofs_per_line)
+                           {
+                             unsigned int i=0;
+                             for (; i<(*finite_elements)[fe_index_1].dofs_per_line; ++i)
+                                   if (((*(line_dof_identities[fe_index_1][fe_index_2]))[i].first != i)
+                                       &&
+                                       ((*(line_dof_identities[fe_index_1][fe_index_2]))[i].second != i))
                                                            // not an identity
-                          break;
+                                     break;
 
-                      if (i == (*finite_elements)[fe_index_1].dofs_per_line)
-                        {
+                             if (i == (*finite_elements)[fe_index_1].dofs_per_line)
+                                   {
                                                            // the dofs of these
                                                            // two finite
                                                            // elements are
@@ -3216,20 +3217,20 @@ template <>
                                                            // the other, which
                                                            // wouldn't make any
                                                            // sense in this case
-                          Assert ((*finite_elements)[fe_index_1].compare_for_face_domination
-                                  ((*finite_elements)[fe_index_2])
-                                  ==
-                                  FiniteElementDomination::either_element_can_dominate,
-                                  ExcInternalError());
+                                     Assert ((*finite_elements)[fe_index_1].compare_for_face_domination
+                                                 ((*finite_elements)[fe_index_2])
+                                                 ==
+                                                 FiniteElementDomination::either_element_can_dominate,
+                                                 ExcInternalError());
 
-                          --unique_sets_of_dofs;
+                                     --unique_sets_of_dofs;
 
-                          for (unsigned int j=0; j<(*finite_elements)[fe_index_1].dofs_per_line; ++j)
-                            {
-                              const unsigned int master_dof_index
-                                = line->dof_index (j, fe_index_1);
-                              const unsigned int slave_dof_index
-                                = line->dof_index (j, fe_index_2);
+                                     for (unsigned int j=0; j<(*finite_elements)[fe_index_1].dofs_per_line; ++j)
+                                       {
+                                         const unsigned int master_dof_index
+                                               = line->dof_index (j, fe_index_1);
+                                         const unsigned int slave_dof_index
+                                               = line->dof_index (j, fe_index_2);
 
                                                                // if master dof
                                                                // was already
@@ -3240,32 +3241,32 @@ template <>
                                                                // constrain
                                                                // slave to
                                                                // master
-                              if (new_dof_indices[master_dof_index] !=
-                                  numbers::invalid_unsigned_int)
-                                {
-                                  Assert (new_dof_indices[new_dof_indices[master_dof_index]] ==
-                                          numbers::invalid_unsigned_int,
-                                          ExcInternalError());
-
-                                  new_dof_indices[slave_dof_index]
-                                    = new_dof_indices[master_dof_index];
-                                }
-                              else
-                                {
-                                  Assert ((new_dof_indices[master_dof_index] ==
-                                           numbers::invalid_unsigned_int)
-                                          ||
-                                          (new_dof_indices[slave_dof_index] ==
-                                           master_dof_index),
-                                          ExcInternalError());
-
-                                  new_dof_indices[slave_dof_index] = master_dof_index;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
+                                         if (new_dof_indices[master_dof_index] !=
+                                                 numbers::invalid_unsigned_int)
+                                               {
+                                                 Assert (new_dof_indices[new_dof_indices[master_dof_index]] ==
+                                                             numbers::invalid_unsigned_int,
+                                                             ExcInternalError());
+
+                                                 new_dof_indices[slave_dof_index]
+                                                   = new_dof_indices[master_dof_index];
+                                               }
+                                         else
+                                               {
+                                                 Assert ((new_dof_indices[master_dof_index] ==
+                                                              numbers::invalid_unsigned_int)
+                                                             ||
+                                                             (new_dof_indices[slave_dof_index] ==
+                                                              master_dof_index),
+                                                             ExcInternalError());
+
+                                                 new_dof_indices[slave_dof_index] = master_dof_index;
+                                               }
+                                       }
+                                   }
+                           }
+                       }
+               }
 
                                          // if at this point, there is only
                                          // one unique set of dofs left, then
@@ -3279,17 +3280,17 @@ template <>
 // the previous problems with step-27 in 3D. But an explanation
 // for this is still required, and what we do here is not what we
 // describe in the paper!.
-        if ((unique_sets_of_dofs == 2) && (dim == 2))
-          {
+           if ((unique_sets_of_dofs == 2) && (dim == 2))
+             {
                                              // find out which is the
                                              // most dominating finite
                                              // element of the ones that
                                              // are used on this line
-            const unsigned int most_dominating_fe_index
-              = internal::hp::get_most_dominating_fe_index<dim,spacedim> (line);
+               const unsigned int most_dominating_fe_index
+                 = internal::hp::get_most_dominating_fe_index<dim,spacedim> (line);
 
-            const unsigned int n_active_fe_indices
-              = line->n_active_fe_indices ();
+               const unsigned int n_active_fe_indices
+                 = line->n_active_fe_indices ();
 
                                              // loop over the indices of
                                              // all the finite elements
@@ -3297,38 +3298,38 @@ template <>
                                              // and identify their dofs
                                              // to the most dominating
                                              // one
-            for (unsigned int f=0; f<n_active_fe_indices; ++f)
-              if (line->nth_active_fe_index (f) !=
-                  most_dominating_fe_index)
-                {
-                  const unsigned int
-                    other_fe_index = line->nth_active_fe_index (f);
-
-                  internal::hp::ensure_existence_of_dof_identities<1>
-                    ((*finite_elements)[most_dominating_fe_index],
-                     (*finite_elements)[other_fe_index],
-                     line_dof_identities[most_dominating_fe_index][other_fe_index]);
-
-                  internal::hp::DoFIdentities &identities
-                    = *line_dof_identities[most_dominating_fe_index][other_fe_index];
-                  for (unsigned int i=0; i<identities.size(); ++i)
-                    {
-                      const unsigned int master_dof_index
-                        = line->dof_index (identities[i].first, most_dominating_fe_index);
-                      const unsigned int slave_dof_index
-                        = line->dof_index (identities[i].second, other_fe_index);
-
-                      Assert ((new_dof_indices[master_dof_index] ==
-                               numbers::invalid_unsigned_int)
-                              ||
-                              (new_dof_indices[slave_dof_index] ==
-                               master_dof_index),
-                              ExcInternalError());
-
-                      new_dof_indices[slave_dof_index] = master_dof_index;
-                    }
-                }
-          }
+               for (unsigned int f=0; f<n_active_fe_indices; ++f)
+                 if (line->nth_active_fe_index (f) !=
+                         most_dominating_fe_index)
+                       {
+                         const unsigned int
+                           other_fe_index = line->nth_active_fe_index (f);
+
+                         internal::hp::ensure_existence_of_dof_identities<1>
+                           ((*finite_elements)[most_dominating_fe_index],
+                            (*finite_elements)[other_fe_index],
+                            line_dof_identities[most_dominating_fe_index][other_fe_index]);
+
+                         internal::hp::DoFIdentities &identities
+                           = *line_dof_identities[most_dominating_fe_index][other_fe_index];
+                         for (unsigned int i=0; i<identities.size(); ++i)
+                           {
+                             const unsigned int master_dof_index
+                                   = line->dof_index (identities[i].first, most_dominating_fe_index);
+                             const unsigned int slave_dof_index
+                                   = line->dof_index (identities[i].second, other_fe_index);
+
+                             Assert ((new_dof_indices[master_dof_index] ==
+                                          numbers::invalid_unsigned_int)
+                                         ||
+                                         (new_dof_indices[slave_dof_index] ==
+                                          master_dof_index),
+                                         ExcInternalError());
+
+                             new_dof_indices[slave_dof_index] = master_dof_index;
+                           }
+                       }
+             }
       }
   }
 
@@ -3395,11 +3396,11 @@ template <>
                                      // particularly frequent case
     Table<2,std_cxx1x::shared_ptr<internal::hp::DoFIdentities> >
       quad_dof_identities (finite_elements->size(),
-                           finite_elements->size());
+                                      finite_elements->size());
 
     for (quad_iterator quad=begin_quad(); quad!=end_quad(); ++quad)
       if (quad->n_active_fe_indices() == 2)
-        {
+           {
                                            // find out which is the
                                            // most dominating finite
                                            // element of the ones that
@@ -3407,8 +3408,8 @@ template <>
           const unsigned int most_dominating_fe_index
             = internal::hp::get_most_dominating_fe_index<dim,spacedim> (quad);
 
-          const unsigned int n_active_fe_indices
-            = quad->n_active_fe_indices ();
+             const unsigned int n_active_fe_indices
+               = quad->n_active_fe_indices ();
 
                                            // loop over the indices of
                                            // all the finite elements
@@ -3445,9 +3446,9 @@ template <>
                             ExcInternalError());
 
                     new_dof_indices[slave_dof_index] = master_dof_index;
-                }
-            }
-        }
+                       }
+               }
+           }
   }
 
 
@@ -3456,7 +3457,7 @@ template <>
   void DoFHandler<dim,spacedim>::set_active_fe_indices (const std::vector<unsigned int>& active_fe_indices)
   {
     Assert(active_fe_indices.size()==get_tria().n_active_cells(),
-           ExcDimensionMismatch(active_fe_indices.size(), get_tria().n_active_cells()));
+              ExcDimensionMismatch(active_fe_indices.size(), get_tria().n_active_cells()));
 
     create_active_fe_table ();
                                      // we could set the values directly, since
@@ -3467,7 +3468,7 @@ template <>
                                      // we would have to duplicate ourselves
                                      // otherwise
     active_cell_iterator cell=begin_active(),
-                         endc=end();
+                                    endc=end();
     for (unsigned int i=0; cell!=endc; ++cell, ++i)
       cell->set_active_fe_index(active_fe_indices[i]);
   }
@@ -3484,7 +3485,7 @@ template <>
                                      // this object, but for simplicity we use
                                      // the cell-wise access.
     active_cell_iterator cell=begin_active(),
-                         endc=end();
+                                    endc=end();
     for (unsigned int i=0; cell!=endc; ++cell, ++i)
       active_fe_indices[i]=cell->active_fe_index();
   }
@@ -3509,8 +3510,8 @@ template <>
                                      // in use on the mesh
     for (active_cell_iterator cell = begin_active(); cell != end(); ++cell)
       Assert (cell->active_fe_index() < finite_elements->size(),
-              ExcInvalidFEIndex (cell->active_fe_index(),
-                                 finite_elements->size()));
+                 ExcInvalidFEIndex (cell->active_fe_index(),
+                                                finite_elements->size()));
 
 
                                      // then allocate space for all
@@ -3537,12 +3538,12 @@ template <>
     {
       unsigned int next_free_dof = 0;
       active_cell_iterator cell = begin_active(),
-                           endc = end();
+                                      endc = end();
 
       for (; cell != endc; ++cell)
-        next_free_dof
-          = internal::hp::DoFHandler::Implementation::template distribute_dofs_on_cell<spacedim> (cell,
-                                                               next_free_dof);
+           next_free_dof
+             = internal::hp::DoFHandler::Implementation::template distribute_dofs_on_cell<spacedim> (cell,
+                                                                                                                             next_free_dof);
 
       number_cache.n_global_dofs = next_free_dof;
     }
@@ -3571,30 +3572,30 @@ template <>
     unsigned int next_free_dof = 0;
     for (unsigned int i=0; i<number_cache.n_global_dofs; ++i)
       if (constrained_indices[i] == numbers::invalid_unsigned_int)
-        {
-          new_dof_indices[i] = next_free_dof;
-          ++next_free_dof;
-        }
+           {
+             new_dof_indices[i] = next_free_dof;
+             ++next_free_dof;
+           }
 
                                      // then loop over all those that
                                      // are constrained and record the
                                      // new dof number for those:
     for (unsigned int i=0; i<number_cache.n_global_dofs; ++i)
       if (constrained_indices[i] != numbers::invalid_unsigned_int)
-        {
-          Assert (new_dof_indices[constrained_indices[i]] !=
-                  numbers::invalid_unsigned_int,
-                  ExcInternalError());
+           {
+             Assert (new_dof_indices[constrained_indices[i]] !=
+                         numbers::invalid_unsigned_int,
+                         ExcInternalError());
 
-          new_dof_indices[i] = new_dof_indices[constrained_indices[i]];
-        }
+             new_dof_indices[i] = new_dof_indices[constrained_indices[i]];
+           }
 
     for (unsigned int i=0; i<number_cache.n_global_dofs; ++i)
       {
-        Assert (new_dof_indices[i] != numbers::invalid_unsigned_int,
-                ExcInternalError());
-        Assert (new_dof_indices[i] < next_free_dof,
-                ExcInternalError());
+           Assert (new_dof_indices[i] != numbers::invalid_unsigned_int,
+                       ExcInternalError());
+           Assert (new_dof_indices[i] < next_free_dof,
+                       ExcInternalError());
       }
 
                                      // finally, do the renumbering
@@ -3610,15 +3611,15 @@ template <>
     number_cache.locally_owned_dofs
       = IndexSet (number_cache.n_global_dofs);
     number_cache.locally_owned_dofs.add_range (0,
-                                               number_cache.n_global_dofs);
+                                                                  number_cache.n_global_dofs);
 
     number_cache.n_locally_owned_dofs_per_processor
       = std::vector<unsigned int> (1,
-                                   number_cache.n_global_dofs);
+                                                  number_cache.n_global_dofs);
 
     number_cache.locally_owned_dofs_per_processor
       = std::vector<IndexSet> (1,
-                               number_cache.locally_owned_dofs);
+                                          number_cache.locally_owned_dofs);
 
                                      // finally restore the user flags
     const_cast<Triangulation<dim,spacedim> &>(*tria).load_user_flags(user_flags);
@@ -3665,39 +3666,39 @@ template <>
   void
   DoFHandler<dim,spacedim>::
   renumber_dofs_internal (const std::vector<unsigned int> &new_numbers,
-                          internal::int2type<0>)
+                                     internal::int2type<0>)
   {
     Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete());
 
     for (unsigned int vertex_index=0; vertex_index<get_tria().n_vertices();
-         ++vertex_index)
+            ++vertex_index)
       {
-        const unsigned int n_active_fe_indices
-          = internal::DoFAccessor::Implementation::
-          n_active_vertex_fe_indices (*this, vertex_index);
-
-        for (unsigned int f=0; f<n_active_fe_indices; ++f)
-          {
-            const unsigned int fe_index
-              = internal::DoFAccessor::Implementation::
-              nth_active_vertex_fe_index (*this, vertex_index, f);
-
-            for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_vertex; ++d)
-              {
-                const unsigned int vertex_dof_index
-                  = internal::DoFAccessor::Implementation::
-                  get_vertex_dof_index(*this,
-                                       vertex_index,
-                                       fe_index,
-                                       d);
-                internal::DoFAccessor::Implementation::
-                  set_vertex_dof_index (*this,
-                                        vertex_index,
-                                        fe_index,
-                                        d,
-                                        new_numbers[vertex_dof_index]);
-              }
-          }
+           const unsigned int n_active_fe_indices
+             = internal::DoFAccessor::Implementation::
+             n_active_vertex_fe_indices (*this, vertex_index);
+
+           for (unsigned int f=0; f<n_active_fe_indices; ++f)
+             {
+               const unsigned int fe_index
+                 = internal::DoFAccessor::Implementation::
+                 nth_active_vertex_fe_index (*this, vertex_index, f);
+
+               for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_vertex; ++d)
+                 {
+                       const unsigned int vertex_dof_index
+                         = internal::DoFAccessor::Implementation::
+                         get_vertex_dof_index(*this,
+                                                      vertex_index,
+                                                      fe_index,
+                                                      d);
+                       internal::DoFAccessor::Implementation::
+                         set_vertex_dof_index (*this,
+                                                           vertex_index,
+                                                           fe_index,
+                                                           d,
+                                                           new_numbers[vertex_dof_index]);
+                 }
+             }
       }
   }
 
@@ -3707,7 +3708,7 @@ template <>
   void
   DoFHandler<dim,spacedim>::
   renumber_dofs_internal (const std::vector<unsigned int> &new_numbers,
-                          internal::int2type<1>)
+                                     internal::int2type<1>)
   {
     Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete());
 
@@ -3715,19 +3716,19 @@ template <>
 
     for (line_iterator line=begin_line(); line!=end_line(); ++line)
       {
-        const unsigned int n_active_fe_indices
-          = line->n_active_fe_indices ();
-
-        for (unsigned int f=0; f<n_active_fe_indices; ++f)
-          {
-            const unsigned int fe_index
-              = line->nth_active_fe_index (f);
-
-            for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_line; ++d)
-              line->set_dof_index (d,
-                                   new_numbers[line->dof_index(d,fe_index)],
-                                   fe_index);
-          }
+           const unsigned int n_active_fe_indices
+             = line->n_active_fe_indices ();
+
+           for (unsigned int f=0; f<n_active_fe_indices; ++f)
+             {
+               const unsigned int fe_index
+                 = line->nth_active_fe_index (f);
+
+               for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_line; ++d)
+                 line->set_dof_index (d,
+                                                  new_numbers[line->dof_index(d,fe_index)],
+                                                  fe_index);
+             }
       }
   }
 
@@ -3738,7 +3739,7 @@ template <>
   void
   DoFHandler<2,2>::
   renumber_dofs_internal (const std::vector<unsigned int> &new_numbers,
-                          internal::int2type<2>)
+                                     internal::int2type<2>)
   {
     Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete());
 
@@ -3746,19 +3747,19 @@ template <>
 
     for (quad_iterator quad=begin_quad(); quad!=end_quad(); ++quad)
       {
-        const unsigned int n_active_fe_indices
-          = quad->n_active_fe_indices ();
-
-        for (unsigned int f=0; f<n_active_fe_indices; ++f)
-          {
-            const unsigned int fe_index
-              = quad->nth_active_fe_index (f);
-
-            for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_quad; ++d)
-              quad->set_dof_index (d,
-                                   new_numbers[quad->dof_index(d,fe_index)],
-                                   fe_index);
-          }
+           const unsigned int n_active_fe_indices
+             = quad->n_active_fe_indices ();
+
+           for (unsigned int f=0; f<n_active_fe_indices; ++f)
+             {
+               const unsigned int fe_index
+                 = quad->nth_active_fe_index (f);
+
+               for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_quad; ++d)
+                 quad->set_dof_index (d,
+                                                  new_numbers[quad->dof_index(d,fe_index)],
+                                                  fe_index);
+             }
       }
   }
 
@@ -3768,7 +3769,7 @@ template <>
   void
   DoFHandler<2,3>::
   renumber_dofs_internal (const std::vector<unsigned int> &new_numbers,
-                          internal::int2type<2>)
+                                     internal::int2type<2>)
   {
     Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete());
 
@@ -3776,19 +3777,19 @@ template <>
 
     for (quad_iterator quad=begin_quad(); quad!=end_quad(); ++quad)
       {
-        const unsigned int n_active_fe_indices
-          = quad->n_active_fe_indices ();
-
-        for (unsigned int f=0; f<n_active_fe_indices; ++f)
-          {
-            const unsigned int fe_index
-              = quad->nth_active_fe_index (f);
-
-            for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_quad; ++d)
-              quad->set_dof_index (d,
-                                   new_numbers[quad->dof_index(d,fe_index)],
-                                   fe_index);
-          }
+           const unsigned int n_active_fe_indices
+             = quad->n_active_fe_indices ();
+
+           for (unsigned int f=0; f<n_active_fe_indices; ++f)
+             {
+               const unsigned int fe_index
+                 = quad->nth_active_fe_index (f);
+
+               for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_quad; ++d)
+                 quad->set_dof_index (d,
+                                                  new_numbers[quad->dof_index(d,fe_index)],
+                                                  fe_index);
+             }
       }
   }
 
@@ -3797,7 +3798,7 @@ template <>
   void
   DoFHandler<3,3>::
   renumber_dofs_internal (const std::vector<unsigned int> &new_numbers,
-                          internal::int2type<2>)
+                                     internal::int2type<2>)
   {
     Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete());
 
@@ -3805,19 +3806,19 @@ template <>
 
     for (quad_iterator quad=begin_quad(); quad!=end_quad(); ++quad)
       {
-        const unsigned int n_active_fe_indices
-          = quad->n_active_fe_indices ();
-
-        for (unsigned int f=0; f<n_active_fe_indices; ++f)
-          {
-            const unsigned int fe_index
-              = quad->nth_active_fe_index (f);
-
-            for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_quad; ++d)
-              quad->set_dof_index (d,
-                                   new_numbers[quad->dof_index(d,fe_index)],
-                                   fe_index);
-          }
+           const unsigned int n_active_fe_indices
+             = quad->n_active_fe_indices ();
+
+           for (unsigned int f=0; f<n_active_fe_indices; ++f)
+             {
+               const unsigned int fe_index
+                 = quad->nth_active_fe_index (f);
+
+               for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_quad; ++d)
+                 quad->set_dof_index (d,
+                                                  new_numbers[quad->dof_index(d,fe_index)],
+                                                  fe_index);
+             }
       }
   }
 
@@ -3826,7 +3827,7 @@ template <>
   void
   DoFHandler<3,3>::
   renumber_dofs_internal (const std::vector<unsigned int> &new_numbers,
-                          internal::int2type<3>)
+                                     internal::int2type<3>)
   {
     Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete());
 
@@ -3834,19 +3835,19 @@ template <>
 
     for (hex_iterator hex=begin_hex(); hex!=end_hex(); ++hex)
       {
-        const unsigned int n_active_fe_indices
-          = hex->n_active_fe_indices ();
-
-        for (unsigned int f=0; f<n_active_fe_indices; ++f)
-          {
-            const unsigned int fe_index
-              = hex->nth_active_fe_index (f);
-
-            for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_hex; ++d)
-              hex->set_dof_index (d,
-                                  new_numbers[hex->dof_index(d,fe_index)],
-                                  fe_index);
-          }
+           const unsigned int n_active_fe_indices
+             = hex->n_active_fe_indices ();
+
+           for (unsigned int f=0; f<n_active_fe_indices; ++f)
+             {
+               const unsigned int fe_index
+                 = hex->nth_active_fe_index (f);
+
+               for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_hex; ++d)
+                 hex->set_dof_index (d,
+                                                 new_numbers[hex->dof_index(d,fe_index)],
+                                                 fe_index);
+             }
       }
   }
 
@@ -3870,13 +3871,13 @@ template <>
 
     switch (dim)
       {
-        case 1:
-              return finite_elements->max_dofs_per_vertex();
-        case 2:
-              return (3*finite_elements->max_dofs_per_vertex()
-                      +
-                      2*finite_elements->max_dofs_per_line());
-        case 3:
+           case 1:
+                 return finite_elements->max_dofs_per_vertex();
+           case 2:
+                 return (3*finite_elements->max_dofs_per_vertex()
+                             +
+                             2*finite_elements->max_dofs_per_line());
+           case 3:
                                                // we need to take refinement of
                                                // one boundary face into consideration
                                                // here; in fact, this function returns
@@ -3890,12 +3891,12 @@ template <>
                                                // it for now does no harm since the
                                                // matrix will cry foul if its requirements
                                                // are not satisfied
-              return (19*finite_elements->max_dofs_per_vertex() +
-                      28*finite_elements->max_dofs_per_line() +
-                      8*finite_elements->max_dofs_per_quad());
-        default:
-              Assert (false, ExcNotImplemented());
-              return 0;
+                 return (19*finite_elements->max_dofs_per_vertex() +
+                             28*finite_elements->max_dofs_per_line() +
+                             8*finite_elements->max_dofs_per_quad());
+           default:
+                 Assert (false, ExcNotImplemented());
+                 return 0;
       }
   }
 
@@ -3949,18 +3950,18 @@ template <>
     Assert (has_children.size () == 0, ExcInternalError ());
     for (unsigned int i=0; i<levels.size(); ++i)
       {
-        const unsigned int cells_on_level = tria->n_raw_cells(i);
-        std::vector<bool> *has_children_level =
+           const unsigned int cells_on_level = tria->n_raw_cells(i);
+           std::vector<bool> *has_children_level =
           new std::vector<bool> (cells_on_level);
 
                                          // Check for each cell, if it has children.
-        std::transform (tria->levels[i]->cells.refinement_cases.begin (),
-                        tria->levels[i]->cells.refinement_cases.end (),
-                        has_children_level->begin (),
-                        std::bind2nd (std::not_equal_to<unsigned char>(),
-                                      static_cast<unsigned char>(RefinementCase<dim>::no_refinement)));
+           std::transform (tria->levels[i]->cells.refinement_cases.begin (),
+                                   tria->levels[i]->cells.refinement_cases.end (),
+                                   has_children_level->begin (),
+                                   std::bind2nd (std::not_equal_to<unsigned char>(),
+                                                     static_cast<unsigned char>(RefinementCase<dim>::no_refinement)));
 
-        has_children.push_back (has_children_level);
+           has_children.push_back (has_children_level);
       }
   }
 
@@ -3978,8 +3979,8 @@ template <>
     Assert (has_children.size () == 0, ExcInternalError ());
     for (unsigned int i=0; i<levels.size(); ++i)
       {
-        const unsigned int cells_on_level = tria->n_raw_cells (i);
-        std::vector<bool> *has_children_level =
+           const unsigned int cells_on_level = tria->n_raw_cells (i);
+           std::vector<bool> *has_children_level =
           new std::vector<bool> (cells_on_level);
 
                                          // Check for each cell, if it has
@@ -3988,12 +3989,12 @@ template <>
                                          // 1d (as there is only one choice
                                          // anyway). use the 'children' vector
                                          // instead
-        std::transform (tria->levels[i]->cells.children.begin (),
-                        tria->levels[i]->cells.children.end (),
-                        has_children_level->begin (),
-                        std::bind2nd (std::not_equal_to<int>(), -1));
+           std::transform (tria->levels[i]->cells.children.begin (),
+                                   tria->levels[i]->cells.children.end (),
+                                   has_children_level->begin (),
+                                   std::bind2nd (std::not_equal_to<int>(), -1));
 
-        has_children.push_back (has_children_level);
+           has_children.push_back (has_children_level);
       }
   }
 
@@ -4011,21 +4012,22 @@ template <>
     Assert (has_children.size () == 0, ExcInternalError ());
     for (unsigned int i=0; i<levels.size(); ++i)
       {
-        const unsigned int lines_on_level = tria->n_raw_lines(i);
-        std::vector<bool> *has_children_level =
+           const unsigned int lines_on_level = tria->n_raw_lines(i);
+           std::vector<bool> *has_children_level =
           new std::vector<bool> (lines_on_level);
 
                                          // Check for each cell, if it has children.
-        std::transform (tria->levels[i]->cells.children.begin (),
-                        tria->levels[i]->cells.children.end (),
-                        has_children_level->begin (),
-                        std::bind2nd (std::not_equal_to<int>(), -1));
+           std::transform (tria->levels[i]->cells.children.begin (),
+                                   tria->levels[i]->cells.children.end (),
+                                   has_children_level->begin (),
+                                   std::bind2nd (std::not_equal_to<int>(), -1));
 
-        has_children.push_back (has_children_level);
+           has_children.push_back (has_children_level);
       }
   }
 
 
+
 template <>
   void DoFHandler<1,3>::pre_refinement_action ()
   {
@@ -4071,8 +4073,8 @@ template <>
                                      // of levels. Hence remove them.
     while (levels.size () > tria->n_levels ())
       {
-        delete levels[levels.size ()-1];
-        levels.pop_back ();
+           delete levels[levels.size ()-1];
+           levels.pop_back ();
       }
 
                                      // Resize active_fe_indices
@@ -4128,8 +4130,8 @@ template <>
                                      // Free buffer objects
     std::vector<std::vector<bool> *>::iterator children_level;
     for (children_level = has_children.begin ();
-         children_level != has_children.end ();
-         ++children_level)
+            children_level != has_children.end ();
+            ++children_level)
       delete (*children_level);
                                      /*
                                        for_each (has_children.begin (),
@@ -4140,6 +4142,31 @@ template <>
   }
 
 
+  template <int dim, int spacedim>
+  template <int structdim>
+  unsigned int
+  DoFHandler<dim,spacedim>::get_dof_index (const unsigned int       obj_level,
+                                           const unsigned int       obj_index,
+                                           const unsigned int       fe_index,
+                                           const unsigned int       local_index) const
+  {
+    
+  }
+
+
+  template <int dim, int spacedim>
+  template <int structdim>
+  void
+  DoFHandler<dim,spacedim>::set_dof_index (const unsigned int obj_level,
+                                           const unsigned int obj_index,
+                                           const unsigned int fe_index,
+                                           const unsigned int local_index,
+                                           const unsigned int global_index) const
+  {
+    
+  }
+
+
   template<int dim, int spacedim>
   void DoFHandler<dim,spacedim>::clear_space ()
   {
index 7759611be3c570aa77f21b987ef41fa8faeafdfa..cb3e1759630ffc01b0211435ee196def025d5598 100644 (file)
@@ -19,10 +19,68 @@ for (deal_II_dimension : DIMENSIONS)
 
 #if deal_II_dimension != 3
     template class DoFHandler<deal_II_dimension, deal_II_dimension+1>;
+    
+    template
+    unsigned int
+    DoFHandler<deal_II_dimension, deal_II_dimension+1>::get_dof_index<1> (const unsigned int, const unsigned int, const unsigned int, const unsigned int) const;
+    
+    template
+    void
+    DoFHandler<deal_II_dimension, deal_II_dimension+1>::set_dof_index<1> (const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int) const;
+    
+    #if deal_II_dimension >= 2
+    template
+    unsigned int
+    DoFHandler<deal_II_dimension, deal_II_dimension+1>::get_dof_index<2> (const unsigned int, const unsigned int, const unsigned int, const unsigned int) const;
+    
+    template
+    void
+    DoFHandler<deal_II_dimension, deal_II_dimension+1>::set_dof_index<2> (const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int) const;
+    #endif
 #endif
 
 #if deal_II_dimension == 3
    template class DoFHandler<1, 3>;
+
+template
+unsigned int
+DoFHandler<1,3>::get_dof_index<1> (const unsigned int, const unsigned int, const unsigned int, const unsigned int) const;
+
+template
+void
+DoFHandler<1,3>::set_dof_index<1> (const unsigned int, const unsigned int, const unsigned int, const unsigned int, unsigned int) const;
+#endif
+
+template
+unsigned int
+DoFHandler<deal_II_dimension>::get_dof_index<1> (const unsigned int, const unsigned int, const unsigned int, const unsigned int) const;
+
+#if deal_II_dimension >= 2
+template
+unsigned int
+DoFHandler<deal_II_dimension>::get_dof_index<2> (const unsigned int, const unsigned int, const unsigned int, const unsigned int) const;
+
+#if deal_II_dimension >= 3
+template
+unsigned int
+DoFHandler<deal_II_dimension>::get_dof_index<3> (const unsigned int, const unsigned int, const unsigned int, const unsigned int) const;
+#endif
+#endif
+
+template
+void
+DoFHandler<deal_II_dimension>::set_dof_index<1> (const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int) const;
+
+#if deal_II_dimension >= 2
+template
+void
+DoFHandler<deal_II_dimension>::set_dof_index<2> (const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int) const;
+
+#if deal_II_dimension >= 3
+template
+void
+DoFHandler<deal_II_dimension>::set_dof_index<3> (const unsigned int, const unsigned int, const unsigned int, const unsigned int, const unsigned int) const;
+#endif
 #endif
   \}
 }
index 9b54a14f498db4cbb0856aad669cf0bd3d7a34df..a87cfb628ac06214e01f6f2fa180363b78fff1bd 100644 (file)
@@ -30,6 +30,7 @@
 #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>
 
@@ -81,7 +82,7 @@ namespace MGTools
     const DoFTools::Coupling)
   {
     Assert(false, ExcNotImplemented());
-  }
+  } 
 
 
   template <>
@@ -108,7 +109,7 @@ namespace MGTools
     const DoFTools::Coupling             flux_coupling)
   {
     Assert (row_lengths.size() == dofs.n_dofs(),
-            ExcDimensionMismatch(row_lengths.size(), dofs.n_dofs()));
+               ExcDimensionMismatch(row_lengths.size(), dofs.n_dofs()));
 
                                      // Function starts here by
                                      // resetting the counters.
@@ -167,7 +168,7 @@ namespace MGTools
 //TODO: This assumes that even in hp context, the dofs per face coincide!
         unsigned int increment = fe.dofs_per_cell - dim * fe.dofs_per_face;
         while (i < fe.first_line_index)
-          row_lengths[cell_indices[i++]] += increment;
+             row_lengths[cell_indices[i++]] += increment;
                                          // From now on, if an object is
                                          // a cell, its dofs only couple
                                          // inside the cell. Since the
@@ -179,21 +180,21 @@ namespace MGTools
                                          // subtract adjacent faces to be
                                          // added in the loop below.
         increment = (dim>1)
-                    ? fe.dofs_per_cell - (dim-1) * fe.dofs_per_face
-                    : fe.dofs_per_cell - GeometryInfo<dim>::faces_per_cell * fe.dofs_per_face;
+                           ? fe.dofs_per_cell - (dim-1) * fe.dofs_per_face
+                           : fe.dofs_per_cell - GeometryInfo<dim>::faces_per_cell * fe.dofs_per_face;
         while (i < fe.first_quad_index)
-          row_lengths[cell_indices[i++]] += increment;
+             row_lengths[cell_indices[i++]] += increment;
 
                                          // Now quads in 2D and 3D
         increment = (dim>2)
-                    ? fe.dofs_per_cell - (dim-2) * fe.dofs_per_face
-                    : fe.dofs_per_cell - GeometryInfo<dim>::faces_per_cell * fe.dofs_per_face;
+                           ? fe.dofs_per_cell - (dim-2) * fe.dofs_per_face
+                           : fe.dofs_per_cell - GeometryInfo<dim>::faces_per_cell * fe.dofs_per_face;
         while (i < fe.first_hex_index)
-          row_lengths[cell_indices[i++]] += increment;
+             row_lengths[cell_indices[i++]] += increment;
                                          // Finally, cells in 3D
         increment = fe.dofs_per_cell - GeometryInfo<dim>::faces_per_cell * fe.dofs_per_face;
         while (i < fe.dofs_per_cell)
-          row_lengths[cell_indices[i++]] += increment;
+             row_lengths[cell_indices[i++]] += increment;
 
                                          // At this point, we have
                                          // counted all dofs
@@ -207,25 +208,25 @@ namespace MGTools
                                          // contribution as well as the
                                          // flux contributions.
         for (unsigned int iface=0;iface<GeometryInfo<dim>::faces_per_cell;++iface)
-          {
-            bool level_boundary = cell->at_boundary(iface);
-            typename MGDoFHandler<dim,spacedim>::cell_iterator neighbor;
-            if (!level_boundary)
-              {
-                neighbor = cell->neighbor(iface);
-                if (static_cast<unsigned int>(neighbor->level()) != level)
-                  level_boundary = true;
-              }
-
-            if (level_boundary)
-              {
-                for (unsigned int i=0;i<fe.dofs_per_cell;++i)
-                  row_lengths[cell_indices[i]] += fe.dofs_per_face;
-                continue;
-              }
-
-            const FiniteElement<dim>& nfe = neighbor->get_fe();
-            typename MGDoFHandler<dim,spacedim>::face_iterator face = cell->face(iface);
+             {
+               bool level_boundary = cell->at_boundary(iface);
+               typename MGDoFHandler<dim,spacedim>::cell_iterator neighbor;
+               if (!level_boundary)
+                 {
+                   neighbor = cell->neighbor(iface);
+                   if (static_cast<unsigned int>(neighbor->level()) != level)
+                         level_boundary = true;
+                 }
+
+               if (level_boundary)
+                 {
+                   for (unsigned int i=0;i<fe.dofs_per_cell;++i)
+                         row_lengths[cell_indices[i]] += fe.dofs_per_face;
+                   continue;
+                 }
+
+               const FiniteElement<dim>& nfe = neighbor->get_fe();
+               typename MGDoFHandler<dim,spacedim>::face_iterator face = cell->face(iface);
 
                                              // Flux couplings are
                                              // computed from both sides
@@ -235,18 +236,18 @@ namespace MGTools
                                              // will be handled below,
                                              // therefore, we subtract them
                                              // here.
-            if (flux_coupling != DoFTools::none)
-              {
-                unsigned int increment = nfe.dofs_per_cell - nfe.dofs_per_face;
-                for (unsigned int i=0;i<fe.dofs_per_cell;++i)
-                  row_lengths[cell_indices[i]] += increment;
-              }
+               if (flux_coupling != DoFTools::none)
+                 {
+                   unsigned int increment = nfe.dofs_per_cell - nfe.dofs_per_face;
+                   for (unsigned int i=0;i<fe.dofs_per_cell;++i)
+                         row_lengths[cell_indices[i]] += increment;
+                 }
 
                                              // Do this only once per
                                              // face.
-            if (face->user_flag_set())
-              continue;
-            face->set_user_flag();
+               if (face->user_flag_set())
+                 continue;
+               face->set_user_flag();
                                              // At this point, we assume
                                              // that each cell added its
                                              // dofs minus the face to
@@ -259,13 +260,13 @@ namespace MGTools
                                              // is refined, all the fine
                                              // face dofs couple with
                                              // the coarse one.
-            neighbor_indices.resize(nfe.dofs_per_cell);
-            neighbor->get_mg_dof_indices(neighbor_indices);
-            for (unsigned int i=0;i<fe.dofs_per_cell;++i)
-              row_lengths[cell_indices[i]] += nfe.dofs_per_face;
-            for (unsigned int i=0;i<nfe.dofs_per_cell;++i)
-              row_lengths[neighbor_indices[i]] += fe.dofs_per_face;
-          }
+               neighbor_indices.resize(nfe.dofs_per_cell);
+               neighbor->get_mg_dof_indices(neighbor_indices);
+               for (unsigned int i=0;i<fe.dofs_per_cell;++i)
+                 row_lengths[cell_indices[i]] += nfe.dofs_per_face;
+               for (unsigned int i=0;i<nfe.dofs_per_cell;++i)
+                 row_lengths[neighbor_indices[i]] += fe.dofs_per_face;
+             }
       }
     user_flags_triangulation.load_user_flags(old_flags);
   }
@@ -282,7 +283,7 @@ namespace MGTools
     const Table<2,DoFTools::Coupling>& flux_couplings)
   {
     Assert (row_lengths.size() == dofs.n_dofs(),
-            ExcDimensionMismatch(row_lengths.size(), dofs.n_dofs()));
+               ExcDimensionMismatch(row_lengths.size(), dofs.n_dofs()));
 
                                      // Function starts here by
                                      // resetting the counters.
@@ -326,13 +327,13 @@ namespace MGTools
         const unsigned int fe_index = cell->active_fe_index();
 
         Assert (couplings.n_rows()==fe.n_components(),
-                ExcDimensionMismatch(couplings.n_rows(), fe.n_components()));
+                   ExcDimensionMismatch(couplings.n_rows(), fe.n_components()));
         Assert (couplings.n_cols()==fe.n_components(),
-                ExcDimensionMismatch(couplings.n_cols(), fe.n_components()));
+                   ExcDimensionMismatch(couplings.n_cols(), fe.n_components()));
         Assert (flux_couplings.n_rows()==fe.n_components(),
-                ExcDimensionMismatch(flux_couplings.n_rows(), fe.n_components()));
+                   ExcDimensionMismatch(flux_couplings.n_rows(), fe.n_components()));
         Assert (flux_couplings.n_cols()==fe.n_components(),
-                ExcDimensionMismatch(flux_couplings.n_cols(), fe.n_components()));
+                   ExcDimensionMismatch(flux_couplings.n_cols(), fe.n_components()));
 
         cell_indices.resize(fe.dofs_per_cell);
         cell->get_mg_dof_indices(cell_indices);
@@ -360,18 +361,18 @@ namespace MGTools
                                          // round.
         unsigned int increment;
         while (i < fe.first_line_index)
-          {
-            for (unsigned int base=0;base<fe.n_base_elements();++base)
-              for (unsigned int mult=0;mult<fe.element_multiplicity(base);++mult)
-                if (couple_cell[fe_index](fe.system_to_block_index(i).first,
-                                          fe.first_block_of_base(base) + mult) != DoFTools::none)
-                  {
-                    increment = fe.base_element(base).dofs_per_cell
-                                - dim * fe.base_element(base).dofs_per_face;
-                    row_lengths[cell_indices[i]] += increment;
-                  }
-            ++i;
-          }
+             {
+               for (unsigned int base=0;base<fe.n_base_elements();++base)
+                 for (unsigned int mult=0;mult<fe.element_multiplicity(base);++mult)
+                   if (couple_cell[fe_index](fe.system_to_block_index(i).first,
+                                                             fe.first_block_of_base(base) + mult) != DoFTools::none)
+                         {
+                           increment = fe.base_element(base).dofs_per_cell
+                                           - dim * fe.base_element(base).dofs_per_face;
+                           row_lengths[cell_indices[i]] += increment;
+                         }
+               ++i;
+             }
                                          // From now on, if an object is
                                          // a cell, its dofs only couple
                                          // inside the cell. Since the
@@ -383,55 +384,55 @@ namespace MGTools
                                          // subtract adjacent faces to be
                                          // added in the loop below.
         while (i < fe.first_quad_index)
-          {
-            for (unsigned int base=0;base<fe.n_base_elements();++base)
-              for (unsigned int mult=0;mult<fe.element_multiplicity(base);++mult)
-                if (couple_cell[fe_index](fe.system_to_block_index(i).first,
-                                          fe.first_block_of_base(base) + mult) != DoFTools::none)
-                  {
-                    increment = fe.base_element(base).dofs_per_cell
-                                - ((dim>1)
-                                   ? (dim-1)
-                                   : GeometryInfo<dim>::faces_per_cell)
-                                * fe.base_element(base).dofs_per_face;
-                    row_lengths[cell_indices[i]] += increment;
-                  }
-            ++i;
-          }
+             {
+               for (unsigned int base=0;base<fe.n_base_elements();++base)
+                 for (unsigned int mult=0;mult<fe.element_multiplicity(base);++mult)
+                   if (couple_cell[fe_index](fe.system_to_block_index(i).first,
+                                                             fe.first_block_of_base(base) + mult) != DoFTools::none)
+                         {
+                           increment = fe.base_element(base).dofs_per_cell
+                                           - ((dim>1)
+                                                  ? (dim-1)
+                                                  : GeometryInfo<dim>::faces_per_cell)
+                                           * fe.base_element(base).dofs_per_face;
+                           row_lengths[cell_indices[i]] += increment;
+                         }
+               ++i;
+             }
 
                                          // Now quads in 2D and 3D
         while (i < fe.first_hex_index)
-          {
-            for (unsigned int base=0;base<fe.n_base_elements();++base)
-              for (unsigned int mult=0;mult<fe.element_multiplicity(base);++mult)
-                if (couple_cell[fe_index](fe.system_to_block_index(i).first,
-                                          fe.first_block_of_base(base) + mult) != DoFTools::none)
-                  {
-                    increment = fe.base_element(base).dofs_per_cell
-                                - ((dim>2)
-                                   ? (dim-2)
-                                   : GeometryInfo<dim>::faces_per_cell)
-                                * fe.base_element(base).dofs_per_face;
-                    row_lengths[cell_indices[i]] += increment;
-                  }
-            ++i;
-          }
+             {
+               for (unsigned int base=0;base<fe.n_base_elements();++base)
+                 for (unsigned int mult=0;mult<fe.element_multiplicity(base);++mult)
+                   if (couple_cell[fe_index](fe.system_to_block_index(i).first,
+                                                             fe.first_block_of_base(base) + mult) != DoFTools::none)
+                         {
+                           increment = fe.base_element(base).dofs_per_cell
+                                           - ((dim>2)
+                                                  ? (dim-2)
+                                                  : GeometryInfo<dim>::faces_per_cell)
+                                           * fe.base_element(base).dofs_per_face;
+                           row_lengths[cell_indices[i]] += increment;
+                     }
+               ++i;
+             }
 
                                          // Finally, cells in 3D
         while (i < fe.dofs_per_cell)
-          {
-            for (unsigned int base=0;base<fe.n_base_elements();++base)
-              for (unsigned int mult=0;mult<fe.element_multiplicity(base);++mult)
-                if (couple_cell[fe_index](fe.system_to_block_index(i).first,
-                                          fe.first_block_of_base(base) + mult) != DoFTools::none)
-                  {
-                    increment = fe.base_element(base).dofs_per_cell
-                                - GeometryInfo<dim>::faces_per_cell
-                                * fe.base_element(base).dofs_per_face;
-                    row_lengths[cell_indices[i]] += increment;
-                  }
-            ++i;
-          }
+             {
+               for (unsigned int base=0;base<fe.n_base_elements();++base)
+                 for (unsigned int mult=0;mult<fe.element_multiplicity(base);++mult)
+                   if (couple_cell[fe_index](fe.system_to_block_index(i).first,
+                                                             fe.first_block_of_base(base) + mult) != DoFTools::none)
+                         {
+                           increment = fe.base_element(base).dofs_per_cell
+                                           - GeometryInfo<dim>::faces_per_cell
+                                           * fe.base_element(base).dofs_per_face;
+                           row_lengths[cell_indices[i]] += increment;
+                         }
+               ++i;
+             }
 
                                          // At this point, we have
                                          // counted all dofs
@@ -445,25 +446,25 @@ namespace MGTools
                                          // contribution as well as the
                                          // flux contributions.
         for (unsigned int iface=0;iface<GeometryInfo<dim>::faces_per_cell;++iface)
-          {
-            bool level_boundary = cell->at_boundary(iface);
-            typename MGDoFHandler<dim,spacedim>::cell_iterator neighbor;
-            if (!level_boundary)
-              {
-                neighbor = cell->neighbor(iface);
-                if (static_cast<unsigned int>(neighbor->level()) != level)
-                  level_boundary = true;
-              }
-
-            if (level_boundary)
-              {
-                for (unsigned int i=0;i<fe.dofs_per_cell;++i)
-                  row_lengths[cell_indices[i]] += fe.dofs_per_face;
-                continue;
-              }
-
-            const FiniteElement<dim>& nfe = neighbor->get_fe();
-            typename MGDoFHandler<dim,spacedim>::face_iterator face = cell->face(iface);
+             {
+               bool level_boundary = cell->at_boundary(iface);
+               typename MGDoFHandler<dim,spacedim>::cell_iterator neighbor;
+               if (!level_boundary)
+                 {
+                   neighbor = cell->neighbor(iface);
+                   if (static_cast<unsigned int>(neighbor->level()) != level)
+                         level_boundary = true;
+                 }
+
+               if (level_boundary)
+                 {
+                   for (unsigned int i=0;i<fe.dofs_per_cell;++i)
+                         row_lengths[cell_indices[i]] += fe.dofs_per_face;
+                   continue;
+                 }
+
+               const FiniteElement<dim>& nfe = neighbor->get_fe();
+               typename MGDoFHandler<dim,spacedim>::face_iterator face = cell->face(iface);
 
                                              // Flux couplings are
                                              // computed from both sides
@@ -473,23 +474,23 @@ namespace MGTools
                                              // will be handled below,
                                              // therefore, we subtract them
                                              // here.
-            for (unsigned int base=0;base<nfe.n_base_elements();++base)
-              for (unsigned int mult=0;mult<nfe.element_multiplicity(base);++mult)
-                for (unsigned int i=0;i<fe.dofs_per_cell;++i)
-                  if (couple_face[fe_index](fe.system_to_block_index(i).first,
-                                            nfe.first_block_of_base(base) + mult) != DoFTools::none)
-                    {
-                      unsigned int increment = nfe.base_element(base).dofs_per_cell
-                                               - nfe.base_element(base).dofs_per_face;
-                      row_lengths[cell_indices[i]] += increment;
-                    }
+               for (unsigned int base=0;base<nfe.n_base_elements();++base)
+                 for (unsigned int mult=0;mult<nfe.element_multiplicity(base);++mult)
+                   for (unsigned int i=0;i<fe.dofs_per_cell;++i)
+                         if (couple_face[fe_index](fe.system_to_block_index(i).first,
+                                                               nfe.first_block_of_base(base) + mult) != DoFTools::none)
+                           {
+                             unsigned int increment = nfe.base_element(base).dofs_per_cell
+                                                                  - nfe.base_element(base).dofs_per_face;
+                             row_lengths[cell_indices[i]] += increment;
+                           }
 
                                              // Do this only once per
                                              // face and not on the
                                              // hanging faces.
-            if (face->user_flag_set())
-              continue;
-            face->set_user_flag();
+               if (face->user_flag_set())
+                 continue;
+               face->set_user_flag();
                                              // At this point, we assume
                                              // that each cell added its
                                              // dofs minus the face to
@@ -510,54 +511,54 @@ namespace MGTools
                                              // This will not work with
                                              // different couplings on
                                              // different cells.
-            neighbor_indices.resize(nfe.dofs_per_cell);
-            neighbor->get_mg_dof_indices(neighbor_indices);
-            for (unsigned int base=0;base<nfe.n_base_elements();++base)
-              for (unsigned int mult=0;mult<nfe.element_multiplicity(base);++mult)
-                for (unsigned int i=0;i<fe.dofs_per_cell;++i)
-                  if (couple_cell[fe_index](fe.system_to_component_index(i).first,
-                                            nfe.first_block_of_base(base) + mult) != DoFTools::none)
-                    row_lengths[cell_indices[i]]
-                      += nfe.base_element(base).dofs_per_face;
-            for (unsigned int base=0;base<fe.n_base_elements();++base)
-              for (unsigned int mult=0;mult<fe.element_multiplicity(base);++mult)
-                for (unsigned int i=0;i<nfe.dofs_per_cell;++i)
-                  if (couple_cell[fe_index](nfe.system_to_component_index(i).first,
-                                            fe.first_block_of_base(base) + mult) != DoFTools::none)
-                    row_lengths[neighbor_indices[i]]
-                      += fe.base_element(base).dofs_per_face;
-          }
+               neighbor_indices.resize(nfe.dofs_per_cell);
+               neighbor->get_mg_dof_indices(neighbor_indices);
+               for (unsigned int base=0;base<nfe.n_base_elements();++base)
+                 for (unsigned int mult=0;mult<nfe.element_multiplicity(base);++mult)
+                   for (unsigned int i=0;i<fe.dofs_per_cell;++i)
+                         if (couple_cell[fe_index](fe.system_to_component_index(i).first,
+                                                               nfe.first_block_of_base(base) + mult) != DoFTools::none)
+                           row_lengths[cell_indices[i]]
+                             += nfe.base_element(base).dofs_per_face;
+               for (unsigned int base=0;base<fe.n_base_elements();++base)
+                 for (unsigned int mult=0;mult<fe.element_multiplicity(base);++mult)
+                   for (unsigned int i=0;i<nfe.dofs_per_cell;++i)
+                         if (couple_cell[fe_index](nfe.system_to_component_index(i).first,
+                                                               fe.first_block_of_base(base) + mult) != DoFTools::none)
+                           row_lengths[neighbor_indices[i]]
+                             += fe.base_element(base).dofs_per_face;
+             }
       }
     user_flags_triangulation.load_user_flags(old_flags);
   }
 
 
 
-  template <int dim, class SparsityPattern, int spacedim>
+  template <class DH, class SparsityPattern>
   void make_sparsity_pattern (
-    const MGDoFHandler<dim,spacedim> &dof,
+    const DH &dof,
     SparsityPattern         &sparsity,
     const unsigned int       level)
   {
     const unsigned int n_dofs = dof.n_dofs(level);
 
     Assert (sparsity.n_rows() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
     Assert (sparsity.n_cols() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
 
     const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell;
     std::vector<unsigned int> dofs_on_this_cell(dofs_per_cell);
-    typename MGDoFHandler<dim,spacedim>::cell_iterator cell = dof.begin(level),
-                                                       endc = dof.end(level);
+    typename DH::cell_iterator cell = dof.begin(level),
+                                                  endc = dof.end(level);
     for (; cell!=endc; ++cell)
       {
         cell->get_mg_dof_indices (dofs_on_this_cell);
                                          // make sparsity pattern for this cell
         for (unsigned int i=0; i<dofs_per_cell; ++i)
-          for (unsigned int j=0; j<dofs_per_cell; ++j)
-            sparsity.add (dofs_on_this_cell[i],
-                          dofs_on_this_cell[j]);
+             for (unsigned int j=0; j<dofs_per_cell; ++j)
+               sparsity.add (dofs_on_this_cell[i],
+                                     dofs_on_this_cell[j]);
       }
   }
 
@@ -573,48 +574,48 @@ namespace MGTools
     const unsigned int n_dofs = dof.n_dofs(level);
 
     Assert (sparsity.n_rows() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
     Assert (sparsity.n_cols() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
 
     const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell;
     std::vector<unsigned int> dofs_on_this_cell(dofs_per_cell);
     std::vector<unsigned int> dofs_on_other_cell(dofs_per_cell);
     typename MGDoFHandler<dim,spacedim>::cell_iterator cell = dof.begin(level),
-                                                       endc = dof.end(level);
+                                                                          endc = dof.end(level);
     for (; cell!=endc; ++cell)
       {
         cell->get_mg_dof_indices (dofs_on_this_cell);
                                          // make sparsity pattern for this cell
         for (unsigned int i=0; i<dofs_per_cell; ++i)
-          for (unsigned int j=0; j<dofs_per_cell; ++j)
-            sparsity.add (dofs_on_this_cell[i],
-                          dofs_on_this_cell[j]);
+             for (unsigned int j=0; j<dofs_per_cell; ++j)
+               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)
-          {
-            if ( (! cell->at_boundary(face)) &&
-                 (static_cast<unsigned int>(cell->neighbor_level(face)) == level) )
-              {
-                typename MGDoFHandler<dim,spacedim>::cell_iterator
-                  neighbor = cell->neighbor(face);
-                neighbor->get_mg_dof_indices (dofs_on_other_cell);
+                face < GeometryInfo<dim>::faces_per_cell;
+                ++face)
+             {
+               if ( (! cell->at_boundary(face)) &&
+                    (static_cast<unsigned int>(cell->neighbor_level(face)) == level) )
+                 {
+                   typename MGDoFHandler<dim,spacedim>::cell_iterator
+                         neighbor = cell->neighbor(face);
+                   neighbor->get_mg_dof_indices (dofs_on_other_cell);
                                                  // only add one direction
                                                  // The other is taken care of
                                                  // by neighbor.
-                for (unsigned int i=0; i<dofs_per_cell; ++i)
-                  {
-                    for (unsigned int j=0; j<dofs_per_cell; ++j)
-                      {
-                        sparsity.add (dofs_on_this_cell[i],
-                                      dofs_on_other_cell[j]);
-                      }
-                  }
-              }
-          }
+                   for (unsigned int i=0; i<dofs_per_cell; ++i)
+                         {
+                           for (unsigned int j=0; j<dofs_per_cell; ++j)
+                             {
+                               sparsity.add (dofs_on_this_cell[i],
+                                                     dofs_on_other_cell[j]);
+                             }
+                         }
+                 }
+             }
       }
   }
 
@@ -628,7 +629,7 @@ namespace MGTools
     const unsigned int level)
   {
     Assert ((level>=1) && (level<dof.get_tria().n_levels()),
-            ExcIndexRange(level, 1, dof.get_tria().n_levels()));
+               ExcIndexRange(level, 1, dof.get_tria().n_levels()));
 
     const unsigned int fine_dofs = dof.n_dofs(level);
     const unsigned int coarse_dofs = dof.n_dofs(level-1);
@@ -636,44 +637,44 @@ namespace MGTools
                                      // Matrix maps from fine level to coarse level
 
     Assert (sparsity.n_rows() == coarse_dofs,
-            ExcDimensionMismatch (sparsity.n_rows(), coarse_dofs));
+               ExcDimensionMismatch (sparsity.n_rows(), coarse_dofs));
     Assert (sparsity.n_cols() == fine_dofs,
-            ExcDimensionMismatch (sparsity.n_cols(), fine_dofs));
+               ExcDimensionMismatch (sparsity.n_cols(), fine_dofs));
 
     const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell;
     std::vector<unsigned int> dofs_on_this_cell(dofs_per_cell);
     std::vector<unsigned int> dofs_on_other_cell(dofs_per_cell);
     typename MGDoFHandler<dim,spacedim>::cell_iterator cell = dof.begin(level),
-                                                       endc = dof.end(level);
+                                                                          endc = dof.end(level);
     for (; cell!=endc; ++cell)
       {
         cell->get_mg_dof_indices (dofs_on_this_cell);
                                          // Loop over all interior neighbors
         for (unsigned int face = 0;
-             face < GeometryInfo<dim>::faces_per_cell;
-             ++face)
-          {
+                face < GeometryInfo<dim>::faces_per_cell;
+                ++face)
+             {
                                              // Neighbor is coarser
 
-            if ( (! cell->at_boundary(face)) &&
-                 (static_cast<unsigned int>(cell->neighbor_level(face)) != level) )
-              {
-                typename MGDoFHandler<dim,spacedim>::cell_iterator
-                  neighbor = cell->neighbor(face);
-                neighbor->get_mg_dof_indices (dofs_on_other_cell);
-
-                for (unsigned int i=0; i<dofs_per_cell; ++i)
-                  {
-                    for (unsigned int j=0; j<dofs_per_cell; ++j)
-                      {
-                        sparsity.add (dofs_on_other_cell[i],
-                                      dofs_on_this_cell[j]);
-                        sparsity.add (dofs_on_other_cell[j],
-                                      dofs_on_this_cell[i]);
-                      }
-                  }
-              }
-          }
+               if ( (! cell->at_boundary(face)) &&
+                    (static_cast<unsigned int>(cell->neighbor_level(face)) != level) )
+                 {
+                   typename MGDoFHandler<dim,spacedim>::cell_iterator
+                         neighbor = cell->neighbor(face);
+                   neighbor->get_mg_dof_indices (dofs_on_other_cell);
+
+                   for (unsigned int i=0; i<dofs_per_cell; ++i)
+                         {
+                           for (unsigned int j=0; j<dofs_per_cell; ++j)
+                             {
+                               sparsity.add (dofs_on_other_cell[i],
+                                                     dofs_on_this_cell[j]);
+                               sparsity.add (dofs_on_other_cell[j],
+                                                     dofs_on_this_cell[i]);
+                             }
+                         }
+                 }
+             }
       }
   }
 
@@ -693,17 +694,17 @@ namespace MGTools
     const unsigned int n_comp = fe.n_components();
 
     Assert (sparsity.n_rows() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
     Assert (sparsity.n_cols() == n_dofs,
-            ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
+               ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
     Assert (int_mask.n_rows() == n_comp,
-            ExcDimensionMismatch (int_mask.n_rows(), n_comp));
+               ExcDimensionMismatch (int_mask.n_rows(), n_comp));
     Assert (int_mask.n_cols() == n_comp,
-            ExcDimensionMismatch (int_mask.n_cols(), n_comp));
+               ExcDimensionMismatch (int_mask.n_cols(), n_comp));
     Assert (flux_mask.n_rows() == n_comp,
-            ExcDimensionMismatch (flux_mask.n_rows(), n_comp));
+               ExcDimensionMismatch (flux_mask.n_rows(), n_comp));
     Assert (flux_mask.n_cols() == n_comp,
-            ExcDimensionMismatch (flux_mask.n_cols(), n_comp));
+               ExcDimensionMismatch (flux_mask.n_cols(), n_comp));
 
     const unsigned int total_dofs = fe.dofs_per_cell;
     std::vector<unsigned int> dofs_on_this_cell(total_dofs);
@@ -711,7 +712,7 @@ namespace MGTools
     Table<2,bool> support_on_face(total_dofs, GeometryInfo<dim>::faces_per_cell);
 
     typename MGDoFHandler<dim,spacedim>::cell_iterator cell = dof.begin(level),
-                                                       endc = dof.end(level);
+                                                                          endc = dof.end(level);
 
     const Table<2,DoFTools::Coupling>
       int_dof_mask  = DoFTools::dof_couplings_from_component_couplings(fe, int_mask),
@@ -738,116 +739,116 @@ namespace MGTools
         cell->get_mg_dof_indices (dofs_on_this_cell);
                                          // make sparsity pattern for this cell
         for (unsigned int i=0; i<total_dofs; ++i)
-          for (unsigned int j=0; j<total_dofs; ++j)
-            if (int_dof_mask[i][j] != DoFTools::none)
-              sparsity.add (dofs_on_this_cell[i],
-                            dofs_on_this_cell[j]);
+             for (unsigned int j=0; j<total_dofs; ++j)
+               if (int_dof_mask[i][j] != DoFTools::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)
-          {
-            typename MGDoFHandler<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<total_dofs; ++i)
-                  {
-                    const bool i_non_zero_i = support_on_face (i, face);
-                    for (unsigned int j=0; j<total_dofs; ++j)
-                      {
-                        const bool j_non_zero_i = support_on_face (j, face);
-
-                        if (flux_dof_mask(i,j) == DoFTools::always)
+                face < GeometryInfo<dim>::faces_per_cell;
+                ++face)
+             {
+               typename MGDoFHandler<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<total_dofs; ++i)
+                         {
+                           const bool i_non_zero_i = support_on_face (i, face);
+                           for (unsigned int j=0; j<total_dofs; ++j)
+                             {
+                               const bool j_non_zero_i = support_on_face (j, face);
+
+                               if (flux_dof_mask(i,j) == DoFTools::always)
                           sparsity.add (dofs_on_this_cell[i],
                                         dofs_on_this_cell[j]);
-                        if (flux_dof_mask(i,j) == DoFTools::nonzero
-                            && i_non_zero_i && j_non_zero_i)
-                          sparsity.add (dofs_on_this_cell[i],
-                                        dofs_on_this_cell[j]);
-                      }
-                  }
-              }
-            else
-              {
-                typename MGDoFHandler<dim,spacedim>::cell_iterator
-                  neighbor = cell->neighbor(face);
-
-                if (neighbor->level() < cell->level())
-                  continue;
-
-                unsigned int neighbor_face = cell->neighbor_of_neighbor(face);
-
-                neighbor->get_mg_dof_indices (dofs_on_other_cell);
-                for (unsigned int i=0; i<total_dofs; ++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<total_dofs; ++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) == DoFTools::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) == DoFTools::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) == DoFTools::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) == DoFTools::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 (flux_dof_mask(i,j) == DoFTools::nonzero
+                                       && i_non_zero_i && j_non_zero_i)
+                                     sparsity.add (dofs_on_this_cell[i],
+                                                       dofs_on_this_cell[j]);
+                             }
+                         }
+                 }
+               else
+                 {
+                   typename MGDoFHandler<dim,spacedim>::cell_iterator
+                         neighbor = cell->neighbor(face);
+
+                   if (neighbor->level() < cell->level())
+                         continue;
+
+                   unsigned int neighbor_face = cell->neighbor_of_neighbor(face);
+
+                   neighbor->get_mg_dof_indices (dofs_on_other_cell);
+                   for (unsigned int i=0; i<total_dofs; ++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<total_dofs; ++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) == DoFTools::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) == DoFTools::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) == DoFTools::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) == DoFTools::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 ();
+                 }
+             }
       }
 
                                      // finally restore the user flags
@@ -866,9 +867,9 @@ namespace MGTools
   {
     const FiniteElement<dim>& fe = dof.get_fe();
     const unsigned int n_comp = fe.n_components();
-
     Assert ((level>=1) && (level<dof.get_tria().n_levels()),
-            ExcIndexRange(level, 1, dof.get_tria().n_levels()));
+               ExcIndexRange(level, 1, dof.get_tria().n_levels()));
 
     const unsigned int fine_dofs = dof.n_dofs(level);
     const unsigned int coarse_dofs = dof.n_dofs(level-1);
@@ -876,13 +877,13 @@ namespace MGTools
                                      // Matrix maps from fine level to coarse level
 
     Assert (sparsity.n_rows() == coarse_dofs,
-            ExcDimensionMismatch (sparsity.n_rows(), coarse_dofs));
+               ExcDimensionMismatch (sparsity.n_rows(), coarse_dofs));
     Assert (sparsity.n_cols() == fine_dofs,
-            ExcDimensionMismatch (sparsity.n_cols(), fine_dofs));
+               ExcDimensionMismatch (sparsity.n_cols(), fine_dofs));
     Assert (flux_mask.n_rows() == n_comp,
-            ExcDimensionMismatch (flux_mask.n_rows(), n_comp));
+               ExcDimensionMismatch (flux_mask.n_rows(), n_comp));
     Assert (flux_mask.n_cols() == n_comp,
-            ExcDimensionMismatch (flux_mask.n_cols(), n_comp));
+               ExcDimensionMismatch (flux_mask.n_cols(), n_comp));
 
     const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell;
     std::vector<unsigned int> dofs_on_this_cell(dofs_per_cell);
@@ -890,7 +891,7 @@ namespace MGTools
     Table<2,bool> support_on_face(dofs_per_cell, GeometryInfo<dim>::faces_per_cell);
 
     typename MGDoFHandler<dim,spacedim>::cell_iterator cell = dof.begin(level),
-                                                       endc = dof.end(level);
+                                                                              endc = dof.end(level);
 
     const Table<2,DoFTools::Coupling> flux_dof_mask
       = DoFTools::dof_couplings_from_component_couplings(fe, flux_mask);
@@ -898,39 +899,39 @@ namespace MGTools
     for (unsigned int i=0; i<dofs_per_cell; ++i)
       for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell;++f)
         support_on_face(i,f) = fe.has_support_on_face(i,f);
-
     for (; cell!=endc; ++cell)
       {
         cell->get_mg_dof_indices (dofs_on_this_cell);
                                          // Loop over all interior neighbors
         for (unsigned int face = 0;
-             face < GeometryInfo<dim>::faces_per_cell;
-             ++face)
-          {
+                face < GeometryInfo<dim>::faces_per_cell;
+                ++face)
+             {
                                              // Neighbor is coarser
 
-            if ( (! cell->at_boundary(face)) &&
-                 (static_cast<unsigned int>(cell->neighbor_level(face)) != level) )
-              {
-                typename MGDoFHandler<dim,spacedim>::cell_iterator
-                  neighbor = cell->neighbor(face);
-                neighbor->get_mg_dof_indices (dofs_on_other_cell);
-
-                for (unsigned int i=0; i<dofs_per_cell; ++i)
-                  {
-                    for (unsigned int j=0; j<dofs_per_cell; ++j)
-                      {
-                        if (flux_dof_mask(i,j) != DoFTools::none)
-                          {
-                            sparsity.add (dofs_on_other_cell[i],
-                                          dofs_on_this_cell[j]);
-                            sparsity.add (dofs_on_other_cell[j],
-                                          dofs_on_this_cell[i]);
-                          }
-                      }
-                  }
-              }
-          }
+               if ( (! cell->at_boundary(face)) &&
+                    (static_cast<unsigned int>(cell->neighbor_level(face)) != level) )
+                 {
+                   typename MGDoFHandler<dim,spacedim>::cell_iterator
+                         neighbor = cell->neighbor(face);
+                   neighbor->get_mg_dof_indices (dofs_on_other_cell);
+
+                   for (unsigned int i=0; i<dofs_per_cell; ++i)
+                         {
+                           for (unsigned int j=0; j<dofs_per_cell; ++j)
+                             {
+                               if (flux_dof_mask(i,j) != DoFTools::none)
+                                     {
+                                       sparsity.add (dofs_on_other_cell[i],
+                                                             dofs_on_this_cell[j]);
+                                       sparsity.add (dofs_on_other_cell[j],
+                                                             dofs_on_this_cell[i]);
+                                     }
+                             }
+                         }
+                 }
+             }
       }
   }
 
@@ -938,28 +939,27 @@ namespace MGTools
 
   template <int dim, int spacedim>
   void
-
   count_dofs_per_component (const MGDoFHandler<dim,spacedim> &dof_handler,
-                            std::vector<std::vector<unsigned int> > &result,
-                            bool                              only_once,
-                            std::vector<unsigned int>         target_component)
+                                       std::vector<std::vector<unsigned int> > &result,
+                                       bool                              only_once,
+                                       std::vector<unsigned int>         target_component)
   {
     const FiniteElement<dim>& fe = dof_handler.get_fe();
     const unsigned int n_components = fe.n_components();
     const unsigned int nlevels = dof_handler.get_tria().n_levels();
 
     Assert (result.size() == nlevels,
-            ExcDimensionMismatch(result.size(), nlevels));
+               ExcDimensionMismatch(result.size(), nlevels));
 
     if (target_component.size() == 0)
       {
         target_component.resize(n_components);
         for (unsigned int i=0;i<n_components;++i)
-          target_component[i] = i;
+             target_component[i] = i;
       }
 
     Assert(target_component.size() == n_components,
-           ExcDimensionMismatch(target_component.size(), n_components));
+              ExcDimensionMismatch(target_component.size(), n_components));
 
     for (unsigned int l=0;l<nlevels;++l)
       {
@@ -971,66 +971,66 @@ namespace MGTools
                                          // since it does not require any
                                          // computations
         if (n_components == 1)
-          {
-            result[l][0] = dof_handler.n_dofs(l);
-          } else {
+             {
+               result[l][0] = dof_handler.n_dofs(l);
+             } else {
                                            // 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<dim>;
-              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<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();
 
                                            // 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());
+           }
       }
   }
 
@@ -1038,25 +1038,24 @@ namespace MGTools
 
   template <int dim, int spacedim>
   void
-
   count_dofs_per_component (const MGDoFHandler<dim,spacedim>        &dof_handler,
-                            std::vector<std::vector<unsigned int> > &result,
-                            std::vector<unsigned int>            target_component)
+                                       std::vector<std::vector<unsigned int> > &result,
+                                       std::vector<unsigned int>            target_component)
   {
     count_dofs_per_component (dof_handler, result,
-                              false, target_component);
+                                         false, target_component);
   }
 
 
 
-  template <int dim, int spacedim>
+  template <class DH>
   void
   count_dofs_per_block (
-    const MGDoFHandler<dim,spacedim>&     dof_handler,
+    const DH&     dof_handler,
     std::vector<std::vector<unsigned int> >& dofs_per_block,
     std::vector<unsigned int>  target_block)
   {
-    const FiniteElement<dim,spacedim>& fe = dof_handler.get_fe();
+    const FiniteElement<DH::dimension,DH::space_dimension>& fe = dof_handler.get_fe();
     const unsigned int n_blocks = fe.n_blocks();
     const unsigned int n_levels = dof_handler.get_tria().n_levels();
 
@@ -1071,14 +1070,14 @@ namespace MGTools
       {
         target_block.resize(n_blocks);
         for (unsigned int i=0;i<n_blocks;++i)
-          target_block[i] = i;
+             target_block[i] = i;
       }
     Assert(target_block.size()==n_blocks,
-           ExcDimensionMismatch(target_block.size(),n_blocks));
+              ExcDimensionMismatch(target_block.size(),n_blocks));
 
     const unsigned int max_block
       = *std::max_element (target_block.begin(),
-                           target_block.end());
+                                      target_block.end());
     const unsigned int n_target_blocks = max_block + 1;
 
     for (unsigned int l=0;l<n_levels;++l)
@@ -1091,7 +1090,7 @@ namespace MGTools
     if (n_blocks == 1)
       {
         for (unsigned int l=0;l<n_levels;++l)
-          dofs_per_block[l][0] = dof_handler.n_dofs(l);
+             dofs_per_block[l][0] = dof_handler.n_dofs(l);
         return;
       }
                                      // otherwise determine the number
@@ -1100,36 +1099,35 @@ namespace MGTools
     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));
+             block_select (n_blocks, std::vector<bool>(n_blocks, false));
         Threads::TaskGroup<> tasks;
         for (unsigned int i=0; i<n_blocks; ++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<dim>;
-            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 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);
+             };
         tasks.join_all ();
 
                                          // next count what we got
         for (unsigned int block=0;block<fe.n_blocks();++block)
-          dofs_per_block[l][target_block[block]]
-            += std::count(dofs_in_block[block].begin(),
-                          dofs_in_block[block].end(),
-                          true);
+             dofs_per_block[l][target_block[block]]
+               += std::count(dofs_in_block[block].begin(),
+                                     dofs_in_block[block].end(),
+                                     true);
       }
   }
 
 
-
   template <>
   void
   make_boundary_list(
@@ -1143,6 +1141,19 @@ namespace MGTools
 
 
 
+  template <>
+  void
+  make_boundary_list(
+    const DoFHandler<1,1>&,
+    const FunctionMap<1>::type&,
+    std::vector<std::set<unsigned int> >&,
+    const std::vector<bool>&)
+  {
+    Assert(false, ExcNotImplemented());
+  }
+
+
+
   template <>
   void
   make_boundary_list(
@@ -1156,6 +1167,19 @@ namespace MGTools
 
 
 
+  template <>
+  void
+  make_boundary_list(
+    const DoFHandler<1,2>&,
+    const FunctionMap<1>::type&,
+    std::vector<std::set<unsigned int> >&,
+    const std::vector<bool>&)
+  {
+    Assert(false, ExcNotImplemented());
+  }
+
+
+
   template <int dim, int spacedim>
   void
   make_boundary_list(
@@ -1182,7 +1206,7 @@ namespace MGTools
     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);
+                  DoFHandler<dim,spacedim>::invalid_dof_index);
 
                                      // First, deal with the simpler
                                      // case when we have to identify
@@ -1190,49 +1214,49 @@ namespace MGTools
     if (component_mask.size() == 0)
       {
         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_t 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_t 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,
-                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
@@ -1244,32 +1268,32 @@ namespace MGTools
                                                // 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"));
-                }
-
-              typename MGDoFHandler<dim,spacedim>::face_iterator face = cell->face(face_no);
-              const types::boundary_id_t boundary_component = face->boundary_indicator();
-              if (function_map.find(boundary_component) != function_map.end())
+                 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"));
+                   }
+
+                 typename MGDoFHandler<dim,spacedim>::face_iterator face = cell->face(face_no);
+                 const types::boundary_id_t 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)
-                    {
+                         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
@@ -1281,13 +1305,13 @@ namespace MGTools
                                                        // *_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
-                            {
+                             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
@@ -1306,26 +1330,25 @@ namespace MGTools
                                                                // 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());
+                                         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
@@ -1350,22 +1373,22 @@ namespace MGTools
 // 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());
-                            }
-
-                          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]);
-                }
-            }
+                                         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());
+                                       }
+
+                                     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]);
+                   }
+               }
       }
   }
 
@@ -1373,15 +1396,229 @@ namespace MGTools
 
   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 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)
+               {
+                 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"));
+               }
+
+             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 = (std::find (fe.get_nonzero_components(cell_i).begin(),
+                                                     fe.get_nonzero_components(cell_i).end(),
+                                                     true)
+                                          -
+                                          fe.get_nonzero_components(cell_i).begin());
+                           }
+
+                         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 std::vector<bool>& 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());
@@ -1390,7 +1627,7 @@ namespace MGTools
       {
         boundary_indices[i] = IndexSet (dof.n_dofs(i));
         boundary_indices[i].add_indices (my_boundary_indices[i].begin(),
-                                         my_boundary_indices[i].end());
+                                                        my_boundary_indices[i].end());
       }
   }
 
@@ -1400,21 +1637,21 @@ namespace MGTools
   template <int dim, int spacedim>
   void
   extract_inner_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
-                                std::vector<std::vector<bool> >  &interface_dofs)
+                                           std::vector<std::vector<bool> >  &interface_dofs)
   {
     Assert (interface_dofs.size() == mg_dof_handler.get_tria().n_levels(),
-            ExcDimensionMismatch (interface_dofs.size(),
-                                  mg_dof_handler.get_tria().n_levels()));
+               ExcDimensionMismatch (interface_dofs.size(),
+                                                 mg_dof_handler.get_tria().n_levels()));
 
     for (unsigned int l=0; l<mg_dof_handler.get_tria().n_levels(); ++l)
       {
         Assert (interface_dofs[l].size() == mg_dof_handler.n_dofs(l),
-                ExcDimensionMismatch (interface_dofs[l].size(),
-                                      mg_dof_handler.n_dofs(l)));
+                   ExcDimensionMismatch (interface_dofs[l].size(),
+                                                     mg_dof_handler.n_dofs(l)));
 
         std::fill (interface_dofs[l].begin(),
-                   interface_dofs[l].end(),
-                   false);
+                          interface_dofs[l].end(),
+                          false);
       }
 
     const FiniteElement<dim,spacedim> &fe = mg_dof_handler.get_fe();
@@ -1426,133 +1663,133 @@ namespace MGTools
     std::vector<bool> cell_dofs(dofs_per_cell, false);
 
     typename MGDoFHandler<dim>::cell_iterator cell = mg_dof_handler.begin(),
-                                              endc = mg_dof_handler.end();
+                                                                 endc = mg_dof_handler.end();
 
     for (; cell!=endc; ++cell)
       {
         std::fill (cell_dofs.begin(), cell_dofs.end(), false);
 
         for (unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
-          {
-            const typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_nr);
-            if (!face->at_boundary())
-              {
+             {
+               const typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_nr);
+               if (!face->at_boundary())
+                 {
                                                  //interior face
-                const typename MGDoFHandler<dim>::cell_iterator
-                  neighbor = cell->neighbor(face_nr);
-
-                if (neighbor->level() < cell->level())
-                  {
-                    for (unsigned int j=0; j<dofs_per_face; ++j)
-                      cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
-
-                  }
-              }
-          }
-
+                   const typename MGDoFHandler<dim>::cell_iterator
+                         neighbor = cell->neighbor(face_nr);
+
+                   if (neighbor->level() < cell->level())
+                         {
+                           for (unsigned int j=0; j<dofs_per_face; ++j)
+                             cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
+
+                         }
+                 }
+             }
         const unsigned int level = cell->level();
         cell->get_mg_dof_indices (local_dof_indices);
 
         for(unsigned int i=0; i<dofs_per_cell; ++i)
-          if (cell_dofs[i])
-            interface_dofs[level][local_dof_indices[i]] = true;
+             if (cell_dofs[i])
+               interface_dofs[level][local_dof_indices[i]] = true;
       }
   }
 
 
-template <int dim, int spacedim>
-void
-extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
-                            std::vector<std::set<unsigned int> >  &non_interface_dofs)
-{
-  Assert (non_interface_dofs.size() == mg_dof_handler.get_tria().n_levels(),
-          ExcDimensionMismatch (non_interface_dofs.size(),
-                                mg_dof_handler.get_tria().n_levels()));
-
-  const FiniteElement<dim,spacedim> &fe = mg_dof_handler.get_fe();
+  template <int dim, int spacedim>
+  void
+  extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
+                             std::vector<std::set<unsigned int> >  &non_interface_dofs)
+  {
+    Assert (non_interface_dofs.size() == mg_dof_handler.get_tria().n_levels(),
+               ExcDimensionMismatch (non_interface_dofs.size(),
+                                                 mg_dof_handler.get_tria().n_levels()));
 
-  const unsigned int   dofs_per_cell   = fe.dofs_per_cell;
-  const unsigned int   dofs_per_face   = fe.dofs_per_face;
+    const FiniteElement<dim,spacedim> &fe = mg_dof_handler.get_fe();
 
-  std::vector<unsigned int> local_dof_indices (dofs_per_cell);
-  std::vector<bool> cell_dofs(dofs_per_cell, false);
-  std::vector<bool> cell_dofs_interface(dofs_per_cell, false);
+    const unsigned int   dofs_per_cell   = fe.dofs_per_cell;
+    const unsigned int   dofs_per_face   = fe.dofs_per_face;
 
-  typename MGDoFHandler<dim>::cell_iterator cell = mg_dof_handler.begin(),
-                                            endc = mg_dof_handler.end();
+    std::vector<unsigned int> local_dof_indices (dofs_per_cell);
+    std::vector<bool> cell_dofs(dofs_per_cell, false);
+    std::vector<bool> cell_dofs_interface(dofs_per_cell, false);
 
+    typename MGDoFHandler<dim>::cell_iterator cell = mg_dof_handler.begin(),
+                                                                 endc = mg_dof_handler.end();
 
-  for (; cell!=endc; ++cell)
-    {
-      std::fill (cell_dofs.begin(), cell_dofs.end(), false);
-      std::fill (cell_dofs_interface.begin(), cell_dofs_interface.end(), false);
 
-      for (unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
-        {
-          const typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_nr);
-          if (!face->at_boundary())
-            {
+    for (; cell!=endc; ++cell)
+      {
+        std::fill (cell_dofs.begin(), cell_dofs.end(), false);
+        std::fill (cell_dofs_interface.begin(), cell_dofs_interface.end(), false);
+        for (unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
+             {
+               const typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_nr);
+               if (!face->at_boundary())
+                 {
                                                //interior face
-              const typename MGDoFHandler<dim>::cell_iterator
-                neighbor = cell->neighbor(face_nr);
-
-              if ((neighbor->level() < cell->level()))
+                   const typename MGDoFHandler<dim>::cell_iterator
+                         neighbor = cell->neighbor(face_nr);
+
+                   if ((neighbor->level() < cell->level()))
+                         {
+                           for (unsigned int j=0; j<dofs_per_face; ++j)
+                             cell_dofs_interface[fe.face_to_cell_index(j,face_nr)] = true;
+                         }
+                else
                 {
                   for (unsigned int j=0; j<dofs_per_face; ++j)
-                    cell_dofs_interface[fe.face_to_cell_index(j,face_nr)] = true;
+                           cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
                 }
-              else
+                 }
+            else
               {
-                for (unsigned int j=0; j<dofs_per_face; ++j)
-                    cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
-              }
-            }
-          else
-          {
                                                //boundary face
                 for (unsigned int j=0; j<dofs_per_face; ++j)
-                    cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
-          }
-        }
+                         cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
+              }
+             }
 
-      const unsigned int level = cell->level();
-      cell->get_mg_dof_indices (local_dof_indices);
+        const unsigned int level = cell->level();
+        cell->get_mg_dof_indices (local_dof_indices);
 
-      for(unsigned int i=0; i<dofs_per_cell; ++i)
-          if (cell_dofs[i] && !cell_dofs_interface[i])
-            non_interface_dofs[level].insert(local_dof_indices[i]);
-    }
-}
+        for(unsigned int i=0; i<dofs_per_cell; ++i)
+             if (cell_dofs[i] && !cell_dofs_interface[i])
+               non_interface_dofs[level].insert(local_dof_indices[i]);
+      }
+  }
 
 
   template <int dim, int spacedim>
   void
   extract_inner_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
-                                std::vector<std::vector<bool> >  &interface_dofs,
-                                std::vector<std::vector<bool> >  &boundary_interface_dofs)
+                                               std::vector<std::vector<bool> >  &interface_dofs,
+                                               std::vector<std::vector<bool> >  &boundary_interface_dofs)
   {
     Assert (interface_dofs.size() == mg_dof_handler.get_tria().n_levels(),
-            ExcDimensionMismatch (interface_dofs.size(),
-                                  mg_dof_handler.get_tria().n_levels()));
+               ExcDimensionMismatch (interface_dofs.size(),
+                                                 mg_dof_handler.get_tria().n_levels()));
     Assert (boundary_interface_dofs.size() == mg_dof_handler.get_tria().n_levels(),
-            ExcDimensionMismatch (boundary_interface_dofs.size(),
-                                  mg_dof_handler.get_tria().n_levels()));
+               ExcDimensionMismatch (boundary_interface_dofs.size(),
+                                                 mg_dof_handler.get_tria().n_levels()));
 
     for (unsigned int l=0; l<mg_dof_handler.get_tria().n_levels(); ++l)
       {
         Assert (interface_dofs[l].size() == mg_dof_handler.n_dofs(l),
-                ExcDimensionMismatch (interface_dofs[l].size(),
-                                      mg_dof_handler.n_dofs(l)));
+                   ExcDimensionMismatch (interface_dofs[l].size(),
+                                                     mg_dof_handler.n_dofs(l)));
         Assert (boundary_interface_dofs[l].size() == mg_dof_handler.n_dofs(l),
-                ExcDimensionMismatch (boundary_interface_dofs[l].size(),
-                                      mg_dof_handler.n_dofs(l)));
+                   ExcDimensionMismatch (boundary_interface_dofs[l].size(),
+                                                     mg_dof_handler.n_dofs(l)));
 
         std::fill (interface_dofs[l].begin(),
-                   interface_dofs[l].end(),
-                   false);
+                          interface_dofs[l].end(),
+                          false);
         std::fill (boundary_interface_dofs[l].begin(),
-                   boundary_interface_dofs[l].end(),
-                   false);
+                          boundary_interface_dofs[l].end(),
+                          false);
       }
 
     const FiniteElement<dim,spacedim> &fe = mg_dof_handler.get_fe();
@@ -1567,7 +1804,7 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
     std::vector<bool> boundary_cell_dofs(dofs_per_cell, false);
 
     typename MGDoFHandler<dim>::cell_iterator cell = mg_dof_handler.begin(),
-                                              endc = mg_dof_handler.end();
+                                                                 endc = mg_dof_handler.end();
 
     for (; cell!=endc; ++cell)
       {
@@ -1577,45 +1814,141 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
         std::fill (boundary_cell_dofs.begin(), boundary_cell_dofs.end(), false);
 
         for (unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
-          {
-            const typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_nr);
-            if (!face->at_boundary())
-              {
+             {
+               const typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_nr);
+               if (!face->at_boundary())
+                 {
                                                  //interior face
-                const typename MGDoFHandler<dim>::cell_iterator
-                  neighbor = cell->neighbor(face_nr);
+                   const typename MGDoFHandler<dim>::cell_iterator
+                         neighbor = cell->neighbor(face_nr);
 
                                                  // Do refinement face
                                                  // from the coarse side
-                if (neighbor->level() < cell->level())
-                  {
-                    for (unsigned int j=0; j<dofs_per_face; ++j)
+                   if (neighbor->level() < cell->level())
+                         {
+                           for (unsigned int j=0; j<dofs_per_face; ++j)
                       cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
 
-                    has_coarser_neighbor = true;
-                  }
-              }
-          }
+                           has_coarser_neighbor = true;
+                         }
+                 }
+             }
+
+        if (has_coarser_neighbor == true)
+             for (unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
+               if(cell->at_boundary(face_nr))
+                 for(unsigned int j=0; j<dofs_per_face; ++j)
+//               if (cell_dofs[fe.face_to_cell_index(j,face_nr)] == true) //is this necessary?
+                       boundary_cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
+
+
+        const unsigned int level = cell->level();
+        cell->get_mg_dof_indices (local_dof_indices);
+
+        for(unsigned int i=0; i<dofs_per_cell; ++i)
+             {
+               if (cell_dofs[i])
+                 interface_dofs[level][local_dof_indices[i]] = true;
+
+               if (boundary_cell_dofs[i])
+                 boundary_interface_dofs[level][local_dof_indices[i]] = true;
+             }
+      }
+  }
+
+
+
+  template <int dim, int spacedim>
+  void
+  extract_inner_interface_dofs (const DoFHandler<dim,spacedim> &dof_handler,
+                               std::vector<std::vector<bool> >  &interface_dofs,
+                               std::vector<std::vector<bool> >  &boundary_interface_dofs)
+  {
+    Assert (interface_dofs.size() == dof_handler.get_tria().n_levels(),
+           ExcDimensionMismatch (interface_dofs.size(),
+                                 dof_handler.get_tria().n_levels()));
+    Assert (boundary_interface_dofs.size() == dof_handler.get_tria().n_levels(),
+           ExcDimensionMismatch (boundary_interface_dofs.size(),
+                                 dof_handler.get_tria().n_levels()));
+
+    for (unsigned int l=0; l<dof_handler.get_tria().n_levels(); ++l)
+      {
+        Assert (interface_dofs[l].size() == dof_handler.n_dofs(l),
+               ExcDimensionMismatch (interface_dofs[l].size(),
+                                     dof_handler.n_dofs(l)));
+        Assert (boundary_interface_dofs[l].size() == dof_handler.n_dofs(l),
+               ExcDimensionMismatch (boundary_interface_dofs[l].size(),
+                                     dof_handler.n_dofs(l)));
+
+        std::fill (interface_dofs[l].begin(),
+                  interface_dofs[l].end(),
+                  false);
+        std::fill (boundary_interface_dofs[l].begin(),
+                  boundary_interface_dofs[l].end(),
+                  false);
+      }
+
+    const FiniteElement<dim,spacedim> &fe = dof_handler.get_fe();
+
+    const unsigned int   dofs_per_cell   = fe.dofs_per_cell;
+    const unsigned int   dofs_per_face   = fe.dofs_per_face;
+
+    std::vector<unsigned int> local_dof_indices (dofs_per_cell);
+    std::vector<unsigned int> face_dof_indices (dofs_per_face);
+
+    std::vector<bool> cell_dofs(dofs_per_cell, false);
+    std::vector<bool> boundary_cell_dofs(dofs_per_cell, false);
+
+    typename DoFHandler<dim>::cell_iterator cell = dof_handler.begin(),
+                                             endc = dof_handler.end();
+
+    for (; cell!=endc; ++cell)
+      {
+        bool has_coarser_neighbor = false;
+
+        std::fill (cell_dofs.begin(), cell_dofs.end(), false);
+        std::fill (boundary_cell_dofs.begin(), boundary_cell_dofs.end(), false);
+
+        for (unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
+         {
+           const typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_nr);
+           if (!face->at_boundary())
+             {
+                                              //interior face
+               const typename DoFHandler<dim>::cell_iterator
+                 neighbor = cell->neighbor(face_nr);
+
+                                              // Do refinement face
+                                              // from the coarse side
+               if (neighbor->level() < cell->level())
+                 {
+                   for (unsigned int j=0; j<dofs_per_face; ++j)
+                        cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
+
+                   has_coarser_neighbor = true;
+                 }
+             }
+         }
 
         if (has_coarser_neighbor == true)
-          for (unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
-            if(cell->at_boundary(face_nr))
-              for(unsigned int j=0; j<dofs_per_face; ++j)
-//            if (cell_dofs[fe.face_to_cell_index(j,face_nr)] == true) //is this necessary?
-                boundary_cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
+         for (unsigned int face_nr=0; face_nr<GeometryInfo<dim>::faces_per_cell; ++face_nr)
+           if(cell->at_boundary(face_nr))
+             for(unsigned int j=0; j<dofs_per_face; ++j)
+//           if (cell_dofs[fe.face_to_cell_index(j,face_nr)] == true) //is this necessary?
+                 boundary_cell_dofs[fe.face_to_cell_index(j,face_nr)] = true;
 
 
         const unsigned int level = cell->level();
         cell->get_mg_dof_indices (local_dof_indices);
 
         for(unsigned int i=0; i<dofs_per_cell; ++i)
-          {
-            if (cell_dofs[i])
-              interface_dofs[level][local_dof_indices[i]] = true;
+         {
+           if (cell_dofs[i])
+             interface_dofs[level][local_dof_indices[i]] = true;
 
-            if (boundary_cell_dofs[i])
-              boundary_interface_dofs[level][local_dof_indices[i]] = true;
-          }
+           if (boundary_cell_dofs[i])
+             boundary_interface_dofs[level][local_dof_indices[i]] = true;
+         }
       }
   }
 
@@ -1647,13 +1980,13 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
     for (unsigned int i=0; i<n_dofs; ++i)
       if (matrix.diag_element(i) != 0)
         {
-          first_nonzero_diagonal_entry = matrix.diag_element(i);
-          break;
+             first_nonzero_diagonal_entry = matrix.diag_element(i);
+             break;
         }
 
 
     std::set<unsigned int>::const_iterator dof  = boundary_dofs.begin(),
-                                           endd = boundary_dofs.end();
+                                                              endd = boundary_dofs.end();
     const SparsityPattern    &sparsity    = matrix.get_sparsity_pattern();
     const std::size_t  *sparsity_rowstart = sparsity.get_rowstart_indices();
     const unsigned int *sparsity_colnums  = sparsity.get_column_numbers();
@@ -1674,7 +2007,7 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                          //     sparsity_rowstart[dof.first])
         const unsigned int last = sparsity_rowstart[dof_number+1];
         for (unsigned int j=sparsity_rowstart[dof_number]+1; j<last; ++j)
-          matrix.global_entry(j) = 0.;
+             matrix.global_entry(j) = 0.;
 
 
                                          // set right hand side to
@@ -1691,8 +2024,8 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                          // store the new rhs entry to make
                                          // the gauss step more efficient
         if(!ignore_zeros)
-          matrix.set (dof_number, dof_number,
-                      first_nonzero_diagonal_entry);
+             matrix.set (dof_number, dof_number,
+                             first_nonzero_diagonal_entry);
                                          // if the user wants to have
                                          // the symmetry of the matrix
                                          // preserved, and if the
@@ -1701,7 +2034,7 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                          // elimination step with the
                                          // present row
         if (preserve_symmetry)
-          {
+             {
                                              // we have to loop over all
                                              // rows of the matrix which
                                              // have a nonzero entry in
@@ -1718,17 +2051,17 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                              // since that is the
                                              // diagonal element and
                                              // thus the present row
-            for (unsigned int j=sparsity_rowstart[dof_number]+1; j<last; ++j)
-              {
-                const unsigned int row = sparsity_colnums[j];
+               for (unsigned int j=sparsity_rowstart[dof_number]+1; j<last; ++j)
+                 {
+                   const unsigned int row = sparsity_colnums[j];
 
                                                  // find the position of
                                                  // element
                                                  // (row,dof_number)
-                const unsigned int *
-                  p = Utilities::lower_bound(&sparsity_colnums[sparsity_rowstart[row]+1],
-                                             &sparsity_colnums[sparsity_rowstart[row+1]],
-                                             dof_number);
+                   const unsigned int *
+                         p = Utilities::lower_bound(&sparsity_colnums[sparsity_rowstart[row]+1],
+                                                            &sparsity_colnums[sparsity_rowstart[row+1]],
+                                                            dof_number);
 
                                                  // check whether this line has
                                                  // an entry in the regarding column
@@ -1739,18 +2072,18 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                                  // to dof_number anyway...)
                                                  //
                                                  // there should be such an entry!
-                Assert ((*p == dof_number) &&
-                        (p != &sparsity_colnums[sparsity_rowstart[row+1]]),
-                        ExcInternalError());
+                   Assert ((*p == dof_number) &&
+                               (p != &sparsity_colnums[sparsity_rowstart[row+1]]),
+                               ExcInternalError());
 
-                const unsigned int global_entry
-                  = (p - &sparsity_colnums[sparsity_rowstart[0]]);
+                   const unsigned int global_entry
+                         = (p - &sparsity_colnums[sparsity_rowstart[0]]);
 
                                                  // correct right hand side
                                                  // set matrix entry to zero
-                matrix.global_entry(global_entry) = 0.;
-              }
-          }
+                   matrix.global_entry(global_entry) = 0.;
+                 }
+             }
       }
   }
 
@@ -1766,14 +2099,14 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
     const unsigned int blocks = matrix.n_block_rows();
 
     Assert (matrix.n_block_rows() == matrix.n_block_cols(),
-            ExcNotQuadratic());
+               ExcNotQuadratic());
     Assert (matrix.get_sparsity_pattern().get_row_indices() ==
-            matrix.get_sparsity_pattern().get_column_indices(),
-            ExcNotQuadratic());
+               matrix.get_sparsity_pattern().get_column_indices(),
+               ExcNotQuadratic());
 
     for (unsigned int i=0; i<blocks; ++i)
       Assert (matrix.block(i,i).get_sparsity_pattern().optimize_diagonal(),
-              SparsityPattern::ExcDiagonalNotOptimized());
+                 SparsityPattern::ExcDiagonalNotOptimized());
 
 
                                      // if no boundary values are to be applied
@@ -1794,17 +2127,17 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
     for (unsigned int diag_block=0; diag_block<blocks; ++diag_block)
       {
         for (unsigned int i=0; i<matrix.block(diag_block,diag_block).n(); ++i)
-          if (matrix.block(diag_block,diag_block).diag_element(i) != 0)
-            {
-              first_nonzero_diagonal_entry
-                = matrix.block(diag_block,diag_block).diag_element(i);
-              break;
-            }
+             if (matrix.block(diag_block,diag_block).diag_element(i) != 0)
+               {
+                 first_nonzero_diagonal_entry
+                   = matrix.block(diag_block,diag_block).diag_element(i);
+                 break;
+               }
                                          // check whether we have found
                                          // something in the present
                                          // block
         if (first_nonzero_diagonal_entry != 0)
-          break;
+             break;
       }
                                      // nothing found on all diagonal
                                      // blocks? if so, use 1.0 instead
@@ -1813,7 +2146,7 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
 
 
     std::set<unsigned int>::const_iterator dof  = boundary_dofs.begin(),
-                                           endd = boundary_dofs.end();
+                                                              endd = boundary_dofs.end();
     const BlockSparsityPattern &
       sparsity_pattern = matrix.get_sparsity_pattern();
 
@@ -1835,7 +2168,7 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                          // dof is located
         const unsigned int dof_number = *dof;
         const std::pair<unsigned int,unsigned int>
-          block_index = index_mapping.global_to_local (dof_number);
+             block_index = index_mapping.global_to_local (dof_number);
 
                                          // for each boundary dof:
 
@@ -1849,10 +2182,10 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                          //     sparsity_rowstart[dof.first])
                                          // of the diagonal block
         for (unsigned int block_col=0; block_col<blocks; ++block_col)
-          {
-            const SparsityPattern &
-              local_sparsity = sparsity_pattern.block(block_index.first,
-                                                      block_col);
+             {
+               const SparsityPattern &
+                 local_sparsity = sparsity_pattern.block(block_index.first,
+                                                                             block_col);
 
                                              // find first and last
                                              // entry in the present row
@@ -1865,19 +2198,19 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                              // matrix so the diagonal
                                              // element is the first of
                                              // this row.
-            const unsigned int
-              last  = local_sparsity.get_rowstart_indices()[block_index.second+1],
-              first = (block_col == block_index.first ?
-                       local_sparsity.get_rowstart_indices()[block_index.second]+1 :
-                       local_sparsity.get_rowstart_indices()[block_index.second]);
+               const unsigned int
+                 last  = local_sparsity.get_rowstart_indices()[block_index.second+1],
+                 first = (block_col == block_index.first ?
+                              local_sparsity.get_rowstart_indices()[block_index.second]+1 :
+                              local_sparsity.get_rowstart_indices()[block_index.second]);
 
-            for (unsigned int j=first; j<last; ++j)
-              matrix.block(block_index.first,block_col).global_entry(j) = 0.;
-          }
+               for (unsigned int j=first; j<last; ++j)
+                 matrix.block(block_index.first,block_col).global_entry(j) = 0.;
+             }
 
         matrix.block(block_index.first, block_index.first)
-          .diag_element(block_index.second)
-          = first_nonzero_diagonal_entry;
+             .diag_element(block_index.second)
+             = first_nonzero_diagonal_entry;
 
                                          // if the user wants to have
                                          // the symmetry of the matrix
@@ -1889,7 +2222,7 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                          // little more complicated for
                                          // block matrices.
         if (preserve_symmetry)
-          {
+             {
                                              // we have to loop over all
                                              // rows of the matrix which
                                              // have a nonzero entry in
@@ -1911,16 +2244,16 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                              // column @p{row} in block
                                              // (c,r), i.e. of the
                                              // transpose block
-            for (unsigned int block_row=0; block_row<blocks; ++block_row)
-              {
+               for (unsigned int block_row=0; block_row<blocks; ++block_row)
+                 {
                                                  // get pointers to the
                                                  // sparsity patterns of
                                                  // this block and of
                                                  // the transpose one
-                const SparsityPattern &this_sparsity
-                  = sparsity_pattern.block (block_row, block_index.first);
-                const SparsityPattern &transpose_sparsity
-                  = sparsity_pattern.block (block_index.first, block_row);
+                   const SparsityPattern &this_sparsity
+                         = sparsity_pattern.block (block_row, block_index.first);
+                   const SparsityPattern &transpose_sparsity
+                         = sparsity_pattern.block (block_index.first, block_row);
 
                                                  // traverse the row of
                                                  // the transpose block
@@ -1930,14 +2263,14 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                                  // don't use the
                                                  // diagonal element of
                                                  // the diagonal block
-                const unsigned int
-                  first = (block_index.first == block_row ?
-                           transpose_sparsity.get_rowstart_indices()[block_index.second]+1 :
-                           transpose_sparsity.get_rowstart_indices()[block_index.second]),
-                  last  = transpose_sparsity.get_rowstart_indices()[block_index.second+1];
-
-                for (unsigned int j=first; j<last; ++j)
-                  {
+                   const unsigned int
+                         first = (block_index.first == block_row ?
+                                      transpose_sparsity.get_rowstart_indices()[block_index.second]+1 :
+                                      transpose_sparsity.get_rowstart_indices()[block_index.second]),
+                         last  = transpose_sparsity.get_rowstart_indices()[block_index.second+1];
+
+                   for (unsigned int j=first; j<last; ++j)
+                         {
                                                      // get the number
                                                      // of the column in
                                                      // this row in
@@ -1948,7 +2281,7 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                                      // block which has
                                                      // an entry in the
                                                      // interesting row
-                    const unsigned int row = transpose_sparsity.get_column_numbers()[j];
+                           const unsigned int row = transpose_sparsity.get_column_numbers()[j];
 
                                                      // find the
                                                      // position of
@@ -1963,28 +2296,28 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                                      // cases with
                                                      // square
                                                      // sub-matrices
-                    const unsigned int *p = 0;
-                    if (this_sparsity.n_rows() == this_sparsity.n_cols())
-                      {
-                        if (this_sparsity.get_column_numbers()
-                            [this_sparsity.get_rowstart_indices()[row]]
-                            ==
-                            block_index.second)
-                          p = &this_sparsity.get_column_numbers()
-                              [this_sparsity.get_rowstart_indices()[row]];
-                        else
-                          p = Utilities::lower_bound(&this_sparsity.get_column_numbers()
-                                                     [this_sparsity.get_rowstart_indices()[row]+1],
-                                                     &this_sparsity.get_column_numbers()
-                                                     [this_sparsity.get_rowstart_indices()[row+1]],
-                                                     block_index.second);
-                      }
-                    else
-                      p = Utilities::lower_bound(&this_sparsity.get_column_numbers()
-                                                 [this_sparsity.get_rowstart_indices()[row]],
-                                                 &this_sparsity.get_column_numbers()
-                                                 [this_sparsity.get_rowstart_indices()[row+1]],
-                                                 block_index.second);
+                           const unsigned int *p = 0;
+                           if (this_sparsity.n_rows() == this_sparsity.n_cols())
+                             {
+                               if (this_sparsity.get_column_numbers()
+                                       [this_sparsity.get_rowstart_indices()[row]]
+                                       ==
+                                       block_index.second)
+                                     p = &this_sparsity.get_column_numbers()
+                                         [this_sparsity.get_rowstart_indices()[row]];
+                               else
+                                     p = Utilities::lower_bound(&this_sparsity.get_column_numbers()
+                                                                        [this_sparsity.get_rowstart_indices()[row]+1],
+                                                                        &this_sparsity.get_column_numbers()
+                                                                        [this_sparsity.get_rowstart_indices()[row+1]],
+                                                                        block_index.second);
+                             }
+                           else
+                             p = Utilities::lower_bound(&this_sparsity.get_column_numbers()
+                                                                    [this_sparsity.get_rowstart_indices()[row]],
+                                                                    &this_sparsity.get_column_numbers()
+                                                                    [this_sparsity.get_rowstart_indices()[row+1]],
+                                                                    block_index.second);
 
                                                      // check whether this line has
                                                      // an entry in the regarding column
@@ -2003,22 +2336,22 @@ extract_non_interface_dofs (const MGDoFHandler<dim,spacedim> &mg_dof_handler,
                                                      // if the sparsity
                                                      // pattern is not
                                                      // symmetric!
-                    Assert ((*p == block_index.second) &&
-                            (p != &this_sparsity.get_column_numbers()
-                             [this_sparsity.get_rowstart_indices()[row+1]]),
-                            ExcInternalError());
+                           Assert ((*p == block_index.second) &&
+                                       (p != &this_sparsity.get_column_numbers()
+                                             [this_sparsity.get_rowstart_indices()[row+1]]),
+                                       ExcInternalError());
 
-                    const unsigned int global_entry
-                      = (p
-                         -
-                         &this_sparsity.get_column_numbers()
-                         [this_sparsity.get_rowstart_indices()[0]]);
+                           const unsigned int global_entry
+                             = (p
+                                -
+                                &this_sparsity.get_column_numbers()
+                                [this_sparsity.get_rowstart_indices()[0]]);
 
                                                      // set matrix entry to zero
-                    matrix.block(block_row,block_index.first).global_entry(global_entry) = 0.;
-                  }
-              }
-          }
+                           matrix.block(block_row,block_index.first).global_entry(global_entry) = 0.;
+                         }
+                 }
+             }
       }
   }
 }
index 8f180f7ede399b988d67f6e1065a0299f4558573..601a010eb47613417c732f4c731a6acde5b8c7b9 100644 (file)
@@ -59,9 +59,9 @@ void MGTransferPrebuilt<VECTOR>::build_matrices (
   for (unsigned int i=0; i<n_levels-1; ++i)
     {
       prolongation_sparsities.push_back
-        (std_cxx1x::shared_ptr<SparsityPattern> (new SparsityPattern));
+           (std_cxx1x::shared_ptr<SparsityPattern> (new SparsityPattern));
       prolongation_matrices.push_back
-        (std_cxx1x::shared_ptr<SparseMatrix<double> > (new SparseMatrix<double>));
+           (std_cxx1x::shared_ptr<SparseMatrix<double> > (new SparseMatrix<double>));
     }
 
                                    // two fields which will store the
@@ -89,43 +89,43 @@ void MGTransferPrebuilt<VECTOR>::build_matrices (
                                        // since a useless diagonal
                                        // element will be stored
       CompressedSimpleSparsityPattern csp (sizes[level+1],
-                                           sizes[level]);
+                                                              sizes[level]);
       std::vector<unsigned int> entries (dofs_per_cell);
       for (typename MGDoFHandler<dim,spacedim>::cell_iterator cell=mg_dof.begin(level);
-           cell != mg_dof.end(level); ++cell)
-        if (cell->has_children())
-          {
-            cell->get_mg_dof_indices (dof_indices_parent);
-
-            Assert(cell->n_children()==GeometryInfo<dim>::max_children_per_cell,
-                   ExcNotImplemented());
-            for (unsigned int child=0; child<cell->n_children(); ++child)
-              {
+              cell != mg_dof.end(level); ++cell)
+           if (cell->has_children())
+             {
+               cell->get_mg_dof_indices (dof_indices_parent);
+
+               Assert(cell->n_children()==GeometryInfo<dim>::max_children_per_cell,
+                          ExcNotImplemented());
+               for (unsigned int child=0; child<cell->n_children(); ++child)
+                 {
                                                  // set an alias to the
                                                  // prolongation matrix for
                                                  // this child
-                const FullMatrix<double> &prolongation
-                  = mg_dof.get_fe().get_prolongation_matrix (child,
-                                                             cell->refinement_case());
+                       const FullMatrix<double> &prolongation
+                         = mg_dof.get_fe().get_prolongation_matrix (child,
+                                                                                        cell->refinement_case());
 
-                Assert (prolongation.n() != 0, ExcNoProlongation());
+                       Assert (prolongation.n() != 0, ExcNoProlongation());
 
-                cell->child(child)->get_mg_dof_indices (dof_indices_child);
+                       cell->child(child)->get_mg_dof_indices (dof_indices_child);
 
                                                  // now tag the entries in the
                                                  // matrix which will be used
                                                  // for this pair of parent/child
-                for (unsigned int i=0; i<dofs_per_cell; ++i)
-                  {
-                    entries.resize(0);
-                    for (unsigned int j=0; j<dofs_per_cell; ++j)
-                      if (prolongation(i,j) != 0)
-                        entries.push_back (dof_indices_parent[j]);
-                    csp.add_entries (dof_indices_child[i],
-                                     entries.begin(), entries.end());
-                  }
-              }
-          }
+                       for (unsigned int i=0; i<dofs_per_cell; ++i)
+                         {
+                           entries.resize(0);
+                           for (unsigned int j=0; j<dofs_per_cell; ++j)
+                             if (prolongation(i,j) != 0)
+                                   entries.push_back (dof_indices_parent[j]);
+                           csp.add_entries (dof_indices_child[i],
+                                                    entries.begin(), entries.end());
+                         }
+                 }
+             }
 
       prolongation_sparsities[level]->copy_from (csp);
       csp.reinit(0,0);
@@ -133,34 +133,34 @@ void MGTransferPrebuilt<VECTOR>::build_matrices (
 
                                        // now actually build the matrices
       for (typename MGDoFHandler<dim,spacedim>::cell_iterator cell=mg_dof.begin(level);
-           cell != mg_dof.end(level); ++cell)
-        if (cell->has_children())
-          {
-            cell->get_mg_dof_indices (dof_indices_parent);
-
-            Assert(cell->n_children()==GeometryInfo<dim>::max_children_per_cell,
-                   ExcNotImplemented());
-            for (unsigned int child=0; child<cell->n_children(); ++child)
-              {
+              cell != mg_dof.end(level); ++cell)
+           if (cell->has_children())
+             {
+               cell->get_mg_dof_indices (dof_indices_parent);
+
+               Assert(cell->n_children()==GeometryInfo<dim>::max_children_per_cell,
+                          ExcNotImplemented());
+               for (unsigned int child=0; child<cell->n_children(); ++child)
+                 {
                                                  // set an alias to the
                                                  // prolongation matrix for
                                                  // this child
-                const FullMatrix<double> &prolongation
-                  = mg_dof.get_fe().get_prolongation_matrix (child,
-                                                             cell->refinement_case());
+                       const FullMatrix<double> &prolongation
+                         = mg_dof.get_fe().get_prolongation_matrix (child,
+                                                                                        cell->refinement_case());
 
-                cell->child(child)->get_mg_dof_indices (dof_indices_child);
+                       cell->child(child)->get_mg_dof_indices (dof_indices_child);
 
                                                  // now set the entries in the
                                                  // matrix
-                for (unsigned int i=0; i<dofs_per_cell; ++i)
-                  prolongation_matrices[level]->set (dof_indices_child[i],
-                                                     dofs_per_cell,
-                                                     &dof_indices_parent[0],
-                                                     &prolongation(i,0),
-                                                     true);
-              }
-          }
+                       for (unsigned int i=0; i<dofs_per_cell; ++i)
+                         prolongation_matrices[level]->set (dof_indices_child[i],
+                                                                            dofs_per_cell,
+                                                                            &dof_indices_parent[0],
+                                                                            &prolongation(i,0),
+                                                                            true);
+                 }
+             }
     }
 
 
@@ -172,36 +172,36 @@ void MGTransferPrebuilt<VECTOR>::build_matrices (
     {
       std::vector<unsigned int> constrain_indices;
       for (int level=n_levels-2; level>=0; --level)
-        {
-          if (mg_constrained_dofs->get_boundary_indices()[level].size() == 0)
-            continue;
+           {
+             if (mg_constrained_dofs->get_boundary_indices()[level].size() == 0)
+               continue;
 
                                 // need to delete all the columns in the
                                 // matrix that are on the boundary. to achieve
                                 // this, create an array as long as there are
                                 // matrix columns, and find which columns we
                                 // need to filter away.
-          constrain_indices.resize (0);
-          constrain_indices.resize (prolongation_matrices[level]->n(), 0);
-          std::set<unsigned int>::const_iterator dof
+             constrain_indices.resize (0);
+             constrain_indices.resize (prolongation_matrices[level]->n(), 0);
+             std::set<unsigned int>::const_iterator dof
             = mg_constrained_dofs->get_boundary_indices()[level].begin(),
-            endd = mg_constrained_dofs->get_boundary_indices()[level].end();
-          for (; dof != endd; ++dof)
-            constrain_indices[*dof] = 1;
-
-          const unsigned int n_dofs = prolongation_matrices[level]->m();
-          for (unsigned int i=0; i<n_dofs; ++i)
-            {
-              SparseMatrix<double>::iterator
-                start_row = prolongation_matrices[level]->begin(i),
-                end_row   = prolongation_matrices[level]->end(i);
-              for(; start_row != end_row; ++start_row)
-                {
-                  if (constrain_indices[start_row->column()] == 1)
-                    start_row->value() = 0;
-                }
-            }
-        }
+               endd = mg_constrained_dofs->get_boundary_indices()[level].end();
+             for (; dof != endd; ++dof)
+               constrain_indices[*dof] = 1;
+
+             const unsigned int n_dofs = prolongation_matrices[level]->m();
+             for (unsigned int i=0; i<n_dofs; ++i)
+               {
+                 SparseMatrix<double>::iterator
+                       start_row = prolongation_matrices[level]->begin(i),
+                       end_row   = prolongation_matrices[level]->end(i);
+                 for(; start_row != end_row; ++start_row)
+                       {
+                         if (constrain_indices[start_row->column()] == 1)
+                           start_row->value() = 0;
+                       }
+               }
+           }
     }
 
                                 // to find the indices that describe the
@@ -223,9 +223,9 @@ void MGTransferPrebuilt<VECTOR>::build_matrices (
     {
       copy_indices[level].clear();
       typename MGDoFHandler<dim,spacedim>::active_cell_iterator
-        level_cell = mg_dof.begin_active(level);
+           level_cell = mg_dof.begin_active(level);
       const typename MGDoFHandler<dim,spacedim>::active_cell_iterator
-        level_end  = mg_dof.end_active(level);
+           level_end  = mg_dof.end_active(level);
 
       temp_copy_indices.resize (0);
       temp_copy_indices.resize (mg_dof.n_dofs(level), numbers::invalid_unsigned_int);
@@ -233,26 +233,26 @@ void MGTransferPrebuilt<VECTOR>::build_matrices (
                                        // Compute coarse level right hand side
                                        // by restricting from fine level.
       for (; level_cell!=level_end; ++level_cell)
-        {
-          DoFAccessor<dim, DoFHandler<dim,spacedim> >& global_cell = *level_cell;
+           {
+             DoFAccessor<dim, DoFHandler<dim,spacedim> >& global_cell = *level_cell;
                                            // get the dof numbers of
                                            // this cell for the global
                                            // and the level-wise
                                            // numbering
-          global_cell.get_dof_indices(global_dof_indices);
-          level_cell->get_mg_dof_indices (level_dof_indices);
+             global_cell.get_dof_indices(global_dof_indices);
+             level_cell->get_mg_dof_indices (level_dof_indices);
 
-          for (unsigned int i=0; i<dofs_per_cell; ++i)
-          {
-            if(mg_constrained_dofs != 0)
+             for (unsigned int i=0; i<dofs_per_cell; ++i)
             {
-              if(!mg_constrained_dofs->at_refinement_edge(level,level_dof_indices[i]))
-                temp_copy_indices[level_dof_indices[i]] = global_dof_indices[i];
+              if(mg_constrained_dofs != 0)
+                {
+                     if(!mg_constrained_dofs->at_refinement_edge(level,level_dof_indices[i]))
+                       temp_copy_indices[level_dof_indices[i]] = global_dof_indices[i];
+                }
+              else
+                   temp_copy_indices[level_dof_indices[i]] = global_dof_indices[i];
             }
-            else
-              temp_copy_indices[level_dof_indices[i]] = global_dof_indices[i];
-          }
-        }
+           }
 
                                 // now all the active dofs got a valid entry,
                                 // the other ones have an invalid entry. Count
@@ -261,15 +261,257 @@ void MGTransferPrebuilt<VECTOR>::build_matrices (
                                 // of global index and level index into
                                 // copy_indices.
       const unsigned int n_active_dofs =
-        std::count_if (temp_copy_indices.begin(), temp_copy_indices.end(),
-                       std::bind2nd(std::not_equal_to<unsigned int>(),
-                                    numbers::invalid_unsigned_int));
+           std::count_if (temp_copy_indices.begin(), temp_copy_indices.end(),
+                              std::bind2nd(std::not_equal_to<unsigned int>(),
+                                                   numbers::invalid_unsigned_int));
+      copy_indices[level].resize (n_active_dofs);
+      unsigned int counter = 0;
+      for (unsigned int i=0; i<temp_copy_indices.size(); ++i)
+           if (temp_copy_indices[i] != numbers::invalid_unsigned_int)
+             copy_indices[level][counter++] =
+               std::pair<unsigned int, unsigned int> (temp_copy_indices[i], i);
+      Assert (counter == n_active_dofs, ExcInternalError());
+    }
+}
+
+
+
+template <typename VECTOR>
+template <int dim, int spacedim>
+void MGTransferPrebuilt<VECTOR>::build_matrices (
+  const DoFHandler<dim,spacedim>  &dof_handler)
+{
+  const unsigned int n_levels      = dof_handler.get_tria().n_levels();
+  const unsigned int dofs_per_cell = dof_handler.get_fe().dofs_per_cell;
+
+  sizes.resize(n_levels);
+  for (unsigned int l=0;l<n_levels;++l)
+    sizes[l] = dof_handler.n_dofs(l);
+
+                                  // reset the size of the array of
+                                  // matrices. call resize(0) first,
+                                  // in order to delete all elements
+                                  // and clear their memory. then
+                                  // repopulate these arrays
+                                  //
+                                  // note that on resize(0), the
+                                  // shared_ptr class takes care of
+                                  // deleting the object it points to
+                                  // by itself
+  prolongation_matrices.resize (0);
+  prolongation_sparsities.resize (0);
+
+  for (unsigned int i=0; i<n_levels-1; ++i)
+    {
+      prolongation_sparsities.push_back
+       (std_cxx1x::shared_ptr<SparsityPattern> (new SparsityPattern));
+      prolongation_matrices.push_back
+       (std_cxx1x::shared_ptr<SparseMatrix<double> > (new SparseMatrix<double>));
+    }
+
+                                  // two fields which will store the
+                                  // indices of the multigrid dofs
+                                  // for a cell and one of its children
+  std::vector<unsigned int> dof_indices_parent (dofs_per_cell);
+  std::vector<unsigned int> dof_indices_child (dofs_per_cell);
+
+                                  // for each level: first build the sparsity
+                                  // pattern of the matrices and then build the
+                                  // matrices themselves. note that we only
+                                  // need to take care of cells on the coarser
+                                  // level which have children
+  for (unsigned int level=0; level<n_levels-1; ++level)
+    {
+
+                                      // reset the dimension of the structure.
+                                      // note that for the number of entries
+                                      // per row, the number of parent dofs
+                                      // coupling to a child dof is
+                                      // necessary. this, of course, is the
+                                      // number of degrees of freedom per
+                                      // cell
+                                      // increment dofs_per_cell
+                                      // since a useless diagonal
+                                      // element will be stored
+      prolongation_sparsities[level]->reinit (sizes[level+1],
+                                             sizes[level],
+                                             dofs_per_cell+1);
+
+      for (typename DoFHandler<dim,spacedim>::cell_iterator cell = dof_handler.begin(level);
+          cell != dof_handler.end(level); ++cell)
+       if (cell->has_children())
+         {
+           cell->get_mg_dof_indices (dof_indices_parent);
+
+           Assert(cell->n_children()==GeometryInfo<dim>::max_children_per_cell,
+                  ExcNotImplemented());
+           for (unsigned int child=0; child<cell->n_children(); ++child)
+             {
+                                                // set an alias to the
+                                                // prolongation matrix for
+                                                // this child
+               const FullMatrix<double> &prolongation
+                 = dof_handler.get_fe().get_prolongation_matrix (child,
+                                                            cell->refinement_case());
+
+               Assert (prolongation.n() != 0, ExcNoProlongation());
+
+               cell->child(child)->get_mg_dof_indices (dof_indices_child);
+
+                                                // now tag the entries in the
+                                                // matrix which will be used
+                                                // for this pair of parent/child
+               for (unsigned int i=0; i<dofs_per_cell; ++i)
+                 for (unsigned int j=0; j<dofs_per_cell; ++j)
+                   if (prolongation(i,j) != 0)
+                     prolongation_sparsities[level]->add (dof_indices_child[i],
+                                                          dof_indices_parent[j]);
+             }
+         }
+
+      prolongation_sparsities[level]->compress ();
+
+      prolongation_matrices[level]->reinit (*prolongation_sparsities[level]);
+
+                                      // now actually build the matrices
+      for (typename DoFHandler<dim,spacedim>::cell_iterator cell = dof_handler.begin(level);
+          cell != dof_handler.end(level); ++cell)
+       if (cell->has_children())
+         {
+           cell->get_mg_dof_indices (dof_indices_parent);
+
+           Assert(cell->n_children()==GeometryInfo<dim>::max_children_per_cell,
+                  ExcNotImplemented());
+           for (unsigned int child=0; child<cell->n_children(); ++child)
+             {
+                                                // set an alias to the
+                                                // prolongation matrix for
+                                                // this child
+               const FullMatrix<double> &prolongation
+                 = dof_handler.get_fe().get_prolongation_matrix (child,
+                                                            cell->refinement_case());
+
+               cell->child(child)->get_mg_dof_indices (dof_indices_child);
+
+                                                // now set the entries in the
+                                                // matrix
+               for (unsigned int i=0; i<dofs_per_cell; ++i)
+                 prolongation_matrices[level]->set (dof_indices_child[i],
+                                                    dofs_per_cell,
+                                                    &dof_indices_parent[0],
+                                                    &prolongation(i,0),
+                                                    true);
+             }
+         }
+    }
+
+
+                               // impose boundary conditions
+                               // but only in the column of
+                               // the prolongation matrix
+  if (mg_constrained_dofs != 0)
+  if (mg_constrained_dofs->set_boundary_values())
+    {
+      std::vector<unsigned int> constrain_indices;
+      for (int level=n_levels-2; level>=0; --level)
+       {
+         if (mg_constrained_dofs->get_boundary_indices()[level].size() == 0)
+           continue;
+
+                               // need to delete all the columns in the
+                               // matrix that are on the boundary. to achive
+                               // this, create an array as long as there are
+                               // matrix columns, and find which columns we
+                               // need to filter away.
+         constrain_indices.resize (0);
+         constrain_indices.resize (prolongation_matrices[level]->n(), 0);
+         std::set<unsigned int>::const_iterator dof
+            = mg_constrained_dofs->get_boundary_indices()[level].begin(),
+           endd = mg_constrained_dofs->get_boundary_indices()[level].end();
+         for (; dof != endd; ++dof)
+           constrain_indices[*dof] = 1;
+
+         const unsigned int n_dofs = prolongation_matrices[level]->m();
+         for (unsigned int i=0; i<n_dofs; ++i)
+           {
+             SparseMatrix<double>::iterator
+               start_row = prolongation_matrices[level]->begin(i),
+               end_row   = prolongation_matrices[level]->end(i);
+             for(; start_row != end_row; ++start_row)
+               {
+                 if (constrain_indices[start_row->column()] == 1)
+                   start_row->value() = 0;
+               }
+           }
+       }
+    }
+
+                               // to find the indices that describe the
+                               // relation between global dofs and local
+                               // numbering on the individual level, first
+                               // create a temp vector where the ith level
+                               // entry contains the respective global
+                               // entry. this gives a neat way to find those
+                               // indices. in a second step, actually build
+                               // the std::vector<std::pair<uint,uint> > that
+                               // only contains the active dofs on the
+                               // levels.
+
+  copy_indices.resize(n_levels);
+  std::vector<unsigned int> temp_copy_indices;
+  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
+  std::vector<unsigned int> level_dof_indices  (dofs_per_cell);
+  for (int level=dof_handler.get_tria().n_levels()-1; level>=0; --level)
+    {
+      copy_indices[level].clear();
+      typename DoFHandler<dim,spacedim>::active_cell_iterator
+       level_cell = dof_handler.begin_active(level);
+      const typename DoFHandler<dim,spacedim>::active_cell_iterator
+       level_end  = dof_handler.end_active(level);
+
+      temp_copy_indices.resize (0);
+      temp_copy_indices.resize (dof_handler.n_dofs(level), numbers::invalid_unsigned_int);
+
+                                      // Compute coarse level right hand side
+                                      // by restricting from fine level.
+      for (; level_cell!=level_end; ++level_cell)
+       {
+         DoFAccessor<dim, DoFHandler<dim,spacedim> >& global_cell = *level_cell;
+                                          // get the dof numbers of
+                                          // this cell for the global
+                                          // and the level-wise
+                                          // numbering
+         global_cell.get_dof_indices(global_dof_indices);
+         level_cell->get_mg_dof_indices (level_dof_indices);
+
+         for (unsigned int i=0; i<dofs_per_cell; ++i)
+          {
+            if(mg_constrained_dofs != 0)
+            {
+             if(!mg_constrained_dofs->at_refinement_edge(level,level_dof_indices[i]))
+               temp_copy_indices[level_dof_indices[i]] = global_dof_indices[i];
+            }
+            else
+             temp_copy_indices[level_dof_indices[i]] = global_dof_indices[i];
+          }
+       }
+
+                               // now all the active dofs got a valid entry,
+                               // the other ones have an invalid entry. Count
+                               // the invalid entries and then resize the
+                               // copy_indices object. Then, insert the pairs
+                               // of global index and level index into
+                               // copy_indices.
+      const unsigned int n_active_dofs =
+       std::count_if (temp_copy_indices.begin(), temp_copy_indices.end(),
+                      std::bind2nd(std::not_equal_to<unsigned int>(),
+                                   numbers::invalid_unsigned_int));
       copy_indices[level].resize (n_active_dofs);
       unsigned int counter = 0;
       for (unsigned int i=0; i<temp_copy_indices.size(); ++i)
-        if (temp_copy_indices[i] != numbers::invalid_unsigned_int)
-          copy_indices[level][counter++] =
-            std::pair<unsigned int, unsigned int> (temp_copy_indices[i], i);
+       if (temp_copy_indices[i] != numbers::invalid_unsigned_int)
+         copy_indices[level][counter++] =
+           std::pair<unsigned int, unsigned int> (temp_copy_indices[i], i);
       Assert (counter == n_active_dofs, ExcInternalError());
     }
 }
index f2bd460769f0d410b4d0cfd91887f8f7ada84e77..74736dc0f0b906612338de4f6fba8ed2038968ce 100644 (file)
@@ -16,6 +16,9 @@ for (deal_II_dimension : DIMENSIONS; V1 : DEAL_II_VEC_TEMPLATES; S1 : REAL_SCALA
     template
       void MGTransferPrebuilt<V1<S1> >::build_matrices<deal_II_dimension>(
        const MGDoFHandler<deal_II_dimension> &mg_dof);
+       template
+      void MGTransferPrebuilt<V1<S1> >::build_matrices<deal_II_dimension>(
+       const DoFHandler<deal_II_dimension> &mg_dof);
   }
 
 for (deal_II_dimension : DIMENSIONS; V1,V2 : DEAL_II_VEC_TEMPLATES; S1, S2 : REAL_SCALARS)
@@ -23,11 +26,20 @@ for (deal_II_dimension : DIMENSIONS; V1,V2 : DEAL_II_VEC_TEMPLATES; S1, S2 : REA
     template void
       MGTransferPrebuilt<V1<S1> >::copy_to_mg (
        const MGDoFHandler<deal_II_dimension>&, MGLevelObject<V1<S1> >&, const V2<S2>&) const;
+    template void
+      MGTransferPrebuilt<V1<S1> >::copy_to_mg (
+       const DoFHandler<deal_II_dimension>&, MGLevelObject<V1<S1> >&, const V2<S2>&) const;
     template void
       MGTransferPrebuilt<V1<S1> >::copy_from_mg (const MGDoFHandler<deal_II_dimension>&, V2<S2>&,
                                             const MGLevelObject<V1<S1> >&) const;
+    template void
+      MGTransferPrebuilt<V1<S1> >::copy_from_mg (const DoFHandler<deal_II_dimension>&, V2<S2>&,
+                                            const MGLevelObject<V1<S1> >&) const;
     template void
       MGTransferPrebuilt<V1<S1> >::copy_from_mg_add (const MGDoFHandler<deal_II_dimension>&, V2<S2>&,
                                                 const MGLevelObject<V1<S1> >&) const;
+    template void
+      MGTransferPrebuilt<V1<S1> >::copy_from_mg_add (const DoFHandler<deal_II_dimension>&, V2<S2>&,
+                                                const MGLevelObject<V1<S1> >&) const;
   }
 

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.