<div dir="ltr"><div dir="ltr">On Fri, Sep 10, 2021 at 2:04 PM Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><br></div><div> I think the following should work for you.</div><div><br></div><div> Create a "wide" DMDA and then call DMSetMatrixPreallocateOnly()</div></div></blockquote><div><br></div><div>Or use -dm_preallocate_only</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div> 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><br></div><div> Now create your regular DMDA and use that to create your vectors and for needed DMGlobalToLocal etc.</div><div><br></div><div> Barry</div><div><div><br></div><div><br><blockquote type="cite"><div>On Sep 10, 2021, at 12:51 PM, Alfredo J Duarte Gomez <<a href="mailto:aduarteg@utexas.edu" target="_blank">aduarteg@utexas.edu</a>> wrote:</div><br><div><div dir="ltr">Good afternoon,<div><br></div><div>I have developed and validated some matrix operators using petsc with a structured dmda.</div><div><br></div><div>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><br></div><div>This is very wasteful and affects my performance, since there are a lot of extra zeros corresponding to the inner points.</div><div><br></div><div>What is the best way to improve this?</div><div><br></div><div>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><br></div><div>Alternatively, is there any way to use a larger stencil width and then trim the zero entries that were entered automatically?</div><div><br></div><div>If there are any other solutions for this problem, please let me know.</div><div><br></div><div>Thank you,</div><div><br></div><div>-Alfredo Duarte</div><div><br></div><div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><font face="arial, sans-serif">Alfredo Duarte</font><div><font face="arial, sans-serif">Graduate Research Assistant</font></div><div><font face="arial, sans-serif">The University of Texas at Austin</font></div></div></div></div></div></div></div>
</div></blockquote></div><br></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>