<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Hong,<div>1) Is there any hope to get PDIPDM to use a MatNest?</div><div>2) Is this fixed <a href="https://lists.mcs.anl.gov/pipermail/petsc-dev/2020-September/026398.html">https://lists.mcs.anl.gov/pipermail/petsc-dev/2020-September/026398.html</a> ?</div><div>I cannot get users to transition away from Ipopt because of these two missing features.</div><div><br></div><div>Thanks,</div><div>Pierre<br><div><br><blockquote type="cite"><div>On 20 Apr 2023, at 5:47 PM, Zhang, Hong via petsc-users <petsc-users@mcs.anl.gov> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);"><span class="ContentPasted2" style="font-family: Calibri, sans-serif; font-size: 14.6667px; background-color: rgb(255, 255, 255); display: inline !important;">Karthik,</span><br></div><div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">We built a KKT matrix in TaoSNESJacobian_PDIPM() (see petsc/src/tao/constrained/impls/ipm/pdipm.c) which assembles several small matrices into a large KKT matrix in mpiaij format. You could take the same approach to insert P and P^T into your K.</div><div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">FYI, I attached our paper.</div><div class="elementToProof ContentPasted0 ContentPasted1" style="font-style: normal; font-variant-caps: normal; font-weight: 400; 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-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; background-color: rgb(255, 255, 255);">Hong</div><div id="appendonsend" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; 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;"></div><hr tabindex="-1" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; 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; display: inline-block; width: 826.125px;"><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; 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; float: none; display: inline !important;"></span><div id="divRplyFwdMsg" dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; 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 face="Calibri, sans-serif" style="font-size: 11pt;"><b>From:</b><span class="Apple-converted-space"> </span>petsc-users <petsc-users-bounces@mcs.anl.gov> on behalf of Matthew Knepley <knepley@gmail.com><br><b>Sent:</b><span class="Apple-converted-space"> </span>Thursday, April 20, 2023 5:37 AM<br><b>To:</b><span class="Apple-converted-space"> </span>Karthikeyan Chockalingam - STFC UKRI <karthikeyan.chockalingam@stfc.ac.uk><br><b>Cc:</b><span class="Apple-converted-space"> </span>petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br><b>Subject:</b><span class="Apple-converted-space"> </span>Re: [petsc-users] question about MatSetLocalToGlobalMapping</font><div> </div></div><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; 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;"><div dir="ltr"><div dir="ltr">On Thu, Apr 20, 2023 at 6:13 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="x_gmail_quote"><blockquote class="x_gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="x_msg4059408548263094035"><div lang="EN-GB"><div class="x_m_-6455518359002065503WordSection1"><div style="margin-top: 0px; margin-bottom: 0px;">Hello,</div><div style="margin-top: 0px; margin-bottom: 0px;"><u></u> <u></u></div><div style="margin-top: 0px; margin-bottom: 0px;">I created a new thread, thought would it be more appropriate (and is a continuation of my previous post). I want to construct the below K matrix (which is composed of submatrices)</div><div style="margin-top: 0px; margin-bottom: 0px;"><u></u> <u></u></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style="">K = [A P^T</span><span style="font-size: 10pt; color: rgb(33, 33, 33);"><u></u><u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""> P 0]<u></u><u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style="">Where K is of type MatMPIAIJ. I first constructed the top left [A] using MatSetValues().<u></u><u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style="">Now, I would like to construct the bottom left [p] and top right [p^T]<span class="Apple-converted-space"> </span></span>using MatSetValuesLocal().</div><div style="margin-top: 0px; margin-bottom: 0px;"><u></u> <u></u></div><div style="margin-top: 0px; margin-bottom: 0px;">To use MatSetValuesLocal(), I first have to create a local-to-global mapping using ISLocalToGlobalMappingCreate. I have created two mapping row_mapping and column_mapping.</div></div></div></div></blockquote><div><br></div><div>I do not understand why they are not the same map. Maybe I was unclear before. It looks like you have two fields, say phi and lambda, where lambda is a Lagrange multiplier imposing some constraint. Then you get a saddle point like this. You can imagine matrices</div><div><br></div><div> (phi, phi) --> A</div><div> (phi, lambda) --> P^T</div><div> (lambda, phi) --> P</div><div><br></div><div>So you make a L2G map for the phi field and the lambda field. Oh, you are calling them row and col map, but they are my phi and lambda</div><div>maps. I do not like the row and col names since in P they reverse.</div><div> </div><blockquote class="x_gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="x_msg4059408548263094035"><div lang="EN-GB"><div class="x_m_-6455518359002065503WordSection1"><div style="margin-top: 0px; margin-bottom: 0px;"><span style="">Q1) At what point should I declare<span class="Apple-converted-space"> </span></span>MatSetLocalToGlobalMapping – is it just before I use MatSetValuesLocal()?</div></div></div></div></blockquote><div><br></div><div>Okay, it is good you are asking this because my thinking was somewhat confused. I think the precise steps are:</div><div><br></div><div> 1) Create the large saddle point matrix K</div><div><br></div><div> 1a) We must call <a href="https://petsc.org/main/manualpages/Mat/MatSetLocalToGlobalMapping/">https://petsc.org/main/manualpages/Mat/MatSetLocalToGlobalMapping/</a><span class="Apple-converted-space"> </span>on it. In the simplest case, this just maps</div><div> the local rows numbers [0, Nrows) to the global rows numbers [rowStart, rowStart + Nrows).</div><div><br></div><div> 2) To form each piece:</div><div><br></div><div> 2a) Extract that block using <a href="https://petsc.org/main/manualpages/Mat/MatGetLocalSubMatrix/">https://petsc.org/main/manualpages/Mat/MatGetLocalSubMatrix/</a></div><div><br></div><div> This gives back a Mat object that you subsequently restore using <a href="https://petsc.org/main/manualpages/Mat/MatRestoreLocalSubMatrix/">https://petsc.org/main/manualpages/Mat/MatRestoreLocalSubMatrix/</a></div><div><br></div><div> 2b) Insert values using<span class="Apple-converted-space"> </span><a href="https://petsc.org/main/manualpages/Mat/MatSetValuesLocal/">https://petsc.org/main/manualpages/Mat/MatSetValuesLocal/</a></div><div><br></div><div> The local indices used for insertion here are indices relative to the block itself, and the L2G map for this matrix</div><div> has been rewritten to insert into that block in the larger matrix. Thus this looks like just calling MatSetValuesLocal()</div><div> on the smaller matrix block, but inserts correctly into the larger matrix.</div><div><br></div><div>Therefore, the code you write code in 2) could work equally well making the large matrix from 1), or independent smaller matrix blocks.</div><div><br></div><div>Does this make sense?</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="x_gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="x_msg4059408548263094035"><div lang="EN-GB"><div class="x_m_-6455518359002065503WordSection1"><div style="margin-top: 0px; margin-bottom: 0px;">I will use MatSetLocalToGlobalMapping(K, row_mapping, column_mapping) to build<span class="Apple-converted-space"> </span><span style="">the bottom left [P].<u></u><u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style="">Q2) Can now I reset the mapping as<span class="Apple-converted-space"> </span></span>MatSetLocalToGlobalMapping(K, column_mapping, row_mapping) to build<span class="Apple-converted-space"> </span><span style="">the top right [P^T]?<span class="Apple-converted-space"> </span><u></u><u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><u></u> <u></u></div><div style="margin-top: 0px; margin-bottom: 0px;">Many thanks!<span style=""><u></u><u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style="">Kind regards,<u></u><u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style="">Karthik.<u></u><u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style=""><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><u></u> <u></u></div><div style="margin-top: 0px; margin-bottom: 0px;"><u></u> <u></u></div><div style="margin-top: 0px; margin-bottom: 0px;"><span style="font-size: 10pt; color: rgb(33, 33, 33);"><u></u> <u></u></span></div><div style="margin-top: 0px; margin-bottom: 0px;"><u></u> <u></u></div></div></div></div></blockquote></div><br clear="all"><div><br></div><span class="x_gmail_signature_prefix">--<span class="Apple-converted-space"> </span></span><br><div dir="ltr" class="x_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></div><span id="cid:AA825F93-5460-43A9-BD3E-EC5B64921BC3"><IET Generation Trans Dist - 2022 - Sundermann - Parallel primal‐dual interior point method for the solution of dynamic.pdf></span></div></blockquote></div><br></div></body></html>