# PETSc jacobian

Tue Mar 6 15:09:26 CST 2007

```Hi Jianing,

The way I understand things, since a DA is fundamentally designed to
handle spatially discretized differential equations, it is good for
distributing your data and automatically handling situations that
arise in PDE/ODE-solving, like updating of ghost points as fields
change over time.  Since a DA is not an operator, it can handle
multiple dimensions without difficulty, as well as take the role of a
'weight matrix' defining some sort of interactions between points.

The PETSc Mat, on the other hand, is fundamentally a linear operator.
It's a way to define a relationship between two vectors in your space.
It can easily multiply vectors and perform other 'linear algebra'
operations, but it really isn't designed designed as a graph between
two vectors.

If I were trying to solve this problem, I would probably use DA to
define my weight operator, then use direct access to the DA components
to extract the columns.  I would only use Mat if I was trying to solve
for some sort of linear system, like Mx = b.

Thanks,
~Aron

PS - I fantasize about elegant designs as well

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?
> - 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?
> - How is such a distributed sparse matrix stored on different
> processors, how is it divided up, and collected?
>
> 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).
>
> Thanks!
>
> Jianing
>
>

```