<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""> I think the following should work for you.</div><div class=""><br class=""></div><div class=""> 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.</div><div class=""><br class=""></div><div class=""> Now create your regular DMDA and use that to create your vectors and for needed DMGlobalToLocal etc.</div><div class=""><br class=""></div><div class=""> Barry</div><div class=""><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On Sep 10, 2021, at 12:51 PM, Alfredo J Duarte Gomez <<a href="mailto:aduarteg@utexas.edu" class="">aduarteg@utexas.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Good afternoon,<div class=""><br class=""></div><div class="">I have developed and validated some matrix operators using petsc with a structured dmda.</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">This is very wasteful and affects my performance, since there are a lot of extra zeros corresponding to the inner points.</div><div class=""><br class=""></div><div class="">What is the best way to improve this?</div><div class=""><br class=""></div><div class="">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?</div><div class=""><br class=""></div><div class="">Alternatively, is there any way to use a larger stencil width and then trim the zero entries that were entered automatically?</div><div class=""><br class=""></div><div class="">If there are any other solutions for this problem, please let me know.</div><div class=""><br class=""></div><div class="">Thank you,</div><div class=""><br class=""></div><div class="">-Alfredo Duarte</div><div class=""><br class=""></div><div class="">-- <br class=""><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><font face="arial, sans-serif" class="">Alfredo Duarte</font><div class=""><font face="arial, sans-serif" class="">Graduate Research Assistant</font></div><div class=""><font face="arial, sans-serif" class="">The University of Texas at Austin</font></div></div></div></div></div></div></div>
</div></blockquote></div><br class=""></div></body></html>