From f75f3f764d8e894b64d72e58d66876aadaf5030e Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Fri, 26 Sep 2014 11:32:54 +0200 Subject: [PATCH] Fix bug in TrilinosVector::sadd with MPI As pointed out by Praveen C on the mailing list, sadd() of the Trilinos vector did not work properly when combining ghosted with non-ghosted vectors. The test supposed to check this used two vectors with the same entries, which did not detect that the wrong vector was scaled. --- doc/news/changes.h | 7 + include/deal.II/lac/trilinos_vector_base.h | 7 +- tests/mpi/trilinos_sadd_02.cc | 14 +- ...sadd_02.with_trilinos=true.mpirun=1.output | 80 ++++----- ...sadd_02.with_trilinos=true.mpirun=2.output | 160 +++++++++--------- 5 files changed, 141 insertions(+), 127 deletions(-) diff --git a/doc/news/changes.h b/doc/news/changes.h index a649296063..0f8bed3e74 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -304,6 +304,13 @@ inconvenience this causes.

Specific improvements

    +
  1. Fixed: The function TrilinosWrappers::VectorBase::sadd(double factor, + VectorBase &v) erroneously added factor*v instead of scaling the calling + vector by factor. This is now fixed. +
    + (Martin Kronbichler, 2014/09/26) +
  2. +
  3. Fixed: The function TrilinosWrappers::SparseMatrix::add(double factor, SparseMatrix &rhs) produced wrong results and ran into an exception if the rhs matrix included off-processor column entries. This is now fixed. diff --git a/include/deal.II/lac/trilinos_vector_base.h b/include/deal.II/lac/trilinos_vector_base.h index 034a63c607..ba77c644bf 100644 --- a/include/deal.II/lac/trilinos_vector_base.h +++ b/include/deal.II/lac/trilinos_vector_base.h @@ -1718,9 +1718,8 @@ namespace TrilinosWrappers } else { - VectorBase tmp = v; - tmp *= s; - this->add(tmp, true); + (*this) *= s; + this->add(v, true); } } @@ -1747,7 +1746,7 @@ namespace TrilinosWrappers } else { - (*this)*=s; + (*this) *= s; VectorBase tmp = v; tmp *= a; this->add(tmp, true); diff --git a/tests/mpi/trilinos_sadd_02.cc b/tests/mpi/trilinos_sadd_02.cc index 565c9bb215..1734d4c553 100644 --- a/tests/mpi/trilinos_sadd_02.cc +++ b/tests/mpi/trilinos_sadd_02.cc @@ -29,7 +29,7 @@ void test () { - TrilinosWrappers::MPI::Vector ghosted, distributed; + TrilinosWrappers::MPI::Vector ghosted, ghosted2, distributed, distributed2; //All processes should own 10 entries const int entries_per_process = 10; const int n_proc = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD); @@ -46,10 +46,13 @@ void test () (local_begin, local_end); distributed.reinit(locally_owned, MPI_COMM_WORLD); + distributed2.reinit(locally_owned, MPI_COMM_WORLD); ghosted.reinit (locally_owned, locally_relevant, MPI_COMM_WORLD); + ghosted2.reinit (locally_owned, locally_relevant, MPI_COMM_WORLD); distributed=1.; ghosted=distributed; + ghosted *= 1.6; distributed.sadd (2., ghosted); ghosted = distributed; deallog << "sadd (s, v)" <