]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Rename a few variables to make their intent clearer. 15043/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 6 Apr 2023 23:35:23 +0000 (17:35 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 6 Apr 2023 23:35:23 +0000 (17:35 -0600)
source/lac/petsc_vector_base.cc

index 010d355d61bc804727d4d94247834ef87f0b896e..1105575a1111d693a1e6e0862ceb65731b0370a1 100644 (file)
@@ -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<IndexSet::size_type>(array[i]));
         ghost_indices.compress();
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.