// $Id$
// Version: $Name$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005 by the deal.II authors
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
void
copy_to_mg (const MGDoFHandler<dim>& mg_dof,
MGLevelObject<VECTOR>& dst,
- const InVector& src) const;
+ const InVector& src) const;
/**
* Transfer from multi-level vector to
*/
template <int dim, class OutVector>
void
- copy_from_mg (const MGDoFHandler<dim> &mg_dof,
- OutVector &dst,
+ copy_from_mg (const MGDoFHandler<dim>& mg_dof,
+ OutVector& dst,
const MGLevelObject<VECTOR> &src) const;
/**
*/
template <int dim, class OutVector>
void
- copy_from_mg_add (const MGDoFHandler<dim> &mg_dof,
- OutVector &dst,
- const MGLevelObject<VECTOR> &src) const;
+ copy_from_mg_add (const MGDoFHandler<dim>& mg_dof,
+ OutVector& dst,
+ const MGLevelObject<VECTOR>& src) const;
/**
* Finite element does not
*/
std::vector<unsigned int> sizes;
-#ifdef DEAL_PREFER_MATRIX_EZ
- /**
- * 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<SparseMatrixEZ<double> > > prolongation_matrices;
-#else
/**
* Sparsity patterns for transfer
* matrices.
* while row indices belong to the
* child cell, i.e. the fine level.
*/
- std::vector<boost::shared_ptr<SparseMatrix<double> > > prolongation_matrices;
-#endif
-
- /**
- * Structure that is used to
- * disambiguate calls to
- * @p copy_to_mg for 1d and
- * non-1d. We provide two
- * functions of @p copy_to_mg,
- * where the 1d function takes an
- * argument of type
- * <tt>is_1d<true></tt> and the other
- * one of type <tt>is_1d<false></tt>.
- */
- template <bool> struct is_1d {};
-
- /**
- * Implementation of the
- * copy_to_mg() function for
- * 1d. We have to resort to some
- * template trickery because we
- * can't specialize template
- * functions on the (outer)
- * template of the class, without
- * also fully specializing the
- * inner (member function)
- * template parameters. However,
- * it can be done by adding the
- * additional argument that
- * converts template
- * specialization into function
- * overloading.
- */
- template <int dim, class InVector>
- void
- copy_to_mg (const MGDoFHandler<dim> &mg_dof,
- MGLevelObject<VECTOR> &dst,
- const InVector &src,
- const is_1d<true> &) const;
-
- /**
- * Same for all other space
- * dimensions.
- */
- template <int dim, class InVector>
- void
- copy_to_mg (const MGDoFHandler<dim> &mg_dof,
- MGLevelObject<VECTOR> &dst,
- const InVector &src,
- const is_1d<false> &) const;
+ std::vector<boost::shared_ptr<SparseMatrix<double> > > prolongation_matrices;
};
* function first.
*/
DeclException0(ExcMatricesNotBuilt);
-
-#ifdef DEAL_PREFER_MATRIX_EZ
- 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<BlockSparseMatrixEZ<double> > > prolongation_matrices;
-#else
+
private:
std::vector<boost::shared_ptr<BlockSparsityPattern> > prolongation_sparsities;
-
+
protected:
-
+
/**
* The actual prolongation matrix.
* column indices belong to the
* child cell, i.e. the fine level.
*/
std::vector<boost::shared_ptr<BlockSparseMatrix<double> > > prolongation_matrices;
-#endif
-
+
/**
* Unused now, but intended to
* hold the mapping for the
MGTransferBlockBase::memory_consumption;
private:
- /**
- * Structure that is used to
- * disambiguate calls to
- * @p copy_to_mg for 1d and
- * non-1d. We provide two
- * functions of @p copy_to_mg,
- * where the 1d function takes an
- * argument of type
- * <tt>is_1d<true></tt> and the other
- * one of type <tt>is_1d<false></tt>.
- */
- template <bool> struct is_1d {};
-
- /**
- * Implementation of the
- * @p copy_to_mg function for
- * 1d. We have to resort to some
- * template trickery because we
- * can't specialize template
- * functions on the (outer)
- * template of the class, without
- * also fully specializing the
- * inner (member function)
- * template parameters. However,
- * it can be done by adding the
- * additional argument that
- * converts template
- * specialization into function
- * overloading.
- */
- template <int dim, class InVector>
- void
- copy_to_mg (const MGDoFHandler<dim> &mg_dof,
- MGLevelObject<BlockVector<number> > &dst,
- const InVector &src,
- const is_1d<true> &) const;
-
- /**
- * Same for all other space
- * dimensions.
- */
- template <int dim, class InVector>
- void
- copy_to_mg (const MGDoFHandler<dim> &mg_dof,
- MGLevelObject<BlockVector<number> > &dst,
- const InVector &src,
- const is_1d<false> &) const;
-
/**
* Optional multiplication
* factors for each
virtual void restrict_and_add (const unsigned int from_level,
Vector<number> &dst,
const Vector<number> &src) const;
-
- /**
- * Structure that is used to
- * disambiguate calls to
- * copy_to_mg() for 1d and
- * non-1d. We provide two
- * functions of copy_to_mg(),
- * where the 1d function takes an
- * argument of type
- * <tt>is_1d<true></tt> and the other
- * one of type <tt>is_1d<false></tt>}.
- */
- template <bool> struct is_1d {};
/**
* Transfer from a vector on the
const unsigned int offset) const;
/**
- * Implementation of the
- * copy_to_mg() function for
- * 1d. We have to resort to some
- * template trickery because we
- * can't specialize template
- * functions on the (outer)
- * template of the class, without
- * also fully specializing the
- * inner (member function)
- * template parameters. However,
- * it can be done by adding the
- * additional argument that
- * converts template
- * specialization into function
- * overloading.
+ * 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 is_1d<true> &) const;
-
- /**
- * Implementation of the
- * copy_to_mg() function for
- * higher dimensions.
- */
- 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 is_1d<false> &) const;
-
+ const unsigned int offset) const;
/**
* Selected component of global vector.
*/
// $Id$
// Version: $Name$
//
-// Copyright (C) 2003, 2004, 2005 by the deal.II authors
+// Copyright (C) 2003, 2004, 2005, 2006 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
MGLevelObject<VECTOR> &dst,
const InVector &src) const
{
- // forward to the correct
- // specialization
- copy_to_mg (mg_dof_handler, dst, src, is_1d<(dim==1)>());
-}
-
-
-template <class VECTOR>
-template <int dim, class InVector>
-void
-MGTransferPrebuilt<VECTOR>::copy_to_mg (
- const MGDoFHandler<dim> &,
- MGLevelObject<VECTOR> &,
- const InVector &,
- const is_1d<true> &) const
-{
- Assert(false, ExcNotImplemented());
-}
-
-
-template <class VECTOR>
-template <int dim, class InVector>
-void
-MGTransferPrebuilt<VECTOR>::copy_to_mg (
- const MGDoFHandler<dim>& mg_dof_handler,
- MGLevelObject<VECTOR>& dst,
- const InVector& src,
- const is_1d<false>&) const
-{
- // Make src a real finite element function
-// InVector src = osrc;
-// constraints->distribute(src);
- const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell;
- const unsigned int dofs_per_face = mg_dof_handler.get_fe().dofs_per_face;
-
+ const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+ Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0));
+
+ 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();
std::vector<unsigned int> global_dof_indices (dofs_per_cell);
std::vector<unsigned int> level_dof_indices (dofs_per_cell);
- std::vector<unsigned int> level_face_indices (dofs_per_face);
-
+
// traverse the grid top-down
// (i.e. starting with the most
// refined grid). this way, we can
const typename MGDoFHandler<dim>::active_cell_iterator
level_end = mg_dof_handler.end_active(level);
-//TODO:[?] Treat hanging nodes properly
-// The single-level vector is not an FE-function, because the values at
-// hanging nodes are set to zero. This should be treated before the restriction.
-
// Compute coarse level right hand side
// by restricting from fine level.
for (; level_cell!=level_end; ++level_cell)
// into the level-wise one
for (unsigned int i=0; i<dofs_per_cell; ++i)
dst[level](level_dof_indices[i]) = src(global_dof_indices[i]);
-
- for (unsigned int face_n=0; face_n<GeometryInfo<dim>::faces_per_cell; ++face_n)
- {
- const typename MGDoFHandler<dim>::face_iterator
- face = level_cell->face(face_n);
- if (face->has_children())
- {
- face->get_mg_dof_indices(level_face_indices);
-
-
- // Delete values on refinement edge,
- // since restriction will add them again.
- for (unsigned int i=0; i<dofs_per_face; ++i)
- dst[level](level_face_indices[i])
- = 0.;
- };
- };
- };
+ }
// for that part of the level
// which is further refined:
// get the defect by
{
restrict_and_add (level+1, dst[level], dst[level+1]);
}
- };
+ }
}
OutVector& dst,
const MGLevelObject<VECTOR>& src) const
{
- const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell;
-
+ const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+ Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0));
+
+ 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);
OutVector &dst,
const MGLevelObject<VECTOR> &src) const
{
- const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell;
-
+ const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+ Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0));
+
+ 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);
MGLevelObject<Vector<number> > &dst,
const BlockVector<number2> &src) const
{
- // forward to the correct
- // specialization
- do_copy_to_mg (mg_dof_handler, dst, src,
- 0, //component_start[selected_component],
- is_1d<(dim==1)>());
+ do_copy_to_mg (mg_dof_handler, dst, src, 0);
}
MGLevelObject<Vector<number> > &dst,
const Vector<number2> &src) const
{
- // forward to the correct
- // specialization
- do_copy_to_mg (mg_dof_handler, dst, src,
- component_start[selected_component],
- is_1d<(dim==1)>());
-}
-
-
-
-template <typename number>
-template <int dim, class InVector>
-void
-MGTransferSelect<number>::do_copy_to_mg (
- const MGDoFHandler<dim>&,
- MGLevelObject<Vector<number> >&,
- const InVector&,
- const unsigned int,
- const is_1d<true>&) const
-{
- Assert(false, ExcNotImplemented());
+ do_copy_to_mg (mg_dof_handler, dst, src, component_start[selected_component]);
}
const MGDoFHandler<dim>& mg_dof_handler,
MGLevelObject<Vector<number> >& dst,
const InVector& src,
- const unsigned int offset,
- const is_1d<false>&) const
+ const unsigned int offset) const
{
- // Make src a real finite element function
-// InVector src = osrc;
-// constraints->distribute(src);
-
const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+ Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0));
+
const unsigned int dofs_per_cell = fe.dofs_per_cell;
- const unsigned int dofs_per_face = fe.dofs_per_face;
-
+
// set the elements of the vectors
// on all levels to zero
unsigned int minlevel = dst.get_minlevel();
std::vector<unsigned int> global_dof_indices (dofs_per_cell);
std::vector<unsigned int> level_dof_indices (dofs_per_cell);
- std::vector<unsigned int> level_face_indices (dofs_per_face);
-
+
// Build a vector of the selected
// indices, since traversing all
// indices on each cell is too
const MGLevelObject<Vector<number> > &src,
const unsigned int offset) const
{
-
const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+ Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0));
+
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);
const MGLevelObject<Vector<number> > &src,
const unsigned int offset) const
{
-
const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+ Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0));
const unsigned int dofs_per_cell = fe.dofs_per_cell;
std::vector<unsigned int> global_dof_indices (dofs_per_cell);
MGLevelObject<BlockVector<number> > &dst,
const InVector &src) const
{
- // forward to the correct
- // specialization
- copy_to_mg (mg_dof_handler, dst, src, is_1d<(dim==1)>());
-}
-
-
-
-template <typename number>
-template <int dim, class InVector>
-void
-MGTransferBlock<number>::copy_to_mg (
- const MGDoFHandler<dim> &,
- MGLevelObject<BlockVector<number> > &,
- const InVector &,
- const is_1d<true> &) const
-{
- Assert(false, ExcNotImplemented());
-}
-
-
-
-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 is_1d<false> &) const
-{
- // Make src a real finite element
- // function
-// InVector src = osrc;
-// constraints->distribute(src);
-
const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+ Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0));
+
const unsigned int dofs_per_cell = fe.dofs_per_cell;
- const unsigned int dofs_per_face = fe.dofs_per_face;
// set the elements of the vectors
// on all levels to zero
std::vector<unsigned int> global_dof_indices (dofs_per_cell);
std::vector<unsigned int> level_dof_indices (dofs_per_cell);
- std::vector<unsigned int> level_face_indices (dofs_per_face);
-
+
// traverse the grid top-down
// (i.e. starting with the most
// refined grid). this way, we can
dst[level](level_dof_indices[i])
= src(global_dof_indices[i]);
}
-//TODO: Special treatment of faces? Copy from MGTransferPrebuilt when done there.
}
// for that part of the level
// which is further refined:
OutVector &dst,
const MGLevelObject<BlockVector<number> > &src) const
{
-
const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+ Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0));
+
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);
const MGLevelObject<BlockVector<number> > &src) const
{
const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
+ Assert (fe.dofs_per_face == 0, ExcDimensionMismatch(fe.dofs_per_face, 0));
+
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);