template void SparseMatrix<TYPEMAT>::TSOR_step (Vector<TYPE2> &, const Vector<TYPE2> &, TYPEMAT) const;
template void SparseMatrix<TYPEMAT>::SSOR_step (Vector<TYPE2> &, const Vector<TYPE2> &, TYPEMAT) const;
-template void SparseVanka<TYPEMAT>::apply(Vector<TYPE2>& dst) const;
+template void SparseVanka<TYPEMAT>::forward(Vector<TYPE2>& dst, const Vector<TYPE2>& dst) const;
+template void SparseVanka<TYPEMAT>::backward(Vector<TYPE2>& dst, const Vector<TYPE2>& dst) const;
// $Id$
// Copyright Guido Kanschat, 1999
-#ifndef __lac_sparsematrix_H
-#define __lac_sparsematrix_H
+#ifndef __lac_sparse_vanka_H
+#define __lac_sparse_vanka_H
#include <base/smartpointer.h>
#include <lac/forward-declarations.h>
*
* This local system is solved and the values are updated into the
* destination vector.
- * @author Guido Kanschat
- */
+ *
+ * Remark: the Vanka method is a non-symmetric preconditioning method.
+ * @author Guido Kanschat */
template<typename number>
class SparseVanka
{
SparseVanka(const SparseMatrix<number>& M,
const vector<int>& indices);
/**
- * Do the preconditioning.
+ * Do the preconditioning. This
+ * function contains a dispatch
+ * mechanism to use the
+ * multiplicative version by
+ * default and the additive version
+ * if requested by #set_additive#.
*/
template<typename number2>
void operator() (Vector<number2>& dst,
const Vector<number2>& src) const;
/**
- * In-place application of the
- * method.
+ * Application of the Vanka operator.
+ * This function takes two vector
+ * arguments, the residual in #src#
+ * and the resulting update vector
+ * in #dst#.
*/
template<typename number2>
- void apply(Vector<number2>& dst) const;
-
+ void forward(Vector<number2>& dst, const Vector<number2>& src) const;
+ /**
+ * Application of the transpose
+ * Vanka operator.
+ * This function takes two vector
+ * arguments, the residual in #src#
+ * and the resulting update vector
+ * in #dst#.
+ */
+ template<typename number2>
+ void backward(Vector<number2>& dst, const Vector<number2>& src) const;
private:
/**
* Pointer to the matrix.
SparseVanka<number>::operator() (Vector<number2>& dst,
const Vector<number2>& src) const
{
- dst = src;
- apply(dst);
+ dst = 0.;
+ forward(dst, src);
}
// $Id$
// Copyright Guido Kanschat, 1999
-#include <lac/sparsevanka.h>
+#include <lac/sparse_vanka.h>
#include <lac/fullmatrix.h>
#include <map>
template<typename number>
template<typename number2>
void
-SparseVanka<number>::apply(Vector<number2>& dst) const
+SparseVanka<number>::forward(Vector<number2>& dst,
+ const Vector<number2>& src) const
{
for (unsigned int global_i=0; global_i<indices.size() ; ++global_i)
{
local_index.insert(pair<unsigned int, unsigned int>
(structure.column_number(row, i), i));
+// for (map<unsigned int, unsigned int>::iterator is=local_index.begin();
+// is!=local_index.end();++is)
+// cerr << "map " << is->first << '\t' << is->second << endl;
+
// Build local matrix
for (map<unsigned int, unsigned int>::iterator is=local_index.begin();
unsigned int i = is->second;
unsigned int n = structure.row_length(irow);
- b(i) = dst(irow);
+ b(i) = src(irow);
for (unsigned int j=0;j<n;++j)
{
= local_index.find(col);
if (js == local_index.end())
{
- b(i) -= matrix->raw_entry(irow,col) * dst(col);
+ b(i) -= matrix->raw_entry(irow,j) * dst(col);
} else {
- A(i,j) = matrix->raw_entry(irow,col);
+ A(i,js->second) = matrix->raw_entry(irow,j);
}
}
}
unsigned int irow = is->first;
unsigned int i = is->second;
dst(irow) = x(i);
- }
+ }
}
}
#include <cmath>
#include <lac/sparsematrix.templates.h>
-#include <lac/sparsevanka.templates.h>
+#include <lac/sparse_vanka.templates.h>
#define TYPEMAT double
#include <cmath>
#include <lac/sparsematrix.templates.h>
-#include <lac/sparsevanka.templates.h>
+#include <lac/sparse_vanka.templates.h>
#define TYPEMAT float
#include <cmath>
#include <lac/sparsematrix.templates.h>
-#include <lac/sparsevanka.templates.h>
+#include <lac/sparse_vanka.templates.h>
#define TYPEMAT long double