for (i=start; i0) {J = I - n; ierr = MatSetValues(C1,1,&I,1,&J,&v,ADD_VALUES);CHKERRQ(ierr);} if (i0) {J = I - 1; ierr = MatSetValues(C1,1,&I,1,&J,&v,ADD_VALUES);CHKERRQ(ierr);} if (j0) {J = I - n; ierr = MatSetValues(C1,1,&I,1,&J,&v,ADD_VALUES);CHKERRQ(ierr);} } /* Modify matrix and right-hand-side for Dirichlet boundary conditions */ ierr = PetscMalloc(4*m*sizeof(int),&rows);CHKERRQ(ierr); for (i=0; i