* returning the solution to the system @p{Ax=b} on the coarsest level
* in @p{x}.
*
- * @author Guido Kanschat, 1999, 2001, 2002, Ralf Hartmann 2002
+ * @author Guido Kanschat, 1999, 2001, 2002, Ralf Hartmann 2002, 2003.
*/
template <class VECTOR>
class Multigrid : public Subscriptor
*/
void set_edge_matrices (const MGMatrixBase<VECTOR>& edge_down,
const MGMatrixBase<VECTOR>& edge_up);
+
+#ifdef MG_DEBUG
+ void print_vector (const unsigned int level,
+ const VECTOR &v,
+ const char *name) const;
+#endif
+
private:
/**
* this level.
*/
void level_mgstep (const unsigned int level);
+
/**
* Level for coarse grid solution.
*/
*/
SmartPointer<const MGMatrixBase<VECTOR> > edge_up;
+ /**
+ * Pointer to the MGDoFHandler
+ * given to the constructor. Only
+ * needed for @p{MG_DEBUG}
+ * defined.
+ */
+#ifdef MG_DEBUG
+ SmartPointer<const MGDoFHandler<deal_II_dimension> > mg_dof_handler;
+#endif
/**
* Exception.
*/
post_smooth(&post_smooth),
edge_down(0),
edge_up(0)
+#ifdef MG_DEBUG
+ , mg_dof_handler(&mg_dof_handler)
+#endif
{}
//---------------------------- multigrid.templates.h ---------------------------
#ifndef __deal2__multigrid_templates_h
#define __deal2__multigrid_templates_h
+#include <multigrid/multigrid.h>
+
+#ifdef MG_DEBUG
+#include <fe/fe.h>
+#include <dofs/dof_accessor.h>
+#include <numerics/data_out.h>
+#include <multigrid/mg_dof_accessor.h>
+#include <multigrid/mg_dof_handler.h>
+#include <fstream>
+#endif
+
-#include <multigrid/multigrid.h>
template <class VECTOR>
void
return;
}
- // smoothing of the residual by modifying s
+ // smoothing of the residual by
+ // modifying s
pre_smooth->smooth(level, solution[level], defect[level]);
#ifdef MG_DEBUG
// t = A*solution[level]
matrix->vmult(level, t[level], solution[level]);
- // make t rhs of lower level
- // The non-refined parts of the
- // coarse-level defect already contain
- // the global defect, the refined parts
- // its restriction.
+ // make t rhs of lower level The
+ // non-refined parts of the
+ // coarse-level defect already
+ // contain the global defect, the
+ // refined parts its restriction.
for (unsigned int l = level;l>minlevel;--l)
{
t[l-1] = 0.;
#ifdef MG_DEBUG
sprintf(name, "MG%d-cgc",level);
- print_vector(level, t, name);
+ print_vector(level, t[level], name);
#endif
solution[level] += t[level];
-// template <int dim>
-// void
-// Multigrid<dim>::print_vector (const unsigned int /*level*/,
-// const Vector<double>& /*v*/,
-// const char* /*name*/) const
-// {
-// if (level!=maxlevel)
-// return;
-
-// const DoFHandler<dim>* dof = mg_dof_handler;
-
-// Vector<double> out_vector(dof->n_dofs());
-
-// out_vector = -10000;
-
-// const unsigned int dofs_per_cell = mg_dof_handler->get_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 DoFHandler<dim>::active_cell_iterator
-// global_cell = dof->begin_active(level);
-// typename MGDoFHandler<dim>::active_cell_iterator
-// level_cell = mg_dof_handler->begin_active(level);
-// const typename MGDoFHandler<dim>::cell_iterator
-// endc = mg_dof_handler->end(level);
-
-// // traverse all cells and copy the
-// // data appropriately to the output
-// // vector
-// for (; level_cell != endc; ++level_cell, ++global_cell)
-// {
-// global_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)
-// out_vector(global_dof_indices[i])
-// = v(level_dof_indices[i]);
-// }
-
-// std::ofstream out_file(name);
-// DataOut<dim> out;
-// out.attach_dof_handler(*dof);
-// out.add_data_vector(out_vector, "v");
-// out.build_patches(5);
-// out.write_gnuplot(out_file);
-//}
#endif
#include <multigrid/multigrid.templates.h>
+
+
+
+#ifdef MG_DEBUG
+template <>
+void
+Multigrid<Vector<double> >::print_vector (const unsigned int level,
+ const Vector<double> &v,
+ const char *name) const
+{
+ if (level!=maxlevel)
+ return;
+ const unsigned int dim=deal_II_dimension;
+
+ const DoFHandler<dim> *dof = mg_dof_handler;
+
+ Vector<double> out_vector(dof->n_dofs());
+
+ out_vector = -10000;
+
+ const unsigned int dofs_per_cell = mg_dof_handler->get_fe().dofs_per_cell;
+
+ std::vector<unsigned int> global_dof_indices (dofs_per_cell);
+ std::vector<unsigned int> level_dof_indices (dofs_per_cell);
+
+ DoFHandler<dim>::active_cell_iterator
+ global_cell = dof->begin_active(level);
+ MGDoFHandler<dim>::active_cell_iterator
+ level_cell = mg_dof_handler->begin_active(level);
+ const MGDoFHandler<dim>::cell_iterator
+ endc = mg_dof_handler->end(level);
+
+ // traverse all cells and copy the
+ // data appropriately to the output
+ // vector
+ for (; level_cell != endc; ++level_cell, ++global_cell)
+ {
+ global_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)
+ out_vector(global_dof_indices[i])
+ = v(level_dof_indices[i]);
+ }
+
+ std::ofstream out_file(name);
+ DataOut<dim> out;
+ out.attach_dof_handler(*dof);
+ out.add_data_vector(out_vector, "v");
+ out.build_patches(5);
+ out.write_gnuplot(out_file);
+}
+
+
+
+template <class VECTOR>
+void
+Multigrid<VECTOR>::print_vector (const unsigned int level,
+ const VECTOR &v,
+ const char *name) const
+{
+ Assert(false, ExcNotImplemented());
+}
+#endif
+
+
+
+
template <typename number>
MGTransferPrebuilt<number>::~MGTransferPrebuilt ()
{}