# PETSc jacobian

Matthew Knepley knepley at gmail.com
Tue Mar 6 16:04:51 CST 2007

```On 3/6/07, Jianing Shi <jianings at gmail.com> wrote:
> Hi PETSc designers,
>
> I have a non-trivial extension to a diffusion problem, that involves
> talking between neighboring (neighboring band) points.  I have a
> question about the data structures in PETSc, since I am fantasized
>
> I have two options: 1) use structured grid (DA)   2) in some
> applications, my grid can be unstructured, in fact a directed graph.
> I am considering the first option now (since I still need to read up
> onto the PETSc mesh/graph).
>
> Suppose I need to represent the connectivity of a point to its
> neighboring points, I need a weight matrix.  I guess I can
> (A) use a DA structure, setting DOF = total number of points connected
> to a point (assuming the connectivity range for each point is the
> same).
> or
> (B) use a Jacobian matrix data structure to store these weights.  In
> this case, I guess I will use MATMPIAIJ or MATMPIBAIJ.
>
> - What is the difference between these two types of Jacobian matrix?

One has a fixed Cartesian topology (connectivity). The other can have
an arbitrary connectivity.

> - For distributed sparse matrix like MATMPIAIJ, MATMPIBAIJ, how
> efficient is it to extract one column of the matrix M(i,:) ?  Does
> PETSc have routines to do this?

It is there, but it is not efficient. Row extraction is efficient.

> - How is such a distributed sparse matrix stored on different
> processors, how is it divided up, and collected?

Row-wise. There is a picture in the manual.

> I want to understand this, because if a distributed sparse matrix is
> an efficient representation of my sparse weight matrix, I will go for
> this option (B).  Otherwise, I will opt for option (A).

I think you are confusing two issues. The DA is not an operator or a matrix.
it is a topology or connectivity. It can create an AIJ matrix with that
connectivity automatically.

Matt

> Thanks!
>
> Jianing
>
>

--
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

```