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
+ // 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
// transfer the global
// defect in the vector
// into the level-wise one
- for (unsigned int i=0; i<dofs_per_cell; ++i)
+ 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)
{
- 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[level](level_dof_indices[i] - level_start)
- = src(global_dof_indices[i] - offset);
- }
+ dst[level](level_dof_indices[*i] - level_start)
+ = src(global_dof_indices[*i] - offset);
}
-
-// 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:
// one level higher
if (static_cast<unsigned int>(level) < maxlevel)
{
- restrict_and_add (level+1, dst[level], dst[level+1]);
+ ;// restrict_and_add (level+1, dst[level], dst[level+1]);
}
};
}
VECTOR2& dst,
const VECTOR2& src) const
{
+ deallog << "copy to" << endl;
+
transfer->copy_to_mg(*mg_dof_handler,
multigrid->defect,
src);
+ deallog << "mg" << endl;
+
multigrid->vcycle();
+ deallog << "copy from " << endl;
+
transfer->copy_from_mg(*mg_dof_handler,
dst,
multigrid->solution);
VECTOR2& dst,
const VECTOR2& src) const
{
+ deallog << "copy to" << endl;
+
transfer->copy_to_mg(*mg_dof_handler,
multigrid->defect,
src);
+
+ deallog << "mg" << endl;
multigrid->vcycle();
+ deallog << "copy from " << endl;
+
transfer->copy_from_mg_add(*mg_dof_handler,
dst,
multigrid->solution);
#define __deal2__multigrid_templates_h
#include <multigrid/multigrid.h>
+#include <base/logstream.h>
+
+#include "iostream"
+
+using namespace std;
template <class VECTOR>
void
return;
}
+// deallog << "Pre-smooth " << level << endl;
+
// smoothing of the residual by
// modifying s
pre_smooth->smooth(level, solution[level], defect[level]);
+// deallog << "vmult " << level << endl;
// t = A*solution[level]
matrix->vmult(level, t[level], solution[level]);
-
+
+// deallog << "restrict " << level << endl;
// make t rhs of lower level The
// non-refined parts of the
// coarse-level defect already
defect[l-1] -= t[l-1];
}
+// deallog << "recursion " << level << endl;
// do recursion
level_mgstep(level-1);
t[level] = 0.;
// do coarse grid correction
-
+// deallog << "prolongate " << level << endl;
transfer->prolongate(level, t[level], solution[level-1]);
solution[level] += t[level];
edge_up->Tvmult(level, t[level], solution[level-1]);
defect[level] -= t[level];
}
-
+// deallog << "Post-smooth " << level << endl;
// post-smoothing
post_smooth->smooth(level, solution[level], defect[level]);
+// deallog << "ready " << level << endl;
}
// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 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/full_matrix.h>
#include <lac/sparse_matrix.h>
-
+//TODO:[GK] Inline simple functions in 1d and 3d
/* ------------------------ MGDoFLineAccessor --------------------------- */
template <int dim>
+inline
unsigned int MGDoFObjectAccessor<2, dim>::mg_dof_index (const unsigned int i) const
{
Assert (this->dof_handler != 0,
template <int dim>
+inline
void MGDoFObjectAccessor<2, dim>::set_mg_dof_index (const unsigned int i,
const unsigned int index) const
{
template <int dim>
+inline
unsigned int MGDoFObjectAccessor<2, dim>::mg_vertex_dof_index (const unsigned int vertex,
const unsigned int i) const
{
template <int dim>
+inline
void MGDoFObjectAccessor<2, dim>::set_mg_vertex_dof_index (const unsigned int vertex,
const unsigned int i,
const unsigned int index) const
template <int dim>
+inline
TriaIterator<dim,MGDoFObjectAccessor<1, dim> >
MGDoFObjectAccessor<2, dim>::line (const unsigned int i) const
{
template <int dim>
+inline
TriaIterator<dim,MGDoFObjectAccessor<2, dim> >
MGDoFObjectAccessor<2, dim>::child (const unsigned int i) const
{
#include <lac/sparse_matrix.h>
#include <lac/block_sparse_matrix.h>
#include <multigrid/mg_transfer.h>
+#include <multigrid/mg_transfer.templates.h>
#include <multigrid/multigrid.templates.h>
// exactly one element, to have a
// valid pointer to some memory
if (vec_len == 0)
- vec_len = 1;
+ {
+ vec_len = 1;
+ if (colnums) delete[] colnums;
+ max_vec_len = vec_len;
+ colnums = new unsigned int[max_vec_len];
+ }
max_row_length = (row_lengths.size() == 0 ?
0 :
if (diagonal_optimized && (max_row_length==0) && (m!=0))
max_row_length = 1;
-
+
// allocate memory for the rowstart
// values, if necessary
if (rows > max_dim)