Reading a Sparse matrix in CRS format from a function to be used in parallel linear solvers

Hong Zhang hzhang at mcs.anl.gov
Wed Jan 31 11:18:24 CST 2007



On Thu, 1 Feb 2007, #DOMINIC DENVER JOHN CHANDAR# wrote:

> Hi,
>
>    Thanks Hong and Matt. So looks like I don't have to call
> MatSetValues() since I specify the row, column indices and the values
> corresponding to it when I use  MatCreateMPIIJWithArrays()?

No, petsc actually does MatSetValues() inside MatCreateMPIAIJWithArrays().
Note, it sould be MatCreateMPIAIJWithArrays()
                           ^^^^^^
I copied wrong name from the web :-(

Please read
http://www-unix.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatCreateMPIAIJWithArrays.html

You must input local i,j,a arrays in standard CSR format, not
exactly your CRS- form.

Hong
>
> Cheers,
> Dominic
>
> -----Original Message-----
> From: owner-petsc-users at mcs.anl.gov
> [mailto:owner-petsc-users at mcs.anl.gov] On Behalf Of Hong Zhang
> Sent: Wednesday, January 31, 2007 11:57 PM
> To: petsc-users at mcs.anl.gov
> Subject: Re: Reading a Sparse matrix in CRS format from a function to be
> used in parallel linear solvers
>
>
> Dominic,
>
> You may use MatCreateMPIIJWithArrays() to achieve this.
>
> Hong
>
> On Wed, 31 Jan 2007, Matthew Knepley wrote:
>
> > On 1/31/07, #DOMINIC DENVER JOHN CHANDAR# <DOMI0002 at ntu.edu.sg> wrote:
> > >
> > >  Hi,
> > >
> > >        I have a function which creates a sparse matrix following a
> > > certain eqn and returns a pointer to the row, column index and the
> > > value of a sparse matrix (CRS- form).
> > > i   j   val
> > > 1  1  1.0
> > > 2  2  1.0
> > > 2  3  -1.5..
> > > so on...
> > >
> > >  The matrix *may not **have a definite pattern* like the one we see
> > > for tridiagonal or pentadiagonal matrices or the test cases (linear
> > > solvers) cited in the petsc documentation. Now, i would like to use
> > > the linear solvers in petsc to solve the system of equations. I do
> > > not want to write that sparse matrix into a file and read it into
> > > petsc since it may be huge.I would like to call that function from
> > > petsc and would return the pointer to i j and val and insert values
> > > of this sparse matrix using MatSetValues in parallel. How can I
> achieve this ?
> > >
> >
> > We do not have CRS format as it is not a very space efficient format.
> > Most of our formats are row-oriented. I suggest looking at the example
>
> > for MatSetValues() and trying to rework the discretization function to
>
> > directly call this. Most discretizations naturally generate row-by-row
>
> > values or even blocks like FEM. Even totally nustructured stuff from
> > economics is row-by-row.
> >
> >   Thanks,
> >
> >     Matt
> >
> > Cheers,
> > > Dominic
> > >
> > --
> > One trouble is that despite this system, anyone who reads journals
> > widely and critically is forced to realize that there are scarcely any
>
> > bars to eventual publication. There seems to be no study too
> > fragmented, no hypothesis too trivial, no literature citation too
> > biased or too egotistical, no design too warped, no methodology too
> > bungled, no presentation of results too inaccurate, too obscure, and
> > too contradictory, no analysis too self-serving, no argument too
> > circular, no conclusions too trifling or too unjustified, and no
> > grammar and syntax too offensive for a paper to end up in print. --
> > Drummond Rennie
> >
>
>




More information about the petsc-users mailing list