]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
set up multigrid transfer by blocks
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Apr 2007 20:32:07 +0000 (20:32 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 26 Apr 2007 20:32:07 +0000 (20:32 +0000)
git-svn-id: https://svn.dealii.org/trunk@14642 0785d39b-7218-0410-832d-ea1e28bc413d

19 files changed:
deal.II/deal.II/include/multigrid/mg_tools.h
deal.II/deal.II/include/multigrid/mg_transfer.h
deal.II/deal.II/include/multigrid/mg_transfer.templates.h
deal.II/deal.II/include/multigrid/mg_transfer_block.h [new file with mode: 0644]
deal.II/deal.II/include/multigrid/mg_transfer_block.templates.h [new file with mode: 0644]
deal.II/deal.II/include/multigrid/mg_transfer_component.h [new file with mode: 0644]
deal.II/deal.II/include/multigrid/mg_transfer_component.templates.h [new file with mode: 0644]
deal.II/deal.II/source/multigrid/mg_dof_tools.cc
deal.II/deal.II/source/multigrid/mg_transfer_block.cc
deal.II/deal.II/source/multigrid/mg_transfer_component.cc [new file with mode: 0644]
deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc
tests/multigrid/Makefile
tests/multigrid/transfer.cc
tests/multigrid/transfer/cmp/x86_64-unknown-linux-gnu+gcc3.3
tests/multigrid/transfer_block.cc
tests/multigrid/transfer_block/cmp/generic
tests/multigrid/transfer_block_select.cc [new file with mode: 0644]
tests/multigrid/transfer_block_select/cmp/generic [new file with mode: 0644]
tests/multigrid/transfer_select.cc

index fbf7c86ac3b9533d2f66536fc6fa29b603ae2f73..187b42f13b3e1ec1fec7129795e47c350e1ab24e 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2005, 2006 by the deal.II authors
+//    Copyright (C) 2005, 2006, 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -267,6 +267,48 @@ class MGTools
       reinit_vector (const MGDoFHandler<dim> &mg_dof,
                     MGLevelObject<Vector<number> > &vector);
 
+                                    /**
+                                     * Ajust vectors on all levels to
+                                     * correct size.  Here, we just
+                                     * count the numbers of degrees
+                                     * of freedom on each level and
+                                     * @p reinit each level vector
+                                     * to this length.
+                                     */
+    template <int dim, typename number>
+      static void
+      reinit_vector (const MGDoFHandler<dim> &mg_dof,
+                    MGLevelObject<BlockVector<number> > &vector);
+
+
+                                    /**
+                                     * Adjust block vectors on all
+                                     * levels to correct size. The
+                                     * degrees of freedom on each
+                                     * level are counted by block.
+                                     */
+    template <int dim, typename number>
+    static void
+    reinit_vector_by_blocks (
+      const MGDoFHandler<dim> &mg_dof,
+      MGLevelObject<Vector<number> > &v,
+      const std::vector<bool> &selected,
+      std::vector<std::vector<unsigned int> >& cached_sizes);
+    
+                                    /**
+                                     * Adjust block vectors on all
+                                     * levels to correct size. The
+                                     * degrees of freedom on each
+                                     * level are counted by block.
+                                     */
+    template <int dim, typename number>
+    static void
+    reinit_vector_by_blocks (
+      const MGDoFHandler<dim> &mg_dof,
+      MGLevelObject<BlockVector<number> > &v,
+      const std::vector<bool> &selected,
+      std::vector<std::vector<unsigned int> >& cached_sizes);
+    
                                     /**
                                      * Adjust block-vectors on all
                                      * levels to correct size.  Count
@@ -303,11 +345,11 @@ class MGTools
                                      */
     template <int dim, typename number>
       static void
-      reinit_vector (const MGDoFHandler<dim>& mg_dof,
-                    MGLevelObject<BlockVector<number> >& v,
-                    const std::vector<bool>& selected = std::vector<bool>(),
-                    const std::vector<unsigned int>& target_component
-                    = std::vector<unsigned int>());
+      reinit_vector_by_components (const MGDoFHandler<dim>& mg_dof,
+                                  MGLevelObject<BlockVector<number> >& v,
+                                  const std::vector<bool>& selected,
+                                  const std::vector<unsigned int>& target_component,
+                                  std::vector<std::vector<unsigned int> >& cached_sizes);
                                     /**
                                      * Adjust vectors on all levels
                                      * to correct size.  Count the
@@ -336,11 +378,12 @@ class MGTools
                                      */
     template <int dim, typename number>
       static void
-      reinit_vector (const MGDoFHandler<dim> &mg_dof,
-                    MGLevelObject<Vector<number> > &v,
-                    const std::vector<bool> &selected,
-                    const std::vector<unsigned int> &target_component,
-                    std::vector<std::vector<unsigned int> >& cached_sizes);
+      reinit_vector_by_components (
+       const MGDoFHandler<dim> &mg_dof,
+       MGLevelObject<Vector<number> > &v,
+       const std::vector<bool> &selected,
+       const std::vector<unsigned int> &target_component,
+       std::vector<std::vector<unsigned int> >& cached_sizes);
 };
 
 /*@}*/
index 7efcd83005edd1d90a69be9dac19dd5ea3c81f39..1500a037dd95f236406105f6de5ec0bf4c81caa0 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -170,529 +170,8 @@ class MGTransferPrebuilt : public MGTransferBase<VECTOR>
 };
 
 
-/**
- * Implementation of matrix generation for MGTransferBlock and
- * MGTransferSelect.
- *
- * @author Guido Kanschat, 2001-2003
- */
-class MGTransferBlockBase
-{
-  public:
-                                    /**
-                                     * Memory used by this object.
-                                     */
-    unsigned int memory_consumption () const;
-    
-
-  protected:  
-                                    /**
-                                     * Actually build the prolongation
-                                     * matrices for each level.
-                                     *
-                                     * This function is only called
-                                     * by derived classes. These can
-                                     * also set the member variables
-                                     * #selected and #mg_selected to
-                                     * restrict the transfer matrices
-                                     * to certain components.
-                                     * Furthermore, they use
-                                     * #target_component and
-                                     * #mg_target_component for
-                                     * re-ordering and grouping of
-                                     * components.
-                                     */
-    template <int dim>
-    void build_matrices (const DoFHandler<dim>& dof,
-                        const MGDoFHandler<dim>& mg_dof);
-
-                                  /**
-                                   * Flag of selected components.
-                                   *
-                                   * The transfer operators only act
-                                   * on the components having a
-                                   * <tt>true</tt> entry here. If
-                                   * renumbering by
-                                   * #target_component is used,
-                                   * this refers to the
-                                   * <b>renumbered</b> components.
-                                   */
-    std::vector<bool> selected;
-
-                                  /**
-                                   * Flag of selected components.
-                                   *
-                                   * The transfer operators only act
-                                   * on the components having a
-                                   * <tt>true</tt> entry here. If
-                                   * renumbering by
-                                   * #mg_target_component is used,
-                                   * this refers to the
-                                   * <b>renumbered</b> components.
-                                   */
-    std::vector<bool> mg_selected;
-
-                                    /**
-                                     * Target component of the
-                                     * fine-level vector if
-                                     * renumbering is required.
-                                     */
-    std::vector<unsigned int> target_component;
-    
-                                    /**
-                                     * Target component if
-                                     * renumbering of level vectors
-                                     * is required.
-                                     */
-    std::vector<unsigned int> mg_target_component;
-    
-                                  /**
-                                   * Sizes of the multi-level vectors.
-                                   */
-    mutable std::vector<std::vector<unsigned int> > sizes;
-  
-                                  /**
-                                   * Start index of each component.
-                                   */
-    std::vector<unsigned int> component_start;
-  
-                                  /**
-                                   * Start index of each component on
-                                   * all levels.
-                                   */
-    std::vector<std::vector<unsigned int> > mg_component_start;
-    
-                                    /**
-                                     * Call build_matrices()
-                                     * function first.
-                                     */
-    DeclException0(ExcMatricesNotBuilt);
-    
-  private:
-    std::vector<boost::shared_ptr<BlockSparsityPattern> >   prolongation_sparsities;
-    
-  protected:
-    
-                                    /**
-                                     * The actual prolongation matrix.
-                                     * column indices belong to the
-                                     * dof indices of the mother cell,
-                                     * i.e. the coarse level.
-                                     * while row indices belong to the
-                                     * child cell, i.e. the fine level.
-                                     */
-    std::vector<boost::shared_ptr<BlockSparseMatrix<double> > > prolongation_matrices;
-    
-                                    /**
-                                     * Unused now, but intended to
-                                     * hold the mapping for the
-                                     * <tt>copy_to/from_mg</tt>-functions.
-                                     */
-    std::vector<std::map<unsigned int, unsigned int> >
-    copy_to_and_from_indices;
-};
-
-//TODO:[GK] Update this class
-
-/**
- * Implementation of the MGTransferBase interface for block
- * matrices and block vectors.
- *
- * Warning! Due to additional requirements on MGTransferSelect, the
- * implementation in the base class has changed. Therefore, this class
- * is left in an untested state. If you use it and you encounter
- * problems, please contact Guido Kanschat.
- *
- * In addition to the functionality of
- * MGTransferPrebuilt, the operation may be restricted to
- * certain blocks of the vector.
- *
- * If the restricted mode is chosen, block vectors used in the
- * transfer routines may only have as many components as there are
- * @p trues in the selected-field.
- *
- * See MGTransferBase to find out which of the transfer classes
- * is best for your needs.
- *
- * @author Guido Kanschat, 2001, 2002
- */
-template <typename number>
-class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
-                       private MGTransferBlockBase
-{
-  public:
-                                    /**
-                                     * Default constructor.
-                                     */
-    MGTransferBlock();
-
-                                    /**
-                                     * Destructor.
-                                     */
-    virtual ~MGTransferBlock ();
-    
-                                    /**
-                                     * Initialize additional #factors
-                                     * and #memory if the restriction
-                                     * of the components is to be
-                                     * weighted differently.
-                                     */
-    void initialize (const std::vector<number>& factors,
-                    VectorMemory<Vector<number> >& memory);
-    
-                                    /**
-                                     * Build the prolongation
-                                     * matrices for each level.
-                                     * 
-                                     * This function is a front-end
-                                     * for the same function in
-                                     * MGTransferBlockBase.
-                                     *
-                                     * If <tt>mg_target_component</tt> is
-                                     * present, this refers to the
-                                     * renumbered components.
-                                     *
-                                     * @arg target_component: this
-                                     * argument allows grouping and
-                                     * renumbering of components in
-                                     * the fine-level vector (see
-                                     * DoFRenumbering::component_wise).
-                                     * 
-                                     * @arg mg_target_component: this
-                                     * argument allows grouping and
-                                     * renumbering of components in
-                                     * the level vectors (see
-                                     * DoFRenumbering::component_wise). It
-                                     * also affects the behavior of
-                                     * the <tt>selected</tt> argument
-                                     */
-    template <int dim>
-    void build_matrices (const DoFHandler<dim> &dof,
-                        const MGDoFHandler<dim> &mg_dof,
-                        const std::vector<unsigned int>& target_component
-                        = std::vector<unsigned int>(),
-                        const std::vector<unsigned int>& mg_target_component
-                        =std::vector<unsigned int>());
-
-    virtual void prolongate (const unsigned int    to_level,
-                            BlockVector<number>       &dst,
-                            const BlockVector<number> &src) const;
-
-    virtual void restrict_and_add (const unsigned int    from_level,
-                                  BlockVector<number>       &dst,
-                                  const BlockVector<number> &src) const;
-
-                                    /**
-                                     * Transfer from a vector on the
-                                     * global grid to a multilevel
-                                     * vector.
-                                     *
-                                     * The action for discontinuous
-                                     * elements is as follows: on an
-                                     * active mesh cell, the global
-                                     * vector entries are simply
-                                     * copied to the corresponding
-                                     * entries of the level
-                                     * vector. Then, these values are
-                                     * restricted down to the
-                                     * coarsest level.
-                                     *
-                                     * If the arguments
-                                     * <tt>target_component</tt> and
-                                     * <tt>mg_target_component</tt>
-                                     * was used in build_matrices(),
-                                     * then the blocks are shuffled
-                                     * around accordingly.
-                                     */
-    template <int dim, class InVector>
-    void
-    copy_to_mg (const MGDoFHandler<dim>             &mg_dof,
-               MGLevelObject<BlockVector<number> > &dst,
-               const InVector                      &src) const;
-
-                                    /**
-                                     * Transfer from multi-level vector to
-                                     * normal vector.
-                                     *
-                                     * Copies data from active
-                                     * portions of a multilevel
-                                     * vector into the respective
-                                     * positions of a global vector.
-                                     *
-                                     * If the arguments
-                                     * <tt>target_component</tt> and
-                                     * <tt>mg_target_component</tt>
-                                     * was used in build_matrices(),
-                                     * then the blocks are shuffled
-                                     * around accordingly.
-                                     */
-    template <int dim, class OutVector>
-    void
-    copy_from_mg (const MGDoFHandler<dim>                   &mg_dof,
-                 OutVector                                 &dst,
-                 const MGLevelObject<BlockVector<number> > &src) const;
-
-                                    /**
-                                     * Add a multi-level vector to a
-                                     * normal vector.
-                                     *
-                                     * Works as the previous
-                                     * function, but probably not for
-                                     * continuous elements.
-                                     */
-    template <int dim, class OutVector>
-    void
-    copy_from_mg_add (const MGDoFHandler<dim>                   &mg_dof,
-                     OutVector                                 &dst,
-                     const MGLevelObject<BlockVector<number> > &src) const;
-
-    MGTransferBlockBase::memory_consumption;
-    
-  private:
-                                    /**
-                                     * Optional multiplication
-                                     * factors for each
-                                     * component. Requires
-                                     * initialization of #memory.
-                                     */
-    std::vector<number> factors;
-
-                                    /**
-                                     * Memory pool required if
-                                     * additional multiplication
-                                     * using #factors is desired.
-                                     */
-    SmartPointer<VectorMemory<Vector<number> > > memory;
-};
-
-
-//TODO:[GK] Update documentation for copy_* functions
-
-/**
- * Implementation of the MGTransferBase interface for block
- * matrices and simple vectors. This class uses MGTransferBlockBase
- * selecting a single component or grouping several components into a
- * single block. The transfer operators themselves are implemented for
- * Vector and BlockVector objects.
- *
- * See MGTransferBase to find out which of the transfer classes
- * is best for your needs.
- *
- * @author Guido Kanschat, 2001, 2002, 2003
- */
-template <typename number>
-class MGTransferSelect : public MGTransferBase<Vector<number> >,
-                        private MGTransferBlockBase
-{
-  public:
-                                    /**
-                                     * Destructor.
-                                     */
-    virtual ~MGTransferSelect ();
-    
-                                    /**
-                                     * Actually build the prolongation
-                                     * matrices for grouped components.
-                                     *
-                                     * This function is a front-end
-                                     * for the same function in
-                                     * MGTransferBlockBase.
-                                     *
-                                     * @arg selected: Number of the
-                                     * component of the global vector
-                                     * to be copied from and to the
-                                     * multilevel vector. This number
-                                     * refers to the renumbering by
-                                     * <tt>target_component</tt>.
-                                     *
-                                     * @arg mg_selected: Number
-                                     * of the component for which the
-                                     * transfer matrices should be
-                                     * built.
-                                     *
-                                     * If <tt>mg_target_component</tt> is
-                                     * present, this refers to the
-                                     * renumbered components.
-                                     *
-                                     * @arg target_component: this
-                                     * argument allows grouping and
-                                     * renumbering of components in
-                                     * the fine-level vector (see
-                                     * DoFRenumbering::component_wise).
-                                     * 
-                                     * @arg mg_target_component: this
-                                     * argument allows grouping and
-                                     * renumbering of components in
-                                     * the level vectors (see
-                                     * DoFRenumbering::component_wise). It
-                                     * also affects the behavior of
-                                     * the <tt>selected</tt> argument
-                                     */
-    template <int dim>
-    void build_matrices (const DoFHandler<dim> &dof,
-                        const MGDoFHandler<dim> &mg_dof,
-                        unsigned int selected,
-                        unsigned int mg_selected,
-                        const std::vector<unsigned int>& target_component
-                        = std::vector<unsigned int>(),
-                        const std::vector<unsigned int>& mg_target_component
-                        = std::vector<unsigned int>());
-
-                                    /**
-                                     * Change selected
-                                     * component. Handle with care!
-                                     */
-    void select (const unsigned int component,
-                const unsigned int mg_component = deal_II_numbers::invalid_unsigned_int);
-    
-    virtual void prolongate (const unsigned int    to_level,
-                            Vector<number>       &dst,
-                            const Vector<number> &src) const;
-
-    virtual void restrict_and_add (const unsigned int    from_level,
-                                  Vector<number>       &dst,
-                                  const Vector<number> &src) const;
-    
-                                    /**
-                                     * Transfer from a vector on the
-                                     * global grid to a multilevel vector.
-                                     */
-    template <int dim, typename number2>
-    void
-    copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
-               MGLevelObject<Vector<number> > &dst,
-               const Vector<number2>          &src) const;
-
-                                    /**
-                                     * Transfer from multilevel vector to
-                                     * normal vector.
-                                     *
-                                     * Copies data from active
-                                     * portions of an multilevel
-                                     * vector into the respective
-                                     * positions of a Vector.
-                                     */
-    template <int dim, typename number2>
-    void
-    copy_from_mg (const MGDoFHandler<dim>              &mg_dof,
-                 Vector<number2>                      &dst,
-                 const MGLevelObject<Vector<number> > &src) const;
-
-                                    /**
-                                     * Add a multi-level vector to a
-                                     * normal vector.
-                                     *
-                                     * Works as the previous
-                                     * function, but probably not for
-                                     * continuous elements.
-                                     */
-    template <int dim, typename number2>
-    void
-    copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof,
-                     Vector<number2>                      &dst,
-                     const MGLevelObject<Vector<number> > &src) const;
-
-                                    /**
-                                     * Transfer from a vector on the
-                                     * global grid to multilevel vectors.
-                                     */
-    template <int dim, typename number2>
-    void
-    copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
-               MGLevelObject<Vector<number> > &dst,
-               const BlockVector<number2>     &src) const;
-
-                                    /**
-                                     * Transfer from multilevel vector to
-                                     * normal vector.
-                                     *
-                                     * Copies data from active
-                                     * portions of a multilevel
-                                     * vector into the respective
-                                     * positions of a global
-                                     * BlockVector.
-                                     */
-    template <int dim, typename number2>
-    void
-    copy_from_mg (const MGDoFHandler<dim>              &mg_dof,
-                 BlockVector<number2>                 &dst,
-                 const MGLevelObject<Vector<number> > &src) const;
-
-                                    /**
-                                     * Add a multi-level vector to a
-                                     * normal vector.
-                                     *
-                                     * Works as the previous
-                                     * function, but probably not for
-                                     * continuous elements.
-                                     */
-    template <int dim, typename number2>
-    void
-    copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof,
-                     BlockVector<number2>                 &dst,
-                     const MGLevelObject<Vector<number> > &src) const;
-
-                                    /**
-                                     * Memory used by this object.
-                                     */
-    unsigned int memory_consumption () const;
-    
-  private:
-                                    /**
-                                     * Implementation of the public
-                                     * function.
-                                     */
-    template <int dim, class OutVector>
-    void
-    do_copy_from_mg (const MGDoFHandler<dim>              &mg_dof,
-                    OutVector                            &dst,
-                    const MGLevelObject<Vector<number> > &src,
-                    const unsigned int offset) const;
-
-                                    /**
-                                     * Implementation of the public
-                                     * function.
-                                     */
-    template <int dim, class OutVector>
-    void
-    do_copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof,
-                        OutVector                            &dst,
-                        const MGLevelObject<Vector<number> > &src,
-                        const unsigned int offset) const;
-
-                                    /**
-                                     * Actual implementation of
-                                     * copy_to_mg().
-                                     */
-    template <int dim, class InVector>
-    void
-    do_copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
-                  MGLevelObject<Vector<number> > &dst,
-                  const InVector                 &src,
-                  const unsigned int              offset) const;
-                                     /**
-                                      * Selected component of global vector.
-                                      */
-    unsigned int selected_component;
-                                     /**
-                                      * Selected component inside multigrid.
-                                      */
-    unsigned int mg_selected_component;
-};
-
 /*@}*/
 
-//---------------------------------------------------------------------------
-template <typename number>
-inline void
-MGTransferSelect<number>::select(const unsigned int component,
-                                const unsigned int mg_component)
-{
-  selected_component = component;
-  mg_selected_component = (mg_component == deal_II_numbers::invalid_unsigned_int)
-                         ? component
-                         : mg_component;
-}
 
 DEAL_II_NAMESPACE_CLOSE
 
index 92306c1cd232a81b497955eb1b9a5096a2bfb75d..bef63bb1283318d48ef4e4889c20e2a6040bdf11 100644 (file)
@@ -2,7 +2,7 @@
 //    mg_transfer.templates.h,v 1.22 2006/01/29 15:03:55 guido Exp
 //    Version: 
 //
-//    Copyright (C) 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 2003, 2004, 2005, 2006, 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -211,476 +211,6 @@ MGTransferPrebuilt<VECTOR>::memory_consumption () const
   return result;
 }
 
-/* --------------------- MGTransferSelect -------------- */
-
-
-
-template <typename number>
-template <int dim, typename number2>
-void
-MGTransferSelect<number>::copy_to_mg (
-  const MGDoFHandler<dim>        &mg_dof_handler,
-  MGLevelObject<Vector<number> > &dst,
-  const BlockVector<number2>     &src) const
-{
-  do_copy_to_mg (mg_dof_handler, dst, src, 0);
-}
-
-
-
-template <typename number>
-template <int dim, typename number2>
-void
-MGTransferSelect<number>::copy_to_mg (
-  const MGDoFHandler<dim>        &mg_dof_handler,
-  MGLevelObject<Vector<number> > &dst,
-  const Vector<number2>          &src) const
-{
-  do_copy_to_mg (mg_dof_handler, dst, src, component_start[selected_component]);
-}
-
-
-
-template <typename number>
-template <int dim, class InVector>
-void
-MGTransferSelect<number>::do_copy_to_mg (
-  const MGDoFHandler<dim>&        mg_dof_handler,
-  MGLevelObject<Vector<number> >& dst,
-  const InVector&                 src,
-  const unsigned int              offset) const
-{
-  const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
-  
-  const unsigned int dofs_per_cell = fe.dofs_per_cell;
-  
-                                  // set the elements of the vectors
-                                  // on all levels to zero
-  unsigned int minlevel = dst.get_minlevel();
-  unsigned int maxlevel = dst.get_maxlevel();
-  
-  dst=0;
-  
-  Assert(sizes.size()==mg_dof_handler.get_tria().n_levels(),
-        ExcMatricesNotBuilt());
-
-  MGTools::reinit_vector(mg_dof_handler, dst,
-                        mg_selected, mg_target_component, sizes);
-  
-  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
-  std::vector<unsigned int> level_dof_indices  (dofs_per_cell);
-  
-                                  // Build a vector of the selected
-                                  // indices, since traversing all
-                                  // indices on each cell is too
-                                  // slow.
-  std::vector<unsigned int> selected_indices;
-  selected_indices.reserve(dofs_per_cell);
-  for (unsigned int i=0; i<dofs_per_cell; ++i)
-    if (mg_selected[mg_target_component[fe.system_to_component_index(i).first]])
-      selected_indices.push_back(i);
-  unsigned int selected_component
-    = mg_target_component[fe.system_to_component_index(selected_indices[0]).first];
-
-                                  // traverse the grid top-down
-                                  // (i.e. starting with the most
-                                  // refined grid). this way, we can
-                                  // always get that part of one
-                                  // level of the output vector which
-                                  // corresponds to a region which is
-                                  // more refined, by restriction of
-                                  // the respective vector on the
-                                  // next finer level, which we then
-                                  // already have built.
-  for (int level=maxlevel; level>=static_cast<signed int>(minlevel); --level)
-    {
-
-  typename MGDoFHandler<dim>::active_cell_iterator
-       level_cell = mg_dof_handler.begin_active(level);
-      const typename MGDoFHandler<dim>::active_cell_iterator
-       level_end  = mg_dof_handler.end_active(level);
-                                      // Compute coarse level right hand side
-                                      // by restricting from fine level.
-      for (; level_cell!=level_end; ++level_cell)
-       {
-                                          // get the dof numbers of
-                                          // this cell for the global
-                                          // and the level-wise
-                                          // numbering
-         level_cell->get_dof_indices(global_dof_indices);
-         level_cell->get_mg_dof_indices (level_dof_indices);
-
-                                          // transfer the global
-                                          // defect in the vector
-                                          // into the level-wise one
-         const unsigned int level_start
-           = mg_component_start[level][selected_component];
-         const typename std::vector<unsigned int>::const_iterator
-           end = selected_indices.end();
-         
-         for (typename std::vector<unsigned int>::const_iterator
-                i=selected_indices.begin();
-              i != end; ++i)
-           {
-             dst[level](level_dof_indices[*i] - level_start)
-               = src(global_dof_indices[*i] - offset);
-           }
-       }
-
-                                      // for that part of the level
-                                      // which is further refined:
-                                      // get the defect by
-                                      // restriction of the defect on
-                                      // one level higher
-      if (static_cast<unsigned int>(level) < maxlevel)
-       {
-         restrict_and_add (level+1, dst[level], dst[level+1]);
-       }
-    };
-}
-
-
-
-template <typename number>
-template <int dim, typename number2>
-void
-MGTransferSelect<number>::copy_from_mg (
-  const MGDoFHandler<dim>&              mg_dof_handler,
-  BlockVector<number2>&                 dst,
-  const MGLevelObject<Vector<number> >& src) const
-{
-  do_copy_from_mg (mg_dof_handler, dst, src, 0);
-}
-
-
-
-template <typename number>
-template <int dim, typename number2>
-void
-MGTransferSelect<number>::copy_from_mg (
-  const MGDoFHandler<dim>&              mg_dof_handler,
-  Vector<number2>&                      dst,
-  const MGLevelObject<Vector<number> >& src) const
-{
-  do_copy_from_mg (mg_dof_handler, dst, src,
-                  component_start[selected_component]);
-}
-
-
-
-template <typename number>
-template <int dim, typename number2>
-void
-MGTransferSelect<number>::copy_from_mg_add (
-  const MGDoFHandler<dim>&              mg_dof_handler,
-  BlockVector<number2>&                 dst,
-  const MGLevelObject<Vector<number> >& src) const
-{
-  do_copy_from_mg_add (mg_dof_handler, dst, src, 0);
-}
-
-
-
-template <typename number>
-template <int dim, typename number2>
-void
-MGTransferSelect<number>::copy_from_mg_add (
-  const MGDoFHandler<dim>&              mg_dof_handler,
-  Vector<number2>&                      dst,
-  const MGLevelObject<Vector<number> >& src) const
-{
-  do_copy_from_mg_add (mg_dof_handler, dst, src,
-                      component_start[selected_component]);
-}
-
-
-
-template <typename number>
-template <int dim, class OutVector>
-void
-MGTransferSelect<number>::do_copy_from_mg (
-  const MGDoFHandler<dim>              &mg_dof_handler,
-  OutVector                            &dst,
-  const MGLevelObject<Vector<number> > &src,
-  const unsigned int offset) const
-{
-  const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
-  
-  const unsigned int dofs_per_cell = fe.dofs_per_cell;
-  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
-  std::vector<unsigned int> level_dof_indices (dofs_per_cell);
-
-  typename MGDoFHandler<dim>::active_cell_iterator
-    level_cell = mg_dof_handler.begin_active();
-  const typename MGDoFHandler<dim>::active_cell_iterator
-    endc = mg_dof_handler.end();
-
-                                  // traverse all cells and copy the
-                                  // data appropriately to the output
-                                  // vector
-
-                                  // Note that the level is
-                                  // monotonuosly increasing
-  for (; level_cell != endc; ++level_cell)
-    {
-      const unsigned int level = level_cell->level();
-
-                                      // get the dof numbers of
-                                      // this cell for the global
-                                      // and the level-wise
-                                      // numbering
-      level_cell->get_dof_indices (global_dof_indices);
-      level_cell->get_mg_dof_indices(level_dof_indices);
-
-                                      // copy level-wise data to
-                                      // global vector
-      for (unsigned int i=0; i<dofs_per_cell; ++i)
-       {
-         const unsigned int component
-           = mg_target_component[fe.system_to_component_index(i).first];
-       if (mg_selected[component])
-         {
-           const unsigned int level_start
-             = mg_component_start[level][component];
-           dst(global_dof_indices[i] - offset)
-             = src[level](level_dof_indices[i]-level_start);
-         }
-       }
-    }
-}
-
-
-
-template <typename number>
-template <int dim, class OutVector>
-void
-MGTransferSelect<number>::do_copy_from_mg_add (
-  const MGDoFHandler<dim>              &mg_dof_handler,
-  OutVector                            &dst,
-  const MGLevelObject<Vector<number> > &src,
-  const unsigned int offset) const
-{
-  const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
-  const unsigned int dofs_per_cell = fe.dofs_per_cell;
-
-  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
-  std::vector<unsigned int> level_dof_indices (dofs_per_cell);
-
-  typename MGDoFHandler<dim>::active_cell_iterator
-    level_cell = mg_dof_handler.begin_active();
-  const typename MGDoFHandler<dim>::active_cell_iterator
-    endc = mg_dof_handler.end();
-
-                                  // traverse all cells and copy the
-                                  // data appropriately to the output
-                                  // vector
-
-                                  // Note that the level is
-                                  // monotonuosly increasing
-  for (; level_cell != endc; ++level_cell)
-    {
-      const unsigned int level = level_cell->level();
-
-                                      // get the dof numbers of
-                                      // this cell for the global
-                                      // and the level-wise
-                                      // numbering
-      level_cell->get_dof_indices (global_dof_indices);
-      level_cell->get_mg_dof_indices(level_dof_indices);
-                                      // copy level-wise data to
-                                      // global vector
-      for (unsigned int i=0; i<dofs_per_cell; ++i)
-       {
-         const unsigned int component
-           = mg_target_component[fe.system_to_component_index(i).first];
-         if (mg_selected[component])
-           {
-             const unsigned int level_start
-               = mg_component_start[level][component];
-             dst(global_dof_indices[i] - offset)
-               += src[level](level_dof_indices[i] - level_start);
-           }
-       }
-    }
-}
-
-
-template <typename number>
-unsigned int
-MGTransferSelect<number>::memory_consumption () const
-{
-  return sizeof(int) + MGTransferBlockBase::memory_consumption();
-}
-
-
-/* --------------------- MGTransferBlock -------------- */
-
-
-
-template <typename number>
-template <int dim, class InVector>
-void
-MGTransferBlock<number>::copy_to_mg (
-  const MGDoFHandler<dim>             &mg_dof_handler,
-  MGLevelObject<BlockVector<number> > &dst,
-  const InVector                      &src) const
-{
-  const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
-  
-  const unsigned int dofs_per_cell = fe.dofs_per_cell;
-
-                                  // set the elements of the vectors
-                                  // on all levels to zero
-  unsigned int minlevel = dst.get_minlevel();
-  unsigned int maxlevel = dst.get_maxlevel();
-  
-  dst=0;
-
-  MGTools::reinit_vector(mg_dof_handler, dst, mg_selected, mg_target_component);
-  
-  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
-  std::vector<unsigned int> level_dof_indices  (dofs_per_cell);
-  
-                                  // traverse the grid top-down
-                                  // (i.e. starting with the most
-                                  // refined grid). this way, we can
-                                  // always get that part of one
-                                  // level of the output vector which
-                                  // corresponds to a region which is
-                                  // more refined, by restriction of
-                                  // the respective vector on the
-                                  // next finer level, which we then
-                                  // already have built.
-  for (int level=maxlevel; level>=static_cast<signed int>(minlevel); --level)
-    {
-      typename MGDoFHandler<dim>::active_cell_iterator
-       level_cell = mg_dof_handler.begin_active(level);
-      const typename MGDoFHandler<dim>::active_cell_iterator
-       level_end  = mg_dof_handler.end_active(level);
-
-                                      // Compute coarse level right hand side
-                                      // by restricting from fine level.
-      for (; level_cell!=level_end; ++level_cell)
-       {
-                                          // get the dof numbers of
-                                          // this cell for the global
-                                          // and the level-wise
-                                          // numbering
-         level_cell->get_dof_indices(global_dof_indices);
-         level_cell->get_mg_dof_indices (level_dof_indices);
-
-                                          // transfer the global
-                                          // defect in the vector
-                                          // into the level-wise one
-         for (unsigned int i=0; i<dofs_per_cell; ++i)
-           {
-//TODO:[GK] Not sure if this works if components are selected
-             dst[level](level_dof_indices[i])
-               = src(global_dof_indices[i]);
-           }
-       }
-                                      // for that part of the level
-                                      // which is further refined:
-                                      // get the defect by
-                                      // restriction of the defect on
-                                      // one level higher
-      if (static_cast<unsigned int>(level) < maxlevel)
-       {
-         restrict_and_add (level+1, dst[level], dst[level+1]);
-       }
-    };
-}
-
-
-
-
-template <typename number>
-template <int dim, class OutVector>
-void
-MGTransferBlock<number>::copy_from_mg (
-  const MGDoFHandler<dim>                   &mg_dof_handler,
-  OutVector                                 &dst,
-  const MGLevelObject<BlockVector<number> > &src) const
-{
-  const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
-  
-  const unsigned int dofs_per_cell = fe.dofs_per_cell;
-  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
-  std::vector<unsigned int> level_dof_indices (dofs_per_cell);
-
-  typename MGDoFHandler<dim>::active_cell_iterator
-    level_cell = mg_dof_handler.begin_active();
-  const typename MGDoFHandler<dim>::active_cell_iterator
-    endc = mg_dof_handler.end();
-                                  // traverse all cells and copy the
-                                  // data appropriately to the output
-                                  // vector
-
-                                  // Note that level is monotonuosly
-                                  // increasing
-  for (; level_cell != endc; ++level_cell)
-    {
-      const unsigned int level = level_cell->level();
-                                      // get the dof numbers of
-                                      // this cell for the global
-                                      // and the level-wise
-                                      // numbering
-      level_cell->get_dof_indices (global_dof_indices);
-      level_cell->get_mg_dof_indices(level_dof_indices);
-
-                                      // copy level-wise data to
-                                      // global vector
-//TODO:[GK] Does this work with selected components?
-      for (unsigned int i=0; i<dofs_per_cell; ++i)
-       dst(global_dof_indices[i])
-         = src[level](level_dof_indices[i]);
-    }
-}
-
-
-
-template <typename number>
-template <int dim, class OutVector>
-void
-MGTransferBlock<number>::copy_from_mg_add (
-  const MGDoFHandler<dim>                   &mg_dof_handler,
-  OutVector                                 &dst,
-  const MGLevelObject<BlockVector<number> > &src) const
-{
-  const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
-  
-  const unsigned int dofs_per_cell = fe.dofs_per_cell;
-  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
-  std::vector<unsigned int> level_dof_indices (dofs_per_cell);
-
-  typename MGDoFHandler<dim>::active_cell_iterator
-    level_cell = mg_dof_handler.begin_active();
-  const typename MGDoFHandler<dim>::active_cell_iterator
-    endc = mg_dof_handler.end();
-
-                                  // traverse all cells and copy the
-                                  // data appropriately to the output
-                                  // vector
-
-                                  // Note that the level monotonuosly
-                                  // increasing
-  for (; level_cell != endc; ++level_cell)
-    {
-      const unsigned int level = level_cell->level();
-
-                                      // get the dof numbers of
-                                      // this cell for the global
-                                      // and the level-wise
-                                      // numbering
-      level_cell->get_dof_indices (global_dof_indices);
-      level_cell->get_mg_dof_indices(level_dof_indices);
-                                      // copy level-wise data to
-                                      // global vector
-      for (unsigned int i=0; i<dofs_per_cell; ++i)
-       dst(global_dof_indices[i])
-         += src[level](level_dof_indices[i]);
-    }
-}
 
 DEAL_II_NAMESPACE_CLOSE
 
diff --git a/deal.II/deal.II/include/multigrid/mg_transfer_block.h b/deal.II/deal.II/include/multigrid/mg_transfer_block.h
new file mode 100644 (file)
index 0000000..e48cdac
--- /dev/null
@@ -0,0 +1,492 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+#ifndef __deal2__mg_transfer_block_h
+#define __deal2__mg_transfer_block_h
+
+#include <base/config.h>
+
+#include <lac/block_vector.h>
+#ifdef DEAL_PREFER_MATRIX_EZ
+#  include <lac/sparse_matrix_ez.h>
+#  include <lac/block_sparse_matrix_ez.h>
+#else
+#  include <lac/sparsity_pattern.h>
+#  include <lac/block_sparsity_pattern.h>
+#endif
+#include <lac/vector_memory.h>
+
+#include <multigrid/mg_base.h>
+#include <multigrid/mg_level_object.h>
+
+
+
+#include <dofs/dof_handler.h>
+
+#include <boost/shared_ptr.hpp>
+
+
+DEAL_II_NAMESPACE_OPEN
+
+
+template <int dim> class MGDoFHandler;
+
+/*
+ * MGTransferBase is defined in mg_base.h
+ */
+
+/*!@addtogroup mg */
+/*@{*/
+
+/**
+ * Implementation of matrix generation for MGTransferBlock.
+ *
+ * This is the base class for MGTransfer objects for systems of
+ * equations where multigrid is applied only to one ore some blocks,
+ * where a @ref GlossBlock comprises all degrees of freedom generated
+ * by one base element.
+ *
+ * @author Guido Kanschat, 2001-2003
+ */
+class MGTransferBlockBase
+{
+  public:
+                                    /**
+                                     * Memory used by this object.
+                                     */
+    unsigned int memory_consumption () const;
+    
+  protected:  
+                                    /**
+                                     * Actually build the prolongation
+                                     * matrices for each level.
+                                     *
+                                     * This function is only called
+                                     * by derived classes. These can
+                                     * also set the member variables
+                                     * #selected and #mg_selected to
+                                     * restrict the transfer matrices
+                                     * to certain blocks.
+                                     */
+    template <int dim>
+    void build_matrices (const DoFHandler<dim>& dof,
+                        const MGDoFHandler<dim>& mg_dof);
+
+                                  /**
+                                   * Flag of selected blocks.
+                                   *
+                                   * The transfer operators only act
+                                   * on the blocks having a
+                                   * <tt>true</tt> entry here.
+                                   */
+    std::vector<bool> selected;
+
+                                    /**
+                                     * For each block of the whole
+                                     * block vector, list to what
+                                     * block of the multigrid vector
+                                     * it is mapped. Since depending
+                                     * on #selected, there may be
+                                     * fewer mutlilevel blocks than
+                                     * original blocks, some of the
+                                     * entries may be illegal
+                                     * unsigned integers.
+                                     */
+    std::vector<unsigned int> mg_block;
+    
+                                  /**
+                                   * Sizes of the multi-level vectors.
+                                   */
+    mutable std::vector<std::vector<unsigned int> > sizes;
+  
+                                  /**
+                                   * Start index of each block.
+                                   */
+    std::vector<unsigned int> block_start;
+  
+                                  /**
+                                   * Start index of each block on
+                                   * all levels.
+                                   */
+    std::vector<std::vector<unsigned int> > mg_block_start;
+    
+                                    /**
+                                     * Call build_matrices()
+                                     * function first.
+                                     */
+    DeclException0(ExcMatricesNotBuilt);
+    
+  private:
+    std::vector<boost::shared_ptr<BlockSparsityPattern> >   prolongation_sparsities;
+    
+  protected:
+    
+                                    /**
+                                     * The actual prolongation matrix.
+                                     * column indices belong to the
+                                     * dof indices of the mother cell,
+                                     * i.e. the coarse level.
+                                     * while row indices belong to the
+                                     * child cell, i.e. the fine level.
+                                     */
+    std::vector<boost::shared_ptr<BlockSparseMatrix<double> > > prolongation_matrices;
+    
+                                    /**
+                                     * Mapping for the
+                                     * <tt>copy_to/from_mg</tt>-functions.
+                                     * The indices into this vector
+                                     * are (in this order): global
+                                     * block number, level
+                                     * number. The data is first the
+                                     * global index inside the block,
+                                     * then the level index inside
+                                     * the block.
+                                    */
+    std::vector<std::vector<std::map<unsigned int, unsigned int> > >
+    copy_indices;
+};
+
+/**
+ * Implementation of the MGTransferBase interface for block
+ * matrices and block vectors.
+ *
+ * @warning This class is in an untested state. If you use it and you
+ * encounter problems, please contact Guido Kanschat.
+ *
+ * In addition to the functionality of
+ * MGTransferPrebuilt, the operation may be restricted to
+ * certain blocks of the vector.
+ *
+ * If the restricted mode is chosen, block vectors used in the
+ * transfer routines may only have as many blocks as there are
+ * @p trues in the selected-field.
+ *
+ * See MGTransferBase to find out which of the transfer classes
+ * is best for your needs.
+ *
+ * @author Guido Kanschat, 2001, 2002
+ */
+template <typename number>
+class MGTransferBlock : public MGTransferBase<BlockVector<number> >,
+                       private MGTransferBlockBase
+{
+  public:
+                                    /**
+                                     * Default constructor.
+                                     */
+    MGTransferBlock();
+
+                                    /**
+                                     * Destructor.
+                                     */
+    virtual ~MGTransferBlock ();
+    
+                                    /**
+                                     * Initialize additional #factors
+                                     * and #memory if the restriction
+                                     * of the blocks is to be
+                                     * weighted differently.
+                                     */
+    void initialize (const std::vector<number>& factors,
+                    VectorMemory<Vector<number> >& memory);
+    
+                                    /**
+                                     * Build the prolongation
+                                     * matrices for each level.
+                                     * 
+                                     * This function is a front-end
+                                     * for the same function in
+                                     * MGTransferBlockBase.
+                                     */
+    template <int dim>
+    void build_matrices (const DoFHandler<dim> &dof,
+                        const MGDoFHandler<dim> &mg_dof,
+                        const std::vector<bool>& selected);
+
+    virtual void prolongate (const unsigned int    to_level,
+                            BlockVector<number>       &dst,
+                            const BlockVector<number> &src) const;
+
+    virtual void restrict_and_add (const unsigned int    from_level,
+                                  BlockVector<number>       &dst,
+                                  const BlockVector<number> &src) const;
+
+                                    /**
+                                     * Transfer from a vector on the
+                                     * global grid to a multilevel
+                                     * vector.
+                                     *
+                                     * The action for discontinuous
+                                     * elements is as follows: on an
+                                     * active mesh cell, the global
+                                     * vector entries are simply
+                                     * copied to the corresponding
+                                     * entries of the level
+                                     * vector. Then, these values are
+                                     * restricted down to the
+                                     * coarsest level.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_to_mg (const MGDoFHandler<dim>& mg_dof,
+               MGLevelObject<BlockVector<number> >& dst,
+               const BlockVector<number2>& src) const;
+
+                                    /**
+                                     * Transfer from multi-level vector to
+                                     * normal vector.
+                                     *
+                                     * Copies data from active
+                                     * portions of a multilevel
+                                     * vector into the respective
+                                     * positions of a global vector.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_from_mg (const MGDoFHandler<dim>& mg_dof,
+                 BlockVector<number2>& dst,
+                 const MGLevelObject<BlockVector<number> > &src) const;
+
+                                    /**
+                                     * Add a multi-level vector to a
+                                     * normal vector.
+                                     *
+                                     * Works as the previous
+                                     * function, but probably not for
+                                     * continuous elements.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_from_mg_add (const MGDoFHandler<dim>& mg_dof,
+                     BlockVector<number2>& dst,
+                     const MGLevelObject<BlockVector<number> > &src) const;
+
+    MGTransferBlockBase::memory_consumption;
+    
+  private:
+                                    /**
+                                     * Optional multiplication
+                                     * factors for each
+                                     * block. Requires
+                                     * initialization of #memory.
+                                     */
+    std::vector<number> factors;
+
+                                    /**
+                                     * Memory pool required if
+                                     * additional multiplication
+                                     * using #factors is desired.
+                                     */
+    SmartPointer<VectorMemory<Vector<number> > > memory;
+};
+
+
+//TODO:[GK] Update documentation for copy_* functions
+
+/**
+ * Implementation of the MGTransferBase interface for block matrices
+ * and simple vectors. This class uses MGTransferBlockBase selecting a
+ * single block. The intergrid transfer operators are implemented for
+ * Vector objects, The copy functions between regular and multigrid
+ * vectors for Vector and BlockVector.
+ *
+ * See MGTransferBase to find out which of the transfer classes
+ * is best for your needs.
+ *
+ * @author Guido Kanschat, 2001, 2002, 2003
+ */
+template <typename number>
+class MGTransferBlockSelect : public MGTransferBase<Vector<number> >,
+                             private MGTransferBlockBase
+{
+  public:
+                                    /**
+                                     * Destructor.
+                                     */
+    virtual ~MGTransferBlockSelect ();
+    
+                                    /**
+                                     * Actually build the prolongation
+                                     * matrices for grouped blocks.
+                                     *
+                                     * This function is a front-end
+                                     * for the same function in
+                                     * MGTransferBlockBase.
+                                     *
+                                     * @arg selected: Number of the
+                                     * block of the global vector
+                                     * to be copied from and to the
+                                     * multilevel vector.
+                                     *
+                                     * @arg mg_selected: Number
+                                     * of the component for which the
+                                     * transfer matrices should be
+                                     * built.
+                                     */
+    template <int dim>
+    void build_matrices (const DoFHandler<dim> &dof,
+                        const MGDoFHandler<dim> &mg_dof,
+                        unsigned int selected);
+
+                                    /**
+                                     * Change selected
+                                     * block. Handle with care!
+                                     */
+    void select (const unsigned int block);
+    
+    virtual void prolongate (const unsigned int    to_level,
+                            Vector<number>       &dst,
+                            const Vector<number> &src) const;
+
+    virtual void restrict_and_add (const unsigned int    from_level,
+                                  Vector<number>       &dst,
+                                  const Vector<number> &src) const;
+    
+                                    /**
+                                     * Transfer a single block from a
+                                     * vector on the global grid to a
+                                     * multilevel vector.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
+               MGLevelObject<Vector<number> > &dst,
+               const Vector<number2>          &src) const;
+
+                                    /**
+                                     * Transfer from multilevel vector to
+                                     * normal vector.
+                                     *
+                                     * Copies data from active
+                                     * portions of an multilevel
+                                     * vector into the respective
+                                     * positions of a Vector.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_from_mg (const MGDoFHandler<dim>              &mg_dof,
+                 Vector<number2>                      &dst,
+                 const MGLevelObject<Vector<number> > &src) const;
+
+                                    /**
+                                     * Add a multi-level vector to a
+                                     * normal vector.
+                                     *
+                                     * Works as the previous
+                                     * function, but probably not for
+                                     * continuous elements.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof,
+                     Vector<number2>                      &dst,
+                     const MGLevelObject<Vector<number> > &src) const;
+
+                                    /**
+                                     * Transfer a block from a vector
+                                     * on the global grid to
+                                     * multilevel vectors. Only the
+                                     * block selected is transfered.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
+               MGLevelObject<Vector<number> > &dst,
+               const BlockVector<number2>     &src) const;
+
+                                    /**
+                                     * Transfer from multilevel vector to
+                                     * normal vector.
+                                     *
+                                     * Copies data from active
+                                     * portions of a multilevel
+                                     * vector into the respective
+                                     * positions of a global
+                                     * BlockVector.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_from_mg (const MGDoFHandler<dim>              &mg_dof,
+                 BlockVector<number2>                 &dst,
+                 const MGLevelObject<Vector<number> > &src) const;
+
+                                    /**
+                                     * Add a multi-level vector to a
+                                     * normal vector.
+                                     *
+                                     * Works as the previous
+                                     * function, but probably not for
+                                     * continuous elements.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof,
+                     BlockVector<number2>                 &dst,
+                     const MGLevelObject<Vector<number> > &src) const;
+
+                                    /**
+                                     * Memory used by this object.
+                                     */
+    unsigned int memory_consumption () const;
+    
+  private:
+                                    /**
+                                     * Implementation of the public
+                                     * function.
+                                     */
+    template <int dim, class OutVector>
+    void
+    do_copy_from_mg (const MGDoFHandler<dim>              &mg_dof,
+                    OutVector                            &dst,
+                    const MGLevelObject<Vector<number> > &src,
+                    const unsigned int offset) const;
+
+                                    /**
+                                     * Implementation of the public
+                                     * function.
+                                     */
+    template <int dim, class OutVector>
+    void
+    do_copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof,
+                        OutVector                            &dst,
+                        const MGLevelObject<Vector<number> > &src,
+                        const unsigned int offset) const;
+
+                                    /**
+                                     * Actual implementation of
+                                     * copy_to_mg().
+                                     */
+    template <int dim, class InVector>
+    void
+    do_copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
+                  MGLevelObject<Vector<number> > &dst,
+                  const InVector                 &src,
+                  const unsigned int              offset) const;
+                                     /**
+                                      * Selected block.
+                                      */
+    unsigned int selected_block;
+};
+
+/*@}*/
+
+//---------------------------------------------------------------------------
+template <typename number>
+inline void
+MGTransferBlockSelect<number>::select(const unsigned int block)
+{
+  selected_block = block;
+}
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
diff --git a/deal.II/deal.II/include/multigrid/mg_transfer_block.templates.h b/deal.II/deal.II/include/multigrid/mg_transfer_block.templates.h
new file mode 100644 (file)
index 0000000..83b3599
--- /dev/null
@@ -0,0 +1,205 @@
+//---------------------------------------------------------------------------
+//    mg_transfer.templates.h,v 1.22 2006/01/29 15:03:55 guido Exp
+//    Version: 
+//
+//    Copyright (C) 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+
+#ifndef __deal2__mg_transfer_block_templates_h
+#define __deal2__mg_transfer_block_templates_h
+
+#include <lac/sparse_matrix.h>
+#include <grid/tria_iterator.h>
+#include <fe/fe.h>
+#include <dofs/dof_constraints.h>
+#include <multigrid/mg_base.h>
+#include <multigrid/mg_dof_accessor.h>
+#include <multigrid/mg_tools.h>
+#include <multigrid/mg_transfer_block.h>
+
+#include <algorithm>
+
+DEAL_II_NAMESPACE_OPEN
+
+/* --------------------- MGTransferBlockSelect -------------- */
+
+// Simplify some things below
+typedef std::map<unsigned int, unsigned int>::const_iterator IT;
+  
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferBlockSelect<number>::copy_to_mg (
+  const MGDoFHandler<dim>        &mg_dof_handler,
+  MGLevelObject<Vector<number> > &dst,
+  const BlockVector<number2>     &src) const
+{
+                                  // For MGTransferBlockSelect, the
+                                  // multilevel block is always the
+                                  // first, since only one block is selected.
+  for (unsigned int level=0;level<mg_dof_handler.get_tria().n_levels();++level)
+    for (IT i= copy_indices[selected_block][level].begin();i!= copy_indices[selected_block][level].end();++i)
+      dst[level](i->second) = src.block(selected_block)(i->first);
+}
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferBlockSelect<number>::copy_to_mg (
+  const MGDoFHandler<dim>        &mg_dof_handler,
+  MGLevelObject<Vector<number> > &dst,
+  const Vector<number2>          &src) const
+{
+                                  // For MGTransferBlockSelect, the
+                                  // multilevel block is always the
+                                  // first, since only one block is selected.
+  for (unsigned int level=0;level<mg_dof_handler.get_tria().n_levels();++level)
+    for (IT i= copy_indices[selected_block][level].begin();
+        i != copy_indices[selected_block][level].end();++i)
+      dst[level](i->second) = src(i->first);
+}
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferBlockSelect<number>::copy_from_mg (
+  const MGDoFHandler<dim>&              mg_dof_handler,
+  BlockVector<number2>&                 dst,
+  const MGLevelObject<Vector<number> >& src) const
+{
+  for (unsigned int level=0;level<mg_dof_handler.get_tria().n_levels();++level)
+    for (IT i= copy_indices[selected_block][level].begin();
+        i != copy_indices[selected_block][level].end();++i)
+      dst.block(selected_block)(i->first) = src[level](i->second);
+}
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferBlockSelect<number>::copy_from_mg (
+  const MGDoFHandler<dim>&              mg_dof_handler,
+  Vector<number2>&                      dst,
+  const MGLevelObject<Vector<number> >& src) const
+{
+  for (unsigned int level=0;level<mg_dof_handler.get_tria().n_levels();++level)
+    for (IT i= copy_indices[selected_block][level].begin();
+        i != copy_indices[selected_block][level].end();++i)
+      dst(i->first) = src[level](i->second);
+}
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferBlockSelect<number>::copy_from_mg_add (
+  const MGDoFHandler<dim>&              mg_dof_handler,
+  BlockVector<number2>&                 dst,
+  const MGLevelObject<Vector<number> >& src) const
+{
+  for (unsigned int level=0;level<mg_dof_handler.get_tria().n_levels();++level)
+    for (IT i= copy_indices[selected_block][level].begin();
+        i != copy_indices[selected_block][level].end();++i)
+      dst.block(selected_block)(i->first) = src[level](i->second);
+}
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferBlockSelect<number>::copy_from_mg_add (
+  const MGDoFHandler<dim>&              mg_dof_handler,
+  Vector<number2>&                      dst,
+  const MGLevelObject<Vector<number> >& src) const
+{
+  for (unsigned int level=0;level<mg_dof_handler.get_tria().n_levels();++level)
+    for (IT i= copy_indices[selected_block][level].begin();
+        i != copy_indices[selected_block][level].end();++i)
+      dst(i->first) += src[level](i->second);
+}
+
+
+
+template <typename number>
+unsigned int
+MGTransferBlockSelect<number>::memory_consumption () const
+{
+  return sizeof(int) + MGTransferBlockBase::memory_consumption();
+}
+
+
+/* --------------------- MGTransferBlock -------------- */
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferBlock<number>::copy_to_mg (
+  const MGDoFHandler<dim>& mg_dof_handler,
+  MGLevelObject<BlockVector<number> >& dst,
+  const BlockVector<number2>& src) const
+{
+  for (unsigned int block=0;block<selected.size();++block)
+    if (selected[block])
+      for (unsigned int level=0;level<mg_dof_handler.get_tria().n_levels();++level)
+       for (IT i= copy_indices[block][level].begin();
+            i != copy_indices[block][level].end();++i)
+         dst[level].block(mg_block[block])(i->second) = src.block(block)(i->first);
+}
+
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferBlock<number>::copy_from_mg (
+  const MGDoFHandler<dim>& mg_dof_handler,
+  BlockVector<number2>& dst,
+  const MGLevelObject<BlockVector<number> >& src) const
+{
+  for (unsigned int block=0;block<selected.size();++block)
+    if (selected[block])
+      for (unsigned int level=0;level<mg_dof_handler.get_tria().n_levels();++level)
+       for (IT i= copy_indices[block][level].begin();
+            i != copy_indices[block][level].end();++i)
+         dst.block(block)(i->first) = src[level].block(mg_block[block])(i->second);
+}
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferBlock<number>::copy_from_mg_add (
+  const MGDoFHandler<dim>& mg_dof_handler,
+  BlockVector<number2>& dst,
+  const MGLevelObject<BlockVector<number> >& src) const
+{
+  for (unsigned int block=0;block<selected.size();++block)
+    if (selected[block])
+      for (unsigned int level=0;level<mg_dof_handler.get_tria().n_levels();++level)
+       for (IT i= copy_indices[block][level].begin();
+            i != copy_indices[block][level].end();++i)
+         dst.block(block)(i->first) += src[level].block(mg_block[block])(i->second);
+}
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
diff --git a/deal.II/deal.II/include/multigrid/mg_transfer_component.h b/deal.II/deal.II/include/multigrid/mg_transfer_component.h
new file mode 100644 (file)
index 0000000..a4b66e5
--- /dev/null
@@ -0,0 +1,405 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+#ifndef __deal2__mg_transfer_component_h
+#define __deal2__mg_transfer_component_h
+
+#include <base/config.h>
+
+#include <lac/block_vector.h>
+#ifdef DEAL_PREFER_MATRIX_EZ
+#  include <lac/sparse_matrix_ez.h>
+#  include <lac/block_sparse_matrix_ez.h>
+#else
+#  include <lac/sparsity_pattern.h>
+#  include <lac/block_sparsity_pattern.h>
+#endif
+#include <lac/vector_memory.h>
+
+#include <multigrid/mg_base.h>
+#include <multigrid/mg_level_object.h>
+
+
+
+#include <dofs/dof_handler.h>
+
+#include <boost/shared_ptr.hpp>
+
+
+DEAL_II_NAMESPACE_OPEN
+
+
+template <int dim> class MGDoFHandler;
+
+/*
+ * MGTransferBase is defined in mg_base.h
+ */
+
+/*!@addtogroup mg */
+/*@{*/
+
+/**
+ * Implementation of matrix generation for component wise multigrid transfer.
+ *
+ * @note MGTransferBlockBase is probably the more logical
+ * class. Still eventually, a class should be developed allowing to
+ * select multiple components.
+ *
+ * @author Guido Kanschat, 2001-2003
+ */
+class MGTransferComponentBase
+{
+  public:
+                                    /**
+                                     * Memory used by this object.
+                                     */
+    unsigned int memory_consumption () const;
+    
+
+  protected:  
+                                    /**
+                                     * Actually build the prolongation
+                                     * matrices for each level.
+                                     *
+                                     * This function is only called
+                                     * by derived classes. These can
+                                     * also set the member variables
+                                     * #selected and #mg_selected to
+                                     * restrict the transfer matrices
+                                     * to certain components.
+                                     * Furthermore, they use
+                                     * #target_component and
+                                     * #mg_target_component for
+                                     * re-ordering and grouping of
+                                     * components.
+                                     */
+    template <int dim>
+    void build_matrices (const DoFHandler<dim>& dof,
+                        const MGDoFHandler<dim>& mg_dof);
+
+                                  /**
+                                   * Flag of selected components.
+                                   *
+                                   * The transfer operators only act
+                                   * on the components having a
+                                   * <tt>true</tt> entry here. If
+                                   * renumbering by
+                                   * #target_component is used,
+                                   * this refers to the
+                                   * <b>renumbered</b> components.
+                                   */
+    std::vector<bool> selected;
+
+                                  /**
+                                   * Flag of selected components.
+                                   *
+                                   * The transfer operators only act
+                                   * on the components having a
+                                   * <tt>true</tt> entry here. If
+                                   * renumbering by
+                                   * #mg_target_component is used,
+                                   * this refers to the
+                                   * <b>renumbered</b> components.
+                                   */
+    std::vector<bool> mg_selected;
+
+                                    /**
+                                     * Target component of the
+                                     * fine-level vector if
+                                     * renumbering is required.
+                                     */
+    std::vector<unsigned int> target_component;
+    
+                                    /**
+                                     * Target component if
+                                     * renumbering of level vectors
+                                     * is required.
+                                     */
+    std::vector<unsigned int> mg_target_component;
+    
+                                  /**
+                                   * Sizes of the multi-level vectors.
+                                   */
+    mutable std::vector<std::vector<unsigned int> > sizes;
+  
+                                  /**
+                                   * Start index of each component.
+                                   */
+    std::vector<unsigned int> component_start;
+  
+                                  /**
+                                   * Start index of each component on
+                                   * all levels.
+                                   */
+    std::vector<std::vector<unsigned int> > mg_component_start;
+    
+                                    /**
+                                     * Call build_matrices()
+                                     * function first.
+                                     */
+    DeclException0(ExcMatricesNotBuilt);
+    
+  private:
+    std::vector<boost::shared_ptr<BlockSparsityPattern> >   prolongation_sparsities;
+    
+  protected:
+    
+                                    /**
+                                     * The actual prolongation matrix.
+                                     * column indices belong to the
+                                     * dof indices of the mother cell,
+                                     * i.e. the coarse level.
+                                     * while row indices belong to the
+                                     * child cell, i.e. the fine level.
+                                     */
+    std::vector<boost::shared_ptr<BlockSparseMatrix<double> > > prolongation_matrices;
+    
+                                    /**
+                                     * Unused now, but intended to
+                                     * hold the mapping for the
+                                     * <tt>copy_to/from_mg</tt>-functions.
+                                     */
+    std::vector<std::map<unsigned int, unsigned int> >
+    copy_to_and_from_indices;
+};
+
+//TODO:[GK] Update documentation for copy_* functions
+
+/**
+ * Implementation of the MGTransferBase interface for block
+ * matrices and simple vectors. This class uses MGTransferComponentBase
+ * selecting a single component or grouping several components into a
+ * single block. The transfer operators themselves are implemented for
+ * Vector and BlockVector objects.
+ *
+ * See MGTransferBase to find out which of the transfer classes
+ * is best for your needs.
+ *
+ * @author Guido Kanschat, 2001, 2002, 2003
+ */
+template <typename number>
+class MGTransferSelect : public MGTransferBase<Vector<number> >,
+                        private MGTransferComponentBase
+{
+  public:
+                                    /**
+                                     * Destructor.
+                                     */
+    virtual ~MGTransferSelect ();
+    
+                                    /**
+                                     * Actually build the prolongation
+                                     * matrices for grouped components.
+                                     *
+                                     * This function is a front-end
+                                     * for the same function in
+                                     * MGTransferComponentBase.
+                                     *
+                                     * @arg selected: Number of the
+                                     * component of the global vector
+                                     * to be copied from and to the
+                                     * multilevel vector. This number
+                                     * refers to the renumbering by
+                                     * <tt>target_component</tt>.
+                                     *
+                                     * @arg mg_selected: Number
+                                     * of the component for which the
+                                     * transfer matrices should be
+                                     * built.
+                                     *
+                                     * If <tt>mg_target_component</tt> is
+                                     * present, this refers to the
+                                     * renumbered components.
+                                     *
+                                     * @arg target_component: this
+                                     * argument allows grouping and
+                                     * renumbering of components in
+                                     * the fine-level vector (see
+                                     * DoFRenumbering::component_wise).
+                                     * 
+                                     * @arg mg_target_component: this
+                                     * argument allows grouping and
+                                     * renumbering of components in
+                                     * the level vectors (see
+                                     * DoFRenumbering::component_wise). It
+                                     * also affects the behavior of
+                                     * the <tt>selected</tt> argument
+                                     */
+    template <int dim>
+    void build_matrices (const DoFHandler<dim> &dof,
+                        const MGDoFHandler<dim> &mg_dof,
+                        unsigned int selected,
+                        unsigned int mg_selected,
+                        const std::vector<unsigned int>& target_component
+                        = std::vector<unsigned int>(),
+                        const std::vector<unsigned int>& mg_target_component
+                        = std::vector<unsigned int>());
+
+                                    /**
+                                     * Change selected
+                                     * component. Handle with care!
+                                     */
+    void select (const unsigned int component,
+                const unsigned int mg_component = deal_II_numbers::invalid_unsigned_int);
+    
+    virtual void prolongate (const unsigned int    to_level,
+                            Vector<number>       &dst,
+                            const Vector<number> &src) const;
+
+    virtual void restrict_and_add (const unsigned int    from_level,
+                                  Vector<number>       &dst,
+                                  const Vector<number> &src) const;
+    
+                                    /**
+                                     * Transfer from a vector on the
+                                     * global grid to a multilevel vector.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
+               MGLevelObject<Vector<number> > &dst,
+               const Vector<number2>          &src) const;
+
+                                    /**
+                                     * Transfer from multilevel vector to
+                                     * normal vector.
+                                     *
+                                     * Copies data from active
+                                     * portions of an multilevel
+                                     * vector into the respective
+                                     * positions of a Vector.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_from_mg (const MGDoFHandler<dim>              &mg_dof,
+                 Vector<number2>                      &dst,
+                 const MGLevelObject<Vector<number> > &src) const;
+
+                                    /**
+                                     * Add a multi-level vector to a
+                                     * normal vector.
+                                     *
+                                     * Works as the previous
+                                     * function, but probably not for
+                                     * continuous elements.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof,
+                     Vector<number2>                      &dst,
+                     const MGLevelObject<Vector<number> > &src) const;
+
+                                    /**
+                                     * Transfer from a vector on the
+                                     * global grid to multilevel vectors.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
+               MGLevelObject<Vector<number> > &dst,
+               const BlockVector<number2>     &src) const;
+
+                                    /**
+                                     * Transfer from multilevel vector to
+                                     * normal vector.
+                                     *
+                                     * Copies data from active
+                                     * portions of a multilevel
+                                     * vector into the respective
+                                     * positions of a global
+                                     * BlockVector.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_from_mg (const MGDoFHandler<dim>              &mg_dof,
+                 BlockVector<number2>                 &dst,
+                 const MGLevelObject<Vector<number> > &src) const;
+
+                                    /**
+                                     * Add a multi-level vector to a
+                                     * normal vector.
+                                     *
+                                     * Works as the previous
+                                     * function, but probably not for
+                                     * continuous elements.
+                                     */
+    template <int dim, typename number2>
+    void
+    copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof,
+                     BlockVector<number2>                 &dst,
+                     const MGLevelObject<Vector<number> > &src) const;
+
+                                    /**
+                                     * Memory used by this object.
+                                     */
+    unsigned int memory_consumption () const;
+    
+  private:
+                                    /**
+                                     * Implementation of the public
+                                     * function.
+                                     */
+    template <int dim, class OutVector>
+    void
+    do_copy_from_mg (const MGDoFHandler<dim>              &mg_dof,
+                    OutVector                            &dst,
+                    const MGLevelObject<Vector<number> > &src,
+                    const unsigned int offset) const;
+
+                                    /**
+                                     * Implementation of the public
+                                     * function.
+                                     */
+    template <int dim, class OutVector>
+    void
+    do_copy_from_mg_add (const MGDoFHandler<dim>              &mg_dof,
+                        OutVector                            &dst,
+                        const MGLevelObject<Vector<number> > &src,
+                        const unsigned int offset) const;
+
+                                    /**
+                                     * Actual implementation of
+                                     * copy_to_mg().
+                                     */
+    template <int dim, class InVector>
+    void
+    do_copy_to_mg (const MGDoFHandler<dim>        &mg_dof,
+                  MGLevelObject<Vector<number> > &dst,
+                  const InVector                 &src,
+                  const unsigned int              offset) const;
+                                     /**
+                                      * Selected component of global vector.
+                                      */
+    unsigned int selected_component;
+                                     /**
+                                      * Selected component inside multigrid.
+                                      */
+    unsigned int mg_selected_component;
+};
+
+/*@}*/
+
+//---------------------------------------------------------------------------
+template <typename number>
+inline void
+MGTransferSelect<number>::select(const unsigned int component,
+                                const unsigned int mg_component)
+{
+  selected_component = component;
+  mg_selected_component = (mg_component == deal_II_numbers::invalid_unsigned_int)
+                         ? component
+                         : mg_component;
+}
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
diff --git a/deal.II/deal.II/include/multigrid/mg_transfer_component.templates.h b/deal.II/deal.II/include/multigrid/mg_transfer_component.templates.h
new file mode 100644 (file)
index 0000000..1c4667e
--- /dev/null
@@ -0,0 +1,335 @@
+//---------------------------------------------------------------------------
+//    mg_transfer.templates.h,v 1.22 2006/01/29 15:03:55 guido Exp
+//    Version: 
+//
+//    Copyright (C) 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+
+#ifndef __deal2__mg_transfer_component_templates_h
+#define __deal2__mg_transfer_component_templates_h
+
+#include <lac/sparse_matrix.h>
+#include <grid/tria_iterator.h>
+#include <fe/fe.h>
+#include <dofs/dof_constraints.h>
+#include <multigrid/mg_base.h>
+#include <multigrid/mg_dof_accessor.h>
+#include <multigrid/mg_tools.h>
+#include <multigrid/mg_transfer_component.h>
+
+#include <algorithm>
+
+DEAL_II_NAMESPACE_OPEN
+
+/* --------------------- MGTransferSelect -------------- */
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferSelect<number>::copy_to_mg (
+  const MGDoFHandler<dim>        &mg_dof_handler,
+  MGLevelObject<Vector<number> > &dst,
+  const BlockVector<number2>     &src) const
+{
+  do_copy_to_mg (mg_dof_handler, dst, src, 0);
+}
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferSelect<number>::copy_to_mg (
+  const MGDoFHandler<dim>        &mg_dof_handler,
+  MGLevelObject<Vector<number> > &dst,
+  const Vector<number2>          &src) const
+{
+  do_copy_to_mg (mg_dof_handler, dst, src, component_start[selected_component]);
+}
+
+
+
+template <typename number>
+template <int dim, class InVector>
+void
+MGTransferSelect<number>::do_copy_to_mg (
+  const MGDoFHandler<dim>&        mg_dof_handler,
+  MGLevelObject<Vector<number> >& dst,
+  const InVector&                 src,
+  const unsigned int              offset) const
+{
+  const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+  
+  const unsigned int dofs_per_cell = fe.dofs_per_cell;
+  
+                                  // set the elements of the vectors
+                                  // on all levels to zero
+  unsigned int minlevel = dst.get_minlevel();
+  unsigned int maxlevel = dst.get_maxlevel();
+  
+  dst=0;
+  
+  Assert(sizes.size()==mg_dof_handler.get_tria().n_levels(),
+        ExcMatricesNotBuilt());
+
+  MGTools::reinit_vector_by_components(
+    mg_dof_handler, dst, mg_selected, mg_target_component, sizes);
+  
+  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
+  std::vector<unsigned int> level_dof_indices  (dofs_per_cell);
+  
+                                  // Build a vector of the selected
+                                  // indices, since traversing all
+                                  // indices on each cell is too
+                                  // slow.
+  std::vector<unsigned int> selected_indices;
+  selected_indices.reserve(dofs_per_cell);
+  for (unsigned int i=0; i<dofs_per_cell; ++i)
+    if (mg_selected[mg_target_component[fe.system_to_component_index(i).first]])
+      selected_indices.push_back(i);
+  unsigned int selected_component
+    = mg_target_component[fe.system_to_component_index(selected_indices[0]).first];
+
+                                  // traverse the grid top-down
+                                  // (i.e. starting with the most
+                                  // refined grid). this way, we can
+                                  // always get that part of one
+                                  // level of the output vector which
+                                  // corresponds to a region which is
+                                  // more refined, by restriction of
+                                  // the respective vector on the
+                                  // next finer level, which we then
+                                  // already have built.
+  for (int level=maxlevel; level>=static_cast<signed int>(minlevel); --level)
+    {
+
+  typename MGDoFHandler<dim>::active_cell_iterator
+       level_cell = mg_dof_handler.begin_active(level);
+      const typename MGDoFHandler<dim>::active_cell_iterator
+       level_end  = mg_dof_handler.end_active(level);
+                                      // Compute coarse level right hand side
+                                      // by restricting from fine level.
+      for (; level_cell!=level_end; ++level_cell)
+       {
+                                          // get the dof numbers of
+                                          // this cell for the global
+                                          // and the level-wise
+                                          // numbering
+         level_cell->get_dof_indices(global_dof_indices);
+         level_cell->get_mg_dof_indices (level_dof_indices);
+
+                                          // transfer the global
+                                          // defect in the vector
+                                          // into the level-wise one
+         const unsigned int level_start
+           = mg_component_start[level][selected_component];
+         const typename std::vector<unsigned int>::const_iterator
+           end = selected_indices.end();
+         
+         for (typename std::vector<unsigned int>::const_iterator
+                i=selected_indices.begin();
+              i != end; ++i)
+           {
+             dst[level](level_dof_indices[*i] - level_start)
+               = src(global_dof_indices[*i] - offset);
+           }
+       }
+
+                                      // for that part of the level
+                                      // which is further refined:
+                                      // get the defect by
+                                      // restriction of the defect on
+                                      // one level higher
+      if (static_cast<unsigned int>(level) < maxlevel)
+       {
+         restrict_and_add (level+1, dst[level], dst[level+1]);
+       }
+    };
+}
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferSelect<number>::copy_from_mg (
+  const MGDoFHandler<dim>&              mg_dof_handler,
+  BlockVector<number2>&                 dst,
+  const MGLevelObject<Vector<number> >& src) const
+{
+  do_copy_from_mg (mg_dof_handler, dst, src, 0);
+}
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferSelect<number>::copy_from_mg (
+  const MGDoFHandler<dim>&              mg_dof_handler,
+  Vector<number2>&                      dst,
+  const MGLevelObject<Vector<number> >& src) const
+{
+  do_copy_from_mg (mg_dof_handler, dst, src,
+                  component_start[selected_component]);
+}
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferSelect<number>::copy_from_mg_add (
+  const MGDoFHandler<dim>&              mg_dof_handler,
+  BlockVector<number2>&                 dst,
+  const MGLevelObject<Vector<number> >& src) const
+{
+  do_copy_from_mg_add (mg_dof_handler, dst, src, 0);
+}
+
+
+
+template <typename number>
+template <int dim, typename number2>
+void
+MGTransferSelect<number>::copy_from_mg_add (
+  const MGDoFHandler<dim>&              mg_dof_handler,
+  Vector<number2>&                      dst,
+  const MGLevelObject<Vector<number> >& src) const
+{
+  do_copy_from_mg_add (mg_dof_handler, dst, src,
+                      component_start[selected_component]);
+}
+
+
+
+template <typename number>
+template <int dim, class OutVector>
+void
+MGTransferSelect<number>::do_copy_from_mg (
+  const MGDoFHandler<dim>              &mg_dof_handler,
+  OutVector                            &dst,
+  const MGLevelObject<Vector<number> > &src,
+  const unsigned int offset) const
+{
+  const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+  
+  const unsigned int dofs_per_cell = fe.dofs_per_cell;
+  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
+  std::vector<unsigned int> level_dof_indices (dofs_per_cell);
+
+  typename MGDoFHandler<dim>::active_cell_iterator
+    level_cell = mg_dof_handler.begin_active();
+  const typename MGDoFHandler<dim>::active_cell_iterator
+    endc = mg_dof_handler.end();
+
+                                  // traverse all cells and copy the
+                                  // data appropriately to the output
+                                  // vector
+
+                                  // Note that the level is
+                                  // monotonuosly increasing
+  for (; level_cell != endc; ++level_cell)
+    {
+      const unsigned int level = level_cell->level();
+
+                                      // get the dof numbers of
+                                      // this cell for the global
+                                      // and the level-wise
+                                      // numbering
+      level_cell->get_dof_indices (global_dof_indices);
+      level_cell->get_mg_dof_indices(level_dof_indices);
+
+                                      // copy level-wise data to
+                                      // global vector
+      for (unsigned int i=0; i<dofs_per_cell; ++i)
+       {
+         const unsigned int component
+           = mg_target_component[fe.system_to_component_index(i).first];
+       if (mg_selected[component])
+         {
+           const unsigned int level_start
+             = mg_component_start[level][component];
+           dst(global_dof_indices[i] - offset)
+             = src[level](level_dof_indices[i]-level_start);
+         }
+       }
+    }
+}
+
+
+
+template <typename number>
+template <int dim, class OutVector>
+void
+MGTransferSelect<number>::do_copy_from_mg_add (
+  const MGDoFHandler<dim>              &mg_dof_handler,
+  OutVector                            &dst,
+  const MGLevelObject<Vector<number> > &src,
+  const unsigned int offset) const
+{
+  const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+  const unsigned int dofs_per_cell = fe.dofs_per_cell;
+
+  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
+  std::vector<unsigned int> level_dof_indices (dofs_per_cell);
+
+  typename MGDoFHandler<dim>::active_cell_iterator
+    level_cell = mg_dof_handler.begin_active();
+  const typename MGDoFHandler<dim>::active_cell_iterator
+    endc = mg_dof_handler.end();
+
+                                  // traverse all cells and copy the
+                                  // data appropriately to the output
+                                  // vector
+
+                                  // Note that the level is
+                                  // monotonuosly increasing
+  for (; level_cell != endc; ++level_cell)
+    {
+      const unsigned int level = level_cell->level();
+
+                                      // get the dof numbers of
+                                      // this cell for the global
+                                      // and the level-wise
+                                      // numbering
+      level_cell->get_dof_indices (global_dof_indices);
+      level_cell->get_mg_dof_indices(level_dof_indices);
+                                      // copy level-wise data to
+                                      // global vector
+      for (unsigned int i=0; i<dofs_per_cell; ++i)
+       {
+         const unsigned int component
+           = mg_target_component[fe.system_to_component_index(i).first];
+         if (mg_selected[component])
+           {
+             const unsigned int level_start
+               = mg_component_start[level][component];
+             dst(global_dof_indices[i] - offset)
+               += src[level](level_dof_indices[i] - level_start);
+           }
+       }
+    }
+}
+
+
+template <typename number>
+unsigned int
+MGTransferSelect<number>::memory_consumption () const
+{
+  return sizeof(int) + MGTransferComponentBase::memory_consumption();
+}
+
+
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
index ff6badc4abcc415b56416f3272fa0d13e53ef8c7..4c5f2009e2f6808db278083070c02246985f32c3 100644 (file)
@@ -30,6 +30,7 @@
 #include <dofs/dof_tools.h>
 #include <fe/fe.h>
 
+#include <iostream>
 #include <vector>
 #include <algorithm>
 #include <numeric>
@@ -1030,10 +1031,13 @@ MGTools::count_dofs_per_block (
   const unsigned int n_blocks = fe.n_blocks();
   const unsigned int n_levels = dof_handler.get_tria().n_levels();
   
-  dofs_per_block.resize (n_levels, std::vector<unsigned int>(n_blocks));
-  for (unsigned int l=0;l<n_levels;++l)
-    std::fill (dofs_per_block[l].begin(), dofs_per_block[l].end(), 0U);
+  dofs_per_block.resize (n_levels);
   
+  for (unsigned int l=0;l<n_levels;++l)
+    {
+      dofs_per_block[l].resize(n_blocks);
+      std::fill (dofs_per_block[l].begin(), dofs_per_block[l].end(), 0U);
+    }
                                   // If the empty vector was given as
                                   // default argument, set up this
                                   // vector as identity.
@@ -1308,9 +1312,30 @@ MGTools::reinit_vector (const MGDoFHandler<dim> &mg_dof,
 template<int dim, typename number>
 void
 MGTools::reinit_vector (const MGDoFHandler<dim> &mg_dof,
-                        MGLevelObject<BlockVector<number> > &v,
-                        const std::vector<bool> &sel,
-                       const std::vector<unsigned int> &target_comp)
+                       MGLevelObject<BlockVector<number> > &v)
+{
+  const unsigned int n_blocks = mg_dof.get_fe().n_blocks();
+  std::vector<std::vector<unsigned int> >
+    ndofs(mg_dof.get_tria().n_levels(),
+         std::vector<unsigned int>(n_blocks));
+  count_dofs_per_block (mg_dof, ndofs);
+  
+  for (unsigned int level=v.get_minlevel();
+       level<=v.get_maxlevel();++level)
+    {
+      v[level].reinit(ndofs[level]);
+    }
+}
+
+
+template<int dim, typename number>
+void
+MGTools::reinit_vector_by_components (
+  const MGDoFHandler<dim> &mg_dof,
+  MGLevelObject<BlockVector<number> > &v,
+  const std::vector<bool> &sel,
+  const std::vector<unsigned int> &target_comp,
+  std::vector<std::vector<unsigned int> >& ndofs)
 {
   std::vector<bool> selected=sel;
   std::vector<unsigned int> target_component=target_comp;
@@ -1351,11 +1376,14 @@ MGTools::reinit_vector (const MGDoFHandler<dim> &mg_dof,
                      selected.end(),
                      0U);
   
-  std::vector<std::vector<unsigned int> >
-    ndofs(mg_dof.get_tria().n_levels(),
-         std::vector<unsigned int>(target_component.size()));
-
-  count_dofs_per_component (mg_dof, ndofs, true, target_component);
+  if (ndofs.size() == 0)
+    {
+      std::vector<std::vector<unsigned int> >
+       new_dofs(mg_dof.get_tria().n_levels(),
+                std::vector<unsigned int>(target_component.size()));
+      std::swap(ndofs, new_dofs);
+      count_dofs_per_component (mg_dof, ndofs, true, target_component);
+    }
   
   for (unsigned int level=v.get_minlevel();
        level<=v.get_maxlevel();++level)
@@ -1376,11 +1404,12 @@ MGTools::reinit_vector (const MGDoFHandler<dim> &mg_dof,
 
 template<int dim, typename number>
 void
-MGTools::reinit_vector (const MGDoFHandler<dim> &mg_dof,
-                        MGLevelObject<Vector<number> > &v,
-                        const std::vector<bool> &selected,
-                       const std::vector<unsigned int> &target_component,
-                       std::vector<std::vector<unsigned int> >& ndofs)
+MGTools::reinit_vector_by_components (
+  const MGDoFHandler<dim> &mg_dof,
+  MGLevelObject<Vector<number> > &v,
+  const std::vector<bool> &selected,
+  const std::vector<unsigned int> &target_component,
+  std::vector<std::vector<unsigned int> >& ndofs)
 {
   Assert (selected.size() == target_component.size(),
          ExcDimensionMismatch(selected.size(), target_component.size()));
@@ -1415,6 +1444,85 @@ MGTools::reinit_vector (const MGDoFHandler<dim> &mg_dof,
 }
 
 
+template<int dim, typename number>
+void
+MGTools::reinit_vector_by_blocks (
+  const MGDoFHandler<dim> &mg_dof,
+  MGLevelObject<BlockVector<number> > &v,
+  const std::vector<bool> &sel,
+  std::vector<std::vector<unsigned int> >& ndofs)
+{
+  std::vector<bool> selected=sel;
+                                  // Compute the number of blocks needed
+  const unsigned int n_selected
+    = std::accumulate(selected.begin(),
+                     selected.end(),
+                     0U);
+  
+  if (ndofs.size() == 0)
+    {
+      std::vector<std::vector<unsigned int> >
+       new_dofs(mg_dof.get_tria().n_levels(),
+                std::vector<unsigned int>(selected.size()));
+      std::swap(ndofs, new_dofs);
+      count_dofs_per_block (mg_dof, ndofs);
+    }
+  
+  for (unsigned int level=v.get_minlevel();
+       level<=v.get_maxlevel();++level)
+    {
+      v[level].reinit(n_selected, 0);
+      unsigned int k=0;
+      for (unsigned int i=0;i<selected.size() && (k<v[level].n_blocks());++i)
+       {
+         if (selected[i])
+           {
+             v[level].block(k++).reinit(ndofs[level][i]);
+           }
+         v[level].collect_sizes();
+       }
+    }
+}
+
+
+template<int dim, typename number>
+void
+MGTools::reinit_vector_by_blocks (
+  const MGDoFHandler<dim> &mg_dof,
+  MGLevelObject<Vector<number> > &v,
+  const std::vector<bool> &selected,
+  std::vector<std::vector<unsigned int> >& ndofs)
+{
+                                  // Compute the number of blocks needed
+#ifdef DEBUG
+  const unsigned int n_selected
+    = std::accumulate(selected.begin(),
+                     selected.end(),
+                     0U);
+  Assert(n_selected == 1, ExcDimensionMismatch(n_selected, 1));
+#endif
+  
+  unsigned int selected_block = 0;
+  while (!selected[selected_block])
+    ++selected_block;
+
+  if (ndofs.size() == 0)
+    {
+      std::vector<std::vector<unsigned int> >
+       new_dofs(mg_dof.get_tria().n_levels(),
+                std::vector<unsigned int>(selected.size()));
+      std::swap(ndofs, new_dofs);
+      count_dofs_per_block (mg_dof, ndofs);
+    }
+  
+  for (unsigned int level=v.get_minlevel();
+       level<=v.get_maxlevel();++level)
+    {
+      v[level].reinit(ndofs[level][selected_block]);
+    }
+}
+
+
 DEAL_II_NAMESPACE_CLOSE
 
 
@@ -1460,29 +1568,60 @@ template void MGTools::reinit_vector<deal_II_dimension> (
   MGLevelObject<Vector<float> >&);
 
 template void MGTools::reinit_vector<deal_II_dimension> (
+  const MGDoFHandler<deal_II_dimension>&,
+  MGLevelObject<BlockVector<double> >&);
+template void MGTools::reinit_vector<deal_II_dimension> (
+  const MGDoFHandler<deal_II_dimension>&,
+  MGLevelObject<BlockVector<float> >&);
+
+template void MGTools::reinit_vector_by_components<deal_II_dimension> (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<BlockVector<double> >&,
   const std::vector<bool> &,
-  const std::vector<unsigned int> &);
-template void MGTools::reinit_vector<deal_II_dimension> (
+  const std::vector<unsigned int> &,
+  std::vector<std::vector<unsigned int> >&);
+template void MGTools::reinit_vector_by_components<deal_II_dimension> (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<BlockVector<float> >&,
   const std::vector<bool> &,
-  const std::vector<unsigned int> &);
+  const std::vector<unsigned int> &,
+  std::vector<std::vector<unsigned int> >&);
 
-template void MGTools::reinit_vector<deal_II_dimension> (
+template void MGTools::reinit_vector_by_components<deal_II_dimension> (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<Vector<double> >&,
   const std::vector<bool>&,
   const std::vector<unsigned int>&,
   std::vector<std::vector<unsigned int> >&);
-template void MGTools::reinit_vector<deal_II_dimension> (
+template void MGTools::reinit_vector_by_components<deal_II_dimension> (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<Vector<float> >&,
   const std::vector<bool>&,
   const std::vector<unsigned int>&,
   std::vector<std::vector<unsigned int> >&);
 
+template void MGTools::reinit_vector_by_blocks<deal_II_dimension> (
+  const MGDoFHandler<deal_II_dimension>&,
+  MGLevelObject<BlockVector<double> >&,
+  const std::vector<bool> &,
+  std::vector<std::vector<unsigned int> >&);
+template void MGTools::reinit_vector_by_blocks<deal_II_dimension> (
+  const MGDoFHandler<deal_II_dimension>&,
+  MGLevelObject<BlockVector<float> >&,
+  const std::vector<bool> &,
+  std::vector<std::vector<unsigned int> >&);
+
+template void MGTools::reinit_vector_by_blocks<deal_II_dimension> (
+  const MGDoFHandler<deal_II_dimension>&,
+  MGLevelObject<Vector<double> >&,
+  const std::vector<bool>&,
+  std::vector<std::vector<unsigned int> >&);
+template void MGTools::reinit_vector_by_blocks<deal_II_dimension> (
+  const MGDoFHandler<deal_II_dimension>&,
+  MGLevelObject<Vector<float> >&,
+  const std::vector<bool>&,
+  std::vector<std::vector<unsigned int> >&);
+
 
 template void MGTools::count_dofs_per_component<deal_II_dimension> (
   const MGDoFHandler<deal_II_dimension>&,
index c3a782ca01cfb6ec2c0e9d0d61c322720d1d70c4..9ff04129f65926f53d7f3987b51c84a1a7a6e8c3 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 2003, 2004, 2005, 2006, 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
 #include <fe/fe.h>
 #include <multigrid/mg_dof_handler.h>
 #include <multigrid/mg_dof_accessor.h>
-#include <multigrid/mg_transfer.h>
-#include <multigrid/mg_transfer.templates.h>
+#include <multigrid/mg_transfer_block.h>
+#include <multigrid/mg_transfer_block.templates.h>
 #include <multigrid/mg_tools.h>
 
 #include <algorithm>
+#include <iostream>
 
 DEAL_II_NAMESPACE_OPEN
 
@@ -38,101 +39,66 @@ void MGTransferBlockBase::build_matrices (
   const DoFHandler<dim>&,
   const MGDoFHandler<dim>& mg_dof)
 {
-                                  // Fill target component with
-                                  // standard values (identity) if it
-                                  // is empty
-  if (target_component.size() == 0)
-    {
-      target_component.resize(mg_dof.get_fe().n_components());
-      for (unsigned int i=0;i<target_component.size();++i)
-       target_component[i] = i;
-    } else {
-                                      // otherwise, check it for consistency
-      Assert (target_component.size() == mg_dof.get_fe().n_components(),
-             ExcDimensionMismatch(target_component.size(),
-                                  mg_dof.get_fe().n_components()));
-      
-      for (unsigned int i=0;i<target_component.size();++i)
-       {
-         Assert(i<target_component.size(),
-                ExcIndexRange(i,0,target_component.size()));
-       }
-    }
-                                  // Do the same for the multilevel
-                                  // components. These may be
-                                  // different.
-  if (mg_target_component.size() == 0)
-    {
-      mg_target_component.resize(mg_dof.get_fe().n_components());
-      for (unsigned int i=0;i<mg_target_component.size();++i)
-       mg_target_component[i] = target_component[i];
-    } else {
-      Assert (mg_target_component.size() == mg_dof.get_fe().n_components(),
-             ExcDimensionMismatch(mg_target_component.size(),
-                                  mg_dof.get_fe().n_components()));
-      
-      for (unsigned int i=0;i<mg_target_component.size();++i)
-       {
-         Assert(i<mg_target_component.size(),
-                ExcIndexRange(i,0,mg_target_component.size()));
-       }
-    }
-  
   const FiniteElement<dim>& fe = mg_dof.get_fe();
-
-                                  // Effective number of components
-                                  // is the maximum entry in
-                                  // mg_target_component. This
-                                  // assumes that the values in that
-                                  // vector don't have holes.
-  const unsigned int n_components  =
-    *std::max_element(mg_target_component.begin(), mg_target_component.end()) + 1;
+  const unsigned int n_blocks  = fe.n_blocks();
   const unsigned int dofs_per_cell = fe.dofs_per_cell;
   const unsigned int n_levels      = mg_dof.get_tria().n_levels();
   
-  Assert (mg_selected.size() == fe.n_components(),
-         ExcDimensionMismatch(mg_selected.size(), fe.n_components()));
+  Assert (selected.size() == n_blocks,
+         ExcDimensionMismatch(selected.size(), n_blocks));
   
+                                  // Compute the mapping between real
+                                  // blocks and blocks used for
+                                  // multigrid computations.
+  mg_block.resize(n_blocks);
+  if (true)
+    {
+      unsigned int k=0;
+      for (unsigned int i=0;i<n_blocks;++i)
+       if (selected[i])
+         mg_block[i] = k++;
+       else
+         mg_block[i] = deal_II_numbers::invalid_unsigned_int;
+    }
                                   // Compute the lengths of all blocks
   sizes.resize(n_levels);
-  MGTools::count_dofs_per_component(mg_dof, sizes, true, mg_target_component);
-
+  MGTools::count_dofs_per_block(mg_dof, sizes);
+  
                                   // Fill some index vectors
                                   // for later use.
-  mg_component_start = sizes;
+  mg_block_start = sizes;
                                   // Compute start indices from sizes
-  for (unsigned int l=0;l<mg_component_start.size();++l)
+  for (unsigned int l=0;l<mg_block_start.size();++l)
     {
       unsigned int k=0;
-      for (unsigned int i=0;i<mg_component_start[l].size();++i)
+      for (unsigned int i=0;i<mg_block_start[l].size();++i)
        {
-         const unsigned int t=mg_component_start[l][i];
-         mg_component_start[l][i] = k;
+         const unsigned int t=mg_block_start[l][i];
+         mg_block_start[l][i] = k;
          k += t;
        }
     }
-
-  component_start.resize(target_component.size());
-  DoFTools::
-    count_dofs_per_component (static_cast<const DoFHandler<dim>&>(mg_dof),
-                              component_start, true, target_component);
+  
+  block_start.resize(n_blocks);
+  DoFTools::count_dofs_per_block (static_cast<const DoFHandler<dim>&>(mg_dof), block_start);
 
   unsigned int k=0;
-  for (unsigned int i=0;i<component_start.size();++i)
+  for (unsigned int i=0;i<block_start.size();++i)
     {
-      const unsigned int t=component_start[i];
-      component_start[i] = k;
+      const unsigned int t=block_start[i];
+      block_start[i] = k;
       k += t;
     }
-
                                   // Build index vectors for
                                   // copy_to_mg and
                                   // copy_from_mg. These vectors must
                                   // be prebuilt, since the
                                   // get_dof_indices functions are
                                   // too slow
-
-  copy_to_and_from_indices.resize(n_levels);
+  copy_indices.resize(n_blocks);
+  for (unsigned int block=0;block<n_blocks;++block)
+    if (selected[block])
+      copy_indices[block].resize(n_levels);
   
 // Building the prolongation matrices starts here!
   
@@ -180,9 +146,9 @@ void MGTransferBlockBase::build_matrices (
                                       // is necessary. this, is the
                                       // number of degrees of freedom
                                       // per cell
-      prolongation_sparsities[level]->reinit (n_components, n_components);
-      for (unsigned int i=0; i<n_components; ++i)
-       for (unsigned int j=0; j<n_components; ++j)
+      prolongation_sparsities[level]->reinit (n_blocks, n_blocks);
+      for (unsigned int i=0; i<n_blocks; ++i)
+       for (unsigned int j=0; j<n_blocks; ++j)
          if (i==j)
            prolongation_sparsities[level]->block(i,j)
              .reinit(sizes[level+1][i],
@@ -220,10 +186,10 @@ void MGTransferBlockBase::build_matrices (
                    if (prolongation(i,j) != 0)
                      {
                        const unsigned int icomp
-                         = fe.system_to_component_index(i).first;
+                         = fe.system_to_block_index(i).first;
                        const unsigned int jcomp
-                         = fe.system_to_component_index(j).first;
-                       if ((icomp==jcomp) && mg_selected[mg_target_component[icomp]])
+                         = fe.system_to_block_index(j).first;
+                       if ((icomp==jcomp) && selected[icomp])
                          prolongation_sparsities[level]->add(dof_indices_child[i],
                                                              dof_indices_parent[j]);
                      };
@@ -255,9 +221,9 @@ void MGTransferBlockBase::build_matrices (
                  for (unsigned int j=0; j<dofs_per_cell; ++j)
                    if (prolongation(i,j) != 0)
                      {
-                       const unsigned int icomp = fe.system_to_component_index(i).first;
-                       const unsigned int jcomp = fe.system_to_component_index(j).first;
-                       if ((icomp==jcomp) && mg_selected[mg_target_component[icomp]])
+                       const unsigned int icomp = fe.system_to_block_index(i).first;
+                       const unsigned int jcomp = fe.system_to_block_index(j).first;
+                       if ((icomp==jcomp) && selected[icomp])
                          prolongation_matrices[level]->set(dof_indices_child[i],
                                                            dof_indices_parent[j],
                                                            prolongation(i,j));
@@ -268,71 +234,79 @@ void MGTransferBlockBase::build_matrices (
 }
 
 
+
 template <typename number>
 template <int dim>
-void MGTransferBlock<number>::build_matrices (
+void MGTransferBlockSelect<number>::build_matrices (
   const DoFHandler<dim> &dof,
   const MGDoFHandler<dim> &mg_dof,
-  const std::vector<unsigned int>& t_component,
-  const std::vector<unsigned int>& mg_t_component)
+  unsigned int select)
 {
-  if (selected.size() == 0)
-    selected = std::vector<bool> (mg_dof.get_fe().n_components(), true);
-  if (mg_selected.size() == 0)
-    mg_selected = std::vector<bool> (mg_dof.get_fe().n_components(), true);
-
-  target_component = t_component;
-  mg_target_component = mg_t_component;
-
+  const FiniteElement<dim>& fe = mg_dof.get_fe();
+  unsigned int n_blocks = mg_dof.get_fe().n_blocks();
+  
+  selected_block = select;
+  selected.resize(n_blocks, false);
+  selected[select] = true;
+  
   MGTransferBlockBase::build_matrices (dof, mg_dof);
+  
+  std::vector<unsigned int> global_dof_indices (fe.dofs_per_cell);
+  std::vector<unsigned int> level_dof_indices  (fe.dofs_per_cell);
+  for (int level=dof.get_tria().n_levels()-1; level>=0; --level)
+    {
+      typename MGDoFHandler<dim>::active_cell_iterator
+       level_cell = mg_dof.begin_active(level);
+      const typename MGDoFHandler<dim>::active_cell_iterator
+       level_end  = mg_dof.end_active(level);
+      
+                                      // Compute coarse level right hand side
+                                      // by restricting from fine level.
+      for (; level_cell!=level_end; ++level_cell)
+       {
+         DoFObjectAccessor<dim, DoFHandler<dim> >& 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<fe.dofs_per_cell; ++i)
+           {
+             const unsigned int block = fe.system_to_block_index(i).first;
+             if (selected[block])
+               copy_indices[block][level].insert(
+                 std::make_pair(global_dof_indices[i] - block_start[block],
+                                level_dof_indices[i] - mg_block_start[level][block]));
+           }
+       }
+    }
 }
 
 
+
+
 template <typename number>
 template <int dim>
-void MGTransferSelect<number>::build_matrices (
+void MGTransferBlock<number>::build_matrices (
   const DoFHandler<dim> &dof,
   const MGDoFHandler<dim> &mg_dof,
-  unsigned int select,
-  unsigned int mg_select,
-  const std::vector<unsigned int>& t_component,
-  const std::vector<unsigned int>& mg_t_component)
+  const std::vector<bool>& sel)
 {
   const FiniteElement<dim>& fe = mg_dof.get_fe();
-  unsigned int ncomp = mg_dof.get_fe().n_components();
-  
-  target_component = t_component;
-  mg_target_component = mg_t_component;
+  unsigned int n_blocks = mg_dof.get_fe().n_blocks();
   
-  selected_component = select;
-  mg_selected_component = mg_select;
-  selected.resize(ncomp, false);
-  selected[select] = true;
-  mg_selected.resize(ncomp, false);
-  mg_selected[mg_select] = true;
-                                  // If components are renumbered,
-                                  // find the first original
-                                  // component corresponding to the
-                                  // target component.
-  for (unsigned int i=0;i<target_component.size();++i)
-    {
-      if (target_component[i] == select)
-       {
-         selected_component = i;
-         break;
-       }
-    }
-    
-  for (unsigned int i=0;i<mg_target_component.size();++i)
+  if (sel.size() != 0)
     {
-      if (mg_target_component[i] == mg_select)
-       {
-         mg_selected_component = i;
-         break;
-       }
-    }    
+      Assert(sel.size() == n_blocks,
+            ExcDimensionMismatch(sel.size(), n_blocks));
+      selected = sel;
+    }  
+  if (selected.size() == 0)
+    selected = std::vector<bool> (n_blocks, true);
+
   MGTransferBlockBase::build_matrices (dof, mg_dof);
-//TODO:[GK] Rewrite this to suit MGTransferBlock and move to base class
   
   std::vector<unsigned int> global_dof_indices (fe.dofs_per_cell);
   std::vector<unsigned int> level_dof_indices  (fe.dofs_per_cell);
@@ -357,17 +331,11 @@ void MGTransferSelect<number>::build_matrices (
          
          for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
            {
-             const unsigned int component
-               = mg_target_component[fe.system_to_component_index(i).first];
-             if (mg_selected[component])
-               {
-                 const unsigned int level_start
-                   = mg_component_start[level][component];
-                 copy_to_and_from_indices[level].insert(
-                   std::make_pair(global_dof_indices[i]
-                                  - component_start[selected_component],
-                                  level_dof_indices[i]-level_start));
-               }
+             const unsigned int block = fe.system_to_block_index(i).first;
+             if (selected[block])
+               copy_indices[block][level].insert(
+                 std::make_pair(global_dof_indices[i] - block_start[block],
+                                level_dof_indices[i] - mg_block_start[level][block]));
            }
        }
     }
@@ -379,155 +347,114 @@ void MGTransferSelect<number>::build_matrices (
 
 template
 void MGTransferBlock<float>::build_matrices<deal_II_dimension>
-(const DoFHandler<deal_II_dimension> &,
- const MGDoFHandler<deal_II_dimension> &,
- const std::vector<unsigned int>&,
- const std::vector<unsigned int>&);
-
-template
-void MGTransferSelect<float>::build_matrices<deal_II_dimension>
-(const DoFHandler<deal_II_dimension> &d,
- const MGDoFHandler<deal_II_dimension> &,
- unsigned int, unsigned int,
- const std::vector<unsigned int>&,
- const std::vector<unsigned int>&);
+(const DoFHandler<deal_II_dimension>&, const MGDoFHandler<deal_II_dimension>&,
+ const std::vector<bool>&);
 
 template
 void MGTransferBlock<double>::build_matrices<deal_II_dimension>
-(const DoFHandler<deal_II_dimension> &,
- const MGDoFHandler<deal_II_dimension> &,
- const std::vector<unsigned int>&,
- const std::vector<unsigned int>&);
+(const DoFHandler<deal_II_dimension>&, const MGDoFHandler<deal_II_dimension>&,
+ const std::vector<bool>&);
 
 template
-void MGTransferSelect<double>::build_matrices<deal_II_dimension>
-(const DoFHandler<deal_II_dimension> &,
- const MGDoFHandler<deal_II_dimension> &,
- unsigned int, unsigned int,
- const std::vector<unsigned int>&,
- const std::vector<unsigned int>&);
+void MGTransferBlockSelect<float>::build_matrices<deal_II_dimension>
+(const DoFHandler<deal_II_dimension>&, const MGDoFHandler<deal_II_dimension>&,
+ const unsigned int);
 
+template
+void MGTransferBlockSelect<double>::build_matrices<deal_II_dimension>
+(const DoFHandler<deal_II_dimension>&, const MGDoFHandler<deal_II_dimension>&,
+ const unsigned int);
 
-template void
-MGTransferBlock<float>::copy_to_mg (
-  const MGDoFHandler<deal_II_dimension>&,
-  MGLevelObject<BlockVector<float> >&,
-  const Vector<double>&) const;
 template void
 MGTransferBlock<float>::copy_to_mg (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<BlockVector<float> >&,
   const BlockVector<double>&) const;
 template void
-MGTransferBlock<float>::copy_from_mg (
-  const MGDoFHandler<deal_II_dimension>&,
-  Vector<double>&,
-  const MGLevelObject<BlockVector<float> >&) const;
-template void
 MGTransferBlock<float>::copy_from_mg (
   const MGDoFHandler<deal_II_dimension>&,
   BlockVector<double>&,
   const MGLevelObject<BlockVector<float> >&) const;
 template void
-MGTransferBlock<float>::copy_from_mg_add (
-  const MGDoFHandler<deal_II_dimension>&,
-  Vector<double>&,
-  const MGLevelObject<BlockVector<float> >&) const;
-template void
 MGTransferBlock<float>::copy_from_mg_add (
   const MGDoFHandler<deal_II_dimension>&,
   BlockVector<double>&,
   const MGLevelObject<BlockVector<float> >&) const;
 
 template void
-MGTransferBlock<double>::copy_to_mg (
-  const MGDoFHandler<deal_II_dimension>&,
-  MGLevelObject<BlockVector<double> >&,
-  const Vector<double>&) const;
-template void
 MGTransferBlock<double>::copy_to_mg (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<BlockVector<double> >&,
   const BlockVector<double>&) const;
 template void
-MGTransferBlock<double>::copy_from_mg (
-  const MGDoFHandler<deal_II_dimension>&,
-  Vector<double>&,
-  const MGLevelObject<BlockVector<double> >&) const;
-template void
 MGTransferBlock<double>::copy_from_mg (
   const MGDoFHandler<deal_II_dimension>&,
   BlockVector<double>&,
   const MGLevelObject<BlockVector<double> >&) const;
 template void
-MGTransferBlock<double>::copy_from_mg_add (
-  const MGDoFHandler<deal_II_dimension>&,
-  Vector<double>&,
-  const MGLevelObject<BlockVector<double> >&) const;
-template void
 MGTransferBlock<double>::copy_from_mg_add (
   const MGDoFHandler<deal_II_dimension>&,
   BlockVector<double>&,
   const MGLevelObject<BlockVector<double> >&) const;
 
 template void
-MGTransferSelect<float>::copy_to_mg (
+MGTransferBlockSelect<float>::copy_to_mg (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<Vector<float> >&,
   const Vector<double>&) const;
 template void
-MGTransferSelect<float>::copy_to_mg (
+MGTransferBlockSelect<float>::copy_to_mg (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<Vector<float> >&,
   const BlockVector<double>&) const;
 template void
-MGTransferSelect<float>::copy_from_mg (
+MGTransferBlockSelect<float>::copy_from_mg (
   const MGDoFHandler<deal_II_dimension>&,
   Vector<double>&,
   const MGLevelObject<Vector<float> >&) const;
 template void
-MGTransferSelect<float>::copy_from_mg (
+MGTransferBlockSelect<float>::copy_from_mg (
   const MGDoFHandler<deal_II_dimension>&,
   BlockVector<double>&,
   const MGLevelObject<Vector<float> >&) const;
 template void
-MGTransferSelect<float>::copy_from_mg_add (
+MGTransferBlockSelect<float>::copy_from_mg_add (
   const MGDoFHandler<deal_II_dimension>&,
   Vector<double>&,
   const MGLevelObject<Vector<float> >&) const;
 template void
-MGTransferSelect<float>::copy_from_mg_add (
+MGTransferBlockSelect<float>::copy_from_mg_add (
   const MGDoFHandler<deal_II_dimension>&,
   BlockVector<double>&,
   const MGLevelObject<Vector<float> >&) const;
 
 template void
-MGTransferSelect<double>::copy_to_mg (
+MGTransferBlockSelect<double>::copy_to_mg (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<Vector<double> >&,
   const Vector<double>&) const;
 template void
-MGTransferSelect<double>::copy_to_mg (
+MGTransferBlockSelect<double>::copy_to_mg (
   const MGDoFHandler<deal_II_dimension>&,
   MGLevelObject<Vector<double> >&,
   const BlockVector<double>&) const;
 template void
-MGTransferSelect<double>::copy_from_mg (
+MGTransferBlockSelect<double>::copy_from_mg (
   const MGDoFHandler<deal_II_dimension>&,
   Vector<double>&,
   const MGLevelObject<Vector<double> >&) const;
 template void
-MGTransferSelect<double>::copy_from_mg (
+MGTransferBlockSelect<double>::copy_from_mg (
   const MGDoFHandler<deal_II_dimension>&,
   BlockVector<double>&,
   const MGLevelObject<Vector<double> >&) const;
 template void
-MGTransferSelect<double>::copy_from_mg_add (
+MGTransferBlockSelect<double>::copy_from_mg_add (
   const MGDoFHandler<deal_II_dimension>&,
   Vector<double>&,
   const MGLevelObject<Vector<double> >&) const;
 template void
-MGTransferSelect<double>::copy_from_mg_add (
+MGTransferBlockSelect<double>::copy_from_mg_add (
   const MGDoFHandler<deal_II_dimension>&,
   BlockVector<double>&,
   const MGLevelObject<Vector<double> >&) const;
diff --git a/deal.II/deal.II/source/multigrid/mg_transfer_component.cc b/deal.II/deal.II/source/multigrid/mg_transfer_component.cc
new file mode 100644 (file)
index 0000000..3c7411b
--- /dev/null
@@ -0,0 +1,437 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+
+#include <base/logstream.h>
+
+#include <lac/vector.h>
+#include <lac/block_vector.h>
+#include <lac/sparse_matrix.h>
+#include <lac/block_sparse_matrix.h>
+#include <grid/tria.h>
+#include <grid/tria_iterator.h>
+#include <dofs/dof_tools.h>
+#include <fe/fe.h>
+#include <multigrid/mg_dof_handler.h>
+#include <multigrid/mg_dof_accessor.h>
+#include <multigrid/mg_transfer_component.h>
+#include <multigrid/mg_transfer_component.templates.h>
+#include <multigrid/mg_tools.h>
+
+#include <algorithm>
+
+DEAL_II_NAMESPACE_OPEN
+
+
+
+template <int dim>
+void MGTransferComponentBase::build_matrices (
+  const DoFHandler<dim>&,
+  const MGDoFHandler<dim>& mg_dof)
+{
+                                  // Fill target component with
+                                  // standard values (identity) if it
+                                  // is empty
+  if (target_component.size() == 0)
+    {
+      target_component.resize(mg_dof.get_fe().n_components());
+      for (unsigned int i=0;i<target_component.size();++i)
+       target_component[i] = i;
+    } else {
+                                      // otherwise, check it for consistency
+      Assert (target_component.size() == mg_dof.get_fe().n_components(),
+             ExcDimensionMismatch(target_component.size(),
+                                  mg_dof.get_fe().n_components()));
+      
+      for (unsigned int i=0;i<target_component.size();++i)
+       {
+         Assert(i<target_component.size(),
+                ExcIndexRange(i,0,target_component.size()));
+       }
+    }
+                                  // Do the same for the multilevel
+                                  // components. These may be
+                                  // different.
+  if (mg_target_component.size() == 0)
+    {
+      mg_target_component.resize(mg_dof.get_fe().n_components());
+      for (unsigned int i=0;i<mg_target_component.size();++i)
+       mg_target_component[i] = target_component[i];
+    } else {
+      Assert (mg_target_component.size() == mg_dof.get_fe().n_components(),
+             ExcDimensionMismatch(mg_target_component.size(),
+                                  mg_dof.get_fe().n_components()));
+      
+      for (unsigned int i=0;i<mg_target_component.size();++i)
+       {
+         Assert(i<mg_target_component.size(),
+                ExcIndexRange(i,0,mg_target_component.size()));
+       }
+    }
+  
+  const FiniteElement<dim>& fe = mg_dof.get_fe();
+
+                                  // Effective number of components
+                                  // is the maximum entry in
+                                  // mg_target_component. This
+                                  // assumes that the values in that
+                                  // vector don't have holes.
+  const unsigned int n_components  =
+    *std::max_element(mg_target_component.begin(), mg_target_component.end()) + 1;
+  const unsigned int dofs_per_cell = fe.dofs_per_cell;
+  const unsigned int n_levels      = mg_dof.get_tria().n_levels();
+  
+  Assert (mg_selected.size() == fe.n_components(),
+         ExcDimensionMismatch(mg_selected.size(), fe.n_components()));
+  
+                                  // Compute the lengths of all blocks
+  sizes.resize(n_levels);
+  MGTools::count_dofs_per_component(mg_dof, sizes, true, mg_target_component);
+
+                                  // Fill some index vectors
+                                  // for later use.
+  mg_component_start = sizes;
+                                  // Compute start indices from sizes
+  for (unsigned int l=0;l<mg_component_start.size();++l)
+    {
+      unsigned int k=0;
+      for (unsigned int i=0;i<mg_component_start[l].size();++i)
+       {
+         const unsigned int t=mg_component_start[l][i];
+         mg_component_start[l][i] = k;
+         k += t;
+       }
+    }
+
+  component_start.resize(target_component.size());
+  DoFTools::
+    count_dofs_per_component (static_cast<const DoFHandler<dim>&>(mg_dof),
+                              component_start, true, target_component);
+
+  unsigned int k=0;
+  for (unsigned int i=0;i<component_start.size();++i)
+    {
+      const unsigned int t=component_start[i];
+      component_start[i] = k;
+      k += t;
+    }
+
+                                  // Build index vectors for
+                                  // copy_to_mg and
+                                  // copy_from_mg. These vectors must
+                                  // be prebuilt, since the
+                                  // get_dof_indices functions are
+                                  // too slow
+
+  copy_to_and_from_indices.resize(n_levels);
+  
+// Building the prolongation matrices starts here!
+  
+                                  // 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 (boost::shared_ptr<BlockSparsityPattern> (new BlockSparsityPattern));
+      prolongation_matrices
+       .push_back (boost::shared_ptr<BlockSparseMatrix<double> > (new BlockSparseMatrix<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, is the
+                                      // number of degrees of freedom
+                                      // per cell
+      prolongation_sparsities[level]->reinit (n_components, n_components);
+      for (unsigned int i=0; i<n_components; ++i)
+       for (unsigned int j=0; j<n_components; ++j)
+         if (i==j)
+           prolongation_sparsities[level]->block(i,j)
+             .reinit(sizes[level+1][i],
+                     sizes[level][j],
+                     dofs_per_cell+1, false);
+         else
+           prolongation_sparsities[level]->block(i,j)
+             .reinit(sizes[level+1][i],
+                     sizes[level][j],
+                     0, false);
+
+      prolongation_sparsities[level]->collect_sizes();
+      
+      for (typename MGDoFHandler<dim>::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);
+
+           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->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)
+                     {
+                       const unsigned int icomp
+                         = fe.system_to_component_index(i).first;
+                       const unsigned int jcomp
+                         = fe.system_to_component_index(j).first;
+                       if ((icomp==jcomp) && mg_selected[mg_target_component[icomp]])
+                         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 MGDoFHandler<dim>::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);
+
+           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->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)
+                 for (unsigned int j=0; j<dofs_per_cell; ++j)
+                   if (prolongation(i,j) != 0)
+                     {
+                       const unsigned int icomp = fe.system_to_component_index(i).first;
+                       const unsigned int jcomp = fe.system_to_component_index(j).first;
+                       if ((icomp==jcomp) && mg_selected[mg_target_component[icomp]])
+                         prolongation_matrices[level]->set(dof_indices_child[i],
+                                                           dof_indices_parent[j],
+                                                           prolongation(i,j));
+                     }
+             }
+         }
+    }
+}
+
+
+template <typename number>
+template <int dim>
+void MGTransferSelect<number>::build_matrices (
+  const DoFHandler<dim> &dof,
+  const MGDoFHandler<dim> &mg_dof,
+  unsigned int select,
+  unsigned int mg_select,
+  const std::vector<unsigned int>& t_component,
+  const std::vector<unsigned int>& mg_t_component)
+{
+  const FiniteElement<dim>& fe = mg_dof.get_fe();
+  unsigned int ncomp = mg_dof.get_fe().n_components();
+  
+  target_component = t_component;
+  mg_target_component = mg_t_component;
+  
+  selected_component = select;
+  mg_selected_component = mg_select;
+  selected.resize(ncomp, false);
+  selected[select] = true;
+  mg_selected.resize(ncomp, false);
+  mg_selected[mg_select] = true;
+                                  // If components are renumbered,
+                                  // find the first original
+                                  // component corresponding to the
+                                  // target component.
+  for (unsigned int i=0;i<target_component.size();++i)
+    {
+      if (target_component[i] == select)
+       {
+         selected_component = i;
+         break;
+       }
+    }
+    
+  for (unsigned int i=0;i<mg_target_component.size();++i)
+    {
+      if (mg_target_component[i] == mg_select)
+       {
+         mg_selected_component = i;
+         break;
+       }
+    }    
+  MGTransferComponentBase::build_matrices (dof, mg_dof);
+  
+  std::vector<unsigned int> global_dof_indices (fe.dofs_per_cell);
+  std::vector<unsigned int> level_dof_indices  (fe.dofs_per_cell);
+  for (int level=dof.get_tria().n_levels()-1; level>=0; --level)
+    {
+      typename MGDoFHandler<dim>::active_cell_iterator
+       level_cell = mg_dof.begin_active(level);
+      const typename MGDoFHandler<dim>::active_cell_iterator
+       level_end  = mg_dof.end_active(level);
+      
+                                      // Compute coarse level right hand side
+                                      // by restricting from fine level.
+      for (; level_cell!=level_end; ++level_cell)
+       {
+         DoFObjectAccessor<dim, DoFHandler<dim> >& 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<fe.dofs_per_cell; ++i)
+           {
+             const unsigned int component
+               = mg_target_component[fe.system_to_component_index(i).first];
+             if (mg_selected[component])
+               {
+                 const unsigned int level_start
+                   = mg_component_start[level][component];
+                 copy_to_and_from_indices[level].insert(
+                   std::make_pair(global_dof_indices[i]
+                                  - component_start[selected_component],
+                                  level_dof_indices[i]-level_start));
+               }
+           }
+       }
+    }
+}
+
+
+
+// explicit instantiations
+
+template
+void MGTransferSelect<float>::build_matrices<deal_II_dimension>
+(const DoFHandler<deal_II_dimension> &d,
+ const MGDoFHandler<deal_II_dimension> &,
+ unsigned int, unsigned int,
+ const std::vector<unsigned int>&,
+ const std::vector<unsigned int>&);
+
+template
+void MGTransferSelect<double>::build_matrices<deal_II_dimension>
+(const DoFHandler<deal_II_dimension> &d,
+ const MGDoFHandler<deal_II_dimension> &,
+ unsigned int, unsigned int,
+ const std::vector<unsigned int>&,
+ const std::vector<unsigned int>&);
+
+template void
+MGTransferSelect<float>::copy_to_mg (
+  const MGDoFHandler<deal_II_dimension>&,
+  MGLevelObject<Vector<float> >&,
+  const Vector<double>&) const;
+template void
+MGTransferSelect<float>::copy_to_mg (
+  const MGDoFHandler<deal_II_dimension>&,
+  MGLevelObject<Vector<float> >&,
+  const BlockVector<double>&) const;
+template void
+MGTransferSelect<float>::copy_from_mg (
+  const MGDoFHandler<deal_II_dimension>&,
+  Vector<double>&,
+  const MGLevelObject<Vector<float> >&) const;
+template void
+MGTransferSelect<float>::copy_from_mg (
+  const MGDoFHandler<deal_II_dimension>&,
+  BlockVector<double>&,
+  const MGLevelObject<Vector<float> >&) const;
+template void
+MGTransferSelect<float>::copy_from_mg_add (
+  const MGDoFHandler<deal_II_dimension>&,
+  Vector<double>&,
+  const MGLevelObject<Vector<float> >&) const;
+template void
+MGTransferSelect<float>::copy_from_mg_add (
+  const MGDoFHandler<deal_II_dimension>&,
+  BlockVector<double>&,
+  const MGLevelObject<Vector<float> >&) const;
+
+template void
+MGTransferSelect<double>::copy_to_mg (
+  const MGDoFHandler<deal_II_dimension>&,
+  MGLevelObject<Vector<double> >&,
+  const Vector<double>&) const;
+template void
+MGTransferSelect<double>::copy_to_mg (
+  const MGDoFHandler<deal_II_dimension>&,
+  MGLevelObject<Vector<double> >&,
+  const BlockVector<double>&) const;
+template void
+MGTransferSelect<double>::copy_from_mg (
+  const MGDoFHandler<deal_II_dimension>&,
+  Vector<double>&,
+  const MGLevelObject<Vector<double> >&) const;
+template void
+MGTransferSelect<double>::copy_from_mg (
+  const MGDoFHandler<deal_II_dimension>&,
+  BlockVector<double>&,
+  const MGLevelObject<Vector<double> >&) const;
+template void
+MGTransferSelect<double>::copy_from_mg_add (
+  const MGDoFHandler<deal_II_dimension>&,
+  Vector<double>&,
+  const MGLevelObject<Vector<double> >&) const;
+template void
+MGTransferSelect<double>::copy_from_mg_add (
+  const MGDoFHandler<deal_II_dimension>&,
+  BlockVector<double>&,
+  const MGLevelObject<Vector<double> >&) const;
+
+DEAL_II_NAMESPACE_CLOSE
index 7e0cbfbc3ccd5908a77569ada9b4ed1621112c03..d5871ad6ed964e2b76c168b50a74553d9e994f81 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
+//    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
 #include <lac/sparse_matrix.h>
 #include <lac/block_sparse_matrix.h>
 #include <multigrid/mg_transfer.h>
+#include <multigrid/mg_transfer_block.h>
+#include <multigrid/mg_transfer_component.h>
 #include <multigrid/mg_smoother.h>
 #include <multigrid/mg_transfer.templates.h>
+#include <multigrid/mg_transfer_block.templates.h>
+#include <multigrid/mg_transfer_component.templates.h>
 #include <multigrid/multigrid.templates.h>
 
 DEAL_II_NAMESPACE_OPEN
@@ -165,14 +169,16 @@ void MGTransferBlock<number>::prolongate (
 {
   Assert ((to_level >= 1) && (to_level<=prolongation_matrices.size()),
          ExcIndexRange (to_level, 1, prolongation_matrices.size()+1));
-
-  unsigned int k=0;
+  Assert (src.n_blocks() == prolongation_matrices[to_level-1]->n_block_cols(),
+         ExcDimensionMismatch(src.n_blocks(),
+                              prolongation_matrices[to_level-1]->n_block_cols()));
+  Assert (dst.n_blocks() == prolongation_matrices[to_level-1]->n_block_rows(),
+         ExcDimensionMismatch(dst.n_blocks(),
+                              prolongation_matrices[to_level-1]->n_block_rows()));
+  
   for (unsigned int b=0; b<src.n_blocks();++b)
     {
-      if (!selected[k])
-       ++k;
-      prolongation_matrices[to_level-1]->block(k,k).vmult (dst.block(b), src.block(b));
-      ++k;
+      prolongation_matrices[to_level-1]->block(b,b).vmult (dst.block(b), src.block(b));
     }
 }
 
@@ -185,32 +191,48 @@ void MGTransferBlock<number>::restrict_and_add (
 {
   Assert ((from_level >= 1) && (from_level<=prolongation_matrices.size()),
          ExcIndexRange (from_level, 1, prolongation_matrices.size()+1));
+  Assert (src.n_blocks() == prolongation_matrices[from_level-1]->n_block_rows(),
+         ExcDimensionMismatch(src.n_blocks(),
+                              prolongation_matrices[from_level-1]->n_block_rows()));
+  Assert (dst.n_blocks() == prolongation_matrices[from_level-1]->n_block_cols(),
+         ExcDimensionMismatch(dst.n_blocks(),
+                              prolongation_matrices[from_level-1]->n_block_cols()));
 
-  unsigned int k=0;
   for (unsigned int b=0; b<src.n_blocks();++b)
     {
-      while (!selected[k]) ++k;
       if (factors.size() != 0)
        {
          Assert (memory != 0, ExcNotInitialized());
          Vector<number>* aux = memory->alloc();
          aux->reinit(dst.block(b));
-         prolongation_matrices[from_level-1]->block(k,k).Tvmult (*aux, src.block(b));
+         prolongation_matrices[from_level-1]->block(b,b).Tvmult (*aux, src.block(b));
          
-         dst.block(b).add(factors[k], *aux);
+         dst.block(b).add(factors[b], *aux);
          memory->free(aux);
        }
       else
        {
-       prolongation_matrices[from_level-1]->block(k,k).Tvmult_add (dst.block(b),
+       prolongation_matrices[from_level-1]->block(b,b).Tvmult_add (dst.block(b),
                                                                    src.block(b));
        }
-      ++k;
     }
 }
 
 
 
+//TODO:[GK] Add all those little vectors.
+unsigned int
+MGTransferComponentBase::memory_consumption () const
+{
+  unsigned int result = sizeof(*this);
+  result += sizeof(unsigned int) * sizes.size();
+  for (unsigned int i=0;i<prolongation_matrices.size();++i)
+    result += prolongation_matrices[i]->memory_consumption()
+             + prolongation_sparsities[i]->memory_consumption();
+  return result;
+}
+
+
 //TODO:[GK] Add all those little vectors.
 unsigned int
 MGTransferBlockBase::memory_consumption () const
@@ -276,6 +298,44 @@ MGSmootherContinuous<VECTOR>::set_zero_interior_boundary (
 }
 
 
+//----------------------------------------------------------------------//
+
+template <typename number>
+MGTransferBlockSelect<number>::~MGTransferBlockSelect () 
+{}
+
+
+template <typename number>
+void MGTransferBlockSelect<number>::prolongate (
+  const unsigned int   to_level,
+  Vector<number>       &dst,
+  const Vector<number> &src) const 
+{
+  Assert ((to_level >= 1) && (to_level<=prolongation_matrices.size()),
+         ExcIndexRange (to_level, 1, prolongation_matrices.size()+1));
+
+      prolongation_matrices[to_level-1]->block(selected_block,
+                                              selected_block)
+       .vmult (dst, src);
+}
+
+
+template <typename number>
+void MGTransferBlockSelect<number>::restrict_and_add (
+  const unsigned int   from_level,
+  Vector<number>       &dst,
+  const Vector<number> &src) const
+{
+  Assert ((from_level >= 1) && (from_level<=prolongation_matrices.size()),
+         ExcIndexRange (from_level, 1, prolongation_matrices.size()+1));
+
+  prolongation_matrices[from_level-1]->block(selected_block,
+                                            selected_block)
+    .Tvmult_add (dst, src);
+}
+
+
+
 // Explicit instantiations
 
 template class Multigrid<Vector<float> >;
@@ -291,6 +351,8 @@ template class MGTransferBlock<float>;
 template class MGTransferBlock<double>;
 template class MGTransferSelect<float>;
 template class MGTransferSelect<double>;
+template class MGTransferBlockSelect<float>;
+template class MGTransferBlockSelect<double>;
 
 template
 void MGSmootherContinuous<Vector<double> >::set_zero_interior_boundary (
index eaee414c461a00313fadfbaa7d19d90de65ca587..5210343b40ceac95c6011485f77b7fbcaaf46078 100644 (file)
@@ -1,6 +1,6 @@
 ############################################################
 # $Id$
-# Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006 by the deal.II authors
+# Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2007 by the deal.II authors
 ############################################################
 
 ############################################################
@@ -22,7 +22,7 @@ default: run-tests
 ############################################################
 
 tests_x = cycles dof_* count_* boundary_* renumbering_* \
-       transfer transfer_select transfer_block \
+       transfer transfer_select transfer_block_select transfer_block \
        smoother_block
 
 # from above list of regular expressions, generate the real set of
index 40a8c977e465b4c0b62e76c417861fcc8958b977..44f12a9a7b2d4a5f030d5264f4e1e18a7516a24d 100644 (file)
@@ -2,7 +2,7 @@
 //    transfer.cc,v 1.13 2005/12/30 16:07:03 guido Exp
 //    Version: 
 //
-//    Copyright (C) 2000 - 2006 by the deal.II authors
+//    Copyright (C) 2000 - 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -90,7 +90,7 @@ void check_simple(const FiniteElement<dim>& fe)
   transfer.restrict_and_add(2,u1,u2);
   transfer.restrict_and_add(1,u0,u1);
   deallog << "u1\t" <<  (u1*u1+.5) << std::endl
-         << "u0\t" <<  (u0*u0+.5) << std::endl;  
+         << "u0\t" <<  (u0*u0+.5) << std::endl;
 }
 
 
@@ -111,7 +111,7 @@ int main()
   check_simple (FESystem<2>(FE_DGQ<2>(1), 2));
   check_simple (FESystem<2>(FE_DGP<2>(1), 2, FE_DGQ<2>(1), 3));
 
-//  check_simple (FE_RaviartThomas<2>(2));
+  check_simple (FE_RaviartThomasNodal<2>(1));
 //  check_simple (FESystem<2>(FE_RaviartThomas<2>(1),1,FE_DGQ<2>(0),2));
   
   check_simple (FE_DGQ<3>(1));
index 975e2d99ed7d560d4183ecfc0a8a878fba2ad064..9126aedebc636ebf6b1eea0f90d4a7a0cfced313 100644 (file)
@@ -87,6 +87,17 @@ DEAL::u1     7.11e+03
 DEAL::u2       2.84e+04
 DEAL::u1       1.14e+05
 DEAL::u0       4.54e+05
+DEAL::FE_RaviartThomasNodal<2>(1)
+DEAL::u0       12.5
+DEAL::u1       40.5
+DEAL::u2       144.
+DEAL::u1       573.
+DEAL::u0       2.21e+03
+DEAL::u0       506.
+DEAL::u1       2.07e+03
+DEAL::u2       8.15e+03
+DEAL::u1       3.40e+04
+DEAL::u0       1.40e+05
 DEAL::FE_DGQ<3>(1)
 DEAL::u0       8.50
 DEAL::u1       64.5
index 396cdae1f23edd14e0fc0a34e9eacbd757ecaf9d..886c6973e7264873ddac7c7ee936bba67f5665d5 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000 - 2006 by the deal.II authors
+//    Copyright (C) 2000 - 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
 #include <fe/fe_dgp.h>
 #include <fe/fe_dgq.h>
 #include <fe/fe_q.h>
+#include <fe/fe_raviart_thomas.h>
 #include <fe/fe_system.h>
 #include <multigrid/mg_dof_handler.h>
-#include <multigrid/mg_transfer.h>
+#include <multigrid/mg_transfer_block.h>
 #include <multigrid/mg_tools.h>
 #include <multigrid/mg_level_object.h>
 
@@ -38,13 +39,14 @@ using namespace std;
 
 template <int dim>
 void check_block(const FiniteElement<dim>& fe,
-                const vector<bool>& /*selected*/,
-                const vector<bool>& /*mg_selected*/,
-                const vector<double>& factors,
-                std::vector<unsigned int> target_component,
-                std::vector<unsigned int> mg_target_component)
+                const vector<bool>& selected,
+                const vector<double>& factors)
 {
-  deallog << fe.get_name() << std::endl;
+  deallog << fe.get_name() << std::endl << "selected ";
+  for (unsigned int i=0;i<selected.size();++i)
+    if (selected[i])
+      deallog << ' ' << i;
+  deallog << std::endl;
   
   Triangulation<dim> tr;
   GridGenerator::hyper_cube(tr);
@@ -53,15 +55,14 @@ void check_block(const FiniteElement<dim>& fe,
   MGDoFHandler<dim> mgdof(tr);
   DoFHandler<dim>& dof=mgdof;
   mgdof.distribute_dofs(fe);
-  DoFRenumbering::component_wise(mgdof, target_component);
-  vector<unsigned int> ndofs(fe.n_components());
-  DoFTools::count_dofs_per_component(mgdof, ndofs, true, target_component);
+  DoFRenumbering::component_wise(mgdof);
+  vector<unsigned int> ndofs(fe.n_blocks());
+  DoFTools::count_dofs_per_block(mgdof, ndofs);
   
   for (unsigned int l=0;l<tr.n_levels();++l)
-    DoFRenumbering::component_wise(mgdof, l, mg_target_component);
-  
+    DoFRenumbering::component_wise(mgdof, l);
   std::vector<std::vector<unsigned int> > mg_ndofs(mgdof.get_tria().n_levels());
-  MGTools::count_dofs_per_component(mgdof, mg_ndofs, true, mg_target_component);
+  MGTools::count_dofs_per_block(mgdof, mg_ndofs);
 
   deallog << "Global  dofs:";
   for (unsigned int i=0;i<ndofs.size();++i)
@@ -77,7 +78,7 @@ void check_block(const FiniteElement<dim>& fe,
   
   PrimitiveVectorMemory<Vector<double> > mem;
   MGTransferBlock<double> transfer;
-  transfer.build_matrices(dof, mgdof, target_component, mg_target_component);
+  transfer.build_matrices(dof, mgdof, selected);
   if (factors.size()>0)
     transfer.initialize(factors, mem);
 
@@ -85,25 +86,30 @@ void check_block(const FiniteElement<dim>& fe,
   BlockVector<double> u1(mg_ndofs[1]);
   BlockVector<double> u0(mg_ndofs[0]);
 
+                                  // Prolongate a constant function
+                                  // twice
   u0 = 1;
   transfer.prolongate(1,u1,u0);
   transfer.prolongate(2,u2,u1);
+                                  // These outputs are just the
+                                  // number of dofs on each level
   deallog << "u0";
   for (unsigned int b=0;b<u0.n_blocks();++b)
-    deallog << '\t' << (int) (u0.block(b)*u0.block(b)+.5);
+    deallog << '\t' << (int) (u0.block(b)*u0.block(b)+.4);
   deallog << std::endl << "u1";
   for (unsigned int b=0;b<u1.n_blocks();++b)
-    deallog << '\t' << (int) (u1.block(b)*u1.block(b)+.5);
+    deallog << '\t' << (int) (u1.block(b)*u1.block(b)+.4);
   deallog << std::endl << "u2";
   for (unsigned int b=0;b<u2.n_blocks();++b)
-    deallog << '\t' << (int) (u2.block(b)*u2.block(b)+.5);
+    deallog << '\t' << (int) (u2.block(b)*u2.block(b)+.4);
   deallog << std::endl;
   
   u1 = 0.;
   u0 = 0.;
   transfer.restrict_and_add(2,u1,u2);
   transfer.restrict_and_add(1,u0,u1);
-
+                                  // After adding the restrictions,
+                                  // things get bigger.
   deallog << "u1";
   for (unsigned int b=0;b<u1.n_blocks();++b)
     deallog << '\t' << (int) (u1.block(b)*u1.block(b)+.5);
@@ -115,16 +121,29 @@ void check_block(const FiniteElement<dim>& fe,
   BlockVector<double> u;
   u.reinit (ndofs);
   for (unsigned int i=0;i<u.size();++i)
-    u(i) = i;
-  
-  MGLevelObject<BlockVector<double> > v;
-  v.resize(2,2);
-  v[2].reinit(mg_ndofs[2]);
+    u(i) = i+1;
 
+  std::vector<std::vector<unsigned int> > cached_sizes;
+  MGLevelObject<BlockVector<double> > v;
+  v.resize(0, tr.n_levels()-1);
+  MGTools::reinit_vector_by_blocks(mgdof, v, selected, cached_sizes);
+  
   transfer.copy_to_mg(mgdof, v, u);
   for (unsigned int i=0; i<v[2].size();++i)
     deallog << ' ' << (int) v[2](i);
   deallog << std::endl;
+
+                                  // Now do the opposite: fill a
+                                  // multigrid vector counting the
+                                  // dofs and see where the numbers go
+  u = 0.;
+  for (unsigned int i=0;i<v[2].size();++i)
+    v[2](i) = i+1;
+  transfer.copy_from_mg_add(mgdof, u, v);
+  for (unsigned int i=0; i<u.size();++i)
+    deallog << ' ' << (int) u(i);
+  deallog << std::endl;
+  
 }
 
 
@@ -136,37 +155,31 @@ int main()
   deallog.depth_console(0);
   deallog.threshold_double(1.e-10);
   
-  std::vector<unsigned int> v1(4);
-  std::vector<unsigned int> v2(4);
-  std::vector<unsigned int> v3(4);
-  for (unsigned int i=0;i<4;++i)
-    {
-      v1[i] = i;
-      v2[i] = 0;
-      v3[i] = i;
-    }
-  v3[0] = 0;
-  v3[1] = 1;
-  v3[2] = 1;
-  v3[3] = 2;
-
   std::vector<double> factors;
+
+  FE_DGQ<2> q0(0);
+  FE_DGQ<2> q1(1);
+  FE_RaviartThomasNodal<2> rt0(0);
+  FE_RaviartThomasNodal<2> rt1(1);
   
-  FESystem<2> fe1(FE_DGQ<2>(1), 4);
-  
-  vector<bool> s1(4, true);
+  FESystem<2> fe0(rt1, 1, q1, 1);
+  FESystem<2> fe1(rt0, 2, q0, 2);
   
-  deallog << "s1 s1 v1 v1" << std::endl;
-  check_block(fe1, s1, s1, factors, v1, v1);
-//   deallog << "s1 s1 v1 v2" << std::endl;
-//   check_block(fe1, s1, s1, factors, v1, v2);
-//   deallog << "s1 s1 v1 v3" << std::endl;
-//   check_block(fe1, s1, s1, factors, v1, v3);
+  vector<bool> s1(2, true);
+  deallog << "All" << std::endl;
+  check_block(fe0, s1, factors);
+  s1[1] = false;
+  deallog << "Velocity" << std::endl;
+  check_block(fe0, s1, factors);
   
-  factors.resize(4, 1.);
-  factors[1] = 2.;
-  deallog << "s1 s1 v1 v1" << std::endl;
-  check_block(fe1, s1, s1, factors, v1, v1);  
-//   deallog << "s1 s1 v1 v3" << std::endl;
-//   check_block(fe1, s1, s1, factors, v1, v3);  
+  s1[1] = true;
+  s1[0] = false;
+  deallog << "Pressure" << std::endl;
+  check_block(fe0, s1, factors);
+
+  s1.resize(4,true);
+  s1[0] = false;
+  s1[2] = false;
+  check_block(fe1, s1, factors);
 }
index 85e4fda8aea003fee8df63c2b1efb55d20370319..b08f07016999de75932f9c9339c63508ca6fb832 100644 (file)
@@ -1,25 +1,56 @@
 
-DEAL::s1 s1 v1 v1
-DEAL::FESystem<2>[FE_DGQ<2>(1)^4]
-DEAL::Global  dofs: 64 64 64 64
-DEAL::Level 0 dofs: 4 4 4 4
-DEAL::Level 1 dofs: 16 16 16 16
-DEAL::Level 2 dofs: 64 64 64 64
-DEAL::u0       4       4       4       4
-DEAL::u1       16      16      16      16
-DEAL::u2       64      64      64      64
-DEAL::u1       256     256     256     256
-DEAL::u0       1024    1024    1024    1024
-DEAL:: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
-DEAL::s1 s1 v1 v1
-DEAL::FESystem<2>[FE_DGQ<2>(1)^4]
-DEAL::Global  dofs: 64 64 64 64
-DEAL::Level 0 dofs: 4 4 4 4
-DEAL::Level 1 dofs: 16 16 16 16
-DEAL::Level 2 dofs: 64 64 64 64
-DEAL::u0       4       4       4       4
-DEAL::u1       16      16      16      16
-DEAL::u2       64      64      64      64
-DEAL::u1       256     1024    256     256
-DEAL::u0       1024    16384   1024    1024
-DEAL:: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
+DEAL::All
+DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(1)-FE_DGQ<2>(1)]
+DEAL::selected  0 1
+DEAL::Global  dofs: 144 64
+DEAL::Level 0 dofs: 12 4
+DEAL::Level 1 dofs: 40 16
+DEAL::Level 2 dofs: 144 64
+DEAL::u0       12      4
+DEAL::u1       40      16
+DEAL::u2       144     64
+DEAL::u1       572     256
+DEAL::u0       2214    1024
+DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
+DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
+DEAL::Velocity
+DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(1)-FE_DGQ<2>(1)]
+DEAL::selected  0
+DEAL::Global  dofs: 144 64
+DEAL::Level 0 dofs: 12 4
+DEAL::Level 1 dofs: 40 16
+DEAL::Level 2 dofs: 144 64
+DEAL::u0       12      4
+DEAL::u1       40      0
+DEAL::u2       144     0
+DEAL::u1       572     0
+DEAL::u0       2214    0
+DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
+DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::Pressure
+DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(1)-FE_DGQ<2>(1)]
+DEAL::selected  1
+DEAL::Global  dofs: 144 64
+DEAL::Level 0 dofs: 12 4
+DEAL::Level 1 dofs: 40 16
+DEAL::Level 2 dofs: 144 64
+DEAL::u0       12      4
+DEAL::u1       0       16
+DEAL::u2       0       64
+DEAL::u1       0       256
+DEAL::u0       0       1024
+DEAL:: 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
+DEAL:: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
+DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(0)^2-FE_DGQ<2>(0)^2]
+DEAL::selected  1 3
+DEAL::Global  dofs: 40 40 16 16
+DEAL::Level 0 dofs: 4 4 1 1
+DEAL::Level 1 dofs: 12 12 4 4
+DEAL::Level 2 dofs: 40 40 16 16
+DEAL::u0       4       4       1       1
+DEAL::u1       0       12      0       4
+DEAL::u2       0       40      0       16
+DEAL::u1       0       136     0       64
+DEAL::u0       0       400     0       256
+DEAL:: 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
+DEAL:: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/tests/multigrid/transfer_block_select.cc b/tests/multigrid/transfer_block_select.cc
new file mode 100644 (file)
index 0000000..94d6996
--- /dev/null
@@ -0,0 +1,155 @@
+//----------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2000 - 2007 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/vector.h>
+#include <lac/block_vector.h>
+#include <grid/tria.h>
+#include <grid/grid_generator.h>
+#include <dofs/dof_renumbering.h>
+#include <dofs/dof_tools.h>
+#include <fe/fe_dgp.h>
+#include <fe/fe_dgq.h>
+#include <fe/fe_q.h>
+#include <fe/fe_raviart_thomas.h>
+#include <fe/fe_system.h>
+#include <multigrid/mg_dof_handler.h>
+#include <multigrid/mg_transfer_block.h>
+#include <multigrid/mg_tools.h>
+#include <multigrid/mg_level_object.h>
+
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <algorithm>
+
+using namespace std;
+
+template <int dim>
+void check_select(const FiniteElement<dim>& fe, unsigned int selected)
+{
+  deallog << fe.get_name()
+         << " select " << selected << std::endl;
+  
+  Triangulation<dim> tr;
+  GridGenerator::hyper_cube(tr);
+  tr.refine_global(2);
+  
+  MGDoFHandler<dim> mgdof(tr);
+  DoFHandler<dim>& dof=mgdof;
+  mgdof.distribute_dofs(fe);
+  DoFRenumbering::component_wise(static_cast<DoFHandler<dim>&>(mgdof));
+  vector<unsigned int> ndofs(fe.n_blocks());
+  DoFTools::count_dofs_per_block(mgdof, ndofs);
+  
+  for (unsigned int l=0;l<tr.n_levels();++l)
+    DoFRenumbering::component_wise(mgdof, l);
+  std::vector<std::vector<unsigned int> > mg_ndofs(mgdof.get_tria().n_levels());
+  MGTools::count_dofs_per_block(mgdof, mg_ndofs);
+
+  deallog << "Global  dofs:";
+  for (unsigned int i=0;i<ndofs.size();++i)
+    deallog << ' ' << ndofs[i];
+  deallog << std::endl;
+  for (unsigned int l=0;l<mg_ndofs.size();++l)
+    {
+      deallog << "Level " << l << " dofs:";
+      for (unsigned int i=0;i<mg_ndofs[l].size();++i)
+       deallog << ' ' << mg_ndofs[l][i];
+      deallog << std::endl;
+    }  
+  
+  MGTransferBlockSelect<double> transfer;
+  transfer.build_matrices(dof, mgdof, selected);
+
+                                  // First, prolongate the constant
+                                  // function from the coarsest mesh
+                                  // to the finer ones. Since this is
+                                  // the embedding, we obtain the
+                                  // constant one and the l2-norm is
+                                  // the number of degrees of freedom.
+  Vector<double> u2(mg_ndofs[2][selected]);
+  Vector<double> u1(mg_ndofs[1][selected]);
+  Vector<double> u0(mg_ndofs[0][selected]);
+
+  u0 = 1;
+  transfer.prolongate(1,u1,u0);
+  transfer.prolongate(2,u2,u1);
+  deallog << "u0\t" << (int) (u0*u0+.5) << std::endl
+         << "u1\t" << (int) (u1*u1+.5) << std::endl
+         << "u2\t" << (int) (u2*u2+.5) << std::endl;
+                                  // Now restrict the same vectors.
+  u1 = 0.;
+  u0 = 0.;
+  transfer.restrict_and_add(2,u1,u2);
+  transfer.restrict_and_add(1,u0,u1);
+  deallog << "u1\t" << (int) (u1*u1+.5) << std::endl
+         << "u0\t" << (int) (u0*u0+.5) << std::endl;
+
+                                  // Fill a global vector by counting
+                                  // from one up
+  BlockVector<double> u;
+  u.reinit (ndofs);
+  for (unsigned int i=0;i<u.size();++i)
+    u(i) = i+1;
+
+                                  // See what part gets copied to mg
+  MGLevelObject<Vector<double> > v;
+  v.resize(2,2);
+  v[2].reinit(mg_ndofs[2][selected]);
+
+  transfer.copy_to_mg(mgdof, v, u);
+  for (unsigned int i=0; i<v[2].size();++i)
+    deallog << ' ' << (int) v[2](i);
+  deallog << std::endl;
+
+                                  // Now do the opposite: fill a
+                                  // multigrid vector counting the
+                                  // dofs and see where the numbers go
+  u = 0.;
+  for (unsigned int i=0;i<v[2].size();++i)
+    v[2](i) = i+1;
+  transfer.copy_from_mg_add(mgdof, u, v);
+  for (unsigned int i=0; i<u.size();++i)
+    deallog << ' ' << (int) u(i);
+  deallog << std::endl;
+  
+}
+
+
+int main()
+{
+  std::ofstream logfile("transfer_block_select/output");
+  logfile.precision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+  
+  FE_DGQ<2> q0(0);
+  FE_DGQ<2> q1(1);
+  FE_RaviartThomasNodal<2> rt0(0);
+  FE_RaviartThomasNodal<2> rt1(1);
+  
+  FESystem<2> fe0(rt1, 1, q1, 1);
+  FESystem<2> fe1(rt0, 2, q0, 2);
+  
+  check_select(fe0, 0);
+  check_select(fe0, 1);
+  
+  check_select(fe1, 0);
+  check_select(fe1, 1);
+  check_select(fe1, 2);
+  check_select(fe1, 3);
+}
diff --git a/tests/multigrid/transfer_block_select/cmp/generic b/tests/multigrid/transfer_block_select/cmp/generic
new file mode 100644 (file)
index 0000000..1a7206b
--- /dev/null
@@ -0,0 +1,73 @@
+
+DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(1)-FE_DGQ<2>(1)] select 0
+DEAL::Global  dofs: 144 64
+DEAL::Level 0 dofs: 12 4
+DEAL::Level 1 dofs: 40 16
+DEAL::Level 2 dofs: 144 64
+DEAL::u0       12
+DEAL::u1       40
+DEAL::u2       144
+DEAL::u1       572
+DEAL::u0       2214
+DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
+DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(1)-FE_DGQ<2>(1)] select 1
+DEAL::Global  dofs: 144 64
+DEAL::Level 0 dofs: 12 4
+DEAL::Level 1 dofs: 40 16
+DEAL::Level 2 dofs: 144 64
+DEAL::u0       4
+DEAL::u1       16
+DEAL::u2       64
+DEAL::u1       256
+DEAL::u0       1024
+DEAL:: 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
+DEAL:: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
+DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(0)^2-FE_DGQ<2>(0)^2] select 0
+DEAL::Global  dofs: 40 40 16 16
+DEAL::Level 0 dofs: 4 4 1 1
+DEAL::Level 1 dofs: 12 12 4 4
+DEAL::Level 2 dofs: 40 40 16 16
+DEAL::u0       4
+DEAL::u1       12
+DEAL::u2       40
+DEAL::u1       136
+DEAL::u0       400
+DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
+DEAL:: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(0)^2-FE_DGQ<2>(0)^2] select 1
+DEAL::Global  dofs: 40 40 16 16
+DEAL::Level 0 dofs: 4 4 1 1
+DEAL::Level 1 dofs: 12 12 4 4
+DEAL::Level 2 dofs: 40 40 16 16
+DEAL::u0       4
+DEAL::u1       12
+DEAL::u2       40
+DEAL::u1       136
+DEAL::u0       400
+DEAL:: 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
+DEAL:: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(0)^2-FE_DGQ<2>(0)^2] select 2
+DEAL::Global  dofs: 40 40 16 16
+DEAL::Level 0 dofs: 4 4 1 1
+DEAL::Level 1 dofs: 12 12 4 4
+DEAL::Level 2 dofs: 40 40 16 16
+DEAL::u0       1
+DEAL::u1       4
+DEAL::u2       16
+DEAL::u1       64
+DEAL::u0       256
+DEAL:: 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
+DEAL:: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+DEAL::FESystem<2>[FE_RaviartThomasNodal<2>(0)^2-FE_DGQ<2>(0)^2] select 3
+DEAL::Global  dofs: 40 40 16 16
+DEAL::Level 0 dofs: 4 4 1 1
+DEAL::Level 1 dofs: 12 12 4 4
+DEAL::Level 2 dofs: 40 40 16 16
+DEAL::u0       1
+DEAL::u1       4
+DEAL::u2       16
+DEAL::u1       64
+DEAL::u0       256
+DEAL:: 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
+DEAL:: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
index f8f71053d598f55416f1452781b2c3d4e69a12eb..edbc45cd6c4c43397e1746e5ab86944151737620 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2000 - 2006 by the deal.II authors
+//    Copyright (C) 2000 - 2007 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -25,7 +25,7 @@
 #include <fe/fe_q.h>
 #include <fe/fe_system.h>
 #include <multigrid/mg_dof_handler.h>
-#include <multigrid/mg_transfer.h>
+#include <multigrid/mg_transfer_component.h>
 #include <multigrid/mg_tools.h>
 #include <multigrid/mg_level_object.h>
 

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.