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 <[email protected]> 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
