// $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
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
*/
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
*/
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);
};
/*@}*/
// $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
};
-/**
- * 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
// 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
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
--- /dev/null
+//---------------------------------------------------------------------------
+// $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
--- /dev/null
+//---------------------------------------------------------------------------
+// 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
--- /dev/null
+//---------------------------------------------------------------------------
+// $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
--- /dev/null
+//---------------------------------------------------------------------------
+// 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
#include <dofs/dof_tools.h>
#include <fe/fe.h>
+#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
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.
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;
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)
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()));
}
+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
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>&,
// $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
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!
// 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],
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]);
};
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));
}
+
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);
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]));
}
}
}
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;
--- /dev/null
+//---------------------------------------------------------------------------
+// $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
// $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
{
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));
}
}
{
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
}
+//----------------------------------------------------------------------//
+
+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> >;
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 (
############################################################
# $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
############################################################
############################################################
############################################################
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
// 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
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;
}
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));
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
// $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>
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);
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)
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);
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);
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;
+
}
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);
}
-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
--- /dev/null
+//----------------------------------------------------------------------------
+// $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);
+}
--- /dev/null
+
+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
// $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_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>