From: Stefano Zampini Date: Tue, 17 Jan 2023 08:38:11 +0000 (+0300) Subject: Remove usage of VecGetValues X-Git-Tag: v9.5.0-rc1~621^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b902005de550cd52b3e6a423e7e62a79363acba;p=dealii.git Remove usage of VecGetValues It fails with the newest versions of PETSc if the vector is not assembled --- diff --git a/source/lac/petsc_vector_base.cc b/source/lac/petsc_vector_base.cc index 17c50e09b6..309fb0e361 100644 --- a/source/lac/petsc_vector_base.cc +++ b/source/lac/petsc_vector_base.cc @@ -108,9 +108,12 @@ namespace PETScWrappers (index < static_cast(end)), ExcAccessToNonlocalElement(index, begin, end - 1)); - PetscInt idx = index; - PetscScalar value; - ierr = VecGetValues(vector.vector, 1, &idx, &value); + const PetscScalar *ptr; + PetscScalar value; + ierr = VecGetArrayRead(vector.vector, &ptr); + AssertThrow(ierr == 0, ExcPETScError(ierr)); + value = *(ptr + index - begin); + ierr = VecRestoreArrayRead(vector.vector, &ptr); AssertThrow(ierr == 0, ExcPETScError(ierr)); return value;