From: Stefano Zampini Date: Sun, 27 Nov 2022 06:15:54 +0000 (+0300) Subject: PETScWrappers::MPI::BlockVector Add missing conversion operator for const X-Git-Tag: v9.5.0-rc1~621^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb12978dd8104cff2cd82aef333dc05221ebfd46;p=dealii.git PETScWrappers::MPI::BlockVector Add missing conversion operator for const --- 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() {