From 0e8824236b9f60a2e74e009cc7f90201298ab9f4 Mon Sep 17 00:00:00 2001 From: ESeNonFossiIo Date: Tue, 12 Apr 2016 22:11:16 +0200 Subject: [PATCH] PETSc Vector reinit helper --- include/deal.II/lac/petsc_parallel_vector.h | 36 +++++++++++++++++++ include/deal.II/lac/petsc_vector.h | 38 +++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/include/deal.II/lac/petsc_parallel_vector.h b/include/deal.II/lac/petsc_parallel_vector.h index dd9a324a61..522a45f937 100644 --- a/include/deal.II/lac/petsc_parallel_vector.h +++ b/include/deal.II/lac/petsc_parallel_vector.h @@ -582,6 +582,42 @@ namespace PETScWrappers } } +namespace internal +{ + namespace LinearOperator + { + template class ReinitHelper; + + /** + * A helper class internally used in linear_operator.h. Specialization for + * TrilinosWrappers::MPI::Vector. + */ + template<> + class ReinitHelper + { + public: + template + static + void reinit_range_vector (const Matrix &matrix, + PETScWrappers::MPI::Vector &v, + bool omit_zeroing_entries) + { + v.reinit(matrix.locally_owned_range_indices(), matrix.get_mpi_communicator()); + } + + template + static + void reinit_domain_vector(const Matrix &matrix, + PETScWrappers::MPI::Vector &v, + bool omit_zeroing_entries) + { + v.reinit(matrix.locally_owned_domain_indices(), matrix.get_mpi_communicator()); + } + }; + + } /* namespace LinearOperator */ +} /* namespace internal */ + /**@}*/ DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/lac/petsc_vector.h b/include/deal.II/lac/petsc_vector.h index f1fb5f5de8..ba4e3c4d5d 100644 --- a/include/deal.II/lac/petsc_vector.h +++ b/include/deal.II/lac/petsc_vector.h @@ -391,6 +391,44 @@ namespace PETScWrappers } +namespace internal +{ + namespace LinearOperator + { + template class ReinitHelper; + + /** + * A helper class internally used in linear_operator.h. Specialization for + * PETScWrappers::Vector. + */ + template<> + class ReinitHelper + { + public: + template + static + void reinit_range_vector (const Matrix &matrix, + PETScWrappers::Vector &v, + bool omit_zeroing_entries) + { + v.reinit( matrix.m(), + omit_zeroing_entries); + } + + template + static + void reinit_domain_vector(const Matrix &matrix, + PETScWrappers::Vector &v, + bool omit_zeroing_entries) + { + v.reinit( matrix.n(), + omit_zeroing_entries); + } + }; + + } /* namespace LinearOperator */ +} /* namespace internal */ + DEAL_II_NAMESPACE_CLOSE #endif // DEAL_II_WITH_PETSC -- 2.39.5