virtual void Tvmult_add (const unsigned int level,
VectorType &dst,
const VectorType &src) const = 0;
+
+ /**
+ * Return the minimal level for which matrices are stored.
+ */
+ virtual unsigned int get_minlevel() const = 0;
+
+ /**
+ * Return the minimal level for which matrices are stored.
+ */
+ virtual unsigned int get_maxlevel() const = 0;
};
virtual void vmult_add (const unsigned int level, VectorType &dst, const VectorType &src) const;
virtual void Tvmult (const unsigned int level, VectorType &dst, const VectorType &src) const;
virtual void Tvmult_add (const unsigned int level, VectorType &dst, const VectorType &src) const;
+ virtual unsigned int get_minlevel() const;
+ virtual unsigned int get_maxlevel() const;
/**
* Memory used by this object.
}
+
template <typename VectorType>
template <typename MatrixType>
inline
}
+
template <typename VectorType>
inline
Matrix<VectorType>::Matrix ()
{}
+
template <typename VectorType>
inline
const PointerMatrixBase<VectorType> &
}
+
template <typename VectorType>
void
Matrix<VectorType>::vmult (const unsigned int level,
}
+
template <typename VectorType>
void
Matrix<VectorType>::vmult_add (const unsigned int level,
}
+
template <typename VectorType>
void
Matrix<VectorType>::Tvmult (const unsigned int level,
}
+
template <typename VectorType>
void
Matrix<VectorType>::Tvmult_add (const unsigned int level,
}
+
+ template <typename VectorType>
+ unsigned int
+ Matrix<VectorType>::get_minlevel() const
+ {
+ return matrices.min_level();
+ }
+
+
+
+ template <typename VectorType>
+ unsigned int
+ Matrix<VectorType>::get_maxlevel() const
+ {
+ return matrices.max_level();
+ }
+
+
+
template <typename VectorType>
inline
std::size_t
}
+
template <typename MatrixType, typename number>
void
MGMatrixSelect<MatrixType, number>::
}
+
template <typename MatrixType, typename number>
void
MGMatrixSelect<MatrixType, number>::
}
+
template <typename MatrixType, typename number>
void
MGMatrixSelect<MatrixType, number>::
}
+
template <typename MatrixType, typename number>
void
MGMatrixSelect<MatrixType, number>::
}
+
template <typename MatrixType, typename number>
void
MGMatrixSelect<MatrixType, number>::
* This function already initializes the vectors which will be used later in
* the course of the computations. You should therefore create objects of
* this type as late as possible.
+ *
+ * @deprecated Use the other constructor instead.
+ * The DoFHandler is actually not needed.
*/
template <int dim>
Multigrid(const DoFHandler<dim> &mg_dof_handler,
const MGTransferBase<VectorType> &transfer,
const MGSmootherBase<VectorType> &pre_smooth,
const MGSmootherBase<VectorType> &post_smooth,
- Cycle cycle = v_cycle,
const unsigned int minlevel = 0,
- const unsigned int maxlevel = numbers::invalid_unsigned_int);
+ const unsigned int maxlevel = numbers::invalid_unsigned_int,
+ Cycle cycle = v_cycle) DEAL_II_DEPRECATED;
/**
- * Constructor. Same as above but without checking validity of minlevel and maxlevel.
+ * Constructor. <tt>transfer</tt> is an object performing prolongation and
+ * restriction. For levels in [minlevel, maxlevel] matrix has to contain
+ * valid matrices. By default the maxlevel is set to the maximal valid level.
+ *
+ * This function already initializes the vectors which will be used later in
+ * the course of the computations. You should therefore create objects of
+ * this type as late as possible.
*/
- Multigrid(const unsigned int minlevel,
- const unsigned int maxlevel,
- const MGMatrixBase<VectorType> &matrix,
+ Multigrid(const MGMatrixBase<VectorType> &matrix,
const MGCoarseGridBase<VectorType> &coarse,
const MGTransferBase<VectorType> &transfer,
const MGSmootherBase<VectorType> &pre_smooth,
const MGSmootherBase<VectorType> &post_smooth,
+ const unsigned int minlevel = 0,
+ const unsigned int maxlevel = numbers::invalid_unsigned_int,
Cycle cycle = v_cycle);
/**
const MGTransferBase<VectorType> &transfer,
const MGSmootherBase<VectorType> &pre_smooth,
const MGSmootherBase<VectorType> &post_smooth,
- Cycle cycle,
const unsigned int min_level,
- const unsigned int max_level)
+ const unsigned int max_level,
+ Cycle cycle)
:
cycle_type(cycle),
minlevel(min_level),
else
maxlevel = max_level;
- Assert (maxlevel <= dof_handler_max_level,
- ExcLowerRangeType<unsigned int>(dof_handler_max_level, max_level));
- Assert (minlevel <= maxlevel,
- ExcLowerRangeType<unsigned int>(max_level, min_level));
+ reinit(minlevel, maxlevel);
+}
+
+
- defect.resize(minlevel,maxlevel);
- solution.resize(minlevel,maxlevel);
- t.resize(minlevel,maxlevel);
- defect2.resize(minlevel,maxlevel);
+template <typename VectorType>
+Multigrid<VectorType>::Multigrid (const MGMatrixBase<VectorType> &matrix,
+ const MGCoarseGridBase<VectorType> &coarse,
+ const MGTransferBase<VectorType> &transfer,
+ const MGSmootherBase<VectorType> &pre_smooth,
+ const MGSmootherBase<VectorType> &post_smooth,
+ const unsigned int min_level,
+ const unsigned int max_level,
+ Cycle cycle)
+ :
+ cycle_type(cycle),
+ matrix(&matrix, typeid(*this).name()),
+ coarse(&coarse, typeid(*this).name()),
+ transfer(&transfer, typeid(*this).name()),
+ pre_smooth(&pre_smooth, typeid(*this).name()),
+ post_smooth(&post_smooth, typeid(*this).name()),
+ edge_out(0, typeid(*this).name()),
+ edge_in(0, typeid(*this).name()),
+ edge_down(0, typeid(*this).name()),
+ edge_up(0, typeid(*this).name()),
+ debug(0)
+{
+ if (max_level == numbers::invalid_unsigned_int)
+ maxlevel = matrix.get_maxlevel();
+ else
+ maxlevel = max_level;
+ reinit(min_level, maxlevel);
}
DEAL_II_NAMESPACE_OPEN
-
-template <typename VectorType>
-Multigrid<VectorType>::Multigrid (const unsigned int minlevel,
- const unsigned int maxlevel,
- const MGMatrixBase<VectorType> &matrix,
- const MGCoarseGridBase<VectorType> &coarse,
- const MGTransferBase<VectorType> &transfer,
- const MGSmootherBase<VectorType> &pre_smooth,
- const MGSmootherBase<VectorType> &post_smooth,
- typename Multigrid<VectorType>::Cycle cycle)
- :
- cycle_type(cycle),
- minlevel(minlevel),
- maxlevel(maxlevel),
- defect(minlevel,maxlevel),
- solution(minlevel,maxlevel),
- t(minlevel,maxlevel),
- matrix(&matrix, typeid(*this).name()),
- coarse(&coarse, typeid(*this).name()),
- transfer(&transfer, typeid(*this).name()),
- pre_smooth(&pre_smooth, typeid(*this).name()),
- post_smooth(&post_smooth, typeid(*this).name()),
- edge_out(0, typeid(*this).name()),
- edge_in(0, typeid(*this).name()),
- edge_down(0, typeid(*this).name()),
- edge_up(0, typeid(*this).name()),
- debug(0)
-{}
-
-
-
template <typename VectorType>
void
Multigrid<VectorType>::reinit (const unsigned int min_level,
const unsigned int max_level)
{
+ Assert (min_level >= matrix->get_minlevel(),
+ ExcLowerRangeType<unsigned int>(min_level, matrix->get_minlevel()));
+ Assert (max_level <= matrix->get_maxlevel(),
+ ExcLowerRangeType<unsigned int>(matrix->get_maxlevel(), max_level));
Assert (min_level <= max_level,
ExcLowerRangeType<unsigned int>(max_level, min_level));
minlevel=min_level;
}
+
template <typename VectorType>
void
Multigrid<VectorType>::set_maxlevel (const unsigned int l)
}
+
template <typename VectorType>
void
Multigrid<VectorType>::set_minlevel (const unsigned int l,
}
+
template <typename VectorType>
void
Multigrid<VectorType>::set_cycle(typename Multigrid<VectorType>::Cycle c)
}
+
template <typename VectorType>
void
Multigrid<VectorType>::set_debug (const unsigned int d)
}
+
template <typename VectorType>
void
Multigrid<VectorType>::set_edge_matrices (const MGMatrixBase<VectorType> &down,
}
+
template <typename VectorType>
void
Multigrid<VectorType>::set_edge_flux_matrices (const MGMatrixBase<VectorType> &down,
}
+
template <typename VectorType>
void
Multigrid<VectorType>::level_v_step (const unsigned int level)
}
+
template <typename VectorType>
void
Multigrid<VectorType>::cycle()
}
+
template <typename VectorType>
void
Multigrid<VectorType>::vcycle()
level_matrices[i].reinit(N, N);
mg::Matrix<VectorType> mgmatrix(level_matrices);
- Multigrid<VectorType> mg1(minlevel, maxlevel, mgmatrix, all, all, all, all,
- Multigrid<VectorType>::v_cycle);
+ Multigrid<VectorType> mg1(mgmatrix, all, all, all, all,
+ minlevel, maxlevel, Multigrid<VectorType>::v_cycle);
mg1.set_debug(3);
for (unsigned int i=minlevel; i<=maxlevel; ++i)
mg1.defect[i].reinit(N);
mg_transfer,
mg_smoother,
mg_smoother,
- Multigrid<Vector<double> >::v_cycle,
min_level,
- triangulation.n_global_levels()-1);
+ triangulation.n_global_levels()-1,
+ Multigrid<Vector<double> >::v_cycle);
mg.set_edge_matrices(mg_interface_down, mg_interface_up);
PreconditionMG<dim, Vector<double>, MGTransferPrebuilt<Vector<double> > >
mg::Matrix<LinearAlgebra::distributed::Vector<double> > mg_interface_up(mg_interface_matrices);
mg::Matrix<LinearAlgebra::distributed::Vector<double> > mg_interface_down(mg_interface_matrices);
- Multigrid<LinearAlgebra::distributed::Vector<double> > mg(min_level,
- triangulation.n_global_levels()-1,
- mg_matrix,
+ Multigrid<LinearAlgebra::distributed::Vector<double> > mg(mg_matrix,
coarse_grid_solver,
mg_transfer,
mg_smoother,
- mg_smoother);
+ mg_smoother,
+ min_level,
+ triangulation.n_global_levels()-1);
+ Assert(min_level == mg.get_minlevel(), ExcInternalError());
+ Assert(triangulation.n_global_levels()-1 == mg.get_maxlevel(), ExcInternalError());
mg.set_edge_matrices(mg_interface_down, mg_interface_up);
PreconditionMG<dim, LinearAlgebra::distributed::Vector<double>, MGTransferPrebuilt<LinearAlgebra::distributed::Vector<double> > >