Subject: Re: [UFC-dev] [DOLFIN-dev] Zeros in matrices

From: Anders Logg <[email-masked]>
Date: Mon, 30 Apr 2007 00:32:07 +0200

On Sun, Apr 29, 2007 at 12:02:59PM +0200, Garth N. Wells wrote:
> 
> 
> Garth N. Wells wrote:
> > 
> > 
> > Anders Logg wrote:
> >> On Fri, Apr 27, 2007 at 05:24:34PM +0200, Garth N. Wells wrote:
> >>>
> >>> Anders Logg wrote:
> >>>> I'm comparing the entries in the Stokes systems between the new code
> >>>> and the old and there seem to be quite a few more zeros in the sparse
> >>>> matrix than before.
> >>>>
> >>> Strange. Have you counted the non-zeroes, or are you displaying the 
> >>> matrix?
> >>
> >> Displaying the matrix and counting everything that looks like zero.
> >> (Just looking at the numbers.)
> >>
> > 
> > There are about double the number of non-zeros (you can get the number 
> > by A.nnz()) for the Stokes example with the new version compared to 
> > version 0.6.4. For poisson and elasticity, the number of non-zeroes is 
> > the same as with version 0.6.4. The linear algebra looks fine - 
> > something is going on with the computation of the sparsity pattern for 
> > the Stokes problem.
> > 
> 
> This is due to the significant number of zeroes in the element matrix 
> for the Stokes problem. Previously, for uBLAS matrices the stiffness 
> matrix was assembled into a temporary matrix A_temp which was then 
> copied to a compressed row matrix A
> 
>    A.assign(A_temp);
> 
> The assign operation removed all non-zero terms. We no longer assemble 
> into the temporary matrix.
> 
> Perhaps FFC could produce something to indicate the non-zero terms in 
> the element matrix, although this would make things more complicated.
> 
> Garth

We could add something like

    void tabulate_nonzero_entries(bool* nonzero_entries);

to go along with tabulate_tensor() in the UFC interface.

This would not catch things like entries being zero because of
geometry (like entries for vertices "diagonal to each other" on a
regular simplicial mesh) but would catch entries that are known to be
always zero.

For 2D Stokes with P2-P1 Taylor-Hood elements, it looks like we have
117 out of 225 entries being zero in the element tensor so then it
would be useful to know this in advance.

Opinions?

/Anders

---

From: "Garth N. Wells" <[email-masked]>
Date: Mon, 30 Apr 2007 09:48:11 +0200

> to go along with tabulate_tensor() in the UFC interface.

I'm not sure that this would help much because we would need to ensure 
that only non-zero entries are assembled. This would require doing extra 
work within the assembly loop to strip out zero values.

The function tabulate_tensor() could tabulate only non-zero terms, and a 
modified dof map would have to reflect this.

Garth

> _______________________________________________
> DOLFIN-dev mailing list
> [email-masked]
> http://www.fenics.org/mailman/listinfo/dolfin-dev
>

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 30 Apr 2007 11:42:13 +0200

> > to go along with tabulate_tensor() in the UFC interface.

I think the simplest solution is to do this at the linear algebra
level, ie make a call to the CRS matrix to make it compact its storage
by removing zeros. I believe this functionality already exists in many
linear algebra classes.

martin

---

From: Anders Logg <[email-masked]>
Date: Mon, 30 Apr 2007 13:34:35 +0200

> by removing zeros. I believe this functionality already exists in many

Agree.

/Anders