[petsc-users] About MAT_NEW_NONZERO_LOCATION[]

Barry Smith bsmith at petsc.dev
Tue Oct 13 09:41:37 CDT 2020


  You only need to provide one of the options. 

   The docs are slightly misleading.The flags only tells the matrix what to do with new nonzero locations, preventing new ones. The Mat actually tracks if new non-zeros locations are actually entered independent of the flags. So, for example even if you did not supply any new flags AND your code did not insert new locations then the structure would be reused.

   Barry

> On Oct 13, 2020, at 7:47 AM, Thibaut Appel <t.appel17 at imperial.ac.uk> wrote:
> 
> Hi there, just a quick question:
> 
> It seems MAT_NEW_NONZERO_LOCATION_ERR set to PETSC_TRUE has kind of the same purpose as MAT_NEW_NONZERO_LOCATIONS set to PETSC_FALSE, the difference being if an additional entry is there, the former produces an error whereas in the latter it is simply ignored.
> 
> However the manual states:
> 
> 'If one wishes to repeatedly assemble matrices that retain the same nonzero pattern (such as within a nonlinear or time-dependent problem), the option MatSetOption(MatA,MAT_NEW_NONZERO_LOCATIONS,PETSC_FALSE); should be specified after the first matrix has been fully assembled. This option ensures that certain data structures and communication information will be reused (instead of regenerated) during successive steps, thereby increasing efficiency'
> 
> If I only declare:
> 
>     CALL MatSetOption(MatA,MAT_NEW_NONZERO_LOCATION_ERR,PETSC_TRUE,ierr)
> 
> Would the data structures still be reused in later matrix assemblies?
> 
> Or does it rather make sense to use conjointly:
> 
>     CALL MatSetOption(MatA,MAT_NEW_NONZERO_LOCATION_ERR,PETSC_TRUE,ierr)
>     CALL MatSetOption(MatA,MAT_NEW_NONZERO_LOCATIONS,PETSC_FALSE,ierr)
> 
> Thank you,
> 
> 
> 
> Thibaut
> 

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


More information about the petsc-users mailing list