// otherwise first flush PETSc caches
matrix->compress ();
- // next get the number of the row
- // relative to the rows this process
- // actually stores (remember that
- // matrices can be distributed)
- signed int local_row = -1;
- if ((dynamic_cast<const PETScWrappers::SparseMatrix *>(matrix) != 0)
- ||
- (dynamic_cast<const PETScWrappers::FullMatrix *>(matrix) != 0))
- {
- local_row = this->a_row;
- }
- else if (dynamic_cast<const PETScWrappers::MPI::SparseMatrix *>(matrix)
- != 0)
- {
- // first verify that the requested
- // element is actually locally
- // available
- int ierr;
- int begin, end;
- ierr = MatGetOwnershipRange (*matrix, &begin, &end);
- AssertThrow (ierr == 0, ExcPETScError(ierr));
-
- AssertThrow ((this->a_row >= static_cast<unsigned int>(begin)) &&
- (this->a_row < static_cast<unsigned int>(end)),
- ExcAccessToNonlocalRow (this->a_row, begin, end-1));
-
- // alright, so we seem to have this
- // particular row on the present
- // processor
- local_row = this->a_row - begin;
- }
- else
- Assert (false, ExcInternalError());
-
// get a representation of the present
// row
int ncols;
PetscScalar *values;
int ierr;
- ierr = MatGetRow(*matrix, local_row, &ncols, &colnums, &values);
+ ierr = MatGetRow(*matrix, this->a_row, &ncols, &colnums, &values);
AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));
// copy it into our caches
value_cache.reset (new std::vector<PetscScalar> (values, values+ncols));
// and finally restore the matrix
- ierr = MatRestoreRow(*matrix, local_row, &ncols, &colnums, &values);
+ ierr = MatRestoreRow(*matrix, this->a_row, &ncols, &colnums, &values);
AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));
}
}