From 588beffb8bfba0fb8226bd7969473cac906f2516 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Sat, 22 Apr 2017 15:02:28 +0200 Subject: [PATCH] Make deal.II compile with Trilinos but without MPI. --- cmake/configure/configure_2_trilinos.cmake | 6 ++- include/deal.II/dofs/dof_accessor.templates.h | 2 +- .../fe/fe_tools_extrapolate.templates.h | 2 + include/deal.II/lac/read_write_vector.h | 2 + include/deal.II/lac/trilinos_epetra_vector.h | 6 +-- include/deal.II/lac/vector_element_access.h | 2 +- include/deal.II/multigrid/mg_transfer.h | 3 +- source/lac/trilinos_sparse_matrix.cc | 41 +++++++++++-------- source/numerics/vector_tools_mean_value.cc | 2 +- 9 files changed, 39 insertions(+), 27 deletions(-) diff --git a/cmake/configure/configure_2_trilinos.cmake b/cmake/configure/configure_2_trilinos.cmake index e00ed23534..5665d907f2 100644 --- a/cmake/configure/configure_2_trilinos.cmake +++ b/cmake/configure/configure_2_trilinos.cmake @@ -55,7 +55,7 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var) ENDFOREACH() IF((TRILINOS_VERSION_MAJOR EQUAL 11 AND - NOT (TRILINOS_VERSION_MINOR LESS 14)) + NOT (TRILINOS_VERSION_MINOR LESS 14)) OR (NOT (TRILINOS_VERSION_MAJOR LESS 12))) ITEM_MATCHES(_module_found MueLu ${Trilinos_PACKAGE_LIST}) @@ -194,7 +194,9 @@ MACRO(FEATURE_TRILINOS_CONFIGURE_EXTERNAL) SET(DEAL_II_EXPAND_TRILINOS_BLOCK_SPARSITY_PATTERN "TrilinosWrappers::BlockSparsityPattern") SET(DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR "TrilinosWrappers::MPI::BlockVector") SET(DEAL_II_EXPAND_TRILINOS_MPI_VECTOR "TrilinosWrappers::MPI::Vector") - SET(DEAL_II_EXPAND_EPETRA_VECTOR "LinearAlgebra::EpetraWrappers::Vector") + IF (TRILINOS_WITH_MPI) + SET(DEAL_II_EXPAND_EPETRA_VECTOR "LinearAlgebra::EpetraWrappers::Vector") + ENDIF() ENDMACRO() diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index fa19f0c392..5a082e200c 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -1494,7 +1494,7 @@ namespace internal -#ifdef DEAL_II_WITH_TRILINOS +#if defined(DEAL_II_WITH_TRILINOS) && defined(DEAL_II_WITH_MPI) static std::vector sort_indices(const types::global_dof_index *v_begin, const types::global_dof_index *v_end) diff --git a/include/deal.II/fe/fe_tools_extrapolate.templates.h b/include/deal.II/fe/fe_tools_extrapolate.templates.h index eee5051ef4..23c7914575 100644 --- a/include/deal.II/fe/fe_tools_extrapolate.templates.h +++ b/include/deal.II/fe/fe_tools_extrapolate.templates.h @@ -1454,6 +1454,7 @@ namespace FETools +#ifdef DEAL_II_WITH_MPI template void reinit_distributed(const DoFHandler &dh, LinearAlgebra::EpetraWrappers::Vector &vector) @@ -1465,6 +1466,7 @@ namespace FETools const IndexSet locally_owned_dofs = dh.locally_owned_dofs(); vector.reinit(locally_owned_dofs, parallel_tria->get_communicator()); } +#endif #endif //DEAL_II_WITH_TRILINOS template diff --git a/include/deal.II/lac/read_write_vector.h b/include/deal.II/lac/read_write_vector.h index 4ae7b29fd3..631125cfb7 100644 --- a/include/deal.II/lac/read_write_vector.h +++ b/include/deal.II/lac/read_write_vector.h @@ -295,6 +295,7 @@ namespace LinearAlgebra std::shared_ptr communication_pattern = std::shared_ptr ()); +#ifdef DEAL_II_WITH_MPI /** * Imports all the elements present in the vector's IndexSet from the input * vector @p epetra_vec. VectorOperation::values @p operation is used to @@ -308,6 +309,7 @@ namespace LinearAlgebra std::shared_ptr communication_pattern = std::shared_ptr ()); #endif +#endif #ifdef DEAL_II_WITH_CUDA /** diff --git a/include/deal.II/lac/trilinos_epetra_vector.h b/include/deal.II/lac/trilinos_epetra_vector.h index 803cc2c230..2be2a661b0 100644 --- a/include/deal.II/lac/trilinos_epetra_vector.h +++ b/include/deal.II/lac/trilinos_epetra_vector.h @@ -19,9 +19,7 @@ #include -#ifdef DEAL_II_WITH_TRILINOS - -#ifdef DEAL_II_WITH_MPI +#if defined(DEAL_II_WITH_TRILINOS) && defined(DEAL_II_WITH_MPI) #include #include @@ -351,5 +349,3 @@ DEAL_II_NAMESPACE_CLOSE #endif #endif - -#endif diff --git a/include/deal.II/lac/vector_element_access.h b/include/deal.II/lac/vector_element_access.h index 1ad1054ad2..2d79a16a45 100644 --- a/include/deal.II/lac/vector_element_access.h +++ b/include/deal.II/lac/vector_element_access.h @@ -69,7 +69,7 @@ namespace internal -#ifdef DEAL_II_WITH_TRILINOS +#if defined(DEAL_II_WITH_TRILINOS) && defined(DEAL_II_WITH_MPI) template <> inline void ElementAccess:: diff --git a/include/deal.II/multigrid/mg_transfer.h b/include/deal.II/multigrid/mg_transfer.h index b585b17560..211c0e6ea3 100644 --- a/include/deal.II/multigrid/mg_transfer.h +++ b/include/deal.II/multigrid/mg_transfer.h @@ -89,6 +89,7 @@ namespace internal }; +#ifdef DEAL_II_WITH_MPI template <> struct MatrixSelector { @@ -102,8 +103,8 @@ namespace internal dh.locally_owned_mg_dofs(level), sp, MPI_COMM_WORLD, true); } - }; +#endif template <> struct MatrixSelector diff --git a/source/lac/trilinos_sparse_matrix.cc b/source/lac/trilinos_sparse_matrix.cc index f97722f38f..9081b440be 100644 --- a/source/lac/trilinos_sparse_matrix.cc +++ b/source/lac/trilinos_sparse_matrix.cc @@ -121,40 +121,41 @@ namespace TrilinosWrappers return V.begin(); } - template <> - double *begin(LinearAlgebra::EpetraWrappers::Vector &V) - { - return V.trilinos_vector()[0]; - } - template const double *begin(const VectorType &V) { return V.begin(); } - template <> - const double *begin(const LinearAlgebra::EpetraWrappers::Vector &V) + template + double *end(VectorType &V) { - return V.trilinos_vector()[0]; + return V.end(); } template - double *end(VectorType &V) + const double *end(const VectorType &V) { return V.end(); } +#ifdef DEAL_II_WITH_MPI template <> - double *end(LinearAlgebra::EpetraWrappers::Vector &V) + double *begin(LinearAlgebra::EpetraWrappers::Vector &V) { - return V.trilinos_vector()[0]+V.trilinos_vector().MyLength(); + return V.trilinos_vector()[0]; } - template - const double *end(const VectorType &V) + template <> + const double *begin(const LinearAlgebra::EpetraWrappers::Vector &V) { - return V.end(); + return V.trilinos_vector()[0]; + } + + template <> + double *end(LinearAlgebra::EpetraWrappers::Vector &V) + { + return V.trilinos_vector()[0]+V.trilinos_vector().MyLength(); } template <> @@ -162,6 +163,7 @@ namespace TrilinosWrappers { return V.trilinos_vector()[0]+V.trilinos_vector().MyLength(); } +#endif } @@ -3460,9 +3462,11 @@ namespace TrilinosWrappers template void SparseMatrix::vmult (dealii::LinearAlgebra::distributed::Vector &, const dealii::LinearAlgebra::distributed::Vector &) const; +#ifdef DEAL_II_WITH_MPI template void SparseMatrix::vmult (dealii::LinearAlgebra::EpetraWrappers::Vector &, const dealii::LinearAlgebra::EpetraWrappers::Vector &) const; +#endif template void SparseMatrix::Tvmult (VectorBase &, const VectorBase &) const; @@ -3478,9 +3482,11 @@ namespace TrilinosWrappers template void SparseMatrix::Tvmult (dealii::LinearAlgebra::distributed::Vector &, const dealii::LinearAlgebra::distributed::Vector &) const; +#ifdef DEAL_II_WITH_MPI template void SparseMatrix::Tvmult (dealii::LinearAlgebra::EpetraWrappers::Vector &, const dealii::LinearAlgebra::EpetraWrappers::Vector &) const; +#endif template void SparseMatrix::vmult_add (VectorBase &, const VectorBase &) const; @@ -3496,9 +3502,11 @@ namespace TrilinosWrappers template void SparseMatrix::vmult_add (dealii::LinearAlgebra::distributed::Vector &, const dealii::LinearAlgebra::distributed::Vector &) const; +#ifdef DEAL_II_WITH_MPI template void SparseMatrix::vmult_add (dealii::LinearAlgebra::EpetraWrappers::Vector &, const dealii::LinearAlgebra::EpetraWrappers::Vector &) const; +#endif template void SparseMatrix::Tvmult_add (VectorBase &, const VectorBase &) const; @@ -3514,10 +3522,11 @@ namespace TrilinosWrappers template void SparseMatrix::Tvmult_add (dealii::LinearAlgebra::distributed::Vector &, const dealii::LinearAlgebra::distributed::Vector &) const; +#ifdef DEAL_II_WITH_MPI template void SparseMatrix::Tvmult_add (dealii::LinearAlgebra::EpetraWrappers::Vector &, const dealii::LinearAlgebra::EpetraWrappers::Vector &) const; - +#endif } DEAL_II_NAMESPACE_CLOSE diff --git a/source/numerics/vector_tools_mean_value.cc b/source/numerics/vector_tools_mean_value.cc index 890ff4d2ce..2861b76a98 100644 --- a/source/numerics/vector_tools_mean_value.cc +++ b/source/numerics/vector_tools_mean_value.cc @@ -18,7 +18,7 @@ DEAL_II_NAMESPACE_OPEN -#ifdef DEAL_II_WITH_TRILINOS +#if defined(DEAL_II_WITH_TRILINOS) && defined(DEAL_II_WITH_MPI) namespace VectorTools { template <> -- 2.39.5