From 3516b6e0e3a6e2d3fc7ac20c65b321e2d6e48af7 Mon Sep 17 00:00:00 2001 From: guido Date: Wed, 12 Jul 2000 20:02:12 +0000 Subject: [PATCH] Tvmult for PreconditionBlockSOR git-svn-id: https://svn.dealii.org/trunk@3152 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/precondition_block.h | 6 ++ .../lac/precondition_block.templates.h | 102 +++++++++++++++++- deal.II/lac/source/precondition_block.cc | 12 +++ 3 files changed, 119 insertions(+), 1 deletion(-) diff --git a/deal.II/lac/include/lac/precondition_block.h b/deal.II/lac/include/lac/precondition_block.h index ea913a9f61..7bbbcf9e10 100644 --- a/deal.II/lac/include/lac/precondition_block.h +++ b/deal.II/lac/include/lac/precondition_block.h @@ -365,6 +365,12 @@ class PreconditionBlockSOR : public Subscriptor, template void vmult (Vector&, const Vector&) const; + /** + * Transpose of @ref{vmult} + */ + template + void Tvmult (Vector&, const Vector&) const; + private: /** * Relaxation parameter. diff --git a/deal.II/lac/include/lac/precondition_block.templates.h b/deal.II/lac/include/lac/precondition_block.templates.h index 22a3404084..6d53a57a2a 100644 --- a/deal.II/lac/include/lac/precondition_block.templates.h +++ b/deal.II/lac/include/lac/precondition_block.templates.h @@ -274,7 +274,6 @@ PreconditionBlockSOR::set_omega(number om) } -//TODO: implement Tvmult template template @@ -368,4 +367,105 @@ void PreconditionBlockSOR::vmult (Vector &ds } +template +template +void PreconditionBlockSOR::Tvmult (Vector &dst, + const Vector &src) const +{ + // introduce the following typedef + // since in the use of exceptions, + // strict C++ requires us to + // specify them fully as they are + // from a template dependent base + // class. thus, we'd have to write + // PreconditionBlock::ExcNoMatrixGivenToUse, + // which is lengthy, but also poses + // some problems to the + // preprocessor due to the comma in + // the template arg list. we could + // then wrap the whole thing into + // parentheses, but that creates a + // parse error for gcc for the + // exceptions that do not take + // args... + typedef PreconditionBlock BaseClass; + + Assert (A!=0, ExcNotInitialized()); + + const SparseMatrix &M=*A; + const unsigned int n_cells=M.m()/blocksize; + + const SparsityPattern &spars = M.get_sparsity_pattern(); + const unsigned int *rowstart = spars.get_rowstart_indices(); + const unsigned int *columns = spars.get_column_numbers(); + + Vector b_cell(blocksize), x_cell(blocksize); + + // cell_row, cell_column are the + // numbering of the blocks (cells). + // row_cell, column_cell are the local + // numbering of the unknowns in the + // blocks. + // row, column are the global numbering + // of the unkowns. + unsigned int row, column, row_cell, end_diag_block=blocksize *n_cells; + number2 b_cell_row; + + if (!inverses_ready()) + { + FullMatrix M_cell(blocksize); + for (int icell=n_cells-1; icell>=0 ; --icell) + { + unsigned int cell = (unsigned int) icell; + // Collect upper triangle + for (row=cell*blocksize, row_cell=0; row_cell= end_diag_block) + b_cell_row -= M.global_entry(j) * dst(column); + } + + b_cell(row_cell)=b_cell_row; + // Collect diagonal block + for (unsigned int column_cell=0, column=cell*blocksize; + column_cell=0 ; --icell) + { + unsigned int cell = (unsigned int) icell; + for (row=cell*blocksize, row_cell=0; row_cell= end_diag_block) + b_cell_row -= M.global_entry(j) * dst(column); + } + b_cell(row_cell)=b_cell_row; + } + inverse(cell).vmult(x_cell, b_cell); + // distribute x_cell to dst + for (row=cell*blocksize, row_cell=0; row_cell::vmult ( Vector &, const Vector &) const; template void PreconditionBlockSOR::vmult ( Vector &, const Vector &) const; +template void PreconditionBlockSOR::Tvmult ( + Vector &, const Vector &) const; +template void PreconditionBlockSOR::Tvmult ( + Vector &, const Vector &) const; // the instantiation for class PreconditionBlockSOR is skipped @@ -91,6 +95,10 @@ template void PreconditionBlockSOR::vmult ( Vector &, const Vector &) const; template void PreconditionBlockSOR::vmult ( Vector &, const Vector &) const; +template void PreconditionBlockSOR::Tvmult ( + Vector &, const Vector &) const; +template void PreconditionBlockSOR::Tvmult ( + Vector &, const Vector &) const; template class PreconditionBlockSOR; @@ -98,5 +106,9 @@ template void PreconditionBlockSOR::vmult ( Vector &, const Vector &) const; template void PreconditionBlockSOR::vmult ( Vector &, const Vector &) const; +template void PreconditionBlockSOR::Tvmult ( + Vector &, const Vector &) const; +template void PreconditionBlockSOR::Tvmult ( + Vector &, const Vector &) const; -- 2.39.5