From 4da95f09c1b5f412a72b9659343fb31aaefd692c Mon Sep 17 00:00:00 2001 From: guido Date: Mon, 5 Jul 1999 13:48:18 +0000 Subject: [PATCH] Vanka works git-svn-id: https://svn.dealii.org/trunk@1536 0785d39b-7218-0410-832d-ea1e28bc413d --- .../lac/include/lac/sparse_matrix.2.templates | 3 +- .../lac/{sparsevanka.h => sparse_vanka.h} | 40 ++++++++++++++----- ...a.templates.h => sparse_vanka.templates.h} | 17 +++++--- deal.II/lac/source/sparse_matrix.double.cc | 2 +- deal.II/lac/source/sparse_matrix.float.cc | 2 +- .../lac/source/sparse_matrix.long_double.cc | 2 +- 6 files changed, 45 insertions(+), 21 deletions(-) rename deal.II/lac/include/lac/{sparsevanka.h => sparse_vanka.h} (66%) rename deal.II/lac/include/lac/{sparsevanka.templates.h => sparse_vanka.templates.h} (80%) diff --git a/deal.II/lac/include/lac/sparse_matrix.2.templates b/deal.II/lac/include/lac/sparse_matrix.2.templates index 177b86395d..1be0e1294e 100644 --- a/deal.II/lac/include/lac/sparse_matrix.2.templates +++ b/deal.II/lac/include/lac/sparse_matrix.2.templates @@ -43,5 +43,6 @@ template void SparseMatrix::SOR_step (Vector &, const Vector::TSOR_step (Vector &, const Vector &, TYPEMAT) const; template void SparseMatrix::SSOR_step (Vector &, const Vector &, TYPEMAT) const; -template void SparseVanka::apply(Vector& dst) const; +template void SparseVanka::forward(Vector& dst, const Vector& dst) const; +template void SparseVanka::backward(Vector& dst, const Vector& dst) const; diff --git a/deal.II/lac/include/lac/sparsevanka.h b/deal.II/lac/include/lac/sparse_vanka.h similarity index 66% rename from deal.II/lac/include/lac/sparsevanka.h rename to deal.II/lac/include/lac/sparse_vanka.h index 0a0664287a..9b3537280e 100644 --- a/deal.II/lac/include/lac/sparsevanka.h +++ b/deal.II/lac/include/lac/sparse_vanka.h @@ -1,8 +1,8 @@ // $Id$ // Copyright Guido Kanschat, 1999 -#ifndef __lac_sparsematrix_H -#define __lac_sparsematrix_H +#ifndef __lac_sparse_vanka_H +#define __lac_sparse_vanka_H #include #include @@ -29,8 +29,9 @@ * * 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 class SparseVanka { @@ -48,19 +49,36 @@ class SparseVanka SparseVanka(const SparseMatrix& M, const vector& 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 void operator() (Vector& dst, const Vector& 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 - void apply(Vector& dst) const; - + void forward(Vector& dst, const Vector& 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 + void backward(Vector& dst, const Vector& src) const; private: /** * Pointer to the matrix. @@ -81,8 +99,8 @@ void SparseVanka::operator() (Vector& dst, const Vector& src) const { - dst = src; - apply(dst); + dst = 0.; + forward(dst, src); } diff --git a/deal.II/lac/include/lac/sparsevanka.templates.h b/deal.II/lac/include/lac/sparse_vanka.templates.h similarity index 80% rename from deal.II/lac/include/lac/sparsevanka.templates.h rename to deal.II/lac/include/lac/sparse_vanka.templates.h index 19e87b7d60..be64dbd955 100644 --- a/deal.II/lac/include/lac/sparsevanka.templates.h +++ b/deal.II/lac/include/lac/sparse_vanka.templates.h @@ -1,7 +1,7 @@ // $Id$ // Copyright Guido Kanschat, 1999 -#include +#include #include #include @@ -16,7 +16,8 @@ SparseVanka::SparseVanka(const SparseMatrix& M, template template void -SparseVanka::apply(Vector& dst) const +SparseVanka::forward(Vector& dst, + const Vector& src) const { for (unsigned int global_i=0; global_i::apply(Vector& dst) const local_index.insert(pair (structure.column_number(row, i), i)); +// for (map::iterator is=local_index.begin(); +// is!=local_index.end();++is) +// cerr << "map " << is->first << '\t' << is->second << endl; + // Build local matrix for (map::iterator is=local_index.begin(); @@ -45,7 +50,7 @@ SparseVanka::apply(Vector& dst) const 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::apply(Vector& dst) const = 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); } } } @@ -71,7 +76,7 @@ SparseVanka::apply(Vector& dst) const unsigned int irow = is->first; unsigned int i = is->second; dst(irow) = x(i); - } + } } } diff --git a/deal.II/lac/source/sparse_matrix.double.cc b/deal.II/lac/source/sparse_matrix.double.cc index d677b3275f..552653314c 100644 --- a/deal.II/lac/source/sparse_matrix.double.cc +++ b/deal.II/lac/source/sparse_matrix.double.cc @@ -11,7 +11,7 @@ #include #include -#include +#include #define TYPEMAT double diff --git a/deal.II/lac/source/sparse_matrix.float.cc b/deal.II/lac/source/sparse_matrix.float.cc index 32b2e0324e..996aa409d6 100644 --- a/deal.II/lac/source/sparse_matrix.float.cc +++ b/deal.II/lac/source/sparse_matrix.float.cc @@ -11,7 +11,7 @@ #include #include -#include +#include #define TYPEMAT float diff --git a/deal.II/lac/source/sparse_matrix.long_double.cc b/deal.II/lac/source/sparse_matrix.long_double.cc index 9afdba4530..4a1b619177 100644 --- a/deal.II/lac/source/sparse_matrix.long_double.cc +++ b/deal.II/lac/source/sparse_matrix.long_double.cc @@ -11,7 +11,7 @@ #include #include -#include +#include #define TYPEMAT long double -- 2.39.5