How to zero all values on a particular row?

Ben Tay zonexo at gmail.com
Sun Jun 10 19:47:17 CDT 2007


Thanks Barry,

I managed to get it working. I realise that I had to call
matssemblybegin/end each time after I zero a particular row. I also tried
MatSetOption(mat,MAT_KEEP_ZEROED_ROWS) as what you 've suggested.

So do I have to callMatSetOption(mat,MAT_KEEP_ZEROED_ROWS) everytime just
before I need to zero it or just once ie after the 1st matassemblybegin/end?

Calling matassemblybegin/end each time before matzerorows gives me the
impression that it is very inefficient. Is that so?

In that case, I wonder if it is better for me to :

1 use matsetvalues to put zeros into those location where I earlier insert
in the 1st full i,j sweep
2. insert correct value using matsetvalues
3. finally matassemblybegin/end - just once.

Lastly, is MatZeroRowsIS exactly the same as matzerorows, except that it is
meant for just 1 row instead of consecutive no. of rows?

Thanks again


On 6/11/07, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
>
>
> 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
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20070611/14542890/attachment.htm>


More information about the petsc-users mailing list