From: kronbichler Date: Tue, 17 Mar 2009 16:26:34 +0000 (+0000) Subject: Make VectorReference a bit faster. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20730cc24f5086cda4d0baa76dbd9fe52fad483c;p=dealii-svn.git Make VectorReference a bit faster. git-svn-id: https://svn.dealii.org/trunk@18491 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/trilinos_vector_base.h b/deal.II/lac/include/lac/trilinos_vector_base.h index 36a46571f8..d86ca5113f 100644 --- a/deal.II/lac/include/lac/trilinos_vector_base.h +++ b/deal.II/lac/include/lac/trilinos_vector_base.h @@ -1016,7 +1016,27 @@ namespace TrilinosWrappers const VectorReference & VectorReference::operator += (const TrilinosScalar &value) const { - vector.add (1, &index, &value); + const int local_row = vector.vector->Map().LID(index); + if (local_row == -1) + { + // write the code explicitly here to make + // it faster. + if (vector.last_action != Add) + { + if (vector.last_action == Insert) + vector.vector->GlobalAssemble(Insert); + vector.last_action = Add; + } + + const int ierr = vector.vector->SumIntoGlobalValues (1, + (const int*)(&index), + &value); + AssertThrow (ierr == 0, ExcTrilinosError(ierr)); + vector.compressed = false; + } + else + (*vector.vector)[0][local_row] += value; + return *this; } @@ -1174,16 +1194,17 @@ namespace TrilinosWrappers const unsigned int *indices, const TrilinosScalar *values) { - if (last_action == Insert) - vector->GlobalAssemble(Insert); - if (last_action != Add) - last_action = Add; + { + if (last_action == Insert) + vector->GlobalAssemble(Insert); + last_action = Add; + } for (unsigned int i=0; iMap().LID(indices[i]); + const int local_row = vector->Map().LID(row); if (local_row == -1) { const int ierr = vector->SumIntoGlobalValues (1,