From f61048f09ea6dac7b087278fd98b9240c0203da8 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 6 Apr 2023 17:35:23 -0600 Subject: [PATCH] Rename a few variables to make their intent clearer. --- source/lac/petsc_vector_base.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/source/lac/petsc_vector_base.cc b/source/lac/petsc_vector_base.cc index 010d355d61..1105575a11 100644 --- a/source/lac/petsc_vector_base.cc +++ b/source/lac/petsc_vector_base.cc @@ -197,21 +197,19 @@ namespace PETScWrappers { Vec tvector; PetscScalar *array; - PetscInt st, en, N, ln; + PetscInt ghost_start_index, end_index, n_elements_stored_locally; ierr = VecGhostRestoreLocalForm(vector, &ghosted_vec); AssertThrow(ierr == 0, ExcPETScError(ierr)); - ierr = VecGetSize(vector, &N); - AssertThrow(ierr == 0, ExcPETScError(ierr)); - ierr = VecGetOwnershipRange(vector, &st, &en); + ierr = VecGetOwnershipRange(vector, &ghost_start_index, &end_index); AssertThrow(ierr == 0, ExcPETScError(ierr)); ierr = VecDuplicate(vector, &tvector); AssertThrow(ierr == 0, ExcPETScError(ierr)); ierr = VecGetArray(tvector, &array); AssertThrow(ierr == 0, ExcPETScError(ierr)); - for (PetscInt i = 0; i < en - st; i++) - array[i] = st + i; + for (PetscInt i = 0; i < end_index - ghost_start_index; i++) + array[i] = ghost_start_index + i; ierr = VecRestoreArray(tvector, &array); AssertThrow(ierr == 0, ExcPETScError(ierr)); ierr = VecGhostUpdateBegin(tvector, INSERT_VALUES, SCATTER_FORWARD); @@ -220,15 +218,17 @@ namespace PETScWrappers AssertThrow(ierr == 0, ExcPETScError(ierr)); ierr = VecGhostGetLocalForm(tvector, &ghosted_vec); AssertThrow(ierr == 0, ExcPETScError(ierr)); - ierr = VecGetLocalSize(ghosted_vec, &ln); + ierr = VecGetLocalSize(ghosted_vec, &n_elements_stored_locally); AssertThrow(ierr == 0, ExcPETScError(ierr)); ierr = VecGetArrayRead(ghosted_vec, (const PetscScalar **)&array); AssertThrow(ierr == 0, ExcPETScError(ierr)); // Populate ghosted and ghost_indices ghosted = true; - ghost_indices.set_size(N); - for (PetscInt i = en - st; i < ln; i++) + ghost_indices.set_size(this->size()); + for (PetscInt i = end_index - ghost_start_index; + i < n_elements_stored_locally; + i++) ghost_indices.add_index(static_cast(array[i])); ghost_indices.compress(); -- 2.39.5