From 0c6f400c5c7cbcd99f517bd1a036ba001ea89a82 Mon Sep 17 00:00:00 2001 From: "daniel.arndt" Date: Mon, 23 Jun 2014 16:16:57 +0000 Subject: [PATCH] Removed the workaround for TrilinosWrappers::VectorBase::sadd when using different maps for version >=11.9, Issue 191 git-svn-id: https://svn.dealii.org/trunk@33081 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/cmake/modules/FindTRILINOS.cmake | 8 +++++++- deal.II/include/deal.II/base/config.h.in | 11 +++++++++++ deal.II/source/lac/trilinos_vector_base.cc | 14 +++++++++----- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/deal.II/cmake/modules/FindTRILINOS.cmake b/deal.II/cmake/modules/FindTRILINOS.cmake index 6fc8c408d4..51b627064e 100644 --- a/deal.II/cmake/modules/FindTRILINOS.cmake +++ b/deal.II/cmake/modules/FindTRILINOS.cmake @@ -65,9 +65,15 @@ IF(DEFINED Trilinos_VERSION) "^[0-9]+\\.([0-9]+).*$" "\\1" TRILINOS_VERSION_MINOR "${Trilinos_VERSION}") + # If there is no subminor number, then the REGEX REPLACE will fail, + # setting TRILINOS_VERSION_PATCH to TRILINOS_VERSION. If that + # is the case, then set the subminor number to zero STRING(REGEX REPLACE - "^[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" + "^[0-9]+\\.[0-9]+\\.([0-9]+)?.*$" "\\1" TRILINOS_VERSION_SUBMINOR "${Trilinos_VERSION}") + IF(${TRILINOS_VERSION_SUBMINOR} STREQUAL "${Trilinos_VERSION}") + SET(TRILINOS_VERSION_SUBMINOR "0") + ENDIF() ENDIF() # diff --git a/deal.II/include/deal.II/base/config.h.in b/deal.II/include/deal.II/base/config.h.in index 8f82a02ee3..3709ce396a 100644 --- a/deal.II/include/deal.II/base/config.h.in +++ b/deal.II/include/deal.II/base/config.h.in @@ -530,6 +530,17 @@ #ifdef DEAL_II_WITH_TRILINOS /** Compatibility definition (with naming from deal.II < 8.0): */ # define DEAL_II_USE_TRILINOS + +# define DEAL_II_TRILINOS_VERSION_MAJOR @TRILINOS_VERSION_MAJOR@ +# define DEAL_II_TRILINOS_VERSION_MINOR @TRILINOS_VERSION_MINOR@ +# define DEAL_II_TRILINOS_VERSION_SUBMINOR @TRILINOS_VERSION_SUBMINOR@ + +# define DEAL_II_TRILINOS_VERSION_GTE(major,minor,subminor) \ + ((DEAL_II_TRILINOS_VERSION_MAJOR * 10000 + \ + DEAL_II_TRILINOS_VERSION_MINOR * 100 + \ + DEAL_II_TRILINOS_VERSION_SUBMINOR) \ + >= \ + (major)*10000 + (minor)*100 + (subminor)) #endif diff --git a/deal.II/source/lac/trilinos_vector_base.cc b/deal.II/source/lac/trilinos_vector_base.cc index da1e491f16..aff9959d20 100644 --- a/deal.II/source/lac/trilinos_vector_base.cc +++ b/deal.II/source/lac/trilinos_vector_base.cc @@ -295,11 +295,14 @@ namespace TrilinosWrappers AssertThrow (size() == v.size(), ExcDimensionMismatch (size(), v.size())); - //HACK: For some reason the following doesn't work properly, so do it manually - // Epetra_Import data_exchange (vector->Map(), v.vector->Map()); - // int ierr = vector->Import(*v.vector, data_exchange, Add); - // AssertThrow (ierr == 0, ExcTrilinosError(ierr)); - // last_action = Add; +#if DEAL_II_TRILINOS_VERSION_GTE(11,9,0) + Epetra_Import data_exchange (vector->Map(), v.vector->Map()); + int ierr = vector->Import(*v.vector, data_exchange, Add); + AssertThrow (ierr == 0, ExcTrilinosError(ierr)); + last_action = Add; +#else + // In versions older than 11.9 the Import function is broken for adding + // Hence, we provide a workaround in this case Epetra_MultiVector dummy(vector->Map(), 1, false); Epetra_Import data_exchange (dummy.Map(), v.vector->Map()); @@ -309,6 +312,7 @@ namespace TrilinosWrappers ierr = vector->Update (1.0, dummy, 1.0); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); +#endif } } -- 2.39.5