<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">Am 24.07.2021 um 07:32 schrieb Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>>:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div> Qi,<div class=""><br class=""></div><div class=""> MatSetLocalGlobalToGlobalMapping() is the routine that provides the information to the matrix so that one can use a "local" ordering and it will get automatically translated to the parallel PETSc ordering on the parallel matrix. Generically yes it includes the ghost point region on each MPI rank. Some DM's provide this information automatically; for DMDA it is pretty simple, for DMStag a bit more complicated. </div><div class=""><br class=""></div></div></div></blockquote><div>The local-to-global mapping should get automatically attached to the Mat if you use a DM to create an operator/Mat, with DMCreateMatrix(). Thus, this is the recommended way to proceed!</div><div><br class=""></div><div><a href="https://petsc.org/release/docs/manualpages/DM/DMCreateMatrix.html" class="">https://petsc.org/release/docs/manualpages/DM/DMCreateMatrix.html</a></div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""> You are correct, the previous manual page for MatZeroRowsLocal() incorrectly states "global" rows from 16+ years ago, likely a cut and paste error. It looks like it has been fixed in the main PETSc repository,</div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""> Barry</div><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jul 23, 2021, at 10:50 AM, Tang, Qi <<a href="mailto:tangqi@msu.edu" class="">tangqi@msu.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
How can we use MatZeroRowsLocal? Is there any doc for the local index vs global index for a matrix?
<div class=""><br class="">
</div>
<div class="">I am asking because we are not sure about how to prepare a proper local index. Does the index include the ghost point region or not?</div>
<div class=""><br class="">
</div>
<div class="">Qi<br class="">
<div class="">
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<br class="Apple-interchange-newline">
</div>
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On Jul 20, 2021, at 9:30 PM, Tang, Qi <<a href="mailto:tangqi@msu.edu" class="">tangqi@msu.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">Hi,</div>
<div class=""><br class="">
</div>
<div class="">Now I think the DMStagStencilToIndexLocal provides the local index for given (stencil) positions. How can we use that local index information to eliminate the rows? </div>
<div class=""><br class="">
</div>
<div class="">Is the following code possible:</div>
<div class=""><br class="">
</div>
<div class="">MatSetLocalToGlobalMapping(…);</div>
<div class="">If (is_boundary){</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>PetscInt ix;</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>DMStagStencilToIndexLocal(…, &ix);</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>MatZeroRowsLocal(… &ix, …);</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class="">The comment of MatZeroRowsLocal said "rows - the global row indices”. But this seems inconsistent with its name, so I am confused.</div>
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class="">
<div class="">Qi</div>
<br class="Apple-interchange-newline">
</div>
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On Jul 20, 2021, at 2:18 AM, Patrick Sanan <<a href="mailto:patrick.sanan@gmail.com" class="">patrick.sanan@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Qi -
<div class=""><br class="">
</div>
<div class="">I just opened a PR to make DMStagStencilToIndexLocal() public</div>
<div class=""><a href="https://urldefense.com/v3/__https://gitlab.com/petsc/petsc/-/merge_requests/4180__;!!HXCxUKc!mAeQntyQFk-B3KHmJJWuOGKXTfKh8A-uC-v9JFZHW-VbJT7ejxWH7LlaFNM-Zg$" class="">https://gitlab.com/petsc/petsc/-/merge_requests/4180</a></div>
<div class=""><br class="">
</div>
<div class="">(Sorry for my inattention - I think I may have missed some communications in processing the flood of PETSc emails too quickly - I still plan to get some more automatic DMStag fieldsplit capabilities into main, if it's not too late).<br class="">
<div class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">Am 20.07.2021 um 02:47 schrieb Tang, Qi <<a href="mailto:tangqi@msu.edu" class="">tangqi@msu.edu</a>>:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class="">Hi,</div>
<div class="">As a part of implementing this process by ourself, we would like to eliminate boundary dofs. By reading DMStag code, we guess we can use</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>DMStagStencilToIndexLocal</div>
<div class=""><span class="Apple-tab-span" style="white-space:pre"></span>MatZeroRowsLocal</div>
<div class=""><br class="">
</div>
<div class="">We note that DMStagStencilToIndexLocal is not explicitly defined in the header file. Is this function ready to use? And will we be able to eliminate the dofs using the above functions?</div>
<div class=""><br class="">
</div>
<div class="">Thanks,</div>
<div class="">Qi<br class="">
<div class=""><br class="">
</div>
<br class="Apple-interchange-newline">
</div>
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On Jul 16, 2021, at 8:17 PM, Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class=""><br class="">
</div>
Zakariae,
<div class=""><br class="">
</div>
<div class=""> MatGetSubMatrix() was removed a long time ago, the routine is now MatCreateSubMatrix() but it does not work in way you had hoped. There is currently no mechanism to move values you put into the sub matrix back into the original larger matrix
(though perhaps there should be?). </div>
<div class=""><br class="">
</div>
<div class=""> Please look at MatCreateSubMatrixVirtual() and also MatCreateNest() to see if either of those approaches satisfy your needs. </div>
<div class=""><br class="">
</div>
<div class=""> Please let us know if there are extensions that would be useful for you to accomplish what you need. </div>
<div class=""><br class="">
</div>
<div class=""> Barry</div>
<div class=""><br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On Jul 16, 2021, at 7:45 PM, Jorti, Zakariae via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div id="divtagdefaultwrapper" dir="ltr" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif;" class="">
<div style="margin-top: 0px; margin-bottom: 0px;" class="">Hello,</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class="">
</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">I have a matrix A = [A00 , A01 ; A10, A11]. </div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">I extract the submatrix A11 with MatGetSubMatrix.</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">I only know the global IS is1 and is2, so to get A11 I call: </div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">MatGetSubMatrix(A,is2,is2,MAT_INITIAL_MATRIX,&A11);</div>
<div style="margin-top: 0px; margin-bottom: 0px;" class="">I want to modify A11 and update the changes on the global matrix A but I could not find any <span style="font-size: 12pt;" class="">MatRestoreSubMatrix routine.</span></div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><span style="font-size: 12pt;" class="">Is there something similar to </span><span style="font-size: 12pt;" class="">VecGetSubVector and VecRestoreSubVector for matrices that uses only global indices?</span></div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><span style="font-size: 12pt;" class="">Many thanks.</span></div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><span style="font-size: 12pt;" class="">Best regards,</span></div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><span style="font-size: 12pt;" class=""><br class="">
</span></div>
<div style="margin-top: 0px; margin-bottom: 0px;" class=""><span style="font-size: 12pt;" class="">Zakariae </span></div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></body></html>