<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Thank you!</p>
<p><br>
</p>
<p>Bests,</p>
<p>LI</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Matthew Knepley <knepley@gmail.com><br>
<b>Sent:</b> Monday, 14 March, 2022 23:44:06<br>
<b>To:</b> liluo<br>
<b>Cc:</b> Mark Adams; jed@jedbrown.org; petsc-users@mcs.anl.gov<br>
<b>Subject:</b> Re: [petsc-users] How to obtain the local matrix from a global matrix in DMDA?</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Mon, Mar 14, 2022 at 11:05 AM liluo <<a href="mailto:liluo@um.edu.mo">liluo@um.edu.mo</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>
<div id="gmail-m_3329168753258936637divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p><span style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Dear developers,</span></p>
<p><br>
</p>
<p><span style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">I defined subdomain problems that have some layers of </span><span style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">ghost points, which are exactly of </span><span style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">the
 "local</span><span style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">" size of a DA.</span></p>
<p><span style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">And I want to generate the corresponding submatrix in each subdomain which contains those layers of ghost points.</span></p>
<p><br>
</p>
<p><span style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">I know that </span><span style="color:rgb(33,33,33);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">MatGetSubMatrices can return a submatrix when determining the index set like
 PCASM, but how can I get the index set including those layers of ghost points? When a DA is setup, such IS for creating ltog mapping was already destroyed.</span></p>
<p><span style="color:rgb(33,33,33);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Or you may have some simpler way to get this?</span></p>
</div>
</div>
</blockquote>
<div>You can use <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__petsc.org_main_docs_manualpages_IS_ISLocalToGlobalMappingGetIndices.html&d=DwMFaQ&c=KXXihdR8fRNGFkKiMQzstu-8MbOxd1NuZkcSBymGmgo&r=6GO4L2UoBZHW81bz8HZAjg&m=tkDjlI2jtepJrixctzCXSLsviiUnPvCpULVGq54Nlnw&s=wCqh9AeSX2TJUI2hj2v77d8pl3SkiwG4dGK8nAjSMMI&e=">https://petsc.org/main/docs/manualpages/IS/ISLocalToGlobalMappingGetIndices.html</a>
 to get the indices out of the L2G map, and then call MatGetSubmatrix().</div>
<div><br>
</div>
<div>  Thanks,</div>
<div><br>
</div>
<div>     Matt <br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div id="gmail-m_3329168753258936637divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p><span style="color:rgb(33,33,33);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Bests,</span></p>
<p><span style="color:rgb(33,33,33);font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Li Luo</span></p>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_3329168753258936637divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>><br>
<b>Sent:</b> Monday, 14 March, 2022 22:49:47<br>
<b>To:</b> liluo<br>
<b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br>
<b>Subject:</b> Re: [petsc-users] How to obtain the local matrix from a global matrix in DMDA?</font>
<div> </div>
</div>
<div>
<div dir="ltr">You might want to explain what you want to do. 
<div>A local vector has ghost values that you can use to compute local residuals. You don't usually want a matrix that conforms with this local vector.</div>
<div>You could get the global equations of the local vector and use MatCreateSubMatrix, but I think there is a better way to do what you want.</div>
<div><br>
</div>
<div>OK, Matt and Jed beat me</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Mon, Mar 14, 2022 at 10:35 AM liluo <<a href="mailto:liluo@um.edu.mo" target="_blank">liluo@um.edu.mo</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div id="gmail-m_3329168753258936637gmail-m_-3120542394385288429divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>Dear developers,</p>
<p><br>
</p>
<p>I created a DMDA object and obtain the local vector from a global vector by using <span>DMGlobalToLocalBegin/End.</span></p>
<p>How can I obtain the corresponding local matrix from the global matrix? </p>
<p>In my case, the global matrix is of MPIBAIJ type created by <span>DMCreateMatrix(da,MATBAIJ,&A);</span><br>
<span></span></p>
<p><br>
</p>
<p>Bests,</p>
<p>LI</p>
<p><span></span></p>
<p><span><br>
</span></p>
<pre width="80"><strong><font color="#4169E1"><br></font></strong></pre>
<p></p>
<div id="gmail-m_3329168753258936637gmail-m_-3120542394385288429Signature">
<div id="gmail-m_3329168753258936637gmail-m_-3120542394385288429divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p></p>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</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="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cse.buffalo.edu_-7Eknepley_&d=DwMFaQ&c=KXXihdR8fRNGFkKiMQzstu-8MbOxd1NuZkcSBymGmgo&r=6GO4L2UoBZHW81bz8HZAjg&m=tkDjlI2jtepJrixctzCXSLsviiUnPvCpULVGq54Nlnw&s=wBtYlAe1bEuUGs7BoKAXU_PVeO1nihvIr00NdejMVWY&e=" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>