/* Solve J Y = F, where J is Jacobian matrix */
ierr = SNESComputeJacobian(snes, X, snes->jacobian, snes->jacobian_pre);
CHKERRQ(ierr);

PetscInt rstart, rend;
MatGetOwnershipRange(snes->jacobian, &rstart, &rend);
PetscInt row=1000, col=1000;
PetscScalar v;
if (row>=rstart && row<rend)
{
    MatGetValues(snes->jacobian, 1, &row, 1, &col, &v);
    PetscPrintf(PETSC_COMM_WORLD, "rstart: %d, rend: %d, row: %d, col: %d,
v: %e\n", rstart, rend, row, col, v);
}

It was supposed to return the value of the matrix at row 1001 and column
1001, but it returned the value at row 2001 and column 2001 instead. There
is a two-fold relationship between these coordinates, and I'm not sure if
it's related to the fact that I set the number of processes to 2.

Reply via email to