[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

calling MatXXPreallocate after MatAssemblyXXX()



  I think it should be possible to call the preallocate again. All the code
needs to do (as Matt noted) is mimic changing the matrix type; in otherwords 
call     ierr = (*mat->ops->destroy)(mat);CHKERRQ(ierr); and then call the
  ierr = (*r)(mat);CHKERRQ(ierr); to set it up again.

  Note: When the preallocation is called again, essentially everything except 
the layout (sizes) of the matrix is lost (but this is ok).

   Barry


For example, I am chugging along on some non-linear or time dependent problem
with linear solves flying by. Then for some reason I know the nonzero structure
of my matrix is going to change dramatically (more space or less space). I 
should be able to properly prepare for the changes by calling the preallocate 
again.

I do not want to create a new matrix since I have a bunch of references in 
different places (including inside the KSP) that would become invalid.
I could change the type to something else, then change it back then call
the MatXXXPreallocate() again but that is just making it artificially confusing
and hard for the user.