[petsc-users] reset the sparsity pattern of a matrix without destroying and recreating it

Barry Smith bsmith at petsc.dev
Fri Oct 23 11:51:19 CDT 2020


  You should be able to call 

MatResetPreallocation()
MatSeqAIJSetPreallocation(new data) 

or any other preallocations routines again and it will clean out the old
material.

 Let us know if this does not work,

  Barry


> On Oct 23, 2020, at 9:11 AM, Aulisa, Eugenio <Eugenio.Aulisa at ttu.edu> wrote:
> 
> 
> Hi
> 
> I have a time dependent problem, where at each iteration
> the sparsity pattern of some rows of an mpi matrix keeps changing.
> 
> I have an estimate at each iteration what the maximum size of these rows should be,
> so I can conservatively pre-allocate the matrix memory.
> 
> I then assembly using the option
> MatSetOption(mat, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
> 
> It runs for few iterations but then it saturates the pre-allocated memory.
> 
> What happens is that at each iteration new columns are added to the changing rows, 
> but old entries that are now zero (and not needed anymore) are not removed, 
> and the size of the changing rows increases till it reaches the maximum allowed value.
> 
> Is there any way, when at each iteration I zero the matrix 
> to forget the previous sparsity pattern and start from fresh, 
> without destroying and recreating the matrix?
> 
> Also, if possible, is it possible to select only the rows where this should happens?
> i.e. keeping the same sparsity pattern for a set of rows and forget it for the others.
> 
> Thanks,
> Eugenio

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20201023/94cd6d0b/attachment.html>


More information about the petsc-users mailing list