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

#DOMINIC DENVER JOHN CHANDAR# DOMI0002 at ntu.edu.sg
Wed Jan 31 10:45:34 CST 2007


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()?

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