//TODO: this function is only for debugging purposes and should be removed sometimes
template<class VECTOR>
static
-void print_vector(ostream& s, const VECTOR& v)
+void print_vector(ostream& s, const VECTOR& v, const char* text)
{
const unsigned int n = (unsigned int)(sqrt(v.size())+.3);
unsigned int k=0;
+ s << endl << "splot '-' title '" << text << "'" << endl;
+
// write the vector entries in a
// kind of square
for (unsigned int i=0;i<n;++i)
{
for (unsigned int j=0;j<n;++j)
- s << '\t' << v(k++);
+ s << '\n' << v(k++);
s << endl;
}
- s << endl;
+ s << "e\npause -1" << endl;
}
const MGSmootherBase &post_smooth,
const MGCoarseGridSolver &coarse_grid_solver)
{
+// static int k=0;
+// cout << "set title 'cycle " << ++k << "'\n";
+
level_mgstep(maxlevel, pre_smooth, post_smooth, coarse_grid_solver);
};
// t = d-As
t.reinit(solution[level].size());
level_vmult(level, t, solution[level], defect[level]);
-
+// print_vector(cout,t,"T");
+
// make t rhs of lower level
//TODO: this function adds the restricted t to defect[level-1].
//TODO: why don't we have to clear it before?
transfer->restrict_and_add (level, defect[level-1], t);
+// print_vector(cout,defect[level-1],"Dl-1");
// do recursion
level_mgstep(level-1, pre_smooth, post_smooth, coarse_grid_solver);
t.reinit(solution[level].size());
// do coarse grid correction
+// print_vector(cout,solution[level-1],"Sl-1");
transfer->prolongate(level, t, solution[level-1]);
+// print_vector(cout,t,"T");
solution[level] += t;
// smoothing (modify solution again)