[petsc-users] DMDA matrices with one sided stencils

Barry Smith bsmith at petsc.dev
Fri Sep 10 13:04:17 CDT 2021


    I think the following should work for you.

   Create a "wide" DMDA and then call DMSetMatrixPreallocateOnly() on it, use this DMDA to create your matrix, this will ensure that only the entries you enter into the matrix are stored (so the extra "layers" of zeros will not appear in the matrix). The matrix vector products will then not use those extra entries and will be faster. Destroy the no longer needed wide DMDA. You can use MatSetValuesStencil() with this matrix.

   Now create your regular DMDA and use that to create your vectors and for needed DMGlobalToLocal etc.

  Barry


> On Sep 10, 2021, at 12:51 PM, Alfredo J Duarte Gomez <aduarteg at utexas.edu> wrote:
> 
> Good afternoon,
> 
> I have developed and validated some matrix operators using petsc with a structured dmda.
> 
> Some of these operators use one-sided stencils at the boundaries, which following the way the dmda uses the stencil width value, requires me to increase the stencil width to accommodate more entries at the boundary only if I want to avoid errors with default options.
> 
> This is very wasteful and affects my performance, since there are a lot of extra zeros corresponding to the inner points.
> 
> What is the best way to improve this?
> 
> I have read in some public threads the possibility of using MatOption to allow us to put more entries into the matrix, but that does not allow me to use MatSetStencil?
> 
> Alternatively, is there any way to use a larger stencil width and then trim the zero entries that were entered automatically?
> 
> If there are any other solutions for this problem, please let me know.
> 
> Thank you,
> 
> -Alfredo Duarte
> 
> -- 
> Alfredo Duarte
> Graduate Research Assistant
> The University of Texas at Austin

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


More information about the petsc-users mailing list