[petsc-users] Zero entries of a sparse matrix in a block-wise style

Jed Brown jed at jedbrown.org
Fri Jul 26 15:11:44 CDT 2019

Can you give an example of what you are trying?  These functions should be capable of handling any set of rows.

Mingchang Ding via petsc-users <petsc-users at mcs.anl.gov> writes:

> Hi, all
> I am trying to apply LDG to discretizing 1D diffusion term u_{xx} with Dirichlet boundary condition. The difficulty I have is that I want to zero all entries (except the diagonal one needs to be set as 1.0) of the beginning and ending DOF rows of the sparse matrix.
> I have tried the MatZeroRows and MatZeroRowsStencil. However, I can only change the very first and last row of the matrix with them. This isn’t right when DOF > 1 because I need to zero the first DOF rows (the diagonal should be set as identity).
> I was wondering if there is anyway I can take to zero the first and last DOF rows (with identity matrix diagonal) in a block-wise style.
> Let me know if any further explanation is needed.
> Thank you in advance!
> Mingchang Ding
> Graduate Student
> EWG 111
> Department of Mathematical Sciences
> University of Delaware

More information about the petsc-users mailing list