[petsc-users] DMDA matrices with one sided stencils

Matthew Knepley knepley at gmail.com
Sat Sep 11 13:55:49 CDT 2021


On Fri, Sep 10, 2021 at 2:04 PM Barry Smith <bsmith at petsc.dev> wrote:

>
>     I think the following should work for you.
>
>    Create a "wide" DMDA and then call DMSetMatrixPreallocateOnly()
>

Or use -dm_preallocate_only

  Thanks,

     Matt


> 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
>
>
>

-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20210911/c257e0e3/attachment.html>


More information about the petsc-users mailing list