From cb12978dd8104cff2cd82aef333dc05221ebfd46 Mon Sep 17 00:00:00 2001 From: Stefano Zampini Date: Sun, 27 Nov 2022 09:15:54 +0300 Subject: [PATCH] PETScWrappers::MPI::BlockVector Add missing conversion operator for const --- include/deal.II/lac/petsc_block_vector.h | 9 +++++++++ source/lac/petsc_parallel_block_vector.cc | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/include/deal.II/lac/petsc_block_vector.h b/include/deal.II/lac/petsc_block_vector.h index 71d9589053..670f2061d4 100644 --- a/include/deal.II/lac/petsc_block_vector.h +++ b/include/deal.II/lac/petsc_block_vector.h @@ -272,6 +272,15 @@ namespace PETScWrappers const MPI_Comm & get_mpi_communicator() const; + /** + * Conversion operator to gain access to the underlying PETSc type. If you + * do this, you cut this class off some information it may need, so this + * conversion operator should only be used if you know what you do. In + * particular, it should only be used for read-only operations into the + * vector. + */ + operator const Vec &() const; + /** * Return a reference to the underlying PETSc type. It can be used to * modify the underlying data, so use it only when you know what you diff --git a/source/lac/petsc_parallel_block_vector.cc b/source/lac/petsc_parallel_block_vector.cc index c00e9dbdcd..88360c6d81 100644 --- a/source/lac/petsc_parallel_block_vector.cc +++ b/source/lac/petsc_parallel_block_vector.cc @@ -93,6 +93,11 @@ namespace PETScWrappers return petsc_nest_vector; } + BlockVector::operator const Vec &() const + { + return petsc_nest_vector; + } + void BlockVector::collect_sizes() { -- 2.39.5