<div dir="ltr"><div dir="ltr">On Tue, Apr 18, 2023 at 5:24 AM Karthikeyan Chockalingam - STFC UKRI via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</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 class="msg8563800262251018830">
<div lang="EN-GB" style="overflow-wrap: break-word;">
<div class="m_8563800262251018830WordSection1">
<p class="MsoNormal"><span style="color:black">Hello,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black">I'm solving a problem using the Lagrange multiplier, the matrix has the form<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black">K = [A P^T<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black"> P 0]<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I am familiar with constructing K using MATMPIAIJ. However, I would like to know if had [A], can I augment it with [P], [P^T] and [0] of type MATMPIAIJ? Likewise for vectors as well.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Can you please point me to the right resource, if it is a common operation in PETSc?</p></div></div></div></blockquote><div><br></div><div>You can do this at least 2 ways:</div><div><br></div><div> 1) Assemble you submatrices directly into the larger matrix by constructing local-to-global maps for the emplacement. so that you do</div><div> not change your assembly code, except to change MatSetValues() to MatSetValuesLocal(). This is usually preferable.</div><div><br></div><div> 2) Use MATNEST and VecNEST to put pointers to submatrices and subvectors directly in.</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 class="msg8563800262251018830"><div lang="EN-GB" style="overflow-wrap: break-word;"><div class="m_8563800262251018830WordSection1">
<p class="MsoNormal">Many thanks.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Kind regards,<u></u><u></u></p>
<p class="MsoNormal">Karthik.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><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>