How to zero all values on a particular row?
Barry Smith
bsmith at mcs.anl.gov
Sun Jun 10 18:54:12 CDT 2007
On Sun, 10 Jun 2007, Ben Tay wrote:
> Hi,
>
> I need to insert values into a matrix and then solve this poisson eqn as
> part of my cfd code. For efficiency sake, I simply use
>
> "do j=1,size_y
>
> do i=1,size_x
>
> matsetvalue ....
>
> end do
>
> end do"
>
> to insert values into all the cells
>
> Then for specific cells, I need to enter some other values. In other words,
> for specific rows of the matrix, I need to zero the whole row and insert new
> values. How can I do that?
>
> I tried to use MatZeroRows but it says it's not for unassembled matrix. But
> I need to zero the particular row, insert values, and then finally assembly
> it. Is there a command to do this?
matassemblybegin/end
matzerorows
matsetvalues, matsetvalues, matsetvalue
matssemblybegin/end
For improved efficiency you will want to call
MatSetOption(mat,MAT_KEEP_ZEROED_ROWS); before the matzerorows()
>
> Thanks
>
More information about the petsc-users
mailing list