From dc248b94989af1ae62e2f68e095563df0ff3d751 Mon Sep 17 00:00:00 2001 From: guido Date: Fri, 19 Oct 2001 08:31:30 +0000 Subject: [PATCH] adding functions for PreconditionBlockJacobi git-svn-id: https://svn.dealii.org/trunk@5156 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/precondition_block.h | 30 ++++++++++++ .../lac/precondition_block.templates.h | 49 ++++++++++++++++--- deal.II/lac/source/precondition_block.cc | 24 +++++++++ 3 files changed, 97 insertions(+), 6 deletions(-) diff --git a/deal.II/lac/include/lac/precondition_block.h b/deal.II/lac/include/lac/precondition_block.h index 9be09e0af7..f2ce8a7b65 100644 --- a/deal.II/lac/include/lac/precondition_block.h +++ b/deal.II/lac/include/lac/precondition_block.h @@ -338,6 +338,36 @@ class PreconditionBlockJacobi : public virtual Subscriptor, */ template void Tvmult (Vector&, const Vector&) const; + /** + * Execute block Jacobi + * preconditioning, adding to @p{dst}. + * + * This function will + * automatically use the inverse + * matrices if they exist, if not + * then BlockJacobi will need + * much time inverting the + * diagonal block matrices in + * each preconditioning step. + */ + template + void vmult_add (Vector&, const Vector&) const; + + /** + * Same as @p{vmult_add}, since Jacobi is symmetric. + */ + template + void Tvmult_add (Vector&, const Vector&) const; + + private: + /** + * Actual implementation of the + * preconditioner. + */ + template + void do_vmult (Vector&, + const Vector&, + bool adding) const; }; diff --git a/deal.II/lac/include/lac/precondition_block.templates.h b/deal.II/lac/include/lac/precondition_block.templates.h index a676d2f1b5..b7d9b53a74 100644 --- a/deal.II/lac/include/lac/precondition_block.templates.h +++ b/deal.II/lac/include/lac/precondition_block.templates.h @@ -226,8 +226,9 @@ PreconditionBlock::memory_consumption () const template template void PreconditionBlockJacobi -::vmult (Vector &dst, - const Vector &src) const +::do_vmult (Vector &dst, + const Vector &src, + bool adding) const { // introduce the following typedef // since in the use of exceptions, @@ -278,7 +279,10 @@ void PreconditionBlockJacobi M_cell.backward(x_cell,b_cell); // distribute x_cell to dst for (row=cell*blocksize, row_cell=0; row_cell inverse(cell).vmult(x_cell, b_cell); // distribute x_cell to dst for (row=cell*blocksize, row_cell=0; row_cell template template void PreconditionBlockJacobi -::Tvmult (Vector &dst, +::vmult (Vector &dst, const Vector &src) const { - vmult(dst, src); + do_vmult(dst, src, false); +} + + +template +template +void PreconditionBlockJacobi +::Tvmult (Vector &dst, + const Vector &src) const +{ + do_vmult(dst, src, false); +} + + +template +template +void PreconditionBlockJacobi +::vmult_add (Vector &dst, + const Vector &src) const +{ + do_vmult(dst, src, true); +} + + +template +template +void PreconditionBlockJacobi +::Tvmult_add (Vector &dst, + const Vector &src) const +{ + do_vmult(dst, src, true); } diff --git a/deal.II/lac/source/precondition_block.cc b/deal.II/lac/source/precondition_block.cc index 193c67f049..529aa78261 100644 --- a/deal.II/lac/source/precondition_block.cc +++ b/deal.II/lac/source/precondition_block.cc @@ -43,6 +43,14 @@ template void PreconditionBlockJacobi::Tvmult (Vector &, const Vector &) const; template void PreconditionBlockJacobi::Tvmult (Vector &, const Vector &) const; +template void PreconditionBlockJacobi::vmult_add +(Vector &, const Vector &) const; +template void PreconditionBlockJacobi::vmult_add +(Vector &, const Vector &) const; +template void PreconditionBlockJacobi::Tvmult_add +(Vector &, const Vector &) const; +template void PreconditionBlockJacobi::Tvmult_add +(Vector &, const Vector &) const; template class PreconditionBlockJacobi; @@ -54,6 +62,14 @@ template void PreconditionBlockJacobi::Tvmult (Vector &, const Vector &) const; template void PreconditionBlockJacobi::Tvmult (Vector &, const Vector &) const; +template void PreconditionBlockJacobi::vmult_add +(Vector &, const Vector &) const; +template void PreconditionBlockJacobi::vmult_add +(Vector &, const Vector &) const; +template void PreconditionBlockJacobi::Tvmult_add +(Vector &, const Vector &) const; +template void PreconditionBlockJacobi::Tvmult_add +(Vector &, const Vector &) const; template class PreconditionBlockJacobi; @@ -65,6 +81,14 @@ template void PreconditionBlockJacobi::Tvmult (Vector &, const Vector &) const; template void PreconditionBlockJacobi::Tvmult (Vector &, const Vector &) const; +template void PreconditionBlockJacobi::vmult_add +(Vector &, const Vector &) const; +template void PreconditionBlockJacobi::vmult_add +(Vector &, const Vector &) const; +template void PreconditionBlockJacobi::Tvmult_add +(Vector &, const Vector &) const; +template void PreconditionBlockJacobi::Tvmult_add +(Vector &, const Vector &) const; /*--------------------- PreconditionBlockGaussSeidel -----------------------*/ -- 2.39.5