[petsc-users] zero pattern of result of matmatmult

Frederik Treue frtr at fysik.dtu.dk
Tue Sep 17 07:59:46 CDT 2013


On Fri, 2013-09-06 at 08:36 -0500, Jed Brown wrote:
> Frederik Treue <frtr at fysik.dtu.dk> writes:
> >>   Multiplying difference operators together is really brittle
> >> (boundary conditions, geometry, etc) and uses more memory than
> >> necessary.
> >
> > Why? Ofcourse, it could go wrong if you get the non-zero pattern of the
> > product matrix wrong, but that's the same as with all other instances of
> > SAME_NONZERO_PATTERN throughout petsc. Why is this one special?
> 
> The symbolic part of the matrix multiply does not use entries, and
> ensures that the numeric part has no memory allocation and no
> conditionals.
> 
> Implementing boundary conditions and variable mesh spacing by splitting
> into first order operators is quite clumsy and a lot less flexible when
> you want to change the discretization.  I think your approach is a false
> economy and you should just write the local routines that evaluate the
> actual Jacobian.  You can factor those functions however you like
> (e.g., finite element and finite volume would look a bit different).

I have done this, but the problem still is that it takes too much time
to recreate the matrix in each timestep (the time it takes to construct
the matrix is roughly equivalent to the time it takes to solve it using
CG with ~50 iterations), so: What is the fastest way to change the
entries in a matrix? Right now I'm reduced to recreating the whole thing
with MatSetValuesStencil in a for loop with MatAssembly afterwards. How
would one ideally do this?

/Frederik



More information about the petsc-users mailing list